aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r--fs/f2fs/super.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f2fe666a6ea9..160b88346b24 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -57,6 +57,8 @@ enum {
57 Opt_flush_merge, 57 Opt_flush_merge,
58 Opt_nobarrier, 58 Opt_nobarrier,
59 Opt_fastboot, 59 Opt_fastboot,
60 Opt_extent_cache,
61 Opt_noinline_data,
60 Opt_err, 62 Opt_err,
61}; 63};
62 64
@@ -78,6 +80,8 @@ static match_table_t f2fs_tokens = {
78 {Opt_flush_merge, "flush_merge"}, 80 {Opt_flush_merge, "flush_merge"},
79 {Opt_nobarrier, "nobarrier"}, 81 {Opt_nobarrier, "nobarrier"},
80 {Opt_fastboot, "fastboot"}, 82 {Opt_fastboot, "fastboot"},
83 {Opt_extent_cache, "extent_cache"},
84 {Opt_noinline_data, "noinline_data"},
81 {Opt_err, NULL}, 85 {Opt_err, NULL},
82}; 86};
83 87
@@ -367,6 +371,12 @@ static int parse_options(struct super_block *sb, char *options)
367 case Opt_fastboot: 371 case Opt_fastboot:
368 set_opt(sbi, FASTBOOT); 372 set_opt(sbi, FASTBOOT);
369 break; 373 break;
374 case Opt_extent_cache:
375 set_opt(sbi, EXTENT_CACHE);
376 break;
377 case Opt_noinline_data:
378 clear_opt(sbi, INLINE_DATA);
379 break;
370 default: 380 default:
371 f2fs_msg(sb, KERN_ERR, 381 f2fs_msg(sb, KERN_ERR,
372 "Unrecognized mount option \"%s\" or missing value", 382 "Unrecognized mount option \"%s\" or missing value",
@@ -392,7 +402,7 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
392 atomic_set(&fi->dirty_pages, 0); 402 atomic_set(&fi->dirty_pages, 0);
393 fi->i_current_depth = 1; 403 fi->i_current_depth = 1;
394 fi->i_advise = 0; 404 fi->i_advise = 0;
395 rwlock_init(&fi->ext.ext_lock); 405 rwlock_init(&fi->ext_lock);
396 init_rwsem(&fi->i_sem); 406 init_rwsem(&fi->i_sem);
397 INIT_RADIX_TREE(&fi->inmem_root, GFP_NOFS); 407 INIT_RADIX_TREE(&fi->inmem_root, GFP_NOFS);
398 INIT_LIST_HEAD(&fi->inmem_pages); 408 INIT_LIST_HEAD(&fi->inmem_pages);
@@ -591,6 +601,8 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
591 seq_puts(seq, ",disable_ext_identify"); 601 seq_puts(seq, ",disable_ext_identify");
592 if (test_opt(sbi, INLINE_DATA)) 602 if (test_opt(sbi, INLINE_DATA))
593 seq_puts(seq, ",inline_data"); 603 seq_puts(seq, ",inline_data");
604 else
605 seq_puts(seq, ",noinline_data");
594 if (test_opt(sbi, INLINE_DENTRY)) 606 if (test_opt(sbi, INLINE_DENTRY))
595 seq_puts(seq, ",inline_dentry"); 607 seq_puts(seq, ",inline_dentry");
596 if (!f2fs_readonly(sbi->sb) && test_opt(sbi, FLUSH_MERGE)) 608 if (!f2fs_readonly(sbi->sb) && test_opt(sbi, FLUSH_MERGE))
@@ -599,6 +611,8 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
599 seq_puts(seq, ",nobarrier"); 611 seq_puts(seq, ",nobarrier");
600 if (test_opt(sbi, FASTBOOT)) 612 if (test_opt(sbi, FASTBOOT))
601 seq_puts(seq, ",fastboot"); 613 seq_puts(seq, ",fastboot");
614 if (test_opt(sbi, EXTENT_CACHE))
615 seq_puts(seq, ",extent_cache");
602 seq_printf(seq, ",active_logs=%u", sbi->active_logs); 616 seq_printf(seq, ",active_logs=%u", sbi->active_logs);
603 617
604 return 0; 618 return 0;
@@ -959,7 +973,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
959 struct buffer_head *raw_super_buf; 973 struct buffer_head *raw_super_buf;
960 struct inode *root; 974 struct inode *root;
961 long err = -EINVAL; 975 long err = -EINVAL;
962 bool retry = true; 976 bool retry = true, need_fsck = false;
963 char *options = NULL; 977 char *options = NULL;
964 int i; 978 int i;
965 979
@@ -984,6 +998,7 @@ try_onemore:
984 sbi->active_logs = NR_CURSEG_TYPE; 998 sbi->active_logs = NR_CURSEG_TYPE;
985 999
986 set_opt(sbi, BG_GC); 1000 set_opt(sbi, BG_GC);
1001 set_opt(sbi, INLINE_DATA);
987 1002
988#ifdef CONFIG_F2FS_FS_XATTR 1003#ifdef CONFIG_F2FS_FS_XATTR
989 set_opt(sbi, XATTR_USER); 1004 set_opt(sbi, XATTR_USER);
@@ -1020,7 +1035,6 @@ try_onemore:
1020 sbi->raw_super = raw_super; 1035 sbi->raw_super = raw_super;
1021 sbi->raw_super_buf = raw_super_buf; 1036 sbi->raw_super_buf = raw_super_buf;
1022 mutex_init(&sbi->gc_mutex); 1037 mutex_init(&sbi->gc_mutex);
1023 mutex_init(&sbi->writepages);
1024 mutex_init(&sbi->cp_mutex); 1038 mutex_init(&sbi->cp_mutex);
1025 init_rwsem(&sbi->node_write); 1039 init_rwsem(&sbi->node_write);
1026 clear_sbi_flag(sbi, SBI_POR_DOING); 1040 clear_sbi_flag(sbi, SBI_POR_DOING);
@@ -1072,6 +1086,8 @@ try_onemore:
1072 INIT_LIST_HEAD(&sbi->dir_inode_list); 1086 INIT_LIST_HEAD(&sbi->dir_inode_list);
1073 spin_lock_init(&sbi->dir_inode_lock); 1087 spin_lock_init(&sbi->dir_inode_lock);
1074 1088
1089 init_extent_cache_info(sbi);
1090
1075 init_ino_entry_info(sbi); 1091 init_ino_entry_info(sbi);
1076 1092
1077 /* setup f2fs internal modules */ 1093 /* setup f2fs internal modules */
@@ -1146,9 +1162,6 @@ try_onemore:
1146 if (err) 1162 if (err)
1147 goto free_proc; 1163 goto free_proc;
1148 1164
1149 if (!retry)
1150 set_sbi_flag(sbi, SBI_NEED_FSCK);
1151
1152 /* recover fsynced data */ 1165 /* recover fsynced data */
1153 if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) { 1166 if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) {
1154 /* 1167 /*
@@ -1160,8 +1173,13 @@ try_onemore:
1160 err = -EROFS; 1173 err = -EROFS;
1161 goto free_kobj; 1174 goto free_kobj;
1162 } 1175 }
1176
1177 if (need_fsck)
1178 set_sbi_flag(sbi, SBI_NEED_FSCK);
1179
1163 err = recover_fsync_data(sbi); 1180 err = recover_fsync_data(sbi);
1164 if (err) { 1181 if (err) {
1182 need_fsck = true;
1165 f2fs_msg(sb, KERN_ERR, 1183 f2fs_msg(sb, KERN_ERR,
1166 "Cannot recover all fsync data errno=%ld", err); 1184 "Cannot recover all fsync data errno=%ld", err);
1167 goto free_kobj; 1185 goto free_kobj;
@@ -1212,7 +1230,7 @@ free_sbi:
1212 1230
1213 /* give only one another chance */ 1231 /* give only one another chance */
1214 if (retry) { 1232 if (retry) {
1215 retry = 0; 1233 retry = false;
1216 shrink_dcache_sb(sb); 1234 shrink_dcache_sb(sb);
1217 goto try_onemore; 1235 goto try_onemore;
1218 } 1236 }
@@ -1278,10 +1296,13 @@ static int __init init_f2fs_fs(void)
1278 err = create_checkpoint_caches(); 1296 err = create_checkpoint_caches();
1279 if (err) 1297 if (err)
1280 goto free_segment_manager_caches; 1298 goto free_segment_manager_caches;
1299 err = create_extent_cache();
1300 if (err)
1301 goto free_checkpoint_caches;
1281 f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj); 1302 f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj);
1282 if (!f2fs_kset) { 1303 if (!f2fs_kset) {
1283 err = -ENOMEM; 1304 err = -ENOMEM;
1284 goto free_checkpoint_caches; 1305 goto free_extent_cache;
1285 } 1306 }
1286 err = register_filesystem(&f2fs_fs_type); 1307 err = register_filesystem(&f2fs_fs_type);
1287 if (err) 1308 if (err)
@@ -1292,6 +1313,8 @@ static int __init init_f2fs_fs(void)
1292 1313
1293free_kset: 1314free_kset:
1294 kset_unregister(f2fs_kset); 1315 kset_unregister(f2fs_kset);
1316free_extent_cache:
1317 destroy_extent_cache();
1295free_checkpoint_caches: 1318free_checkpoint_caches:
1296 destroy_checkpoint_caches(); 1319 destroy_checkpoint_caches();
1297free_segment_manager_caches: 1320free_segment_manager_caches:
@@ -1309,6 +1332,7 @@ static void __exit exit_f2fs_fs(void)
1309 remove_proc_entry("fs/f2fs", NULL); 1332 remove_proc_entry("fs/f2fs", NULL);
1310 f2fs_destroy_root_stats(); 1333 f2fs_destroy_root_stats();
1311 unregister_filesystem(&f2fs_fs_type); 1334 unregister_filesystem(&f2fs_fs_type);
1335 destroy_extent_cache();
1312 destroy_checkpoint_caches(); 1336 destroy_checkpoint_caches();
1313 destroy_segment_manager_caches(); 1337 destroy_segment_manager_caches();
1314 destroy_node_manager_caches(); 1338 destroy_node_manager_caches();