super.c (9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e) super.c (b62e71be2110d8b52bf5faf3c3ed7ca1a0c113a5)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/super.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/module.h>

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

159 Opt_compress_mode,
160 Opt_compress_cache,
161 Opt_atgc,
162 Opt_gc_merge,
163 Opt_nogc_merge,
164 Opt_discard_unit,
165 Opt_memory_mode,
166 Opt_age_extent_cache,
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/super.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/module.h>

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

159 Opt_compress_mode,
160 Opt_compress_cache,
161 Opt_atgc,
162 Opt_gc_merge,
163 Opt_nogc_merge,
164 Opt_discard_unit,
165 Opt_memory_mode,
166 Opt_age_extent_cache,
167 Opt_errors,
167 Opt_err,
168};
169
170static match_table_t f2fs_tokens = {
171 {Opt_gc_background, "background_gc=%s"},
172 {Opt_disable_roll_forward, "disable_roll_forward"},
173 {Opt_norecovery, "norecovery"},
174 {Opt_discard, "discard"},

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

238 {Opt_compress_mode, "compress_mode=%s"},
239 {Opt_compress_cache, "compress_cache"},
240 {Opt_atgc, "atgc"},
241 {Opt_gc_merge, "gc_merge"},
242 {Opt_nogc_merge, "nogc_merge"},
243 {Opt_discard_unit, "discard_unit=%s"},
244 {Opt_memory_mode, "memory=%s"},
245 {Opt_age_extent_cache, "age_extent_cache"},
168 Opt_err,
169};
170
171static match_table_t f2fs_tokens = {
172 {Opt_gc_background, "background_gc=%s"},
173 {Opt_disable_roll_forward, "disable_roll_forward"},
174 {Opt_norecovery, "norecovery"},
175 {Opt_discard, "discard"},

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

239 {Opt_compress_mode, "compress_mode=%s"},
240 {Opt_compress_cache, "compress_cache"},
241 {Opt_atgc, "atgc"},
242 {Opt_gc_merge, "gc_merge"},
243 {Opt_nogc_merge, "nogc_merge"},
244 {Opt_discard_unit, "discard_unit=%s"},
245 {Opt_memory_mode, "memory=%s"},
246 {Opt_age_extent_cache, "age_extent_cache"},
247 {Opt_errors, "errors=%s"},
246 {Opt_err, NULL},
247};
248
249void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...)
250{
251 struct va_format vaf;
252 va_list args;
253 int level;

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

875 return -EINVAL;
876 }
877 kfree(name);
878 break;
879 case Opt_io_size_bits:
880 if (args->from && match_int(args, &arg))
881 return -EINVAL;
882 if (arg <= 0 || arg > __ilog2_u32(BIO_MAX_VECS)) {
248 {Opt_err, NULL},
249};
250
251void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...)
252{
253 struct va_format vaf;
254 va_list args;
255 int level;

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

877 return -EINVAL;
878 }
879 kfree(name);
880 break;
881 case Opt_io_size_bits:
882 if (args->from && match_int(args, &arg))
883 return -EINVAL;
884 if (arg <= 0 || arg > __ilog2_u32(BIO_MAX_VECS)) {
883 f2fs_warn(sbi, "Not support %d, larger than %d",
884 1 << arg, BIO_MAX_VECS);
885 f2fs_warn(sbi, "Not support %ld, larger than %d",
886 BIT(arg), BIO_MAX_VECS);
885 return -EINVAL;
886 }
887 F2FS_OPTION(sbi).write_io_size_bits = arg;
888 break;
889#ifdef CONFIG_F2FS_FAULT_INJECTION
890 case Opt_fault_injection:
891 if (args->from && match_int(args, &arg))
892 return -EINVAL;

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

1174 return -EINVAL;
1175 }
1176
1177 strcpy(noext[noext_cnt], name);
1178 F2FS_OPTION(sbi).nocompress_ext_cnt++;
1179 kfree(name);
1180 break;
1181 case Opt_compress_chksum:
887 return -EINVAL;
888 }
889 F2FS_OPTION(sbi).write_io_size_bits = arg;
890 break;
891#ifdef CONFIG_F2FS_FAULT_INJECTION
892 case Opt_fault_injection:
893 if (args->from && match_int(args, &arg))
894 return -EINVAL;

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

1176 return -EINVAL;
1177 }
1178
1179 strcpy(noext[noext_cnt], name);
1180 F2FS_OPTION(sbi).nocompress_ext_cnt++;
1181 kfree(name);
1182 break;
1183 case Opt_compress_chksum:
1184 if (!f2fs_sb_has_compression(sbi)) {
1185 f2fs_info(sbi, "Image doesn't support compression");
1186 break;
1187 }
1182 F2FS_OPTION(sbi).compress_chksum = true;
1183 break;
1184 case Opt_compress_mode:
1188 F2FS_OPTION(sbi).compress_chksum = true;
1189 break;
1190 case Opt_compress_mode:
1191 if (!f2fs_sb_has_compression(sbi)) {
1192 f2fs_info(sbi, "Image doesn't support compression");
1193 break;
1194 }
1185 name = match_strdup(&args[0]);
1186 if (!name)
1187 return -ENOMEM;
1188 if (!strcmp(name, "fs")) {
1189 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
1190 } else if (!strcmp(name, "user")) {
1191 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_USER;
1192 } else {
1193 kfree(name);
1194 return -EINVAL;
1195 }
1196 kfree(name);
1197 break;
1198 case Opt_compress_cache:
1195 name = match_strdup(&args[0]);
1196 if (!name)
1197 return -ENOMEM;
1198 if (!strcmp(name, "fs")) {
1199 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
1200 } else if (!strcmp(name, "user")) {
1201 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_USER;
1202 } else {
1203 kfree(name);
1204 return -EINVAL;
1205 }
1206 kfree(name);
1207 break;
1208 case Opt_compress_cache:
1209 if (!f2fs_sb_has_compression(sbi)) {
1210 f2fs_info(sbi, "Image doesn't support compression");
1211 break;
1212 }
1199 set_opt(sbi, COMPRESS_CACHE);
1200 break;
1201#else
1202 case Opt_compress_algorithm:
1203 case Opt_compress_log_size:
1204 case Opt_compress_extension:
1205 case Opt_nocompress_extension:
1206 case Opt_compress_chksum:

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

1251 kfree(name);
1252 return -EINVAL;
1253 }
1254 kfree(name);
1255 break;
1256 case Opt_age_extent_cache:
1257 set_opt(sbi, AGE_EXTENT_CACHE);
1258 break;
1213 set_opt(sbi, COMPRESS_CACHE);
1214 break;
1215#else
1216 case Opt_compress_algorithm:
1217 case Opt_compress_log_size:
1218 case Opt_compress_extension:
1219 case Opt_nocompress_extension:
1220 case Opt_compress_chksum:

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

1265 kfree(name);
1266 return -EINVAL;
1267 }
1268 kfree(name);
1269 break;
1270 case Opt_age_extent_cache:
1271 set_opt(sbi, AGE_EXTENT_CACHE);
1272 break;
1273 case Opt_errors:
1274 name = match_strdup(&args[0]);
1275 if (!name)
1276 return -ENOMEM;
1277 if (!strcmp(name, "remount-ro")) {
1278 F2FS_OPTION(sbi).errors =
1279 MOUNT_ERRORS_READONLY;
1280 } else if (!strcmp(name, "continue")) {
1281 F2FS_OPTION(sbi).errors =
1282 MOUNT_ERRORS_CONTINUE;
1283 } else if (!strcmp(name, "panic")) {
1284 F2FS_OPTION(sbi).errors =
1285 MOUNT_ERRORS_PANIC;
1286 } else {
1287 kfree(name);
1288 return -EINVAL;
1289 }
1290 kfree(name);
1291 break;
1259 default:
1260 f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
1261 p);
1262 return -EINVAL;
1263 }
1264 }
1265default_check:
1266#ifdef CONFIG_QUOTA

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

1305#ifdef CONFIG_F2FS_FS_COMPRESSION
1306 if (f2fs_test_compress_extension(sbi)) {
1307 f2fs_err(sbi, "invalid compress or nocompress extension");
1308 return -EINVAL;
1309 }
1310#endif
1311
1312 if (F2FS_IO_SIZE_BITS(sbi) && !f2fs_lfs_mode(sbi)) {
1292 default:
1293 f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
1294 p);
1295 return -EINVAL;
1296 }
1297 }
1298default_check:
1299#ifdef CONFIG_QUOTA

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

1338#ifdef CONFIG_F2FS_FS_COMPRESSION
1339 if (f2fs_test_compress_extension(sbi)) {
1340 f2fs_err(sbi, "invalid compress or nocompress extension");
1341 return -EINVAL;
1342 }
1343#endif
1344
1345 if (F2FS_IO_SIZE_BITS(sbi) && !f2fs_lfs_mode(sbi)) {
1313 f2fs_err(sbi, "Should set mode=lfs with %uKB-sized IO",
1346 f2fs_err(sbi, "Should set mode=lfs with %luKB-sized IO",
1314 F2FS_IO_SIZE_KB(sbi));
1315 return -EINVAL;
1316 }
1317
1318 if (test_opt(sbi, INLINE_XATTR_SIZE)) {
1319 int min_size, max_size;
1320
1321 if (!f2fs_sb_has_extra_attr(sbi) ||

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

1605 * above failed with error.
1606 */
1607 f2fs_destroy_stats(sbi);
1608
1609 /* destroy f2fs internal modules */
1610 f2fs_destroy_node_manager(sbi);
1611 f2fs_destroy_segment_manager(sbi);
1612
1347 F2FS_IO_SIZE_KB(sbi));
1348 return -EINVAL;
1349 }
1350
1351 if (test_opt(sbi, INLINE_XATTR_SIZE)) {
1352 int min_size, max_size;
1353
1354 if (!f2fs_sb_has_extra_attr(sbi) ||

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

1638 * above failed with error.
1639 */
1640 f2fs_destroy_stats(sbi);
1641
1642 /* destroy f2fs internal modules */
1643 f2fs_destroy_node_manager(sbi);
1644 f2fs_destroy_segment_manager(sbi);
1645
1646 /* flush s_error_work before sbi destroy */
1647 flush_work(&sbi->s_error_work);
1648
1613 f2fs_destroy_post_read_wq(sbi);
1614
1615 kvfree(sbi->ckpt);
1616
1617 sb->s_fs_info = NULL;
1618 if (sbi->s_chksum_driver)
1619 crypto_free_shash(sbi->s_chksum_driver);
1620 kfree(sbi->raw_super);

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

2035 if (test_opt(sbi, ATGC))
2036 seq_puts(seq, ",atgc");
2037
2038 if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_NORMAL)
2039 seq_printf(seq, ",memory=%s", "normal");
2040 else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW)
2041 seq_printf(seq, ",memory=%s", "low");
2042
1649 f2fs_destroy_post_read_wq(sbi);
1650
1651 kvfree(sbi->ckpt);
1652
1653 sb->s_fs_info = NULL;
1654 if (sbi->s_chksum_driver)
1655 crypto_free_shash(sbi->s_chksum_driver);
1656 kfree(sbi->raw_super);

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

2071 if (test_opt(sbi, ATGC))
2072 seq_puts(seq, ",atgc");
2073
2074 if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_NORMAL)
2075 seq_printf(seq, ",memory=%s", "normal");
2076 else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW)
2077 seq_printf(seq, ",memory=%s", "low");
2078
2079 if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_READONLY)
2080 seq_printf(seq, ",errors=%s", "remount-ro");
2081 else if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_CONTINUE)
2082 seq_printf(seq, ",errors=%s", "continue");
2083 else if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_PANIC)
2084 seq_printf(seq, ",errors=%s", "panic");
2085
2043 return 0;
2044}
2045
2046static void default_options(struct f2fs_sb_info *sbi)
2047{
2048 /* init some FS parameters */
2049 if (f2fs_sb_has_readonly(sbi))
2050 F2FS_OPTION(sbi).active_logs = NR_CURSEG_RO_TYPE;

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

2055 if (le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count_main) <=
2056 SMALL_VOLUME_SEGMENTS)
2057 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
2058 else
2059 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT;
2060 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX;
2061 F2FS_OPTION(sbi).s_resuid = make_kuid(&init_user_ns, F2FS_DEF_RESUID);
2062 F2FS_OPTION(sbi).s_resgid = make_kgid(&init_user_ns, F2FS_DEF_RESGID);
2086 return 0;
2087}
2088
2089static void default_options(struct f2fs_sb_info *sbi)
2090{
2091 /* init some FS parameters */
2092 if (f2fs_sb_has_readonly(sbi))
2093 F2FS_OPTION(sbi).active_logs = NR_CURSEG_RO_TYPE;

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

2098 if (le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count_main) <=
2099 SMALL_VOLUME_SEGMENTS)
2100 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
2101 else
2102 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT;
2103 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX;
2104 F2FS_OPTION(sbi).s_resuid = make_kuid(&init_user_ns, F2FS_DEF_RESUID);
2105 F2FS_OPTION(sbi).s_resgid = make_kgid(&init_user_ns, F2FS_DEF_RESGID);
2063 F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZ4;
2064 F2FS_OPTION(sbi).compress_log_size = MIN_COMPRESS_LOG_SIZE;
2065 F2FS_OPTION(sbi).compress_ext_cnt = 0;
2066 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
2106 if (f2fs_sb_has_compression(sbi)) {
2107 F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZ4;
2108 F2FS_OPTION(sbi).compress_log_size = MIN_COMPRESS_LOG_SIZE;
2109 F2FS_OPTION(sbi).compress_ext_cnt = 0;
2110 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
2111 }
2067 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
2068 F2FS_OPTION(sbi).memory_mode = MEMORY_MODE_NORMAL;
2112 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
2113 F2FS_OPTION(sbi).memory_mode = MEMORY_MODE_NORMAL;
2114 F2FS_OPTION(sbi).errors = MOUNT_ERRORS_CONTINUE;
2069
2070 sbi->sb->s_flags &= ~SB_INLINECRYPT;
2071
2072 set_opt(sbi, INLINE_XATTR);
2073 set_opt(sbi, INLINE_DATA);
2074 set_opt(sbi, INLINE_DENTRY);
2075 set_opt(sbi, READ_EXTENT_CACHE);
2076 set_opt(sbi, NOHEAP);

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

2262
2263 default_options(sbi);
2264
2265 /* parse mount options */
2266 err = parse_options(sb, data, true);
2267 if (err)
2268 goto restore_opts;
2269
2115
2116 sbi->sb->s_flags &= ~SB_INLINECRYPT;
2117
2118 set_opt(sbi, INLINE_XATTR);
2119 set_opt(sbi, INLINE_DATA);
2120 set_opt(sbi, INLINE_DENTRY);
2121 set_opt(sbi, READ_EXTENT_CACHE);
2122 set_opt(sbi, NOHEAP);

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

2308
2309 default_options(sbi);
2310
2311 /* parse mount options */
2312 err = parse_options(sb, data, true);
2313 if (err)
2314 goto restore_opts;
2315
2316 /* flush outstanding errors before changing fs state */
2317 flush_work(&sbi->s_error_work);
2318
2270 /*
2271 * Previous and new state of filesystem is RO,
2272 * so skip checking GC and FLUSH_MERGE conditions.
2273 */
2274 if (f2fs_readonly(sb) && (*flags & SB_RDONLY))
2275 goto skip;
2276
2319 /*
2320 * Previous and new state of filesystem is RO,
2321 * so skip checking GC and FLUSH_MERGE conditions.
2322 */
2323 if (f2fs_readonly(sb) && (*flags & SB_RDONLY))
2324 goto skip;
2325
2277 if (f2fs_sb_has_readonly(sbi) && !(*flags & SB_RDONLY)) {
2326 if (f2fs_dev_is_readonly(sbi) && !(*flags & SB_RDONLY)) {
2278 err = -EROFS;
2279 goto restore_opts;
2280 }
2281
2282#ifdef CONFIG_QUOTA
2283 if (!f2fs_readonly(sb) && (*flags & SB_RDONLY)) {
2284 err = dquot_suspend(sb, -1);
2285 if (err < 0)

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

2482 }
2483#endif
2484 sbi->mount_opt = org_mount_opt;
2485 sb->s_flags = old_sb_flags;
2486 return err;
2487}
2488
2489#ifdef CONFIG_QUOTA
2327 err = -EROFS;
2328 goto restore_opts;
2329 }
2330
2331#ifdef CONFIG_QUOTA
2332 if (!f2fs_readonly(sb) && (*flags & SB_RDONLY)) {
2333 err = dquot_suspend(sb, -1);
2334 if (err < 0)

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

2531 }
2532#endif
2533 sbi->mount_opt = org_mount_opt;
2534 sb->s_flags = old_sb_flags;
2535 return err;
2536}
2537
2538#ifdef CONFIG_QUOTA
2539static bool f2fs_need_recovery(struct f2fs_sb_info *sbi)
2540{
2541 /* need to recovery orphan */
2542 if (is_set_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG))
2543 return true;
2544 /* need to recovery data */
2545 if (test_opt(sbi, DISABLE_ROLL_FORWARD))
2546 return false;
2547 if (test_opt(sbi, NORECOVERY))
2548 return false;
2549 return !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG);
2550}
2551
2552static bool f2fs_recover_quota_begin(struct f2fs_sb_info *sbi)
2553{
2554 bool readonly = f2fs_readonly(sbi->sb);
2555
2556 if (!f2fs_need_recovery(sbi))
2557 return false;
2558
2559 /* it doesn't need to check f2fs_sb_has_readonly() */
2560 if (f2fs_hw_is_readonly(sbi))
2561 return false;
2562
2563 if (readonly) {
2564 sbi->sb->s_flags &= ~SB_RDONLY;
2565 set_sbi_flag(sbi, SBI_IS_WRITABLE);
2566 }
2567
2568 /*
2569 * Turn on quotas which were not enabled for read-only mounts if
2570 * filesystem has quota feature, so that they are updated correctly.
2571 */
2572 return f2fs_enable_quota_files(sbi, readonly);
2573}
2574
2575static void f2fs_recover_quota_end(struct f2fs_sb_info *sbi,
2576 bool quota_enabled)
2577{
2578 if (quota_enabled)
2579 f2fs_quota_off_umount(sbi->sb);
2580
2581 if (is_sbi_flag_set(sbi, SBI_IS_WRITABLE)) {
2582 clear_sbi_flag(sbi, SBI_IS_WRITABLE);
2583 sbi->sb->s_flags |= SB_RDONLY;
2584 }
2585}
2586
2490/* Read data from quotafile */
2491static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
2492 size_t len, loff_t off)
2493{
2494 struct inode *inode = sb_dqopt(sb)->files[type];
2495 struct address_space *mapping = inode->i_mapping;
2496 block_t blkidx = F2FS_BYTES_TO_BLK(off);
2497 int offset = off & (sb->s_blocksize - 1);

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

3255 } else if (main_end_blkaddr < seg_end_blkaddr) {
3256 int err = 0;
3257 char *res;
3258
3259 /* fix in-memory information all the time */
3260 raw_super->segment_count = cpu_to_le32((main_end_blkaddr -
3261 segment0_blkaddr) >> log_blocks_per_seg);
3262
2587/* Read data from quotafile */
2588static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
2589 size_t len, loff_t off)
2590{
2591 struct inode *inode = sb_dqopt(sb)->files[type];
2592 struct address_space *mapping = inode->i_mapping;
2593 block_t blkidx = F2FS_BYTES_TO_BLK(off);
2594 int offset = off & (sb->s_blocksize - 1);

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

3352 } else if (main_end_blkaddr < seg_end_blkaddr) {
3353 int err = 0;
3354 char *res;
3355
3356 /* fix in-memory information all the time */
3357 raw_super->segment_count = cpu_to_le32((main_end_blkaddr -
3358 segment0_blkaddr) >> log_blocks_per_seg);
3359
3263 if (f2fs_readonly(sb) || bdev_read_only(sb->s_bdev)) {
3360 if (f2fs_readonly(sb) || f2fs_hw_is_readonly(sbi)) {
3264 set_sbi_flag(sbi, SBI_NEED_SB_WRITE);
3265 res = "internally";
3266 } else {
3267 err = __f2fs_commit_super(bh, NULL);
3268 res = err ? "failed" : "done";
3269 }
3270 f2fs_info(sbi, "Fix alignment : %s, start(%u) end(%llu) block(%u)",
3271 res, main_blkaddr, seg_end_blkaddr,

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

3343
3344 segment_count = le32_to_cpu(raw_super->segment_count);
3345 segment_count_main = le32_to_cpu(raw_super->segment_count_main);
3346 segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
3347 secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
3348 total_sections = le32_to_cpu(raw_super->section_count);
3349
3350 /* blocks_per_seg should be 512, given the above check */
3361 set_sbi_flag(sbi, SBI_NEED_SB_WRITE);
3362 res = "internally";
3363 } else {
3364 err = __f2fs_commit_super(bh, NULL);
3365 res = err ? "failed" : "done";
3366 }
3367 f2fs_info(sbi, "Fix alignment : %s, start(%u) end(%llu) block(%u)",
3368 res, main_blkaddr, seg_end_blkaddr,

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

3440
3441 segment_count = le32_to_cpu(raw_super->segment_count);
3442 segment_count_main = le32_to_cpu(raw_super->segment_count_main);
3443 segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
3444 secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
3445 total_sections = le32_to_cpu(raw_super->section_count);
3446
3447 /* blocks_per_seg should be 512, given the above check */
3351 blocks_per_seg = 1 << le32_to_cpu(raw_super->log_blocks_per_seg);
3448 blocks_per_seg = BIT(le32_to_cpu(raw_super->log_blocks_per_seg));
3352
3353 if (segment_count > F2FS_MAX_SEGMENT ||
3354 segment_count < F2FS_MIN_SEGMENTS) {
3355 f2fs_info(sbi, "Invalid segment count (%u)", segment_count);
3356 return -EFSCORRUPTED;
3357 }
3358
3359 if (total_sections > segment_count_main || total_sections < 1 ||

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

3612static void init_sb_info(struct f2fs_sb_info *sbi)
3613{
3614 struct f2fs_super_block *raw_super = sbi->raw_super;
3615 int i;
3616
3617 sbi->log_sectors_per_block =
3618 le32_to_cpu(raw_super->log_sectors_per_block);
3619 sbi->log_blocksize = le32_to_cpu(raw_super->log_blocksize);
3449
3450 if (segment_count > F2FS_MAX_SEGMENT ||
3451 segment_count < F2FS_MIN_SEGMENTS) {
3452 f2fs_info(sbi, "Invalid segment count (%u)", segment_count);
3453 return -EFSCORRUPTED;
3454 }
3455
3456 if (total_sections > segment_count_main || total_sections < 1 ||

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

3709static void init_sb_info(struct f2fs_sb_info *sbi)
3710{
3711 struct f2fs_super_block *raw_super = sbi->raw_super;
3712 int i;
3713
3714 sbi->log_sectors_per_block =
3715 le32_to_cpu(raw_super->log_sectors_per_block);
3716 sbi->log_blocksize = le32_to_cpu(raw_super->log_blocksize);
3620 sbi->blocksize = 1 << sbi->log_blocksize;
3717 sbi->blocksize = BIT(sbi->log_blocksize);
3621 sbi->log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
3718 sbi->log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
3622 sbi->blocks_per_seg = 1 << sbi->log_blocks_per_seg;
3719 sbi->blocks_per_seg = BIT(sbi->log_blocks_per_seg);
3623 sbi->segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
3624 sbi->secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
3625 sbi->total_sections = le32_to_cpu(raw_super->section_count);
3626 sbi->total_node_count =
3627 (le32_to_cpu(raw_super->segment_count_nat) / 2)
3628 * sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK;
3629 F2FS_ROOT_INO(sbi) = le32_to_cpu(raw_super->root_ino);
3630 F2FS_NODE_INO(sbi) = le32_to_cpu(raw_super->node_ino);

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

3739 f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");
3740 return -EINVAL;
3741 }
3742
3743 if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
3744 SECTOR_TO_BLOCK(zone_sectors))
3745 return -EINVAL;
3746 sbi->blocks_per_blkz = SECTOR_TO_BLOCK(zone_sectors);
3720 sbi->segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
3721 sbi->secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
3722 sbi->total_sections = le32_to_cpu(raw_super->section_count);
3723 sbi->total_node_count =
3724 (le32_to_cpu(raw_super->segment_count_nat) / 2)
3725 * sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK;
3726 F2FS_ROOT_INO(sbi) = le32_to_cpu(raw_super->root_ino);
3727 F2FS_NODE_INO(sbi) = le32_to_cpu(raw_super->node_ino);

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

3836 f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");
3837 return -EINVAL;
3838 }
3839
3840 if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
3841 SECTOR_TO_BLOCK(zone_sectors))
3842 return -EINVAL;
3843 sbi->blocks_per_blkz = SECTOR_TO_BLOCK(zone_sectors);
3747 if (sbi->log_blocks_per_blkz && sbi->log_blocks_per_blkz !=
3748 __ilog2_u32(sbi->blocks_per_blkz))
3749 return -EINVAL;
3750 sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz);
3751 FDEV(devi).nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >>
3752 sbi->log_blocks_per_blkz;
3844 FDEV(devi).nr_blkz = div_u64(SECTOR_TO_BLOCK(nr_sectors),
3845 sbi->blocks_per_blkz);
3753 if (nr_sectors & (zone_sectors - 1))
3754 FDEV(devi).nr_blkz++;
3755
3756 FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi,
3757 BITS_TO_LONGS(FDEV(devi).nr_blkz)
3758 * sizeof(unsigned long),
3759 GFP_KERNEL);
3760 if (!FDEV(devi).blkz_seq)

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

3831
3832int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
3833{
3834 struct buffer_head *bh;
3835 __u32 crc = 0;
3836 int err;
3837
3838 if ((recover && f2fs_readonly(sbi->sb)) ||
3846 if (nr_sectors & (zone_sectors - 1))
3847 FDEV(devi).nr_blkz++;
3848
3849 FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi,
3850 BITS_TO_LONGS(FDEV(devi).nr_blkz)
3851 * sizeof(unsigned long),
3852 GFP_KERNEL);
3853 if (!FDEV(devi).blkz_seq)

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

3924
3925int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
3926{
3927 struct buffer_head *bh;
3928 __u32 crc = 0;
3929 int err;
3930
3931 if ((recover && f2fs_readonly(sbi->sb)) ||
3839 bdev_read_only(sbi->sb->s_bdev)) {
3932 f2fs_hw_is_readonly(sbi)) {
3840 set_sbi_flag(sbi, SBI_NEED_SB_WRITE);
3841 return -EROFS;
3842 }
3843
3844 /* we should update superblock crc here */
3845 if (!recover && f2fs_sb_has_sb_chksum(sbi)) {
3846 crc = f2fs_crc32(sbi, F2FS_RAW_SUPER(sbi),
3847 offsetof(struct f2fs_super_block, crc));

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

3863 bh = sb_bread(sbi->sb, sbi->valid_super_block);
3864 if (!bh)
3865 return -EIO;
3866 err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi));
3867 brelse(bh);
3868 return err;
3869}
3870
3933 set_sbi_flag(sbi, SBI_NEED_SB_WRITE);
3934 return -EROFS;
3935 }
3936
3937 /* we should update superblock crc here */
3938 if (!recover && f2fs_sb_has_sb_chksum(sbi)) {
3939 crc = f2fs_crc32(sbi, F2FS_RAW_SUPER(sbi),
3940 offsetof(struct f2fs_super_block, crc));

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

3956 bh = sb_bread(sbi->sb, sbi->valid_super_block);
3957 if (!bh)
3958 return -EIO;
3959 err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi));
3960 brelse(bh);
3961 return err;
3962}
3963
3871void f2fs_handle_stop(struct f2fs_sb_info *sbi, unsigned char reason)
3964static void save_stop_reason(struct f2fs_sb_info *sbi, unsigned char reason)
3872{
3965{
3966 unsigned long flags;
3967
3968 spin_lock_irqsave(&sbi->error_lock, flags);
3969 if (sbi->stop_reason[reason] < GENMASK(BITS_PER_BYTE - 1, 0))
3970 sbi->stop_reason[reason]++;
3971 spin_unlock_irqrestore(&sbi->error_lock, flags);
3972}
3973
3974static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)
3975{
3873 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
3976 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
3977 unsigned long flags;
3874 int err;
3875
3876 f2fs_down_write(&sbi->sb_lock);
3877
3978 int err;
3979
3980 f2fs_down_write(&sbi->sb_lock);
3981
3878 if (raw_super->s_stop_reason[reason] < ((1 << BITS_PER_BYTE) - 1))
3879 raw_super->s_stop_reason[reason]++;
3982 spin_lock_irqsave(&sbi->error_lock, flags);
3983 memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON);
3984 spin_unlock_irqrestore(&sbi->error_lock, flags);
3880
3881 err = f2fs_commit_super(sbi, false);
3985
3986 err = f2fs_commit_super(sbi, false);
3882 if (err)
3883 f2fs_err(sbi, "f2fs_commit_super fails to record reason:%u err:%d",
3884 reason, err);
3987
3885 f2fs_up_write(&sbi->sb_lock);
3988 f2fs_up_write(&sbi->sb_lock);
3989 if (err)
3990 f2fs_err(sbi, "f2fs_commit_super fails to record err:%d", err);
3886}
3887
3991}
3992
3888static void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag)
3993void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag)
3889{
3994{
3890 spin_lock(&sbi->error_lock);
3995 unsigned long flags;
3996
3997 spin_lock_irqsave(&sbi->error_lock, flags);
3891 if (!test_bit(flag, (unsigned long *)sbi->errors)) {
3892 set_bit(flag, (unsigned long *)sbi->errors);
3893 sbi->error_dirty = true;
3894 }
3998 if (!test_bit(flag, (unsigned long *)sbi->errors)) {
3999 set_bit(flag, (unsigned long *)sbi->errors);
4000 sbi->error_dirty = true;
4001 }
3895 spin_unlock(&sbi->error_lock);
4002 spin_unlock_irqrestore(&sbi->error_lock, flags);
3896}
3897
3898static bool f2fs_update_errors(struct f2fs_sb_info *sbi)
3899{
4003}
4004
4005static bool f2fs_update_errors(struct f2fs_sb_info *sbi)
4006{
4007 unsigned long flags;
3900 bool need_update = false;
3901
4008 bool need_update = false;
4009
3902 spin_lock(&sbi->error_lock);
4010 spin_lock_irqsave(&sbi->error_lock, flags);
3903 if (sbi->error_dirty) {
3904 memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors,
3905 MAX_F2FS_ERRORS);
3906 sbi->error_dirty = false;
3907 need_update = true;
3908 }
4011 if (sbi->error_dirty) {
4012 memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors,
4013 MAX_F2FS_ERRORS);
4014 sbi->error_dirty = false;
4015 need_update = true;
4016 }
3909 spin_unlock(&sbi->error_lock);
4017 spin_unlock_irqrestore(&sbi->error_lock, flags);
3910
3911 return need_update;
3912}
3913
3914void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
3915{
3916 int err;
3917

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

3925 err = f2fs_commit_super(sbi, false);
3926 if (err)
3927 f2fs_err(sbi, "f2fs_commit_super fails to record errors:%u, err:%d",
3928 error, err);
3929out_unlock:
3930 f2fs_up_write(&sbi->sb_lock);
3931}
3932
4018
4019 return need_update;
4020}
4021
4022void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
4023{
4024 int err;
4025

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

4033 err = f2fs_commit_super(sbi, false);
4034 if (err)
4035 f2fs_err(sbi, "f2fs_commit_super fails to record errors:%u, err:%d",
4036 error, err);
4037out_unlock:
4038 f2fs_up_write(&sbi->sb_lock);
4039}
4040
4041static bool system_going_down(void)
4042{
4043 return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF
4044 || system_state == SYSTEM_RESTART;
4045}
4046
4047void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason,
4048 bool irq_context)
4049{
4050 struct super_block *sb = sbi->sb;
4051 bool shutdown = reason == STOP_CP_REASON_SHUTDOWN;
4052 bool continue_fs = !shutdown &&
4053 F2FS_OPTION(sbi).errors == MOUNT_ERRORS_CONTINUE;
4054
4055 set_ckpt_flags(sbi, CP_ERROR_FLAG);
4056
4057 if (!f2fs_hw_is_readonly(sbi)) {
4058 save_stop_reason(sbi, reason);
4059
4060 if (irq_context && !shutdown)
4061 schedule_work(&sbi->s_error_work);
4062 else
4063 f2fs_record_stop_reason(sbi);
4064 }
4065
4066 /*
4067 * We force ERRORS_RO behavior when system is rebooting. Otherwise we
4068 * could panic during 'reboot -f' as the underlying device got already
4069 * disabled.
4070 */
4071 if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_PANIC &&
4072 !shutdown && !system_going_down() &&
4073 !is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN))
4074 panic("F2FS-fs (device %s): panic forced after error\n",
4075 sb->s_id);
4076
4077 if (shutdown)
4078 set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
4079
4080 /* continue filesystem operators if errors=continue */
4081 if (continue_fs || f2fs_readonly(sb))
4082 return;
4083
4084 f2fs_warn(sbi, "Remounting filesystem read-only");
4085 /*
4086 * Make sure updated value of ->s_mount_flags will be visible before
4087 * ->s_flags update
4088 */
4089 smp_wmb();
4090 sb->s_flags |= SB_RDONLY;
4091}
4092
4093static void f2fs_record_error_work(struct work_struct *work)
4094{
4095 struct f2fs_sb_info *sbi = container_of(work,
4096 struct f2fs_sb_info, s_error_work);
4097
4098 f2fs_record_stop_reason(sbi);
4099}
4100
3933static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
3934{
3935 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
3936 unsigned int max_devices = MAX_DEVICES;
3937 unsigned int logical_blksize;
3938 int i;
3939
3940 /* Initialize single device information */

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

4020 }
4021#endif
4022 f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x",
4023 i, FDEV(i).path,
4024 FDEV(i).total_segments,
4025 FDEV(i).start_blk, FDEV(i).end_blk);
4026 }
4027 f2fs_info(sbi,
4101static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
4102{
4103 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
4104 unsigned int max_devices = MAX_DEVICES;
4105 unsigned int logical_blksize;
4106 int i;
4107
4108 /* Initialize single device information */

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

4188 }
4189#endif
4190 f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x",
4191 i, FDEV(i).path,
4192 FDEV(i).total_segments,
4193 FDEV(i).start_blk, FDEV(i).end_blk);
4194 }
4195 f2fs_info(sbi,
4028 "IO Block Size: %8d KB", F2FS_IO_SIZE_KB(sbi));
4196 "IO Block Size: %8ld KB", F2FS_IO_SIZE_KB(sbi));
4029 return 0;
4030}
4031
4032static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
4033{
4034#if IS_ENABLED(CONFIG_UNICODE)
4035 if (f2fs_sb_has_casefold(sbi) && !sbi->sb->s_encoding) {
4036 const struct f2fs_sb_encodings *encoding_info;

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

4097 struct f2fs_super_block *raw_super;
4098 struct inode *root;
4099 int err;
4100 bool skip_recovery = false, need_fsck = false;
4101 char *options = NULL;
4102 int recovery, i, valid_super_block;
4103 struct curseg_info *seg_i;
4104 int retry_cnt = 1;
4197 return 0;
4198}
4199
4200static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
4201{
4202#if IS_ENABLED(CONFIG_UNICODE)
4203 if (f2fs_sb_has_casefold(sbi) && !sbi->sb->s_encoding) {
4204 const struct f2fs_sb_encodings *encoding_info;

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

4265 struct f2fs_super_block *raw_super;
4266 struct inode *root;
4267 int err;
4268 bool skip_recovery = false, need_fsck = false;
4269 char *options = NULL;
4270 int recovery, i, valid_super_block;
4271 struct curseg_info *seg_i;
4272 int retry_cnt = 1;
4273#ifdef CONFIG_QUOTA
4274 bool quota_enabled = false;
4275#endif
4105
4106try_onemore:
4107 err = -EINVAL;
4108 raw_super = NULL;
4109 valid_super_block = -1;
4110 recovery = 0;
4111
4112 /* allocate memory for f2fs-specific super block info */

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

4152 err = read_raw_super_block(sbi, &raw_super, &valid_super_block,
4153 &recovery);
4154 if (err)
4155 goto free_sbi;
4156
4157 sb->s_fs_info = sbi;
4158 sbi->raw_super = raw_super;
4159
4276
4277try_onemore:
4278 err = -EINVAL;
4279 raw_super = NULL;
4280 valid_super_block = -1;
4281 recovery = 0;
4282
4283 /* allocate memory for f2fs-specific super block info */

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

4323 err = read_raw_super_block(sbi, &raw_super, &valid_super_block,
4324 &recovery);
4325 if (err)
4326 goto free_sbi;
4327
4328 sb->s_fs_info = sbi;
4329 sbi->raw_super = raw_super;
4330
4331 INIT_WORK(&sbi->s_error_work, f2fs_record_error_work);
4160 memcpy(sbi->errors, raw_super->s_errors, MAX_F2FS_ERRORS);
4332 memcpy(sbi->errors, raw_super->s_errors, MAX_F2FS_ERRORS);
4333 memcpy(sbi->stop_reason, raw_super->s_stop_reason, MAX_STOP_REASON);
4161
4162 /* precompute checksum seed for metadata */
4163 if (f2fs_sb_has_inode_chksum(sbi))
4164 sbi->s_chksum_seed = f2fs_chksum(sbi, ~0, raw_super->uuid,
4165 sizeof(raw_super->uuid));
4166
4167 default_options(sbi);
4168 /* parse mount options */

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

4390
4391#ifdef CONFIG_QUOTA
4392 /* Enable quota usage during mount */
4393 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) {
4394 err = f2fs_enable_quotas(sb);
4395 if (err)
4396 f2fs_err(sbi, "Cannot turn on quotas: error %d", err);
4397 }
4334
4335 /* precompute checksum seed for metadata */
4336 if (f2fs_sb_has_inode_chksum(sbi))
4337 sbi->s_chksum_seed = f2fs_chksum(sbi, ~0, raw_super->uuid,
4338 sizeof(raw_super->uuid));
4339
4340 default_options(sbi);
4341 /* parse mount options */

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

4563
4564#ifdef CONFIG_QUOTA
4565 /* Enable quota usage during mount */
4566 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) {
4567 err = f2fs_enable_quotas(sb);
4568 if (err)
4569 f2fs_err(sbi, "Cannot turn on quotas: error %d", err);
4570 }
4571
4572 quota_enabled = f2fs_recover_quota_begin(sbi);
4398#endif
4399 /* if there are any orphan inodes, free them */
4400 err = f2fs_recover_orphan_inodes(sbi);
4401 if (err)
4402 goto free_meta;
4403
4404 if (unlikely(is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)))
4405 goto reset_checkpoint;

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

4447
4448 if (!f2fs_readonly(sb) && err > 0) {
4449 err = -EINVAL;
4450 f2fs_err(sbi, "Need to recover fsync data");
4451 goto free_meta;
4452 }
4453 }
4454
4573#endif
4574 /* if there are any orphan inodes, free them */
4575 err = f2fs_recover_orphan_inodes(sbi);
4576 if (err)
4577 goto free_meta;
4578
4579 if (unlikely(is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)))
4580 goto reset_checkpoint;

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

4622
4623 if (!f2fs_readonly(sb) && err > 0) {
4624 err = -EINVAL;
4625 f2fs_err(sbi, "Need to recover fsync data");
4626 goto free_meta;
4627 }
4628 }
4629
4630#ifdef CONFIG_QUOTA
4631 f2fs_recover_quota_end(sbi, quota_enabled);
4632#endif
4633
4455 /*
4456 * If the f2fs is not readonly and fsync data recovery succeeds,
4457 * check zoned block devices' write pointer consistency.
4458 */
4459 if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
4460 err = f2fs_check_write_pointer(sbi);
4461 if (err)
4462 goto free_meta;

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

4543free_nm:
4544 /* stop discard thread before destroying node manager */
4545 f2fs_stop_discard_thread(sbi);
4546 f2fs_destroy_node_manager(sbi);
4547free_sm:
4548 f2fs_destroy_segment_manager(sbi);
4549stop_ckpt_thread:
4550 f2fs_stop_ckpt_thread(sbi);
4634 /*
4635 * If the f2fs is not readonly and fsync data recovery succeeds,
4636 * check zoned block devices' write pointer consistency.
4637 */
4638 if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
4639 err = f2fs_check_write_pointer(sbi);
4640 if (err)
4641 goto free_meta;

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

4722free_nm:
4723 /* stop discard thread before destroying node manager */
4724 f2fs_stop_discard_thread(sbi);
4725 f2fs_destroy_node_manager(sbi);
4726free_sm:
4727 f2fs_destroy_segment_manager(sbi);
4728stop_ckpt_thread:
4729 f2fs_stop_ckpt_thread(sbi);
4730 /* flush s_error_work before sbi destroy */
4731 flush_work(&sbi->s_error_work);
4551 f2fs_destroy_post_read_wq(sbi);
4552free_devices:
4553 destroy_device_list(sbi);
4554 kvfree(sbi->ckpt);
4555free_meta_inode:
4556 make_bad_inode(sbi->meta_inode);
4557 iput(sbi->meta_inode);
4558 sbi->meta_inode = NULL;

--- 236 unchanged lines hidden ---
4732 f2fs_destroy_post_read_wq(sbi);
4733free_devices:
4734 destroy_device_list(sbi);
4735 kvfree(sbi->ckpt);
4736free_meta_inode:
4737 make_bad_inode(sbi->meta_inode);
4738 iput(sbi->meta_inode);
4739 sbi->meta_inode = NULL;

--- 236 unchanged lines hidden ---