f2fs: introduce checkpoint=merge mount option
Subsystems (2)
PATCH v3 1/2 f2fs: introduce checkpoint=merge mount option
From: Daeho Jeong <[email protected]>
We've added a new mount option "checkpoint=merge", which creates a kernel daemon and makes it to merge concurrent checkpoint requests as much as possible to eliminate redundant checkpoint issues. Plus, we can eliminate the sluggish issue caused by slow checkpoint operation when the checkpoint is done in a process context in a cgroup having low i/o budget and cpu shares, and The below verification result explains this.
The basic idea has come from https://opensource.samsung.com.
[Verification]
Android Pixel Device(ARM64, 7GB RAM, 256GB UFS) Create two I/O cgroups (fg w/ weight 100, bg w/ wight 20) Set "strict_guarantees" to "1" in BFQ tunables
In "fg" cgroup,
- thread A => trigger 1000 checkpoint operations
"for i in seq 1 1000; do touch test_dir1/file; fsync test_dir1;
done"
- thread B => gererating async. I/O
"fio --rw=write --numjobs=1 --bs=128k --runtime=3600 --time_based=1
--filename=test_img --name=test"
In "bg" cgroup,
- thread C => trigger repeated checkpoint operations
"echo $$ > /dev/blkio/bg/tasks; while true; do touch test_dir2/file;
fsync test_dir2; done"
We've measured thread A's execution time.
[ w/o patch ]
Elapsed Time: Avg. 68 seconds
[ w/ patch ]
Elapsed Time: Avg. 48 seconds
---
v2:
- inlined ckpt_req_control into f2fs_sb_info and collected stastics of checkpoint merge operations
v3:
- fixed some minor errors and cleaned up f2fs_sync_fs()
--- Documentation/filesystems/f2fs.rst | 6 + fs/f2fs/checkpoint.c | 177 +++++++++++++++++++++++++++++ fs/f2fs/debug.c | 12 ++ fs/f2fs/f2fs.h | 27 +++++ fs/f2fs/super.c | 55 +++++++-- 5 files changed, 269 insertions(+), 8 deletions(-)
Documentation/filesystems/f2fs.rst +6 -0
@@ -247,6 +247,12 @@ checkpoint=%s[:%u[%]] Set to "disable" to turn off checkpointing. Set to "enabl hide up to all remaining free space. The actual space that would be unusable can be viewed at /sys/fs/f2fs/<disk>/unusable This space is reclaimed once checkpoint=enable. + Here is another option "merge", which creates a kernel daemon + and makes it to merge concurrent checkpoint requests as much + as possible to eliminate redundant checkpoint issues. Plus, + we can eliminate the sluggish issue caused by slow checkpoint + operation when the checkpoint is done in a process context in + a cgroup having low i/o budget and cpu shares. compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo", "lz4", "zstd" and "lzo-rle" algorithm. compress_log_size=%u Support configuring compress cluster size, the size will
fs/f2fs/checkpoint.c +177 -0
192 lines not on this page · raw message
fs/f2fs/debug.c +12 -0
@@ -120,6 +120,13 @@ static void update_general_status(struct f2fs_sb_info *sbi)atomic_read (&SM_I (sbi)->dcc_info->discard_cmd_cnt); si->undiscard_blks =SM_I (sbi)->dcc_info->undiscard_blks; } + si->nr_issued_ckpt =atomic_read (&sbi->cprc_info.issued_ckpt); + si->nr_total_ckpt =atomic_read (&sbi->cprc_info.total_ckpt); + si->nr_queued_ckpt =atomic_read (&sbi->cprc_info.queued_ckpt); +spin_lock (&sbi->cprc_info.stat_lock); + si->cur_ckpt_time = sbi->cprc_info.cur_time; + si->peak_ckpt_time = sbi->cprc_info.peak_time; +spin_unlock (&sbi->cprc_info.stat_lock); si->total_count = (int )sbi->user_block_count / sbi->blocks_per_seg; si->rsvd_segs =reserved_segments (sbi); si->overp_segs =overprovision_segments (sbi);
@@ -417,6 +424,11 @@ static int stat_show(struct seq_file *s, void *v) si->meta_count[META_NAT]);seq_printf (s," - ssa blocks : %u\n" , si->meta_count[META_SSA ]); +seq_printf (s,"CP merge (Queued: %4d, Issued: %4d, Total: %4d, " +"Cur time: %4d(ms), Peak time: %4d(ms))\n" , + si->nr_queued_ckpt, si->nr_issued_ckpt, + si->nr_total_ckpt, si->cur_ckpt_time, + si->peak_ckpt_time);seq_printf (s,"GC calls: %d (BG: %d)\n" , si->call_count, si->bg_gc); seq_printf(s, " - data segments : %d (%d)\n",
fs/f2fs/f2fs.h +27 -0
@@ -97,6 +97,7 @@ extern const char *f2fs_fault_name[FAULT_MAX];#define F2FS_MOUNT_DISABLE_CHECKPOINT 0x02000000#define F2FS_MOUNT_NORECOVERY 0x04000000#define F2FS_MOUNT_ATGC 0x08000000 +#define F2FS_MOUNT_MERGE_CHECKPOINT 0x10000000#define F2FS_OPTION (sbi) ((sbi)->mount_opt)#define clear_opt (sbi, option) (F2FS_OPTION(sbi).opt &= ~F2FS_MOUNT_##option)
@@ -266,6 +267,25 @@ struct fsync_node_entry {unsigned int seq_id;/* sequence id */ }; +struct ckpt_req { +struct completion wait;/* completion for checkpoint done */ +struct llist_node llnode;/* llist_node to be linked in wait queue */ +int ret;/* return code of checkpoint */ +ktime_t queue_time;/* request queued time */ +}; + +struct ckpt_req_control { +struct task_struct *f2fs_issue_ckpt;/* checkpoint task */ +wait_queue_head_t ckpt_wait_queue;/* waiting queue for wake-up */ +atomic_t issued_ckpt;/* # of actually issued ckpts */ +atomic_t total_ckpt;/* # of total ckpts */ +atomic_t queued_ckpt;/* # of queued ckpts */ +struct llist_head issue_list;/* list for command issue */ +spinlock_t stat_lock;/* lock for below checkpoint time stats */ +unsigned int cur_time;/* cur wait time in msec for currently issued checkpoint */ +unsigned int peak_time;/* peak wait time in msec until now */ +}; +/* for the bitmap indicate blocks to be discarded */ struct discard_entry {struct list_head list;/* list head */
@@ -1404,6 +1424,7 @@ struct f2fs_sb_info {wait_queue_head_t cp_wait;unsigned long last_time[MAX_TIME ];/* to store time in jiffies */ long interval_time[MAX_TIME ];/* to store thresholds */ +struct ckpt_req_control cprc_info;/* for checkpoint request control */ struct inode_management im[MAX_INO_ENTRY ];/* manage inode cache */
@@ -3418,6 +3439,10 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc);void f2fs_init_ino_entry_info (struct f2fs_sb_info *sbi);int __init f2fs_create_checkpoint_caches (void );void f2fs_destroy_checkpoint_caches (void ); +int f2fs_issue_checkpoint (struct f2fs_sb_info *sbi); +int f2fs_start_ckpt_thread (struct f2fs_sb_info *sbi); +void f2fs_stop_ckpt_thread (struct f2fs_sb_info *sbi); +void f2fs_init_ckpt_req_control (struct f2fs_sb_info *sbi);/* * data.c
@@ -3530,6 +3555,8 @@ struct f2fs_stat_info {int nr_discarding, nr_discarded;int nr_discard_cmd;unsigned int undiscard_blks; +int nr_issued_ckpt, nr_total_ckpt, nr_queued_ckpt; +unsigned int cur_ckpt_time, peak_ckpt_time;int inline_xattr, inline_inode, inline_dir, append, update, orphans;int compr_inode;unsigned long long compr_blocks;
fs/f2fs/super.c +47 -8
116 lines not on this page · raw message
Signature · 8 lines
2.30.0.296.g2bfb1c46d8-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 9 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
We've added a new mount option "checkpoint=merge", which creates a kernel daemon and makes it to merge concurrent checkpoint requests as much as possible to eliminate redundant checkpoint issues. Plus, we can eliminate the sluggish issue caused by slow checkpoint operation when the checkpoint is done in a process context in a cgroup having low i/o budget and cpu shares, and The below verification result explains this.
Could you please summary and add below info into commit message and f2fs.rst?
"Actually, the default I/O priority of kernel thread is "4". So, we're going to raise this
priority by one, because we want to give one higher priority for checkpointing thread
than other normal threads. This is the same way to give a I/O priority to the jbd2 journaling
thread of ext4 filesystem."
Otherwise this patch looks good to me.
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel