f2fs: export SSR allocation threshold
authorChao Yu <yuchao0@huawei.com>
Sat, 28 Oct 2017 08:52:33 +0000 (16:52 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 19 Dec 2017 03:28:30 +0000 (19:28 -0800)
This patch exports min_ssr_segments threshold in sysfs to let user
control triggering SSR allocation flexibly.

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

index fc1dff659df44e5816133c660c0ce383b3fcaf56..a7799c2fca2855eced4740cb6a82e5f26a448287 100644 (file)
@@ -57,6 +57,12 @@ Contact:     "Jaegeuk Kim" <jaegeuk@kernel.org>
 Description:
                 Controls the dirty page count condition for redefining hot data.
 
+What:          /sys/fs/f2fs/<disk>/min_ssr_sections
+Date:          October 2017
+Contact:       "Chao Yu" <yuchao0@huawei.com>
+Description:
+                Controls the fee section threshold to trigger SSR allocation.
+
 What:          /sys/fs/f2fs/<disk>/max_small_discards
 Date:          November 2013
 Contact:       "Jaegeuk Kim" <jaegeuk.kim@samsung.com>
index 2b9b1d8b38706427ac0fc2656bf005a048042df5..ee10c5206b2f4bf2772200106ed150f9d559a328 100644 (file)
@@ -840,6 +840,7 @@ struct f2fs_sm_info {
        unsigned int min_ipu_util;      /* in-place-update threshold */
        unsigned int min_fsync_blocks;  /* threshold for fsync */
        unsigned int min_hot_blocks;    /* threshold for hot block allocation */
+       unsigned int min_ssr_sections;  /* threshold to trigger SSR allocation */
 
        /* for flush command control */
        struct flush_cmd_control *fcc_info;
@@ -1077,6 +1078,7 @@ struct f2fs_sb_info {
        int active_logs;                        /* # of active logs */
        int dir_level;                          /* directory level */
        int inline_xattr_size;                  /* inline xattr size */
+       unsigned int trigger_ssr_threshold;     /* threshold to trigger ssr */
 
        block_t user_block_count;               /* # of user blocks */
        block_t total_valid_block_count;        /* # of valid blocks */
index d2b2351e7d9cac87324ab309e17050bfc9f8e805..0de1761928d393e52970e10ea7693a1add442d7e 100644 (file)
@@ -181,7 +181,7 @@ bool need_SSR(struct f2fs_sb_info *sbi)
                return true;
 
        return free_sections(sbi) <= (node_secs + 2 * dent_secs + imeta_secs +
-                                               2 * reserved_sections(sbi));
+                       SM_I(sbi)->min_ssr_sections + reserved_sections(sbi));
 }
 
 void register_inmem_page(struct inode *inode, struct page *page)
@@ -3671,6 +3671,7 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
        sm_info->min_ipu_util = DEF_MIN_IPU_UTIL;
        sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;
        sm_info->min_hot_blocks = DEF_MIN_HOT_BLOCKS;
+       sm_info->min_ssr_sections = reserved_sections(sbi);
 
        sm_info->trim_sections = DEF_BATCHED_TRIM_SECTIONS;
 
index 4166ac74e837006c9695337eabd6fb57933862b3..f0fdc89ce82fe42c845b7f5f8e5132dd67dbecfd 100644 (file)
@@ -285,6 +285,7 @@ F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy);
 F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util);
 F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_fsync_blocks, min_fsync_blocks);
 F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_hot_blocks, min_hot_blocks);
+F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ssr_sections, min_ssr_sections);
 F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh);
 F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ra_nid_pages, ra_nid_pages);
 F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, dirty_nats_ratio, dirty_nats_ratio);
@@ -330,6 +331,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(min_ipu_util),
        ATTR_LIST(min_fsync_blocks),
        ATTR_LIST(min_hot_blocks),
+       ATTR_LIST(min_ssr_sections),
        ATTR_LIST(max_victim_search),
        ATTR_LIST(dir_level),
        ATTR_LIST(ram_thresh),