f2fs: introduce max_io_bytes, a sysfs entry, to limit bio size
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 3 Dec 2020 17:52:45 +0000 (09:52 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 7 Dec 2020 16:41:25 +0000 (08:41 -0800)
This patch adds max_io_bytes to limit bio size when f2fs tries to merge
consecutive IOs. This can give a testing point to split out bios and check
end_io handles those bios correctly. This is used to capture a recent bug
on the decompression and fsverity flow.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Documentation/ABI/testing/sysfs-fs-f2fs
fs/f2fs/data.c
fs/f2fs/f2fs.h
fs/f2fs/sysfs.c

index 67b3ed8..3dfee94 100644 (file)
@@ -370,3 +370,10 @@ Date:              April 2020
 Contact:       "Daeho Jeong" <daehojeong@google.com>
 Description:   Give a way to change iostat_period time. 3secs by default.
                The new iostat trace gives stats gap given the period.
+What:          /sys/fs/f2fs/<disk>/max_io_bytes
+Date:          December 2020
+Contact:       "Jaegeuk Kim" <jaegeuk@kernel.org>
+Description:   This gives a control to limit the bio size in f2fs.
+               Default is zero, which will follow underlying block layer limit,
+               whereas, if it has a certain bytes value, f2fs won't submit a
+               bio larger than that size.
index e85fd8f..cb28089 100644 (file)
@@ -736,6 +736,9 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
 static bool page_is_mergeable(struct f2fs_sb_info *sbi, struct bio *bio,
                                block_t last_blkaddr, block_t cur_blkaddr)
 {
+       if (unlikely(sbi->max_io_bytes &&
+                       bio->bi_iter.bi_size >= sbi->max_io_bytes))
+               return false;
        if (last_blkaddr + 1 != cur_blkaddr)
                return false;
        return __same_bdev(sbi, cur_blkaddr, bio);
index 36090cd..594df63 100644 (file)
@@ -1446,6 +1446,7 @@ struct f2fs_sb_info {
        loff_t max_file_blocks;                 /* max block index of file */
        int dir_level;                          /* directory level */
        int readdir_ra;                         /* readahead inode in readdir */
+       u64 max_io_bytes;                       /* max io bytes to merge IOs */
 
        block_t user_block_count;               /* # of user blocks */
        block_t total_valid_block_count;        /* # of valid blocks */
index fce2997..989a649 100644 (file)
@@ -567,6 +567,7 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info,
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_enable, iostat_enable);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_period_ms, iostat_period_ms);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, readdir_ra, readdir_ra);
+F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_io_bytes, max_io_bytes);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_super_block, extension_list, extension_list);
 #ifdef CONFIG_F2FS_FAULT_INJECTION
@@ -651,6 +652,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(iostat_enable),
        ATTR_LIST(iostat_period_ms),
        ATTR_LIST(readdir_ra),
+       ATTR_LIST(max_io_bytes),
        ATTR_LIST(gc_pin_file_thresh),
        ATTR_LIST(extension_list),
 #ifdef CONFIG_F2FS_FAULT_INJECTION