diff options
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r-- | fs/f2fs/super.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 0ea5bcccab6d..58d9a5574bb0 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -126,6 +126,19 @@ static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type) | |||
126 | return NULL; | 126 | return NULL; |
127 | } | 127 | } |
128 | 128 | ||
129 | static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a, | ||
130 | struct f2fs_sb_info *sbi, char *buf) | ||
131 | { | ||
132 | struct super_block *sb = sbi->sb; | ||
133 | |||
134 | if (!sb->s_bdev->bd_part) | ||
135 | return snprintf(buf, PAGE_SIZE, "0\n"); | ||
136 | |||
137 | return snprintf(buf, PAGE_SIZE, "%llu\n", | ||
138 | (unsigned long long)(sbi->kbytes_written + | ||
139 | BD_PART_WRITTEN(sbi))); | ||
140 | } | ||
141 | |||
129 | static ssize_t f2fs_sbi_show(struct f2fs_attr *a, | 142 | static ssize_t f2fs_sbi_show(struct f2fs_attr *a, |
130 | struct f2fs_sb_info *sbi, char *buf) | 143 | struct f2fs_sb_info *sbi, char *buf) |
131 | { | 144 | { |
@@ -204,6 +217,9 @@ static struct f2fs_attr f2fs_attr_##_name = { \ | |||
204 | f2fs_sbi_show, f2fs_sbi_store, \ | 217 | f2fs_sbi_show, f2fs_sbi_store, \ |
205 | offsetof(struct struct_name, elname)) | 218 | offsetof(struct struct_name, elname)) |
206 | 219 | ||
220 | #define F2FS_GENERAL_RO_ATTR(name) \ | ||
221 | static struct f2fs_attr f2fs_attr_##name = __ATTR(name, 0444, name##_show, NULL) | ||
222 | |||
207 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_min_sleep_time, min_sleep_time); | 223 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_min_sleep_time, min_sleep_time); |
208 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_max_sleep_time, max_sleep_time); | 224 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_max_sleep_time, max_sleep_time); |
209 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time); | 225 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time); |
@@ -221,6 +237,7 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search); | |||
221 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); | 237 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); |
222 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, interval_time[CP_TIME]); | 238 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, interval_time[CP_TIME]); |
223 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, idle_interval, interval_time[REQ_TIME]); | 239 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, idle_interval, interval_time[REQ_TIME]); |
240 | F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes); | ||
224 | 241 | ||
225 | #define ATTR_LIST(name) (&f2fs_attr_##name.attr) | 242 | #define ATTR_LIST(name) (&f2fs_attr_##name.attr) |
226 | static struct attribute *f2fs_attrs[] = { | 243 | static struct attribute *f2fs_attrs[] = { |
@@ -241,6 +258,7 @@ static struct attribute *f2fs_attrs[] = { | |||
241 | ATTR_LIST(dirty_nats_ratio), | 258 | ATTR_LIST(dirty_nats_ratio), |
242 | ATTR_LIST(cp_interval), | 259 | ATTR_LIST(cp_interval), |
243 | ATTR_LIST(idle_interval), | 260 | ATTR_LIST(idle_interval), |
261 | ATTR_LIST(lifetime_write_kbytes), | ||
244 | NULL, | 262 | NULL, |
245 | }; | 263 | }; |
246 | 264 | ||
@@ -768,8 +786,6 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) | |||
768 | bool need_stop_gc = false; | 786 | bool need_stop_gc = false; |
769 | bool no_extent_cache = !test_opt(sbi, EXTENT_CACHE); | 787 | bool no_extent_cache = !test_opt(sbi, EXTENT_CACHE); |
770 | 788 | ||
771 | sync_filesystem(sb); | ||
772 | |||
773 | /* | 789 | /* |
774 | * Save the old mount options in case we | 790 | * Save the old mount options in case we |
775 | * need to restore them. | 791 | * need to restore them. |
@@ -777,6 +793,13 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) | |||
777 | org_mount_opt = sbi->mount_opt; | 793 | org_mount_opt = sbi->mount_opt; |
778 | active_logs = sbi->active_logs; | 794 | active_logs = sbi->active_logs; |
779 | 795 | ||
796 | if (*flags & MS_RDONLY) { | ||
797 | set_opt(sbi, FASTBOOT); | ||
798 | set_sbi_flag(sbi, SBI_IS_DIRTY); | ||
799 | } | ||
800 | |||
801 | sync_filesystem(sb); | ||
802 | |||
780 | sbi->mount_opt.opt = 0; | 803 | sbi->mount_opt.opt = 0; |
781 | default_options(sbi); | 804 | default_options(sbi); |
782 | 805 | ||
@@ -1244,6 +1267,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) | |||
1244 | bool retry = true, need_fsck = false; | 1267 | bool retry = true, need_fsck = false; |
1245 | char *options = NULL; | 1268 | char *options = NULL; |
1246 | int recovery, i, valid_super_block; | 1269 | int recovery, i, valid_super_block; |
1270 | struct curseg_info *seg_i; | ||
1247 | 1271 | ||
1248 | try_onemore: | 1272 | try_onemore: |
1249 | err = -EINVAL; | 1273 | err = -EINVAL; |
@@ -1374,6 +1398,17 @@ try_onemore: | |||
1374 | goto free_nm; | 1398 | goto free_nm; |
1375 | } | 1399 | } |
1376 | 1400 | ||
1401 | /* For write statistics */ | ||
1402 | if (sb->s_bdev->bd_part) | ||
1403 | sbi->sectors_written_start = | ||
1404 | (u64)part_stat_read(sb->s_bdev->bd_part, sectors[1]); | ||
1405 | |||
1406 | /* Read accumulated write IO statistics if exists */ | ||
1407 | seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE); | ||
1408 | if (__exist_node_summaries(sbi)) | ||
1409 | sbi->kbytes_written = | ||
1410 | le64_to_cpu(seg_i->sum_blk->info.kbytes_written); | ||
1411 | |||
1377 | build_gc_manager(sbi); | 1412 | build_gc_manager(sbi); |
1378 | 1413 | ||
1379 | /* get an inode for node space */ | 1414 | /* get an inode for node space */ |