Re: [f2fs-dev] [PATCH v2] f2fs: introduce fragment allocation mode mount option
On 2021/8/26 2:57, Daeho Jeong wrote: From: Daeho Jeong Added two options into "mode=" mount option to make it possible for developers to make the filesystem fragmented or simulate filesystem fragmentation/after-GC situation itself. The developers use these modes to understand filesystem fragmentation/after-GC condition well, and eventually get some insights to handle them better. "fragment:segment": f2fs allocates a new segment in ramdom position. With this, we can simulate the after-GC condition. "fragment:block" : We can scatter block allocation with "fragment_chunk_max" and "fragment_hole_max" sysfs nodes. f2fs will allocate 1.. blocks in a chunk and make a hole in the length of 1.. by turns in a newly allocated free segment. I'd like to add a fixed chunk/hole fragmentation mode in addition, then userspace can control the fragmented chunk/hole with fixed size. How do you think of renaming "fragment:block" to "fragment:rand_block", and then I can add "fragment:fixed_block" option and its logic in addition? Signed-off-by: Daeho Jeong --- v2: changed mode name and added sysfs nodes to control the fragmentation pattern. --- Documentation/ABI/testing/sysfs-fs-f2fs | 18 ++ Documentation/filesystems/f2fs.rst | 16 fs/f2fs/f2fs.h | 16 fs/f2fs/gc.c| 5 - fs/f2fs/segment.c | 17 +++-- fs/f2fs/super.c | 11 +++ fs/f2fs/sysfs.c | 20 7 files changed, 100 insertions(+), 3 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index f627e705e663..dba3997895ef 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -512,3 +512,21 @@ Date: July 2021 Contact: "Daeho Jeong" Description: You can control the multiplier value of bdi device readahead window size between 2 (default) and 256 for POSIX_FADV_SEQUENTIAL advise option. + +What: /sys/fs/f2fs//fragment_chunk_max +Date: August 2021 +Contact: "Daeho Jeong" +Description: With "mode=fragment:block" mount option, we can scatter block allocation. + Using this node, f2fs will allocate 1.. blocks in a chunk + and make a hole in the length of 1.. by turns in a newly + allocated free segment. This value can be set between 1..512 and the default + value is 4. + +What: /sys/fs/f2fs//fragment_hole_max +Date: August 2021 +Contact: "Daeho Jeong" +Description: With "mode=fragment:block" mount option, we can scatter block allocation. + Using this node, f2fs will allocate 1.. blocks in a chunk + and make a hole in the length of 1.. by turns in a newly + allocated free segment. This value can be set between 1..512 and the default + value is 4. diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst index 09de6ebbbdfa..d2ddc1273f67 100644 --- a/Documentation/filesystems/f2fs.rst +++ b/Documentation/filesystems/f2fs.rst @@ -201,6 +201,22 @@ fault_type=%d Support configuring fault injection type, should be mode=%sControl block allocation mode which supports "adaptive" and "lfs". In "lfs" mode, there should be no random writes towards main area. +"fragment:segment" and "fragment:block" are newly added here. +These are developer options for experiments to make the filesystem +fragmented or simulate filesystem fragmentation/after-GC situation +itself. The developers use these modes to understand filesystem +fragmentation/after-GC condition well, and eventually get some +insights to handle them better. +In "fragment:segment", f2fs allocates a new segment in ramdom +position. With this, we can simulate the after-GC condition. +In "fragment:block", we can scatter block allocation with +"fragment_chunk_max" and "fragment_hole_max" sysfs nodes. f2fs will +allocate 1.. blocks in a chunk and make +a hole in the length of 1.. by turns in a newly +allocated free segment. With this, the newly allocated blocks will +be scattered throughout the whole partition. Please, use these +options for your experiments and we strongly recommend
Re: [f2fs-dev] [PATCH v3] f2fs: don't ignore writing pages on fsync during checkpoint=disable
>From 64fe93a7f9c35c2b5a34cfa3cf84158852c201be Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 19 Aug 2021 14:00:57 -0700 Subject: [PATCH] f2fs: guarantee to write dirty data when enabling checkpoint back We must flush all the dirty data when enabling checkpoint back. Let's guarantee that first by adding a retry logic on sync_inodes_sb(). In addition to that, this patch adds to flush data in fsync when checkpoint is disabled, which can mitigate the sync_inodes_sb() failures in advance. Signed-off-by: Jaegeuk Kim --- Change log from v2: - repharse the patch description a bit - fix retry condition check fs/f2fs/file.c | 5 ++--- fs/f2fs/super.c | 11 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index cc2080866c54..3330efb41f22 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -263,8 +263,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, }; unsigned int seq_id = 0; - if (unlikely(f2fs_readonly(inode->i_sb) || - is_sbi_flag_set(sbi, SBI_CP_DISABLED))) + if (unlikely(f2fs_readonly(inode->i_sb))) return 0; trace_f2fs_sync_file_enter(inode); @@ -278,7 +277,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, ret = file_write_and_wait_range(file, start, end); clear_inode_flag(inode, FI_NEED_IPU); - if (ret) { + if (ret || is_sbi_flag_set(sbi, SBI_CP_DISABLED)) { trace_f2fs_sync_file_exit(inode, cp_reason, datasync, ret); return ret; } diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 49e153fd8183..b8fecf4f37e0 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2088,8 +2088,17 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi) static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi) { + int retry = DEFAULT_RETRY_IO_COUNT; + /* we should flush all the data to keep data consistency */ - sync_inodes_sb(sbi->sb); + do { + sync_inodes_sb(sbi->sb); + cond_resched(); + congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT); + } while (get_pages(sbi, F2FS_DIRTY_DATA) && retry--); + + if (unlikely(retry < 0)) + f2fs_warn(sbi, "checkpoint=enable has some unwritten data."); down_write(&sbi->gc_lock); f2fs_dirty_to_prefree(sbi); -- 2.33.0.rc2.250.ged5fa647cd-goog ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel