1. 01 6月, 2018 7 次提交
    • C
      f2fs: clean up symbol namespace · 4d57b86d
      Chao Yu 提交于
      As Ted reported:
      
      "Hi, I was looking at f2fs's sources recently, and I noticed that there
      is a very large number of non-static symbols which don't have a f2fs
      prefix.  There's well over a hundred (see attached below).
      
      As one example, in fs/f2fs/dir.c there is:
      
      unsigned char get_de_type(struct f2fs_dir_entry *de)
      
      This function is clearly only useful for f2fs, but it has a generic
      name.  This means that if any other file system tries to have the same
      symbol name, there will be a symbol conflict and the kernel would not
      successfully build.  It also means that when someone is looking f2fs
      sources, it's not at all obvious whether a function such as
      read_data_page(), invalidate_blocks(), is a generic kernel function
      found in the fs, mm, or block layers, or a f2fs specific function.
      
      You might want to fix this at some point.  Hopefully Kent's bcachefs
      isn't similarly using genericly named functions, since that might
      cause conflicts with f2fs's functions --- but just as this would be a
      problem that we would rightly insist that Kent fix, this is something
      that we should have rightly insisted that f2fs should have fixed
      before it was integrated into the mainline kernel.
      
      acquire_orphan_inode
      add_ino_entry
      add_orphan_inode
      allocate_data_block
      allocate_new_segments
      alloc_nid
      alloc_nid_done
      alloc_nid_failed
      available_free_memory
      ...."
      
      This patch adds "f2fs_" prefix for all non-static symbols in order to:
      a) avoid conflict with other kernel generic symbols;
      b) to indicate the function is f2fs specific one instead of generic
      one;
      Reported-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      4d57b86d
    • A
      disable loading f2fs module on PAGE_SIZE > 4KB · 4071e67c
      Anatoly Pugachev 提交于
      The following patch disables loading of f2fs module on architectures
      which have PAGE_SIZE > 4096 , since it is impossible to mount f2fs on
      such architectures , log messages are:
      
      mount: /mnt: wrong fs type, bad option, bad superblock on
      /dev/vdiskb1, missing codepage or helper program, or other error.
      /dev/vdiskb1: F2FS filesystem,
      UUID=1d8b9ca4-2389-4910-af3b-10998969f09c, volume name ""
      
      May 15 18:03:13 ttip kernel: F2FS-fs (vdiskb1): Invalid
      page_cache_size (8192), supports only 4KB
      May 15 18:03:13 ttip kernel: F2FS-fs (vdiskb1): Can't find valid F2FS
      filesystem in 1th superblock
      May 15 18:03:13 ttip kernel: F2FS-fs (vdiskb1): Invalid
      page_cache_size (8192), supports only 4KB
      May 15 18:03:13 ttip kernel: F2FS-fs (vdiskb1): Can't find valid F2FS
      filesystem in 2th superblock
      May 15 18:03:13 ttip kernel: F2FS-fs (vdiskb1): Invalid
      page_cache_size (8192), supports only 4KB
      
      which was introduced by git commit 5c9b4692
      
      tested on git kernel 4.17.0-rc6-00309-gec30dcf7
      
      with patch applied:
      
      modprobe: ERROR: could not insert 'f2fs': Invalid argument
      May 28 01:40:28 v215 kernel: F2FS not supported on PAGE_SIZE(8192) != 4096
      Signed-off-by: NAnatoly Pugachev <matorola@gmail.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      4071e67c
    • C
      f2fs: keep migration IO order in LFS mode · 107a805d
      Chao Yu 提交于
      For non-migration IO, we will keep order of data/node blocks' submitting
      as allocation sequence by sorting IOs in per log io_list list, but for
      migration IO, it could be out-of-order.
      
      In LFS mode, we should keep all IOs including migration IO be ordered,
      so that this patch fixes to add an additional lock to keep submitting
      order.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      107a805d
    • C
      f2fs: fix to initialize i_current_depth according to inode type · 1c41e680
      Chao Yu 提交于
      i_current_depth is used only for directory inode, but its space is
      shared with i_gc_failures field used for regular inode, in order to
      avoid affecting i_gc_failures' value, this patch fixes to initialize
      the union's fields according to inode type.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      1c41e680
    • J
      f2fs: enhance sanity_check_raw_super() to avoid potential overflows · 0cfe75c5
      Jaegeuk Kim 提交于
      In order to avoid the below overflow issue, we should have checked the
      boundaries in superblock before reaching out to allocation. As Linus suggested,
      the right place should be sanity_check_raw_super().
      
      Dr Silvio Cesare of InfoSect reported:
      
      There are integer overflows with using the cp_payload superblock field in the
      f2fs filesystem potentially leading to memory corruption.
      
      include/linux/f2fs_fs.h
      
      struct f2fs_super_block {
      ...
              __le32 cp_payload;
      
      fs/f2fs/f2fs.h
      
      typedef u32 block_t;    /*
                               * should not change u32, since it is the on-disk block
                               * address format, __le32.
                               */
      ...
      
      static inline block_t __cp_payload(struct f2fs_sb_info *sbi)
      {
              return le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload);
      }
      
      fs/f2fs/checkpoint.c
      
              block_t start_blk, orphan_blocks, i, j;
      ...
              start_blk = __start_cp_addr(sbi) + 1 + __cp_payload(sbi);
              orphan_blocks = __start_sum_addr(sbi) - 1 - __cp_payload(sbi);
      
      +++ integer overflows
      
      ...
              unsigned int cp_blks = 1 + __cp_payload(sbi);
      ...
              sbi->ckpt = kzalloc(cp_blks * blk_size, GFP_KERNEL);
      
      +++ integer overflow leading to incorrect heap allocation.
      
              int cp_payload_blks = __cp_payload(sbi);
      ...
              ckpt->cp_pack_start_sum = cpu_to_le32(1 + cp_payload_blks +
                              orphan_blocks);
      
      +++ sign bug and integer overflow
      
      ...
              for (i = 1; i < 1 + cp_payload_blks; i++)
      
      +++ integer overflow
      
      ...
      
            sbi->max_orphans = (sbi->blocks_per_seg - F2FS_CP_PACKS -
                              NR_CURSEG_TYPE - __cp_payload(sbi)) *
                                      F2FS_ORPHANS_PER_BLOCK;
      
      +++ integer overflow
      Reported-by: NGreg KH <greg@kroah.com>
      Reported-by: NSilvio Cesare <silvio.cesare@gmail.com>
      Suggested-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0cfe75c5
    • C
      f2fs: rename dio_rwsem to i_gc_rwsem · b2532c69
      Chao Yu 提交于
      RW semphore dio_rwsem in struct f2fs_inode_info is introduced to avoid
      race between dio and data gc, but now, it is more wildly used to avoid
      foreground operation vs data gc. So rename it to i_gc_rwsem to improve
      its readability.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      b2532c69
    • C
      f2fs: introduce private inode status mapping · 59c84408
      Chao Yu 提交于
      Previously, we use generic FS_*_FL defined by vfs to indicate inode status
      for each bit of i_flags, so f2fs's flag status definition is tied to vfs'
      one, it will be hard for f2fs to reuse bits f2fs never used to indicate
      new status..
      
      In order to solve this issue, we introduce private inode status mapping,
      Note, for these bits have already been persisted into disk, we should
      never change their definition, for other ones, we can remap them for
      later new coming status.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      59c84408
  2. 30 5月, 2018 1 次提交
  3. 03 5月, 2018 1 次提交
    • E
      f2fs: refactor read path to allow multiple postprocessing steps · 6dbb1796
      Eric Biggers 提交于
      Currently f2fs's ->readpage() and ->readpages() assume that either the
      data undergoes no postprocessing, or decryption only.  But with
      fs-verity, there will be an additional authenticity verification step,
      and it may be needed either by itself, or combined with decryption.
      
      To support this, store a 'struct bio_post_read_ctx' in ->bi_private
      which contains a work struct, a bitmask of postprocessing steps that are
      enabled, and an indicator of the current step.  The bio completion
      routine, if there was no I/O error, enqueues the first postprocessing
      step.  When that completes, it continues to the next step.  Pages that
      fail any postprocessing step have PageError set.  Once all steps have
      completed, pages without PageError set are set Uptodate, and all pages
      are unlocked.
      
      Also replace f2fs_encrypted_file() with a new function
      f2fs_post_read_required() in places like direct I/O and garbage
      collection that really should be testing whether the file needs special
      I/O processing, not whether it is encrypted specifically.
      
      This may also be useful for other future f2fs features such as
      compression.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6dbb1796
  4. 28 3月, 2018 1 次提交
  5. 19 3月, 2018 1 次提交
    • R
      f2fs: Set GF_NOFS in read_cache_page_gfp while doing f2fs_quota_read · 02117b8a
      Ritesh Harjani 提交于
      Quota code itself is serializing the operations by taking mutex_lock.
      It seems a below deadlock can happen if GF_NOFS is not used in
      f2fs_quota_read
      
      __switch_to+0x88
      __schedule+0x5b0
      schedule+0x78
      schedule_preempt_disabled+0x20
      __mutex_lock_slowpath+0xdc   		//mutex owner is itself
      mutex_lock+0x2c
      dquot_commit+0x30			//mutex_lock(&dqopt->dqio_mutex);
      dqput+0xe0
      __dquot_drop+0x80
      dquot_drop+0x48
      f2fs_evict_inode+0x218
      evict+0xa8
      dispose_list+0x3c
      prune_icache_sb+0x58
      super_cache_scan+0xf4
      do_shrink_slab+0x208
      shrink_slab.part.40+0xac
      shrink_zone+0x1b0
      do_try_to_free_pages+0x25c
      try_to_free_pages+0x164
      __alloc_pages_nodemask+0x534
      do_read_cache_page+0x6c
      read_cache_page+0x14
      f2fs_quota_read+0xa4
      read_blk+0x54
      find_tree_dqentry+0xe4
      find_tree_dqentry+0xb8
      find_tree_dqentry+0xb8
      find_tree_dqentry+0xb8
      qtree_read_dquot+0x68
      v2_read_dquot+0x24
      dquot_acquire+0x5c			// mutex_lock(&dqopt->dqio_mutex);
      dqget+0x238
      __dquot_initialize+0xd4
      dquot_initialize+0x10
      dquot_file_open+0x34
      f2fs_file_open+0x6c
      do_dentry_open+0x1e4
      vfs_open+0x6c
      path_openat+0xa20
      do_filp_open+0x4c
      do_sys_open+0x178
      Signed-off-by: NRitesh Harjani <riteshh@codeaurora.org>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      02117b8a
  6. 17 3月, 2018 6 次提交
  7. 13 3月, 2018 10 次提交
  8. 23 1月, 2018 1 次提交
  9. 17 1月, 2018 5 次提交
  10. 04 1月, 2018 1 次提交
  11. 03 1月, 2018 4 次提交
  12. 28 11月, 2017 1 次提交
    • L
      Rename superblock flags (MS_xyz -> SB_xyz) · 1751e8a6
      Linus Torvalds 提交于
      This is a pure automated search-and-replace of the internal kernel
      superblock flags.
      
      The s_flags are now called SB_*, with the names and the values for the
      moment mirroring the MS_* flags that they're equivalent to.
      
      Note how the MS_xyz flags are the ones passed to the mount system call,
      while the SB_xyz flags are what we then use in sb->s_flags.
      
      The script to do this was:
      
          # places to look in; re security/*: it generally should *not* be
          # touched (that stuff parses mount(2) arguments directly), but
          # there are two places where we really deal with superblock flags.
          FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
                  include/linux/fs.h include/uapi/linux/bfs_fs.h \
                  security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
          # the list of MS_... constants
          SYMS="RDONLY NOSUID NODEV NOEXEC SYNCHRONOUS REMOUNT MANDLOCK \
                DIRSYNC NOATIME NODIRATIME BIND MOVE REC VERBOSE SILENT \
                POSIXACL UNBINDABLE PRIVATE SLAVE SHARED RELATIME KERNMOUNT \
                I_VERSION STRICTATIME LAZYTIME SUBMOUNT NOREMOTELOCK NOSEC BORN \
                ACTIVE NOUSER"
      
          SED_PROG=
          for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done
      
          # we want files that contain at least one of MS_...,
          # with fs/namespace.c and fs/pnode.c excluded.
          L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')
      
          for f in $L; do sed -i $f $SED_PROG; done
      Requested-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1751e8a6
  13. 06 11月, 2017 1 次提交