super.c (85dc2f2c6c84e99e9864ef660f79683aaad85f42) super.c (caf0047e7e1e60a7ad1d655d3b81b32e2dfb6095)
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

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

447 f2fs_destroy_stats(sbi);
448 stop_gc_thread(sbi);
449
450 /*
451 * We don't need to do checkpoint when superblock is clean.
452 * But, the previous checkpoint was not done by umount, it needs to do
453 * clean checkpoint again.
454 */
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

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

447 f2fs_destroy_stats(sbi);
448 stop_gc_thread(sbi);
449
450 /*
451 * We don't need to do checkpoint when superblock is clean.
452 * But, the previous checkpoint was not done by umount, it needs to do
453 * clean checkpoint again.
454 */
455 if (sbi->s_dirty ||
455 if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) ||
456 !is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG)) {
457 struct cp_control cpc = {
458 .reason = CP_UMOUNT,
459 };
460 write_checkpoint(sbi, &cpc);
461 }
462
463 /*

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

487{
488 struct f2fs_sb_info *sbi = F2FS_SB(sb);
489
490 trace_f2fs_sync_fs(sb, sync);
491
492 if (sync) {
493 struct cp_control cpc;
494
456 !is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG)) {
457 struct cp_control cpc = {
458 .reason = CP_UMOUNT,
459 };
460 write_checkpoint(sbi, &cpc);
461 }
462
463 /*

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

487{
488 struct f2fs_sb_info *sbi = F2FS_SB(sb);
489
490 trace_f2fs_sync_fs(sb, sync);
491
492 if (sync) {
493 struct cp_control cpc;
494
495 cpc.reason = (test_opt(sbi, FASTBOOT) || sbi->s_closing) ?
496 CP_UMOUNT : CP_SYNC;
495 cpc.reason = (test_opt(sbi, FASTBOOT) ||
496 is_sbi_flag_set(sbi, SBI_IS_CLOSE)) ?
497 CP_UMOUNT : CP_SYNC;
497 mutex_lock(&sbi->gc_mutex);
498 write_checkpoint(sbi, &cpc);
499 mutex_unlock(&sbi->gc_mutex);
500 } else {
501 f2fs_balance_fs(sbi);
502 }
503 f2fs_trace_ios(NULL, NULL, 1);
504

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

890 sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
891 sbi->cur_victim_sec = NULL_SECNO;
892 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
893
894 for (i = 0; i < NR_COUNT_TYPE; i++)
895 atomic_set(&sbi->nr_pages[i], 0);
896
897 sbi->dir_level = DEF_DIR_LEVEL;
498 mutex_lock(&sbi->gc_mutex);
499 write_checkpoint(sbi, &cpc);
500 mutex_unlock(&sbi->gc_mutex);
501 } else {
502 f2fs_balance_fs(sbi);
503 }
504 f2fs_trace_ios(NULL, NULL, 1);
505

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

891 sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
892 sbi->cur_victim_sec = NULL_SECNO;
893 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
894
895 for (i = 0; i < NR_COUNT_TYPE; i++)
896 atomic_set(&sbi->nr_pages[i], 0);
897
898 sbi->dir_level = DEF_DIR_LEVEL;
898 sbi->need_fsck = false;
899 clear_sbi_flag(sbi, SBI_NEED_FSCK);
899}
900
901/*
902 * Read f2fs raw super block.
903 * Because we have two copies of super block, so read the first one at first,
904 * if the first one is invalid, move to read the second one.
905 */
906static int read_raw_super_block(struct super_block *sb,

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

1001 /* init f2fs-specific super block info */
1002 sbi->sb = sb;
1003 sbi->raw_super = raw_super;
1004 sbi->raw_super_buf = raw_super_buf;
1005 mutex_init(&sbi->gc_mutex);
1006 mutex_init(&sbi->writepages);
1007 mutex_init(&sbi->cp_mutex);
1008 init_rwsem(&sbi->node_write);
900}
901
902/*
903 * Read f2fs raw super block.
904 * Because we have two copies of super block, so read the first one at first,
905 * if the first one is invalid, move to read the second one.
906 */
907static int read_raw_super_block(struct super_block *sb,

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

1002 /* init f2fs-specific super block info */
1003 sbi->sb = sb;
1004 sbi->raw_super = raw_super;
1005 sbi->raw_super_buf = raw_super_buf;
1006 mutex_init(&sbi->gc_mutex);
1007 mutex_init(&sbi->writepages);
1008 mutex_init(&sbi->cp_mutex);
1009 init_rwsem(&sbi->node_write);
1009 sbi->por_doing = false;
1010 clear_sbi_flag(sbi, SBI_POR_DOING);
1010 spin_lock_init(&sbi->stat_lock);
1011
1012 init_rwsem(&sbi->read_io.io_rwsem);
1013 sbi->read_io.sbi = sbi;
1014 sbi->read_io.bio = NULL;
1015 for (i = 0; i < NR_PAGE_TYPE; i++) {
1016 init_rwsem(&sbi->write_io[i].io_rwsem);
1017 sbi->write_io[i].sbi = sbi;

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

1125 sbi->s_kobj.kset = f2fs_kset;
1126 init_completion(&sbi->s_kobj_unregister);
1127 err = kobject_init_and_add(&sbi->s_kobj, &f2fs_ktype, NULL,
1128 "%s", sb->s_id);
1129 if (err)
1130 goto free_proc;
1131
1132 if (!retry)
1011 spin_lock_init(&sbi->stat_lock);
1012
1013 init_rwsem(&sbi->read_io.io_rwsem);
1014 sbi->read_io.sbi = sbi;
1015 sbi->read_io.bio = NULL;
1016 for (i = 0; i < NR_PAGE_TYPE; i++) {
1017 init_rwsem(&sbi->write_io[i].io_rwsem);
1018 sbi->write_io[i].sbi = sbi;

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

1126 sbi->s_kobj.kset = f2fs_kset;
1127 init_completion(&sbi->s_kobj_unregister);
1128 err = kobject_init_and_add(&sbi->s_kobj, &f2fs_ktype, NULL,
1129 "%s", sb->s_id);
1130 if (err)
1131 goto free_proc;
1132
1133 if (!retry)
1133 sbi->need_fsck = true;
1134 set_sbi_flag(sbi, SBI_NEED_FSCK);
1134
1135 /* recover fsynced data */
1136 if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) {
1137 err = recover_fsync_data(sbi);
1138 if (err) {
1139 f2fs_msg(sb, KERN_ERR,
1140 "Cannot recover all fsync data errno=%ld", err);
1141 goto free_kobj;

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

1194 const char *dev_name, void *data)
1195{
1196 return mount_bdev(fs_type, flags, dev_name, data, f2fs_fill_super);
1197}
1198
1199static void kill_f2fs_super(struct super_block *sb)
1200{
1201 if (sb->s_root)
1135
1136 /* recover fsynced data */
1137 if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) {
1138 err = recover_fsync_data(sbi);
1139 if (err) {
1140 f2fs_msg(sb, KERN_ERR,
1141 "Cannot recover all fsync data errno=%ld", err);
1142 goto free_kobj;

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

1195 const char *dev_name, void *data)
1196{
1197 return mount_bdev(fs_type, flags, dev_name, data, f2fs_fill_super);
1198}
1199
1200static void kill_f2fs_super(struct super_block *sb)
1201{
1202 if (sb->s_root)
1202 F2FS_SB(sb)->s_closing = true;
1203 set_sbi_flag(F2FS_SB(sb), SBI_IS_CLOSE);
1203 kill_block_super(sb);
1204}
1205
1206static struct file_system_type f2fs_fs_type = {
1207 .owner = THIS_MODULE,
1208 .name = "f2fs",
1209 .mount = f2fs_mount,
1210 .kill_sb = kill_f2fs_super,

--- 86 unchanged lines hidden ---
1204 kill_block_super(sb);
1205}
1206
1207static struct file_system_type f2fs_fs_type = {
1208 .owner = THIS_MODULE,
1209 .name = "f2fs",
1210 .mount = f2fs_mount,
1211 .kill_sb = kill_f2fs_super,

--- 86 unchanged lines hidden ---