Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1ce1b02 authored by Jaegeuk Kim's avatar Jaegeuk Kim
Browse files

f2fs: give an option to enable in-place-updates during fsync to users



If user wrote F2FS_IPU_FSYNC:4 in /sys/fs/f2fs/ipu_policy, f2fs_sync_file
only starts to try in-place-updates.
And, if the number of dirty pages is over /sys/fs/f2fs/min_fsync_blocks, it
keeps out-of-order manner. Otherwise, it triggers in-place-updates.

This may be used by storage showing very high random write performance.

For example, it can be used when,

Seq. writes (Data) + wait + Seq. writes (Node)

is pretty much slower than,

Rand. writes (Data)

Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent a7ffdbe2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -44,6 +44,13 @@ Description:
		 Controls the FS utilization condition for the in-place-update
		 policies.

What:		/sys/fs/f2fs/<disk>/min_fsync_blocks
Date:		September 2014
Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
Description:
		 Controls the dirty page count condition for the in-place-update
		 policies.

What:		/sys/fs/f2fs/<disk>/max_small_discards
Date:		November 2013
Contact:	"Jaegeuk Kim" <jaegeuk.kim@samsung.com>
+8 −1
Original line number Diff line number Diff line
@@ -194,13 +194,20 @@ Files in /sys/fs/f2fs/<devname>
                              updates in f2fs. There are five policies:
                               0: F2FS_IPU_FORCE, 1: F2FS_IPU_SSR,
                               2: F2FS_IPU_UTIL,  3: F2FS_IPU_SSR_UTIL,
                               4: F2FS_IPU_DISABLE.
                               4: F2FS_IPU_FSYNC, 5: F2FS_IPU_DISABLE.

 min_ipu_util                 This parameter controls the threshold to trigger
                              in-place-updates. The number indicates percentage
                              of the filesystem utilization, and used by
                              F2FS_IPU_UTIL and F2FS_IPU_SSR_UTIL policies.

 min_fsync_blocks             This parameter controls the threshold to trigger
                              in-place-updates when F2FS_IPU_FSYNC mode is set.
			      The number indicates the number of dirty pages
			      when fsync needs to flush on its call path. If
			      the number is less than this value, it triggers
			      in-place-updates.

 max_victim_search	      This parameter controls the number of trials to
			      find a victim segment when conducting SSR and
			      cleaning operations. The default value is 4096
+1 −0
Original line number Diff line number Diff line
@@ -386,6 +386,7 @@ struct f2fs_sm_info {

	unsigned int ipu_policy;	/* in-place-update policy */
	unsigned int min_ipu_util;	/* in-place-update threshold */
	unsigned int min_fsync_blocks;	/* threshold for fsync */

	/* for flush command control */
	struct flush_cmd_control *cmd_control_info;
+3 −4
Original line number Diff line number Diff line
@@ -154,12 +154,11 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
	trace_f2fs_sync_file_enter(inode);

	/* if fdatasync is triggered, let's do in-place-update */
	if (datasync)
	if (get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)
		set_inode_flag(fi, FI_NEED_IPU);

	ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
	if (datasync)
	clear_inode_flag(fi, FI_NEED_IPU);

	if (ret) {
		trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
		return ret;
+2 −1
Original line number Diff line number Diff line
@@ -1928,8 +1928,9 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
	sm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr);
	sm_info->rec_prefree_segments = sm_info->main_segments *
					DEF_RECLAIM_PREFREE_SEGMENTS / 100;
	sm_info->ipu_policy = F2FS_IPU_DISABLE;
	sm_info->ipu_policy = F2FS_IPU_FSYNC;
	sm_info->min_ipu_util = DEF_MIN_IPU_UTIL;
	sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;

	INIT_LIST_HEAD(&sm_info->discard_list);
	sm_info->nr_discards = 0;
Loading