f2fs: change reclaim rate in percentage
authorJaegeuk Kim <jaegeuk.kim@samsung.com>
Wed, 19 Mar 2014 05:17:21 +0000 (14:17 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Thu, 20 Mar 2014 13:10:10 +0000 (22:10 +0900)
It is more reasonable to determine the reclaiming rate of prefree segments
according to the volume size, which is set to 5% by default.
For example, if the volume is 128GB, the prefree segments are reclaimed
when the number reaches to 6.4GB.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Documentation/filesystems/f2fs.txt
fs/f2fs/segment.c
fs/f2fs/segment.h

index f415b9fc4cc8fe698134c403be1a6ad1ff27a98b..2f6d0218dd22b6d222d4fbfe9d4cb9792f07eec2 100644 (file)
@@ -169,9 +169,11 @@ Files in /sys/fs/f2fs/<devname>
 
  reclaim_segments             This parameter controls the number of prefree
                               segments to be reclaimed. If the number of prefree
-                             segments is larger than this number, f2fs tries to
-                             conduct checkpoint to reclaim the prefree segments
-                             to free segments. By default, 100 segments, 200MB.
+                             segments is larger than the number of segments
+                             in the proportion to the percentage over total
+                             volume size, f2fs tries to conduct checkpoint to
+                             reclaim the prefree segments to free segments.
+                             By default, 5% over total # of segments.
 
  max_small_discards          This parameter controls the number of discard
                              commands that consist small blocks less than 2MB.
index 6c5a4f0218ca21cded90baf047430e2900d84db5..e7ff23a536a400872bb63592ac1ea4d370906cfb 100644 (file)
@@ -1758,7 +1758,8 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
        sm_info->ovp_segments = le32_to_cpu(ckpt->overprov_segment_count);
        sm_info->main_segments = le32_to_cpu(raw_super->segment_count_main);
        sm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr);
-       sm_info->rec_prefree_segments = DEF_RECLAIM_PREFREE_SEGMENTS;
+       sm_info->rec_prefree_segments = sm_info->main_segments *
+                                       DEF_RECLAIM_PREFREE_SEGMENTS / 100;
        sm_info->ipu_policy = F2FS_IPU_DISABLE;
        sm_info->min_ipu_util = DEF_MIN_IPU_UTIL;
 
index 9fc46ee27bb8ce65ec94662bf1b3ce4829936c93..7091204680f49383ff269f0b8c35834e2c5297d8 100644 (file)
@@ -14,7 +14,7 @@
 #define NULL_SEGNO                     ((unsigned int)(~0))
 #define NULL_SECNO                     ((unsigned int)(~0))
 
-#define DEF_RECLAIM_PREFREE_SEGMENTS   100     /* 200MB of prefree segments */
+#define DEF_RECLAIM_PREFREE_SEGMENTS   5       /* 5% over total segments */
 
 /* L: Logical segment # in volume, R: Relative segment # in main area */
 #define GET_L2R_SEGNO(free_i, segno)   (segno - free_i->start_segno)