Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+25 -7
+1 -1
fs/f2fs/checkpoint.c
··· 1139 1139 "checkpoint: version = %llx", ckpt_ver); 1140 1140 1141 1141 /* do checkpoint periodically */ 1142 - sbi->cp_expires = round_jiffies_up(jiffies + HZ * sbi->cp_interval); 1142 + f2fs_update_time(sbi, CP_TIME); 1143 1143 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint"); 1144 1144 out: 1145 1145 mutex_unlock(&sbi->cp_mutex);
+20 -1
fs/f2fs/f2fs.h
··· 721 721 SBI_POR_DOING, /* recovery is doing or not */ 722 722 }; 723 723 724 + enum { 725 + CP_TIME, 726 + MAX_TIME, 727 + }; 728 + 724 729 struct f2fs_sb_info { 725 730 struct super_block *sb; /* pointer to VFS super block */ 726 731 struct proc_dir_entry *s_proc; /* proc entry */ ··· 752 747 struct rw_semaphore node_write; /* locking node writes */ 753 748 struct mutex writepages; /* mutex for writepages() */ 754 749 wait_queue_head_t cp_wait; 755 - long cp_expires, cp_interval; /* next expected periodic cp */ 750 + unsigned long last_time[MAX_TIME]; /* to store time in jiffies */ 751 + long interval_time[MAX_TIME]; /* to store thresholds */ 756 752 757 753 struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */ 758 754 ··· 842 836 struct mutex umount_mutex; 843 837 unsigned int shrinker_run_no; 844 838 }; 839 + 840 + static inline void f2fs_update_time(struct f2fs_sb_info *sbi, int type) 841 + { 842 + sbi->last_time[type] = jiffies; 843 + } 844 + 845 + static inline bool f2fs_time_over(struct f2fs_sb_info *sbi, int type) 846 + { 847 + struct timespec ts = {sbi->interval_time[type], 0}; 848 + unsigned long interval = timespec_to_jiffies(&ts); 849 + 850 + return time_after(jiffies, sbi->last_time[type] + interval); 851 + } 845 852 846 853 /* 847 854 * Inline functions
+1 -1
fs/f2fs/segment.c
··· 293 293 if (!available_free_memory(sbi, NAT_ENTRIES) || 294 294 excess_prefree_segs(sbi) || 295 295 !available_free_memory(sbi, INO_ENTRIES) || 296 - jiffies > sbi->cp_expires) { 296 + f2fs_time_over(sbi, CP_TIME)) { 297 297 if (test_opt(sbi, DATA_FLUSH)) 298 298 sync_dirty_inodes(sbi, FILE_INODE); 299 299 f2fs_sync_fs(sbi->sb, true);
+3 -4
fs/f2fs/super.c
··· 218 218 F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ra_nid_pages, ra_nid_pages); 219 219 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search); 220 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 223 #define ATTR_LIST(name) (&f2fs_attr_##name.attr) 224 224 static struct attribute *f2fs_attrs[] = { ··· 1122 1122 atomic_set(&sbi->nr_pages[i], 0); 1123 1123 1124 1124 sbi->dir_level = DEF_DIR_LEVEL; 1125 - sbi->cp_interval = DEF_CP_INTERVAL; 1125 + sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL; 1126 1126 clear_sbi_flag(sbi, SBI_NEED_FSCK); 1127 1127 1128 1128 INIT_LIST_HEAD(&sbi->s_list); ··· 1467 1467 f2fs_commit_super(sbi, true); 1468 1468 } 1469 1469 1470 - sbi->cp_expires = round_jiffies_up(jiffies); 1471 - 1470 + f2fs_update_time(sbi, CP_TIME); 1472 1471 return 0; 1473 1472 1474 1473 free_kobj: