aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/super.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2014-03-19 00:31:37 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-03-20 09:10:09 -0400
commitcdfc41c134d48c1923066bcfa6630b94588ad6bc (patch)
tree066af8a1d30379162ed299f3d30275f6e4809ab0 /fs/f2fs/super.c
parent40bb0058c871c6ddcd4aff9fe2f5224e59aba47b (diff)
f2fs: throttle the memory footprint with a sysfs entry
This patch introduces ram_thresh, a sysfs entry, which controls the memory footprint used by the free nid list and the nat cache. Previously, the free nid list was controlled by MAX_FREE_NIDS, while the nat cache was managed by NM_WOUT_THRESHOLD. However, this approach cannot be applied dynamically according to the system. So, this patch adds ram_thresh that users can specify the threshold, which is in order of 1 / 1024. For example, if the total ram size is 4GB and the value is set to 10 by default, f2fs tries to control the number of free nids and nat caches not to consume over 10 * (4GB / 1024) = 10MB. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r--fs/f2fs/super.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index dbe402b1a4b7..34c47b2010bc 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -74,6 +74,7 @@ static match_table_t f2fs_tokens = {
74enum { 74enum {
75 GC_THREAD, /* struct f2fs_gc_thread */ 75 GC_THREAD, /* struct f2fs_gc_thread */
76 SM_INFO, /* struct f2fs_sm_info */ 76 SM_INFO, /* struct f2fs_sm_info */
77 NM_INFO, /* struct f2fs_nm_info */
77 F2FS_SBI, /* struct f2fs_sb_info */ 78 F2FS_SBI, /* struct f2fs_sb_info */
78}; 79};
79 80
@@ -92,6 +93,8 @@ static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type)
92 return (unsigned char *)sbi->gc_thread; 93 return (unsigned char *)sbi->gc_thread;
93 else if (struct_type == SM_INFO) 94 else if (struct_type == SM_INFO)
94 return (unsigned char *)SM_I(sbi); 95 return (unsigned char *)SM_I(sbi);
96 else if (struct_type == NM_INFO)
97 return (unsigned char *)NM_I(sbi);
95 else if (struct_type == F2FS_SBI) 98 else if (struct_type == F2FS_SBI)
96 return (unsigned char *)sbi; 99 return (unsigned char *)sbi;
97 return NULL; 100 return NULL;
@@ -183,6 +186,7 @@ F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
183F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, max_small_discards, max_discards); 186F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, max_small_discards, max_discards);
184F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy); 187F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy);
185F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util); 188F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util);
189F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh);
186F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search); 190F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search);
187F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); 191F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level);
188 192
@@ -198,6 +202,7 @@ static struct attribute *f2fs_attrs[] = {
198 ATTR_LIST(min_ipu_util), 202 ATTR_LIST(min_ipu_util),
199 ATTR_LIST(max_victim_search), 203 ATTR_LIST(max_victim_search),
200 ATTR_LIST(dir_level), 204 ATTR_LIST(dir_level),
205 ATTR_LIST(ram_thresh),
201 NULL, 206 NULL,
202}; 207};
203 208