super.c (79828b4fa835f73cdaf4bffa48696abdcbea9d02) super.c (ea1a29a0bdfffd56ca98335c0655308e8d7d0e22)
1/*
2 * fs/f2fs/super.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 199 unchanged lines hidden (view full) ---

208F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle);
209F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
210F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, max_small_discards, max_discards);
211F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections);
212F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy);
213F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util);
214F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_fsync_blocks, min_fsync_blocks);
215F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh);
1/*
2 * fs/f2fs/super.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 199 unchanged lines hidden (view full) ---

208F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle);
209F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
210F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, max_small_discards, max_discards);
211F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections);
212F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy);
213F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util);
214F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_fsync_blocks, min_fsync_blocks);
215F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh);
216F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ra_nid_pages, ra_nid_pages);
216F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search);
217F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level);
217F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search);
218F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level);
219F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, cp_interval);
218
219#define ATTR_LIST(name) (&f2fs_attr_##name.attr)
220static struct attribute *f2fs_attrs[] = {
221 ATTR_LIST(gc_min_sleep_time),
222 ATTR_LIST(gc_max_sleep_time),
223 ATTR_LIST(gc_no_gc_sleep_time),
224 ATTR_LIST(gc_idle),
225 ATTR_LIST(reclaim_segments),
226 ATTR_LIST(max_small_discards),
227 ATTR_LIST(batched_trim_sections),
228 ATTR_LIST(ipu_policy),
229 ATTR_LIST(min_ipu_util),
230 ATTR_LIST(min_fsync_blocks),
231 ATTR_LIST(max_victim_search),
232 ATTR_LIST(dir_level),
233 ATTR_LIST(ram_thresh),
220
221#define ATTR_LIST(name) (&f2fs_attr_##name.attr)
222static struct attribute *f2fs_attrs[] = {
223 ATTR_LIST(gc_min_sleep_time),
224 ATTR_LIST(gc_max_sleep_time),
225 ATTR_LIST(gc_no_gc_sleep_time),
226 ATTR_LIST(gc_idle),
227 ATTR_LIST(reclaim_segments),
228 ATTR_LIST(max_small_discards),
229 ATTR_LIST(batched_trim_sections),
230 ATTR_LIST(ipu_policy),
231 ATTR_LIST(min_ipu_util),
232 ATTR_LIST(min_fsync_blocks),
233 ATTR_LIST(max_victim_search),
234 ATTR_LIST(dir_level),
235 ATTR_LIST(ram_thresh),
236 ATTR_LIST(ra_nid_pages),
237 ATTR_LIST(cp_interval),
234 NULL,
235};
236
237static const struct sysfs_ops f2fs_attr_ops = {
238 .show = f2fs_attr_show,
239 .store = f2fs_attr_store,
240};
241

--- 45 unchanged lines hidden (view full) ---

287 token = match_token(p, f2fs_tokens, args);
288
289 switch (token) {
290 case Opt_gc_background:
291 name = match_strdup(&args[0]);
292
293 if (!name)
294 return -ENOMEM;
238 NULL,
239};
240
241static const struct sysfs_ops f2fs_attr_ops = {
242 .show = f2fs_attr_show,
243 .store = f2fs_attr_store,
244};
245

--- 45 unchanged lines hidden (view full) ---

291 token = match_token(p, f2fs_tokens, args);
292
293 switch (token) {
294 case Opt_gc_background:
295 name = match_strdup(&args[0]);
296
297 if (!name)
298 return -ENOMEM;
295 if (strlen(name) == 2 && !strncmp(name, "on", 2))
299 if (strlen(name) == 2 && !strncmp(name, "on", 2)) {
296 set_opt(sbi, BG_GC);
300 set_opt(sbi, BG_GC);
297 else if (strlen(name) == 3 && !strncmp(name, "off", 3))
301 clear_opt(sbi, FORCE_FG_GC);
302 } else if (strlen(name) == 3 && !strncmp(name, "off", 3)) {
298 clear_opt(sbi, BG_GC);
303 clear_opt(sbi, BG_GC);
299 else {
304 clear_opt(sbi, FORCE_FG_GC);
305 } else if (strlen(name) == 4 && !strncmp(name, "sync", 4)) {
306 set_opt(sbi, BG_GC);
307 set_opt(sbi, FORCE_FG_GC);
308 } else {
300 kfree(name);
301 return -EINVAL;
302 }
303 kfree(name);
304 break;
305 case Opt_disable_roll_forward:
306 set_opt(sbi, DISABLE_ROLL_FORWARD);
307 break;

--- 318 unchanged lines hidden (view full) ---

626
627 return 0;
628}
629
630static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
631{
632 struct f2fs_sb_info *sbi = F2FS_SB(root->d_sb);
633
309 kfree(name);
310 return -EINVAL;
311 }
312 kfree(name);
313 break;
314 case Opt_disable_roll_forward:
315 set_opt(sbi, DISABLE_ROLL_FORWARD);
316 break;

--- 318 unchanged lines hidden (view full) ---

635
636 return 0;
637}
638
639static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
640{
641 struct f2fs_sb_info *sbi = F2FS_SB(root->d_sb);
642
634 if (!f2fs_readonly(sbi->sb) && test_opt(sbi, BG_GC))
635 seq_printf(seq, ",background_gc=%s", "on");
636 else
643 if (!f2fs_readonly(sbi->sb) && test_opt(sbi, BG_GC)) {
644 if (test_opt(sbi, FORCE_FG_GC))
645 seq_printf(seq, ",background_gc=%s", "sync");
646 else
647 seq_printf(seq, ",background_gc=%s", "on");
648 } else {
637 seq_printf(seq, ",background_gc=%s", "off");
649 seq_printf(seq, ",background_gc=%s", "off");
650 }
638 if (test_opt(sbi, DISABLE_ROLL_FORWARD))
639 seq_puts(seq, ",disable_roll_forward");
640 if (test_opt(sbi, DISCARD))
641 seq_puts(seq, ",discard");
642 if (test_opt(sbi, NOHEAP))
643 seq_puts(seq, ",no_heap_alloc");
644#ifdef CONFIG_F2FS_FS_XATTR
645 if (test_opt(sbi, XATTR_USER))

--- 91 unchanged lines hidden (view full) ---

737
738static int f2fs_remount(struct super_block *sb, int *flags, char *data)
739{
740 struct f2fs_sb_info *sbi = F2FS_SB(sb);
741 struct f2fs_mount_info org_mount_opt;
742 int err, active_logs;
743 bool need_restart_gc = false;
744 bool need_stop_gc = false;
651 if (test_opt(sbi, DISABLE_ROLL_FORWARD))
652 seq_puts(seq, ",disable_roll_forward");
653 if (test_opt(sbi, DISCARD))
654 seq_puts(seq, ",discard");
655 if (test_opt(sbi, NOHEAP))
656 seq_puts(seq, ",no_heap_alloc");
657#ifdef CONFIG_F2FS_FS_XATTR
658 if (test_opt(sbi, XATTR_USER))

--- 91 unchanged lines hidden (view full) ---

750
751static int f2fs_remount(struct super_block *sb, int *flags, char *data)
752{
753 struct f2fs_sb_info *sbi = F2FS_SB(sb);
754 struct f2fs_mount_info org_mount_opt;
755 int err, active_logs;
756 bool need_restart_gc = false;
757 bool need_stop_gc = false;
758 bool no_extent_cache = !test_opt(sbi, EXTENT_CACHE);
745
746 sync_filesystem(sb);
747
748 /*
749 * Save the old mount options in case we
750 * need to restore them.
751 */
752 org_mount_opt = sbi->mount_opt;

--- 9 unchanged lines hidden (view full) ---

762
763 /*
764 * Previous and new state of filesystem is RO,
765 * so skip checking GC and FLUSH_MERGE conditions.
766 */
767 if (f2fs_readonly(sb) && (*flags & MS_RDONLY))
768 goto skip;
769
759
760 sync_filesystem(sb);
761
762 /*
763 * Save the old mount options in case we
764 * need to restore them.
765 */
766 org_mount_opt = sbi->mount_opt;

--- 9 unchanged lines hidden (view full) ---

776
777 /*
778 * Previous and new state of filesystem is RO,
779 * so skip checking GC and FLUSH_MERGE conditions.
780 */
781 if (f2fs_readonly(sb) && (*flags & MS_RDONLY))
782 goto skip;
783
784 /* disallow enable/disable extent_cache dynamically */
785 if (no_extent_cache == !!test_opt(sbi, EXTENT_CACHE)) {
786 err = -EINVAL;
787 f2fs_msg(sbi->sb, KERN_WARNING,
788 "switch extent_cache option is not allowed");
789 goto restore_opts;
790 }
791
770 /*
771 * We stop the GC thread if FS is mounted as RO
772 * or if background_gc = off is passed in mount
773 * option. Also sync the filesystem.
774 */
775 if ((*flags & MS_RDONLY) || !test_opt(sbi, BG_GC)) {
776 if (sbi->gc_thread) {
777 stop_gc_thread(sbi);

--- 213 unchanged lines hidden (view full) ---

991 sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
992 sbi->cur_victim_sec = NULL_SECNO;
993 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
994
995 for (i = 0; i < NR_COUNT_TYPE; i++)
996 atomic_set(&sbi->nr_pages[i], 0);
997
998 sbi->dir_level = DEF_DIR_LEVEL;
792 /*
793 * We stop the GC thread if FS is mounted as RO
794 * or if background_gc = off is passed in mount
795 * option. Also sync the filesystem.
796 */
797 if ((*flags & MS_RDONLY) || !test_opt(sbi, BG_GC)) {
798 if (sbi->gc_thread) {
799 stop_gc_thread(sbi);

--- 213 unchanged lines hidden (view full) ---

1013 sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
1014 sbi->cur_victim_sec = NULL_SECNO;
1015 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
1016
1017 for (i = 0; i < NR_COUNT_TYPE; i++)
1018 atomic_set(&sbi->nr_pages[i], 0);
1019
1020 sbi->dir_level = DEF_DIR_LEVEL;
1021 sbi->cp_interval = DEF_CP_INTERVAL;
999 clear_sbi_flag(sbi, SBI_NEED_FSCK);
1000
1001 INIT_LIST_HEAD(&sbi->s_list);
1002 mutex_init(&sbi->umount_mutex);
1003}
1004
1005/*
1006 * Read f2fs raw super block.

--- 320 unchanged lines hidden (view full) ---

1327 kfree(options);
1328
1329 /* recover broken superblock */
1330 if (recovery && !f2fs_readonly(sb) && !bdev_read_only(sb->s_bdev)) {
1331 f2fs_msg(sb, KERN_INFO, "Recover invalid superblock");
1332 f2fs_commit_super(sbi, true);
1333 }
1334
1022 clear_sbi_flag(sbi, SBI_NEED_FSCK);
1023
1024 INIT_LIST_HEAD(&sbi->s_list);
1025 mutex_init(&sbi->umount_mutex);
1026}
1027
1028/*
1029 * Read f2fs raw super block.

--- 320 unchanged lines hidden (view full) ---

1350 kfree(options);
1351
1352 /* recover broken superblock */
1353 if (recovery && !f2fs_readonly(sb) && !bdev_read_only(sb->s_bdev)) {
1354 f2fs_msg(sb, KERN_INFO, "Recover invalid superblock");
1355 f2fs_commit_super(sbi, true);
1356 }
1357
1358 sbi->cp_expires = round_jiffies_up(jiffies);
1359
1335 return 0;
1336
1337free_kobj:
1338 kobject_del(&sbi->s_kobj);
1339free_proc:
1340 if (sbi->s_proc) {
1341 remove_proc_entry("segment_info", sbi->s_proc);
1342 remove_proc_entry(sb->s_id, f2fs_proc_root);

--- 159 unchanged lines hidden ---
1360 return 0;
1361
1362free_kobj:
1363 kobject_del(&sbi->s_kobj);
1364free_proc:
1365 if (sbi->s_proc) {
1366 remove_proc_entry("segment_info", sbi->s_proc);
1367 remove_proc_entry(sb->s_id, f2fs_proc_root);

--- 159 unchanged lines hidden ---