diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-01-08 18:51:50 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-01-11 18:36:27 -0500 |
commit | 6beceb5427aa8731f958d2484e0fd8ff21d604dc (patch) | |
tree | 5130a15bba97035a283d99602d8b538e2ec88023 | |
parent | 9b72a388f5867f4a31113a41d24bbf1026611d7b (diff) |
f2fs: introduce time and interval facility
This patch adds time and interval arrays to store some timing variables.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/checkpoint.c | 2 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 21 | ||||
-rw-r--r-- | fs/f2fs/segment.c | 2 | ||||
-rw-r--r-- | fs/f2fs/super.c | 7 |
4 files changed, 25 insertions, 7 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 5dbafd5e83d9..3842af954cd5 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -1139,7 +1139,7 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
1139 | "checkpoint: version = %llx", ckpt_ver); | 1139 | "checkpoint: version = %llx", ckpt_ver); |
1140 | 1140 | ||
1141 | /* do checkpoint periodically */ | 1141 | /* do checkpoint periodically */ |
1142 | sbi->cp_expires = round_jiffies_up(jiffies + HZ * sbi->cp_interval); | 1142 | f2fs_update_time(sbi, CP_TIME); |
1143 | trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint"); | 1143 | trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint"); |
1144 | out: | 1144 | out: |
1145 | mutex_unlock(&sbi->cp_mutex); | 1145 | mutex_unlock(&sbi->cp_mutex); |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index ae0007df6c2c..5bbb6a407e79 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -721,6 +721,11 @@ enum { | |||
721 | SBI_POR_DOING, /* recovery is doing or not */ | 721 | SBI_POR_DOING, /* recovery is doing or not */ |
722 | }; | 722 | }; |
723 | 723 | ||
724 | enum { | ||
725 | CP_TIME, | ||
726 | MAX_TIME, | ||
727 | }; | ||
728 | |||
724 | struct f2fs_sb_info { | 729 | struct f2fs_sb_info { |
725 | struct super_block *sb; /* pointer to VFS super block */ | 730 | struct super_block *sb; /* pointer to VFS super block */ |
726 | struct proc_dir_entry *s_proc; /* proc entry */ | 731 | struct proc_dir_entry *s_proc; /* proc entry */ |
@@ -747,7 +752,8 @@ struct f2fs_sb_info { | |||
747 | struct rw_semaphore node_write; /* locking node writes */ | 752 | struct rw_semaphore node_write; /* locking node writes */ |
748 | struct mutex writepages; /* mutex for writepages() */ | 753 | struct mutex writepages; /* mutex for writepages() */ |
749 | wait_queue_head_t cp_wait; | 754 | wait_queue_head_t cp_wait; |
750 | long cp_expires, cp_interval; /* next expected periodic cp */ | 755 | unsigned long last_time[MAX_TIME]; /* to store time in jiffies */ |
756 | long interval_time[MAX_TIME]; /* to store thresholds */ | ||
751 | 757 | ||
752 | struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */ | 758 | struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */ |
753 | 759 | ||
@@ -837,6 +843,19 @@ struct f2fs_sb_info { | |||
837 | unsigned int shrinker_run_no; | 843 | unsigned int shrinker_run_no; |
838 | }; | 844 | }; |
839 | 845 | ||
846 | static inline void f2fs_update_time(struct f2fs_sb_info *sbi, int type) | ||
847 | { | ||
848 | sbi->last_time[type] = jiffies; | ||
849 | } | ||
850 | |||
851 | static inline bool f2fs_time_over(struct f2fs_sb_info *sbi, int type) | ||
852 | { | ||
853 | struct timespec ts = {sbi->interval_time[type], 0}; | ||
854 | unsigned long interval = timespec_to_jiffies(&ts); | ||
855 | |||
856 | return time_after(jiffies, sbi->last_time[type] + interval); | ||
857 | } | ||
858 | |||
840 | /* | 859 | /* |
841 | * Inline functions | 860 | * Inline functions |
842 | */ | 861 | */ |
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index c7bbc915d962..fed23d5a7b34 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -293,7 +293,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) | |||
293 | if (!available_free_memory(sbi, NAT_ENTRIES) || | 293 | if (!available_free_memory(sbi, NAT_ENTRIES) || |
294 | excess_prefree_segs(sbi) || | 294 | excess_prefree_segs(sbi) || |
295 | !available_free_memory(sbi, INO_ENTRIES) || | 295 | !available_free_memory(sbi, INO_ENTRIES) || |
296 | jiffies > sbi->cp_expires) { | 296 | f2fs_time_over(sbi, CP_TIME)) { |
297 | if (test_opt(sbi, DATA_FLUSH)) | 297 | if (test_opt(sbi, DATA_FLUSH)) |
298 | sync_dirty_inodes(sbi, FILE_INODE); | 298 | sync_dirty_inodes(sbi, FILE_INODE); |
299 | f2fs_sync_fs(sbi->sb, true); | 299 | f2fs_sync_fs(sbi->sb, true); |
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index f5cc790646e2..787047f59c00 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -218,7 +218,7 @@ F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh); | |||
218 | F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ra_nid_pages, ra_nid_pages); | 218 | F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ra_nid_pages, ra_nid_pages); |
219 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search); | 219 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search); |
220 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); | 220 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); |
221 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, cp_interval); | 221 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, interval_time[CP_TIME]); |
222 | 222 | ||
223 | #define ATTR_LIST(name) (&f2fs_attr_##name.attr) | 223 | #define ATTR_LIST(name) (&f2fs_attr_##name.attr) |
224 | static struct attribute *f2fs_attrs[] = { | 224 | static struct attribute *f2fs_attrs[] = { |
@@ -1122,7 +1122,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi) | |||
1122 | atomic_set(&sbi->nr_pages[i], 0); | 1122 | atomic_set(&sbi->nr_pages[i], 0); |
1123 | 1123 | ||
1124 | sbi->dir_level = DEF_DIR_LEVEL; | 1124 | sbi->dir_level = DEF_DIR_LEVEL; |
1125 | sbi->cp_interval = DEF_CP_INTERVAL; | 1125 | sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL; |
1126 | clear_sbi_flag(sbi, SBI_NEED_FSCK); | 1126 | clear_sbi_flag(sbi, SBI_NEED_FSCK); |
1127 | 1127 | ||
1128 | INIT_LIST_HEAD(&sbi->s_list); | 1128 | INIT_LIST_HEAD(&sbi->s_list); |
@@ -1467,8 +1467,7 @@ try_onemore: | |||
1467 | f2fs_commit_super(sbi, true); | 1467 | f2fs_commit_super(sbi, true); |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | sbi->cp_expires = round_jiffies_up(jiffies); | 1470 | f2fs_update_time(sbi, CP_TIME); |
1471 | |||
1472 | return 0; | 1471 | return 0; |
1473 | 1472 | ||
1474 | free_kobj: | 1473 | free_kobj: |