1. 09 5月, 2019 6 次提交
    • C
      f2fs: relocate chksum_offset for large_nat_bitmap feature · b471eb99
      Chao Yu 提交于
      For large_nat_bitmap feature, there is a design flaw:
      
      Previous:
      
      struct f2fs_checkpoint layout:
      +--------------------------+  0x0000
      | checkpoint_ver           |
      | ......                   |
      | checksum_offset          |------+
      | ......                   |      |
      | sit_nat_version_bitmap[] |<-----|-------+
      | ......                   |      |       |
      | checksum_value           |<-----+       |
      +--------------------------+  0x1000      |
      |                          |      nat_bitmap + sit_bitmap
      | payload blocks           |              |
      |                          |              |
      +--------------------------|<-------------+
      
      Obviously, if nat_bitmap size + sit_bitmap size is larger than
      MAX_BITMAP_SIZE_IN_CKPT, nat_bitmap or sit_bitmap may overlap
      checkpoint checksum's position, once checkpoint() is triggered
      from kernel, nat or sit bitmap will be damaged by checksum field.
      
      In order to fix this, let's relocate checksum_value's position
      to the head of sit_nat_version_bitmap as below, then nat/sit
      bitmap and chksum value update will become safe.
      
      After:
      
      struct f2fs_checkpoint layout:
      +--------------------------+  0x0000
      | checkpoint_ver           |
      | ......                   |
      | checksum_offset          |------+
      | ......                   |      |
      | sit_nat_version_bitmap[] |<-----+
      | ......                   |<-------------+
      |                          |              |
      +--------------------------+  0x1000      |
      |                          |      nat_bitmap + sit_bitmap
      | payload blocks           |              |
      |                          |              |
      +--------------------------|<-------------+
      
      Related report and discussion:
      
      https://sourceforge.net/p/linux-f2fs/mailman/message/36642346/Reported-by: NPark Ju Hyung <qkrwngud825@gmail.com>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      b471eb99
    • C
      f2fs: allow address pointer number of dnode aligning to specified size · d02a6e61
      Chao Yu 提交于
      This patch expands scalability of dnode layout, it allows address pointer
      number of dnode aligning to specified size (now, the size is one byte by
      default), and later the number can align to compress cluster size
      (1 << n bytes, n=[2,..)), it can avoid cluster acrossing two dnode, making
      design of compress meta layout simple.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      d02a6e61
    • C
      f2fs: fix wrong __is_meta_io() macro · 6dc3a126
      Chao Yu 提交于
      This patch changes codes as below:
      - don't use is_read_io() as a condition to judge the meta IO.
      - use .is_por to replace .is_meta to indicate IO is from recovery explicitly.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      6dc3a126
    • C
      f2fs: fix to avoid panic in dec_valid_node_count() · ea6d7e72
      Chao Yu 提交于
      As Jungyeon reported in bugzilla:
      
      https://bugzilla.kernel.org/show_bug.cgi?id=203213
      
      - Overview
      When mounting the attached crafted image and running program, I got this error.
      Additionally, it hangs on sync after running the this script.
      
      The image is intentionally fuzzed from a normal f2fs image for testing and I enabled option CONFIG_F2FS_CHECK_FS on.
      
      - Reproduces
      mkdir test
      mount -t f2fs tmp.img test
      cp a.out test
      cd test
      sudo ./a.out
      sync
      
       kernel BUG at fs/f2fs/f2fs.h:2012!
       RIP: 0010:truncate_node+0x2c9/0x2e0
       Call Trace:
        f2fs_truncate_xattr_node+0xa1/0x130
        f2fs_remove_inode_page+0x82/0x2d0
        f2fs_evict_inode+0x2a3/0x3a0
        evict+0xba/0x180
        __dentry_kill+0xbe/0x160
        dentry_kill+0x46/0x180
        dput+0xbb/0x100
        do_renameat2+0x3c9/0x550
        __x64_sys_rename+0x17/0x20
        do_syscall_64+0x43/0xf0
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      The reason is dec_valid_node_count() will trigger kernel panic due to
      inconsistent count in between inode.i_blocks and actual block.
      
      To avoid panic, let's just print debug message and set SBI_NEED_FSCK to
      give a hint to fsck for latter repairing.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: fix build warning and add unlikely]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      ea6d7e72
    • C
      f2fs: fix to avoid panic in dec_valid_block_count() · 5e159cd3
      Chao Yu 提交于
      As Jungyeon reported in bugzilla:
      
      https://bugzilla.kernel.org/show_bug.cgi?id=203209
      
      - Overview
      When mounting the attached crafted image and running program, I got this error.
      Additionally, it hangs on sync after the this script.
      
      The image is intentionally fuzzed from a normal f2fs image for testing and I enabled option CONFIG_F2FS_CHECK_FS on.
      
      - Reproduces
      cc poc_01.c
      ./run.sh f2fs
      sync
      
       kernel BUG at fs/f2fs/f2fs.h:1788!
       RIP: 0010:f2fs_truncate_data_blocks_range+0x342/0x350
       Call Trace:
        f2fs_truncate_blocks+0x36d/0x3c0
        f2fs_truncate+0x88/0x110
        f2fs_setattr+0x3e1/0x460
        notify_change+0x2da/0x400
        do_truncate+0x6d/0xb0
        do_sys_ftruncate+0xf1/0x160
        do_syscall_64+0x43/0xf0
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      The reason is dec_valid_block_count() will trigger kernel panic due to
      inconsistent count in between inode.i_blocks and actual block.
      
      To avoid panic, let's just print debug message and set SBI_NEED_FSCK to
      give a hint to fsck for latter repairing.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: fix build warning and add unlikely]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      5e159cd3
    • C
      f2fs: fix to use inline space only if inline_xattr is enable · 622927f3
      Chao Yu 提交于
      With below mkfs and mount option:
      
      MKFS_OPTIONS  -- -O extra_attr -O project_quota -O inode_checksum -O flexible_inline_xattr -O inode_crtime -f
      MOUNT_OPTIONS -- -o noinline_xattr
      
      We may miss xattr data with below testcase:
      - mkdir dir
      - setfattr -n "user.name" -v 0 dir
      - for ((i = 0; i < 190; i++)) do touch dir/$i; done
      - umount
      - mount
      - getfattr -n "user.name" dir
      
      user.name: No such attribute
      
      The root cause is that we persist xattr data into reserved inline xattr
      space, even if inline_xattr is not enable in inline directory inode, after
      inline dentry conversion, reserved space no longer exists, so that xattr
      data missed.
      
      Let's use inline xattr space only if inline_xattr flag is set on inode
      to fix this iusse.
      
      Fixes: 6afc662e ("f2fs: support flexible inline xattr size")
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      622927f3
  2. 06 4月, 2019 4 次提交
    • C
      f2fs: add comment for conditional compilation statement · e1074d4b
      Chao Yu 提交于
      Commit af033b2a ("f2fs: guarantee journalled quota data by checkpoint")
      added function is_journalled_quota() in f2fs.h, but it located outside of
      _LINUX_F2FS_H macro coverage, it has been fixed with commit 0af725fc
      ("f2fs: fix wrong #endif").
      
      But anyway, in order to avoid making same mistake latter, let's add single
      line comment to notice which #if the last #endif is corresponding to.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: Remove unnecessary empty EOL]
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      e1074d4b
    • D
      f2fs: improve discard handling with multi-device volumes · 7f3d7719
      Damien Le Moal 提交于
      f2fs_hw_support_discard() only tests if the super block device supports
      discard. However, for a multi-device volume, not all disks used may
      support discard. Improve the check performed to test all devices of
      the volume and report discard as supported if at least one device of
      the volume supports discard. To implement this, introduce the helper
      function f2fs_bdev_support_discard(), which returns true for zoned block
      devices (where discard is processed as a zone reset) and for regular
      disks supporting the discard command.
      
      f2fs_bdev_support_discard() is also used in __queue_discard_cmd() to
      handle discard command issuing for a particular device of the volume.
      That is, prevent issuing a discard command for block devices that do
      not support it.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7f3d7719
    • D
      f2fs: Reduce zoned block device memory usage · 95175daf
      Damien Le Moal 提交于
      For zoned block devices, an array of zone types for each device is
      allocated and initialized in order to determine if a section is stored
      on a sequential zone (zone reset needed) or a conventional zone (no
      zone reset needed and regular discard applies). Considering this usage,
      the zone types stored in memory can be replaced with a bitmap to
      indicate an equivalent information, that is, if a zone is sequential or
      not. This reduces the memory usage for each zoned device by roughly 8:
      on a 14TB disk with zones of 256 MB, the zone type array consumes
      13x4KB pages while the bitmap uses only 2x4KB pages.
      
      This patch changes the f2fs_dev_info structure blkz_type field to the
      bitmap blkz_seq. Access to this bitmap is done using the helper
      function f2fs_blkz_is_seq(), which is a rewrite of the function
      get_blkz_type().
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      95175daf
    • D
      f2fs: Fix use of number of devices · 0916878d
      Damien Le Moal 提交于
      For a single device mount using a zoned block device, the zone
      information for the device is stored in the sbi->devs single entry
      array and sbi->s_ndevs is set to 1. This differs from a single device
      mount using a regular block device which does not allocate sbi->devs
      and sets sbi->s_ndevs to 0.
      
      However, sbi->s_devs == 0 condition is used throughout the code to
      differentiate a single device mount from a multi-device mount where
      sbi->s_ndevs is always larger than 1. This results in problems with
      single zoned block device volumes as these are treated as multi-device
      mounts but do not have the start_blk and end_blk information set. One
      of the problem observed is skipping of zone discard issuing resulting in
      write commands being issued to full zones or unaligned to a zone write
      pointer.
      
      Fix this problem by simply treating the cases sbi->s_ndevs == 0 (single
      regular block device mount) and sbi->s_ndevs == 1 (single zoned block
      device mount) in the same manner. This is done by introducing the
      helper function f2fs_is_multi_device() and using this helper in place
      of direct tests of sbi->s_ndevs value, improving code readability.
      
      Fixes: 7bb3a371 ("f2fs: Fix zoned block device support")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      0916878d
  3. 13 3月, 2019 3 次提交
  4. 06 3月, 2019 2 次提交
    • C
      f2fs: fix to check inline_xattr_size boundary correctly · 500e0b28
      Chao Yu 提交于
      We use below condition to check inline_xattr_size boundary:
      
      	if (!F2FS_OPTION(sbi).inline_xattr_size ||
      		F2FS_OPTION(sbi).inline_xattr_size >=
      				DEF_ADDRS_PER_INODE -
      				F2FS_TOTAL_EXTRA_ATTR_SIZE -
      				DEF_INLINE_RESERVED_SIZE -
      				DEF_MIN_INLINE_SIZE)
      
      There is there problems in that check:
      - we should allow inline_xattr_size equaling to min size of inline
      {data,dentry} area.
      - F2FS_TOTAL_EXTRA_ATTR_SIZE and inline_xattr_size are based on
      different size unit, previous one is 4 bytes, latter one is 1 bytes.
      - DEF_MIN_INLINE_SIZE only indicate min size of inline data area,
      however, we need to consider min size of inline dentry area as well,
      minimal inline dentry should at least contain two entries: '.' and
      '..', so that min inline_dentry size is 40 bytes.
      
      .bitmap		1 * 1 = 1
      .reserved	1 * 1 = 1
      .dentry		11 * 2 = 22
      .filename	8 * 2 = 16
      total		40
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      500e0b28
    • C
      f2fs: fix potential data inconsistence of checkpoint · c42d28ce
      Chao Yu 提交于
      Previously, we changed lock from cp_rwsem to node_change, it solved
      the deadlock issue which was caused by below race condition:
      
      Thread A			Thread B
      - f2fs_setattr
       - f2fs_lock_op  -- read_lock
       - dquot_transfer
        - __dquot_transfer
         - dquot_acquire
          - commit_dqblk
           - f2fs_quota_write
            - f2fs_write_begin
             - f2fs_write_failed
      				- write_checkpoint
      				 - block_operations
      				  - f2fs_lock_all  -- write_lock
              - f2fs_truncate_blocks
               - f2fs_lock_op  -- read_lock
      
      But it breaks the sematics of cp_rwsem, in other callers like:
      - f2fs_file_write_iter -> f2fs_write_begin -> f2fs_write_failed
      - f2fs_direct_IO -> f2fs_write_failed
      
      We allow to truncate dnode w/o cp_rwsem held, result in incorrect sit
      bitmap update, which can cause further data corruption.
      
      So this patch reverts previous fix implementation, and try to fix
      deadlock by skipping calling f2fs_truncate_blocks() in f2fs_write_failed()
      only for quota file, and keep the preallocated data/node in the tail of
      quota file, we can expecte that the preallocated space can be used to
      store quota info latter soon.
      
      Fixes: af033b2a ("f2fs: guarantee journalled quota data by checkpoint")
      Signed-off-by: NGao Xiang <gaoxiang25@huawei.com>
      Signed-off-by: NSheng Yong <shengyong1@huawei.com>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      c42d28ce
  5. 16 2月, 2019 2 次提交
  6. 05 2月, 2019 1 次提交
  7. 24 1月, 2019 2 次提交
  8. 23 1月, 2019 2 次提交
  9. 22 1月, 2019 1 次提交
  10. 09 1月, 2019 2 次提交
  11. 27 12月, 2018 6 次提交
    • C
      f2fs: check PageWriteback flag for ordered case · bae0ee7a
      Chao Yu 提交于
      For all ordered cases in f2fs_wait_on_page_writeback(), we need to
      check PageWriteback status, so let's clean up to relocate the check
      into f2fs_wait_on_page_writeback().
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      bae0ee7a
    • C
      f2fs: clean up structure extent_node · c0362117
      Chao Yu 提交于
      The union in struct extent_node wass only to indicate below fields
      
      	struct rb_node rb_node;
      	union {
      		struct {
      			unsigned int fofs;
      			unsigned int len;
      		...
      	...
      
      can be parsed as fields in struct rb_entry, but they were never be
      used explicitly before, so let's remove them for cleanup.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      c0362117
    • S
      f2fs: fix sbi->extent_list corruption issue · e4589fa5
      Sahitya Tummala 提交于
      When there is a failure in f2fs_fill_super() after/during
      the recovery of fsync'd nodes, it frees the current sbi and
      retries again. This time the mount is successful, but the files
      that got recovered before retry, still holds the extent tree,
      whose extent nodes list is corrupted since sbi and sbi->extent_list
      is freed up. The list_del corruption issue is observed when the
      file system is getting unmounted and when those recoverd files extent
      node is being freed up in the below context.
      
      list_del corruption. prev->next should be fffffff1e1ef5480, but was (null)
      <...>
      kernel BUG at kernel/msm-4.14/lib/list_debug.c:53!
      lr : __list_del_entry_valid+0x94/0xb4
      pc : __list_del_entry_valid+0x94/0xb4
      <...>
      Call trace:
      __list_del_entry_valid+0x94/0xb4
      __release_extent_node+0xb0/0x114
      __free_extent_tree+0x58/0x7c
      f2fs_shrink_extent_tree+0xdc/0x3b0
      f2fs_leave_shrinker+0x28/0x7c
      f2fs_put_super+0xfc/0x1e0
      generic_shutdown_super+0x70/0xf4
      kill_block_super+0x2c/0x5c
      kill_f2fs_super+0x44/0x50
      deactivate_locked_super+0x60/0x8c
      deactivate_super+0x68/0x74
      cleanup_mnt+0x40/0x78
      __cleanup_mnt+0x1c/0x28
      task_work_run+0x48/0xd0
      do_notify_resume+0x678/0xe98
      work_pending+0x8/0x14
      
      Fix this by not creating extents for those recovered files if shrinker is
      not registered yet. Once mount is successful and shrinker is registered,
      those files can have extents again.
      Signed-off-by: NSahitya Tummala <stummala@codeaurora.org>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      e4589fa5
    • J
      f2fs: correct wrong spelling, issing_* · 72691af6
      Jaegeuk Kim 提交于
      Let's use "queued" instead of "issuing".
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      72691af6
    • J
      f2fs: use kvmalloc, if kmalloc is failed · 5222595d
      Jaegeuk Kim 提交于
      One report says memalloc failure during mount.
      
       (unwind_backtrace) from [<c010cd4c>] (show_stack+0x10/0x14)
       (show_stack) from [<c049c6b8>] (dump_stack+0x8c/0xa0)
       (dump_stack) from [<c024fcf0>] (warn_alloc+0xc4/0x160)
       (warn_alloc) from [<c0250218>] (__alloc_pages_nodemask+0x3f4/0x10d0)
       (__alloc_pages_nodemask) from [<c0270450>] (kmalloc_order_trace+0x2c/0x120)
       (kmalloc_order_trace) from [<c03fa748>] (build_node_manager+0x35c/0x688)
       (build_node_manager) from [<c03de494>] (f2fs_fill_super+0xf0c/0x16cc)
       (f2fs_fill_super) from [<c02a5864>] (mount_bdev+0x15c/0x188)
       (mount_bdev) from [<c03da624>] (f2fs_mount+0x18/0x20)
       (f2fs_mount) from [<c02a68b8>] (mount_fs+0x158/0x19c)
       (mount_fs) from [<c02c3c9c>] (vfs_kern_mount+0x78/0x134)
       (vfs_kern_mount) from [<c02c76ac>] (do_mount+0x474/0xca4)
       (do_mount) from [<c02c8264>] (SyS_mount+0x94/0xbc)
       (SyS_mount) from [<c0108180>] (ret_fast_syscall+0x0/0x48)
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      5222595d
    • Y
      f2fs: remove redundant comment of unused wio_mutex · af56b487
      Yunlong Song 提交于
      Commit 089842de ("f2fs: remove codes of unused wio_mutex") removes codes
      of unused wio_mutex, but missing the comment, so delete it.
      Signed-off-by: NYunlong Song <yunlong.song@huawei.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      af56b487
  12. 14 12月, 2018 1 次提交
  13. 28 11月, 2018 1 次提交
  14. 27 11月, 2018 7 次提交
    • A
      f2fs: make "f2fs_fault_name[]" const char * · 19880e6e
      Alexey Dobriyan 提交于
      Those strings are immutable.
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      19880e6e
    • J
      f2fs: avoid build warn of fall_through · f5d5510e
      Jaegeuk Kim 提交于
      After merging the f2fs tree, today's linux-next build
       (x86_64_allmodconfig) produced this warning:
      
       In file included from fs/f2fs/dir.c:11:
       fs/f2fs/f2fs.h: In function '__mark_inode_dirty_flag':
       fs/f2fs/f2fs.h:2388:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
          if (set)
             ^
       fs/f2fs/f2fs.h:2390:2: note: here
         case FI_DATA_EXIST:
         ^~~~
      
       Exposed by my use of -Wimplicit-fallthrough
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      f5d5510e
    • C
      f2fs: fix out-place-update DIO write · f9d6d059
      Chao Yu 提交于
      In get_more_blocks(), we may override @create as below code:
      
      	create = dio->op == REQ_OP_WRITE;
      	if (dio->flags & DIO_SKIP_HOLES) {
      		if (fs_startblk <= ((i_size_read(dio->inode) - 1) >>
      						i_blkbits))
      			create = 0;
      	}
      
      But in f2fs_map_blocks(), we only trigger f2fs_balance_fs() if @create
      is 1, so in LFS mode, dio overwrite under LFS mode can easily run out
      of free segments, result in below panic.
      
       Call Trace:
        allocate_segment_by_default+0xa8/0x270 [f2fs]
        f2fs_allocate_data_block+0x1ea/0x5c0 [f2fs]
        __allocate_data_block+0x306/0x480 [f2fs]
        f2fs_map_blocks+0x6f6/0x920 [f2fs]
        __get_data_block+0x4f/0xb0 [f2fs]
        get_data_block_dio_write+0x50/0x60 [f2fs]
        do_blockdev_direct_IO+0xcd5/0x21e0
        __blockdev_direct_IO+0x3a/0x3c
        f2fs_direct_IO+0x1ff/0x4a0 [f2fs]
        generic_file_direct_write+0xd9/0x160
        __generic_file_write_iter+0xbb/0x1e0
        f2fs_file_write_iter+0xaf/0x220 [f2fs]
        __vfs_write+0xd0/0x130
        vfs_write+0xb2/0x1b0
        SyS_pwrite64+0x69/0xa0
        ? vtime_user_exit+0x29/0x70
        do_syscall_64+0x6e/0x160
        entry_SYSCALL64_slow_path+0x25/0x25
       RIP: new_curseg+0x36f/0x380 [f2fs] RSP: ffffac570393f7a8
      
      So this patch introduces a parameter map.m_may_create to indicate that
      f2fs_map_blocks() is called from write or read path, which can give the
      right hint to let f2fs_map_blocks() trigger OPU allocation and call
      f2fs_balanc_fs() correctly.
      
      BTW, it disables physical address preallocation for direct IO in
      f2fs_preallocate_blocks, which is redundant to OPU allocation of
      f2fs_map_blocks.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      f9d6d059
    • C
      f2fs: fix to be aware discard/preflush/dio command in is_idle() · fef4129e
      Chao Yu 提交于
      This patch adds missing in-flight discard/preflush/dio command count
      check in is_idle().
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      fef4129e
    • C
      f2fs: add to account direct IO · 02b16d0a
      Chao Yu 提交于
      This patch adds f2fs_dio_submit_bio() to hook submit_io/end_io functions
      in direct IO path, in order to account DIO.
      
      Later, we will add this count into is_idle() to let background GC/Discard
      thread be aware of DIO.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      02b16d0a
    • C
      f2fs: clean up f2fs_sb_has_##feature_name · 7beb01f7
      Chao Yu 提交于
      In F2FS_HAS_FEATURE(), we will use F2FS_SB(sb) to get sbi pointer to
      access .raw_super field, to avoid unneeded pointer conversion, this
      patch changes to F2FS_HAS_FEATURE() accept sbi parameter directly.
      
      Just do cleanup, no logic change.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      7beb01f7
    • C
      f2fs: support subsectional garbage collection · e3080b01
      Chao Yu 提交于
      Section is minimal garbage collection unit of f2fs, in zoned block
      device, or ancient block mapping flash device, in order to improve
      GC efficiency, we can align GC unit to lower device erase unit,
      normally, it consists of multiple of segments.
      
      Once background or foreground GC triggers, it brings a large number
      of IOs, which will impact user IO, and also occupy cpu/memory resource
      intensively.
      
      So, to reduce impact of GC on large size section, this patch supports
      subsectional GC, in one cycle of GC, it only migrate partial segment{s}
      in victim section. Currently, by default, we use sbi->segs_per_sec as
      migration granularity.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      e3080b01