diff options
-rw-r--r-- | Documentation/ABI/testing/sysfs-fs-f2fs | 6 | ||||
-rw-r--r-- | fs/f2fs/checkpoint.c | 3 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 2 | ||||
-rw-r--r-- | fs/f2fs/segment.c | 4 | ||||
-rw-r--r-- | fs/f2fs/super.c | 5 |
5 files changed, 19 insertions, 1 deletions
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 2c4cc42006e8..e066281dfd4e 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs | |||
@@ -80,3 +80,9 @@ Date: February 2015 | |||
80 | Contact: "Jaegeuk Kim" <jaegeuk@kernel.org> | 80 | Contact: "Jaegeuk Kim" <jaegeuk@kernel.org> |
81 | Description: | 81 | Description: |
82 | Controls the trimming rate in batch mode. | 82 | Controls the trimming rate in batch mode. |
83 | |||
84 | What: /sys/fs/f2fs/<disk>/cp_interval | ||
85 | Date: October 2015 | ||
86 | Contact: "Jaegeuk Kim" <jaegeuk@kernel.org> | ||
87 | Description: | ||
88 | Controls the checkpoint timing. | ||
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index ff53405aee39..0569097dbd7a 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -1114,6 +1114,9 @@ void write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
1114 | if (cpc->reason == CP_RECOVERY) | 1114 | if (cpc->reason == CP_RECOVERY) |
1115 | f2fs_msg(sbi->sb, KERN_NOTICE, | 1115 | f2fs_msg(sbi->sb, KERN_NOTICE, |
1116 | "checkpoint: version = %llx", ckpt_ver); | 1116 | "checkpoint: version = %llx", ckpt_ver); |
1117 | |||
1118 | /* do checkpoint periodically */ | ||
1119 | sbi->cp_expires = round_jiffies_up(jiffies + HZ * sbi->cp_interval); | ||
1117 | out: | 1120 | out: |
1118 | mutex_unlock(&sbi->cp_mutex); | 1121 | mutex_unlock(&sbi->cp_mutex); |
1119 | trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint"); | 1122 | trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint"); |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 00bd47045c1e..aad4720c516e 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -124,6 +124,7 @@ enum { | |||
124 | (SM_I(sbi)->trim_sections * (sbi)->segs_per_sec) | 124 | (SM_I(sbi)->trim_sections * (sbi)->segs_per_sec) |
125 | #define BATCHED_TRIM_BLOCKS(sbi) \ | 125 | #define BATCHED_TRIM_BLOCKS(sbi) \ |
126 | (BATCHED_TRIM_SEGMENTS(sbi) << (sbi)->log_blocks_per_seg) | 126 | (BATCHED_TRIM_SEGMENTS(sbi) << (sbi)->log_blocks_per_seg) |
127 | #define DEF_CP_INTERVAL 60 /* 60 secs */ | ||
127 | 128 | ||
128 | struct cp_control { | 129 | struct cp_control { |
129 | int reason; | 130 | int reason; |
@@ -734,6 +735,7 @@ struct f2fs_sb_info { | |||
734 | struct rw_semaphore node_write; /* locking node writes */ | 735 | struct rw_semaphore node_write; /* locking node writes */ |
735 | struct mutex writepages; /* mutex for writepages() */ | 736 | struct mutex writepages; /* mutex for writepages() */ |
736 | wait_queue_head_t cp_wait; | 737 | wait_queue_head_t cp_wait; |
738 | long cp_expires, cp_interval; /* next expected periodic cp */ | ||
737 | 739 | ||
738 | struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */ | 740 | struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */ |
739 | 741 | ||
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 6b8edf21a152..1d86a35ae9fe 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/prefetch.h> | 15 | #include <linux/prefetch.h> |
16 | #include <linux/kthread.h> | 16 | #include <linux/kthread.h> |
17 | #include <linux/swap.h> | 17 | #include <linux/swap.h> |
18 | #include <linux/timer.h> | ||
18 | 19 | ||
19 | #include "f2fs.h" | 20 | #include "f2fs.h" |
20 | #include "segment.h" | 21 | #include "segment.h" |
@@ -315,7 +316,8 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) | |||
315 | /* checkpoint is the only way to shrink partial cached entries */ | 316 | /* checkpoint is the only way to shrink partial cached entries */ |
316 | if (!available_free_memory(sbi, NAT_ENTRIES) || | 317 | if (!available_free_memory(sbi, NAT_ENTRIES) || |
317 | excess_prefree_segs(sbi) || | 318 | excess_prefree_segs(sbi) || |
318 | !available_free_memory(sbi, INO_ENTRIES)) | 319 | !available_free_memory(sbi, INO_ENTRIES) || |
320 | jiffies > sbi->cp_expires) | ||
319 | f2fs_sync_fs(sbi->sb, true); | 321 | f2fs_sync_fs(sbi->sb, true); |
320 | } | 322 | } |
321 | 323 | ||
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index ba058d08cb33..cb23d85a4ed3 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -215,6 +215,7 @@ F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_fsync_blocks, min_fsync_blocks); | |||
215 | F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh); | 215 | F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh); |
216 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search); | 216 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search); |
217 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); | 217 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); |
218 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, cp_interval); | ||
218 | 219 | ||
219 | #define ATTR_LIST(name) (&f2fs_attr_##name.attr) | 220 | #define ATTR_LIST(name) (&f2fs_attr_##name.attr) |
220 | static struct attribute *f2fs_attrs[] = { | 221 | static struct attribute *f2fs_attrs[] = { |
@@ -231,6 +232,7 @@ static struct attribute *f2fs_attrs[] = { | |||
231 | ATTR_LIST(max_victim_search), | 232 | ATTR_LIST(max_victim_search), |
232 | ATTR_LIST(dir_level), | 233 | ATTR_LIST(dir_level), |
233 | ATTR_LIST(ram_thresh), | 234 | ATTR_LIST(ram_thresh), |
235 | ATTR_LIST(cp_interval), | ||
234 | NULL, | 236 | NULL, |
235 | }; | 237 | }; |
236 | 238 | ||
@@ -1014,6 +1016,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi) | |||
1014 | atomic_set(&sbi->nr_pages[i], 0); | 1016 | atomic_set(&sbi->nr_pages[i], 0); |
1015 | 1017 | ||
1016 | sbi->dir_level = DEF_DIR_LEVEL; | 1018 | sbi->dir_level = DEF_DIR_LEVEL; |
1019 | sbi->cp_interval = DEF_CP_INTERVAL; | ||
1017 | clear_sbi_flag(sbi, SBI_NEED_FSCK); | 1020 | clear_sbi_flag(sbi, SBI_NEED_FSCK); |
1018 | 1021 | ||
1019 | INIT_LIST_HEAD(&sbi->s_list); | 1022 | INIT_LIST_HEAD(&sbi->s_list); |
@@ -1350,6 +1353,8 @@ try_onemore: | |||
1350 | f2fs_commit_super(sbi, true); | 1353 | f2fs_commit_super(sbi, true); |
1351 | } | 1354 | } |
1352 | 1355 | ||
1356 | sbi->cp_expires = round_jiffies_up(jiffies); | ||
1357 | |||
1353 | return 0; | 1358 | return 0; |
1354 | 1359 | ||
1355 | free_kobj: | 1360 | free_kobj: |