hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/fs/f2fs/super.c
....@@ -24,13 +24,15 @@
2424 #include <linux/sysfs.h>
2525 #include <linux/quota.h>
2626 #include <linux/unicode.h>
27
+#include <linux/part_stat.h>
28
+#include <linux/zstd.h>
29
+#include <linux/lz4.h>
2730
2831 #include "f2fs.h"
2932 #include "node.h"
3033 #include "segment.h"
3134 #include "xattr.h"
3235 #include "gc.h"
33
-#include "trace.h"
3436
3537 #define CREATE_TRACE_POINTS
3638 #include <trace/events/f2fs.h>
....@@ -44,7 +46,6 @@
4446 [FAULT_KVMALLOC] = "kvmalloc",
4547 [FAULT_PAGE_ALLOC] = "page alloc",
4648 [FAULT_PAGE_GET] = "page get",
47
- [FAULT_ALLOC_BIO] = "alloc bio",
4849 [FAULT_ALLOC_NID] = "alloc nid",
4950 [FAULT_ORPHAN] = "orphan",
5051 [FAULT_BLOCK] = "no more block",
....@@ -142,9 +143,19 @@
142143 Opt_checkpoint_disable_cap,
143144 Opt_checkpoint_disable_cap_perc,
144145 Opt_checkpoint_enable,
146
+ Opt_checkpoint_merge,
147
+ Opt_nocheckpoint_merge,
145148 Opt_compress_algorithm,
146149 Opt_compress_log_size,
147150 Opt_compress_extension,
151
+ Opt_compress_chksum,
152
+ Opt_compress_mode,
153
+ Opt_compress_cache,
154
+ Opt_atgc,
155
+ Opt_gc_merge,
156
+ Opt_nogc_merge,
157
+ Opt_memory_mode,
158
+ Opt_age_extent_cache,
148159 Opt_err,
149160 };
150161
....@@ -209,9 +220,19 @@
209220 {Opt_checkpoint_disable_cap, "checkpoint=disable:%u"},
210221 {Opt_checkpoint_disable_cap_perc, "checkpoint=disable:%u%%"},
211222 {Opt_checkpoint_enable, "checkpoint=enable"},
223
+ {Opt_checkpoint_merge, "checkpoint_merge"},
224
+ {Opt_nocheckpoint_merge, "nocheckpoint_merge"},
212225 {Opt_compress_algorithm, "compress_algorithm=%s"},
213226 {Opt_compress_log_size, "compress_log_size=%u"},
214227 {Opt_compress_extension, "compress_extension=%s"},
228
+ {Opt_compress_chksum, "compress_chksum"},
229
+ {Opt_compress_mode, "compress_mode=%s"},
230
+ {Opt_compress_cache, "compress_cache"},
231
+ {Opt_atgc, "atgc"},
232
+ {Opt_gc_merge, "gc_merge"},
233
+ {Opt_nogc_merge, "nogc_merge"},
234
+ {Opt_memory_mode, "memory=%s"},
235
+ {Opt_age_extent_cache, "age_extent_cache"},
215236 {Opt_err, NULL},
216237 };
217238
....@@ -260,17 +281,35 @@
260281
261282 return 0;
262283 }
284
+
285
+struct kmem_cache *f2fs_cf_name_slab;
286
+static int __init f2fs_create_casefold_cache(void)
287
+{
288
+ f2fs_cf_name_slab = f2fs_kmem_cache_create("f2fs_casefolded_name",
289
+ F2FS_NAME_LEN);
290
+ if (!f2fs_cf_name_slab)
291
+ return -ENOMEM;
292
+ return 0;
293
+}
294
+
295
+static void f2fs_destroy_casefold_cache(void)
296
+{
297
+ kmem_cache_destroy(f2fs_cf_name_slab);
298
+}
299
+#else
300
+static int __init f2fs_create_casefold_cache(void) { return 0; }
301
+static void f2fs_destroy_casefold_cache(void) { }
263302 #endif
264303
265304 static inline void limit_reserve_root(struct f2fs_sb_info *sbi)
266305 {
267
- block_t limit = min((sbi->user_block_count << 1) / 1000,
306
+ block_t limit = min((sbi->user_block_count >> 3),
268307 sbi->user_block_count - sbi->reserved_blocks);
269308
270
- /* limit is 0.2%, and cannot be too small */
271
- limit = max(limit, MIN_ROOT_RESERVED_BLOCKS);
309
+ /* limit is 12.5% */
272310 if (test_opt(sbi, RESERVE_ROOT) &&
273
- F2FS_OPTION(sbi).root_reserved_blocks > limit) {
311
+ F2FS_OPTION(sbi).root_reserved_blocks > limit &&
312
+ F2FS_OPTION(sbi).root_reserved_blocks > MIN_ROOT_RESERVED_BLOCKS) {
274313 F2FS_OPTION(sbi).root_reserved_blocks = limit;
275314 f2fs_info(sbi, "Reduce reserved blocks for root = %u",
276315 F2FS_OPTION(sbi).root_reserved_blocks);
....@@ -285,6 +324,46 @@
285324 F2FS_OPTION(sbi).s_resuid),
286325 from_kgid_munged(&init_user_ns,
287326 F2FS_OPTION(sbi).s_resgid));
327
+}
328
+
329
+static inline int adjust_reserved_segment(struct f2fs_sb_info *sbi)
330
+{
331
+ unsigned int sec_blks = sbi->blocks_per_seg * sbi->segs_per_sec;
332
+ unsigned int avg_vblocks;
333
+ unsigned int wanted_reserved_segments;
334
+ block_t avail_user_block_count;
335
+
336
+ if (!F2FS_IO_ALIGNED(sbi))
337
+ return 0;
338
+
339
+ /* average valid block count in section in worst case */
340
+ avg_vblocks = sec_blks / F2FS_IO_SIZE(sbi);
341
+
342
+ /*
343
+ * we need enough free space when migrating one section in worst case
344
+ */
345
+ wanted_reserved_segments = (F2FS_IO_SIZE(sbi) / avg_vblocks) *
346
+ reserved_segments(sbi);
347
+ wanted_reserved_segments -= reserved_segments(sbi);
348
+
349
+ avail_user_block_count = sbi->user_block_count -
350
+ sbi->current_reserved_blocks -
351
+ F2FS_OPTION(sbi).root_reserved_blocks;
352
+
353
+ if (wanted_reserved_segments * sbi->blocks_per_seg >
354
+ avail_user_block_count) {
355
+ f2fs_err(sbi, "IO align feature can't grab additional reserved segment: %u, available segments: %u",
356
+ wanted_reserved_segments,
357
+ avail_user_block_count >> sbi->log_blocks_per_seg);
358
+ return -ENOSPC;
359
+ }
360
+
361
+ SM_I(sbi)->additional_reserved_segments = wanted_reserved_segments;
362
+
363
+ f2fs_info(sbi, "IO align feature needs additional reserved segment: %u",
364
+ wanted_reserved_segments);
365
+
366
+ return 0;
288367 }
289368
290369 static inline void adjust_unusable_cap_perc(struct f2fs_sb_info *sbi)
....@@ -350,7 +429,7 @@
350429 set_opt(sbi, QUOTA);
351430 return 0;
352431 errout:
353
- kvfree(qname);
432
+ kfree(qname);
354433 return ret;
355434 }
356435
....@@ -362,7 +441,7 @@
362441 f2fs_err(sbi, "Cannot change journaled quota options when quota turned on");
363442 return -EINVAL;
364443 }
365
- kvfree(F2FS_OPTION(sbi).s_qf_names[qtype]);
444
+ kfree(F2FS_OPTION(sbi).s_qf_names[qtype]);
366445 F2FS_OPTION(sbi).s_qf_names[qtype] = NULL;
367446 return 0;
368447 }
....@@ -433,12 +512,12 @@
433512 * needed to allow it to be set or changed during remount. We do allow
434513 * it to be specified during remount, but only if there is no change.
435514 */
436
- if (is_remount && !F2FS_OPTION(sbi).dummy_enc_ctx.ctx) {
515
+ if (is_remount && !F2FS_OPTION(sbi).dummy_enc_policy.policy) {
437516 f2fs_warn(sbi, "Can't set test_dummy_encryption on remount");
438517 return -EINVAL;
439518 }
440519 err = fscrypt_set_test_dummy_encryption(
441
- sb, arg, &F2FS_OPTION(sbi).dummy_enc_ctx);
520
+ sb, arg->from, &F2FS_OPTION(sbi).dummy_enc_policy);
442521 if (err) {
443522 if (err == -EEXIST)
444523 f2fs_warn(sbi,
....@@ -458,22 +537,94 @@
458537 return 0;
459538 }
460539
540
+#ifdef CONFIG_F2FS_FS_COMPRESSION
541
+#ifdef CONFIG_F2FS_FS_LZ4
542
+static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str)
543
+{
544
+#ifdef CONFIG_F2FS_FS_LZ4HC
545
+ unsigned int level;
546
+#endif
547
+
548
+ if (strlen(str) == 3) {
549
+ F2FS_OPTION(sbi).compress_level = 0;
550
+ return 0;
551
+ }
552
+
553
+#ifdef CONFIG_F2FS_FS_LZ4HC
554
+ str += 3;
555
+
556
+ if (str[0] != ':') {
557
+ f2fs_info(sbi, "wrong format, e.g. <alg_name>:<compr_level>");
558
+ return -EINVAL;
559
+ }
560
+ if (kstrtouint(str + 1, 10, &level))
561
+ return -EINVAL;
562
+
563
+ if (level < LZ4HC_MIN_CLEVEL || level > LZ4HC_MAX_CLEVEL) {
564
+ f2fs_info(sbi, "invalid lz4hc compress level: %d", level);
565
+ return -EINVAL;
566
+ }
567
+
568
+ F2FS_OPTION(sbi).compress_level = level;
569
+ return 0;
570
+#else
571
+ f2fs_info(sbi, "kernel doesn't support lz4hc compression");
572
+ return -EINVAL;
573
+#endif
574
+}
575
+#endif
576
+
577
+#ifdef CONFIG_F2FS_FS_ZSTD
578
+static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)
579
+{
580
+ unsigned int level;
581
+ int len = 4;
582
+
583
+ if (strlen(str) == len) {
584
+ F2FS_OPTION(sbi).compress_level = 0;
585
+ return 0;
586
+ }
587
+
588
+ str += len;
589
+
590
+ if (str[0] != ':') {
591
+ f2fs_info(sbi, "wrong format, e.g. <alg_name>:<compr_level>");
592
+ return -EINVAL;
593
+ }
594
+ if (kstrtouint(str + 1, 10, &level))
595
+ return -EINVAL;
596
+
597
+ if (!level || level > ZSTD_maxCLevel()) {
598
+ f2fs_info(sbi, "invalid zstd compress level: %d", level);
599
+ return -EINVAL;
600
+ }
601
+
602
+ F2FS_OPTION(sbi).compress_level = level;
603
+ return 0;
604
+}
605
+#endif
606
+#endif
607
+
461608 static int parse_options(struct super_block *sb, char *options, bool is_remount)
462609 {
463610 struct f2fs_sb_info *sbi = F2FS_SB(sb);
464611 substring_t args[MAX_OPT_ARGS];
612
+#ifdef CONFIG_F2FS_FS_COMPRESSION
465613 unsigned char (*ext)[F2FS_EXTENSION_LEN];
614
+ int ext_cnt;
615
+#endif
466616 char *p, *name;
467
- int arg = 0, ext_cnt;
617
+ int arg = 0;
468618 kuid_t uid;
469619 kgid_t gid;
470620 int ret;
471621
472622 if (!options)
473
- return 0;
623
+ goto default_check;
474624
475625 while ((p = strsep(&options, ",")) != NULL) {
476626 int token;
627
+
477628 if (!*p)
478629 continue;
479630 /*
....@@ -496,10 +647,10 @@
496647 } else if (!strcmp(name, "sync")) {
497648 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_SYNC;
498649 } else {
499
- kvfree(name);
650
+ kfree(name);
500651 return -EINVAL;
501652 }
502
- kvfree(name);
653
+ kfree(name);
503654 break;
504655 case Opt_disable_roll_forward:
505656 set_opt(sbi, DISABLE_ROLL_FORWARD);
....@@ -577,7 +728,8 @@
577728 case Opt_active_logs:
578729 if (args->from && match_int(args, &arg))
579730 return -EINVAL;
580
- if (arg != 2 && arg != 4 && arg != NR_CURSEG_TYPE)
731
+ if (arg != 2 && arg != 4 &&
732
+ arg != NR_CURSEG_PERSIST_TYPE)
581733 return -EINVAL;
582734 F2FS_OPTION(sbi).active_logs = arg;
583735 break;
....@@ -606,10 +758,10 @@
606758 set_opt(sbi, FASTBOOT);
607759 break;
608760 case Opt_extent_cache:
609
- set_opt(sbi, EXTENT_CACHE);
761
+ set_opt(sbi, READ_EXTENT_CACHE);
610762 break;
611763 case Opt_noextent_cache:
612
- clear_opt(sbi, EXTENT_CACHE);
764
+ clear_opt(sbi, READ_EXTENT_CACHE);
613765 break;
614766 case Opt_noinline_data:
615767 clear_opt(sbi, INLINE_DATA);
....@@ -656,17 +808,17 @@
656808 if (!strcmp(name, "adaptive")) {
657809 if (f2fs_sb_has_blkzoned(sbi)) {
658810 f2fs_warn(sbi, "adaptive mode is not allowed with zoned block device feature");
659
- kvfree(name);
811
+ kfree(name);
660812 return -EINVAL;
661813 }
662814 F2FS_OPTION(sbi).fs_mode = FS_MODE_ADAPTIVE;
663815 } else if (!strcmp(name, "lfs")) {
664816 F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS;
665817 } else {
666
- kvfree(name);
818
+ kfree(name);
667819 return -EINVAL;
668820 }
669
- kvfree(name);
821
+ kfree(name);
670822 break;
671823 case Opt_io_size_bits:
672824 if (args->from && match_int(args, &arg))
....@@ -792,10 +944,10 @@
792944 } else if (!strcmp(name, "fs-based")) {
793945 F2FS_OPTION(sbi).whint_mode = WHINT_MODE_FS;
794946 } else {
795
- kvfree(name);
947
+ kfree(name);
796948 return -EINVAL;
797949 }
798
- kvfree(name);
950
+ kfree(name);
799951 break;
800952 case Opt_alloc:
801953 name = match_strdup(&args[0]);
....@@ -807,10 +959,10 @@
807959 } else if (!strcmp(name, "reuse")) {
808960 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
809961 } else {
810
- kvfree(name);
962
+ kfree(name);
811963 return -EINVAL;
812964 }
813
- kvfree(name);
965
+ kfree(name);
814966 break;
815967 case Opt_fsync:
816968 name = match_strdup(&args[0]);
....@@ -824,10 +976,10 @@
824976 F2FS_OPTION(sbi).fsync_mode =
825977 FSYNC_MODE_NOBARRIER;
826978 } else {
827
- kvfree(name);
979
+ kfree(name);
828980 return -EINVAL;
829981 }
830
- kvfree(name);
982
+ kfree(name);
831983 break;
832984 case Opt_test_dummy_encryption:
833985 ret = f2fs_set_test_dummy_encryption(sb, p, &args[0],
....@@ -837,7 +989,7 @@
837989 break;
838990 case Opt_inlinecrypt:
839991 #ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT
840
- F2FS_OPTION(sbi).inlinecrypt = true;
992
+ sb->s_flags |= SB_INLINECRYPT;
841993 #else
842994 f2fs_info(sbi, "inline encryption not supported");
843995 #endif
....@@ -862,23 +1014,61 @@
8621014 case Opt_checkpoint_enable:
8631015 clear_opt(sbi, DISABLE_CHECKPOINT);
8641016 break;
1017
+ case Opt_checkpoint_merge:
1018
+ set_opt(sbi, MERGE_CHECKPOINT);
1019
+ break;
1020
+ case Opt_nocheckpoint_merge:
1021
+ clear_opt(sbi, MERGE_CHECKPOINT);
1022
+ break;
1023
+#ifdef CONFIG_F2FS_FS_COMPRESSION
8651024 case Opt_compress_algorithm:
8661025 if (!f2fs_sb_has_compression(sbi)) {
867
- f2fs_err(sbi, "Compression feature if off");
868
- return -EINVAL;
1026
+ f2fs_info(sbi, "Image doesn't support compression");
1027
+ break;
8691028 }
8701029 name = match_strdup(&args[0]);
8711030 if (!name)
8721031 return -ENOMEM;
8731032 if (!strcmp(name, "lzo")) {
1033
+#ifdef CONFIG_F2FS_FS_LZO
1034
+ F2FS_OPTION(sbi).compress_level = 0;
8741035 F2FS_OPTION(sbi).compress_algorithm =
8751036 COMPRESS_LZO;
876
- } else if (!strcmp(name, "lz4")) {
1037
+#else
1038
+ f2fs_info(sbi, "kernel doesn't support lzo compression");
1039
+#endif
1040
+ } else if (!strncmp(name, "lz4", 3)) {
1041
+#ifdef CONFIG_F2FS_FS_LZ4
1042
+ ret = f2fs_set_lz4hc_level(sbi, name);
1043
+ if (ret) {
1044
+ kfree(name);
1045
+ return -EINVAL;
1046
+ }
8771047 F2FS_OPTION(sbi).compress_algorithm =
8781048 COMPRESS_LZ4;
879
- } else if (!strcmp(name, "zstd")) {
1049
+#else
1050
+ f2fs_info(sbi, "kernel doesn't support lz4 compression");
1051
+#endif
1052
+ } else if (!strncmp(name, "zstd", 4)) {
1053
+#ifdef CONFIG_F2FS_FS_ZSTD
1054
+ ret = f2fs_set_zstd_level(sbi, name);
1055
+ if (ret) {
1056
+ kfree(name);
1057
+ return -EINVAL;
1058
+ }
8801059 F2FS_OPTION(sbi).compress_algorithm =
8811060 COMPRESS_ZSTD;
1061
+#else
1062
+ f2fs_info(sbi, "kernel doesn't support zstd compression");
1063
+#endif
1064
+ } else if (!strcmp(name, "lzo-rle")) {
1065
+#ifdef CONFIG_F2FS_FS_LZORLE
1066
+ F2FS_OPTION(sbi).compress_level = 0;
1067
+ F2FS_OPTION(sbi).compress_algorithm =
1068
+ COMPRESS_LZORLE;
1069
+#else
1070
+ f2fs_info(sbi, "kernel doesn't support lzorle compression");
1071
+#endif
8821072 } else {
8831073 kfree(name);
8841074 return -EINVAL;
....@@ -887,8 +1077,8 @@
8871077 break;
8881078 case Opt_compress_log_size:
8891079 if (!f2fs_sb_has_compression(sbi)) {
890
- f2fs_err(sbi, "Compression feature is off");
891
- return -EINVAL;
1080
+ f2fs_info(sbi, "Image doesn't support compression");
1081
+ break;
8921082 }
8931083 if (args->from && match_int(args, &arg))
8941084 return -EINVAL;
....@@ -902,8 +1092,8 @@
9021092 break;
9031093 case Opt_compress_extension:
9041094 if (!f2fs_sb_has_compression(sbi)) {
905
- f2fs_err(sbi, "Compression feature is off");
906
- return -EINVAL;
1095
+ f2fs_info(sbi, "Image doesn't support compression");
1096
+ break;
9071097 }
9081098 name = match_strdup(&args[0]);
9091099 if (!name)
....@@ -924,12 +1114,71 @@
9241114 F2FS_OPTION(sbi).compress_ext_cnt++;
9251115 kfree(name);
9261116 break;
1117
+ case Opt_compress_chksum:
1118
+ F2FS_OPTION(sbi).compress_chksum = true;
1119
+ break;
1120
+ case Opt_compress_mode:
1121
+ name = match_strdup(&args[0]);
1122
+ if (!name)
1123
+ return -ENOMEM;
1124
+ if (!strcmp(name, "fs")) {
1125
+ F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
1126
+ } else if (!strcmp(name, "user")) {
1127
+ F2FS_OPTION(sbi).compress_mode = COMPR_MODE_USER;
1128
+ } else {
1129
+ kfree(name);
1130
+ return -EINVAL;
1131
+ }
1132
+ kfree(name);
1133
+ break;
1134
+ case Opt_compress_cache:
1135
+ set_opt(sbi, COMPRESS_CACHE);
1136
+ break;
1137
+#else
1138
+ case Opt_compress_algorithm:
1139
+ case Opt_compress_log_size:
1140
+ case Opt_compress_extension:
1141
+ case Opt_compress_chksum:
1142
+ case Opt_compress_mode:
1143
+ case Opt_compress_cache:
1144
+ f2fs_info(sbi, "compression options not supported");
1145
+ break;
1146
+#endif
1147
+ case Opt_atgc:
1148
+ set_opt(sbi, ATGC);
1149
+ break;
1150
+ case Opt_gc_merge:
1151
+ set_opt(sbi, GC_MERGE);
1152
+ break;
1153
+ case Opt_nogc_merge:
1154
+ clear_opt(sbi, GC_MERGE);
1155
+ break;
1156
+ case Opt_age_extent_cache:
1157
+ set_opt(sbi, AGE_EXTENT_CACHE);
1158
+ break;
1159
+ case Opt_memory_mode:
1160
+ name = match_strdup(&args[0]);
1161
+ if (!name)
1162
+ return -ENOMEM;
1163
+ if (!strcmp(name, "normal")) {
1164
+ F2FS_OPTION(sbi).memory_mode =
1165
+ MEMORY_MODE_NORMAL;
1166
+ } else if (!strcmp(name, "low")) {
1167
+ F2FS_OPTION(sbi).memory_mode =
1168
+ MEMORY_MODE_LOW;
1169
+ } else {
1170
+ kfree(name);
1171
+ return -EINVAL;
1172
+ }
1173
+ kfree(name);
1174
+ break;
9271175 default:
9281176 f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
9291177 p);
9301178 return -EINVAL;
9311179 }
9321180 }
1181
+default_check:
9331182 #ifdef CONFIG_QUOTA
9341183 if (f2fs_check_quota_options(sbi))
9351184 return -EINVAL;
....@@ -947,6 +1196,17 @@
9471196 if (f2fs_sb_has_casefold(sbi)) {
9481197 f2fs_err(sbi,
9491198 "Filesystem with casefold feature cannot be mounted without CONFIG_UNICODE");
1199
+ return -EINVAL;
1200
+ }
1201
+#endif
1202
+ /*
1203
+ * The BLKZONED feature indicates that the drive was formatted with
1204
+ * zone alignment optimization. This is optional for host-aware
1205
+ * devices, but mandatory for host-managed zoned block devices.
1206
+ */
1207
+#ifndef CONFIG_BLK_DEV_ZONED
1208
+ if (f2fs_sb_has_blkzoned(sbi)) {
1209
+ f2fs_err(sbi, "Zoned block device support is not enabled");
9501210 return -EINVAL;
9511211 }
9521212 #endif
....@@ -982,15 +1242,20 @@
9821242 }
9831243
9841244 if (test_opt(sbi, DISABLE_CHECKPOINT) && f2fs_lfs_mode(sbi)) {
985
- f2fs_err(sbi, "LFS not compatible with checkpoint=disable\n");
1245
+ f2fs_err(sbi, "LFS not compatible with checkpoint=disable");
9861246 return -EINVAL;
9871247 }
9881248
9891249 /* Not pass down write hints if the number of active logs is lesser
990
- * than NR_CURSEG_TYPE.
1250
+ * than NR_CURSEG_PERSIST_TYPE.
9911251 */
992
- if (F2FS_OPTION(sbi).active_logs != NR_CURSEG_TYPE)
1252
+ if (F2FS_OPTION(sbi).active_logs != NR_CURSEG_PERSIST_TYPE)
9931253 F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF;
1254
+
1255
+ if (f2fs_sb_has_readonly(sbi) && !f2fs_readonly(sbi->sb)) {
1256
+ f2fs_err(sbi, "Allow to mount readonly mode only");
1257
+ return -EROFS;
1258
+ }
9941259 return 0;
9951260 }
9961261
....@@ -1006,17 +1271,18 @@
10061271
10071272 /* Initialize f2fs-specific inode info */
10081273 atomic_set(&fi->dirty_pages, 0);
1009
- init_rwsem(&fi->i_sem);
1274
+ atomic_set(&fi->i_compr_blocks, 0);
1275
+ init_f2fs_rwsem(&fi->i_sem);
10101276 spin_lock_init(&fi->i_size_lock);
10111277 INIT_LIST_HEAD(&fi->dirty_list);
10121278 INIT_LIST_HEAD(&fi->gdirty_list);
10131279 INIT_LIST_HEAD(&fi->inmem_ilist);
10141280 INIT_LIST_HEAD(&fi->inmem_pages);
10151281 mutex_init(&fi->inmem_lock);
1016
- init_rwsem(&fi->i_gc_rwsem[READ]);
1017
- init_rwsem(&fi->i_gc_rwsem[WRITE]);
1018
- init_rwsem(&fi->i_mmap_sem);
1019
- init_rwsem(&fi->i_xattr_sem);
1282
+ init_f2fs_rwsem(&fi->i_gc_rwsem[READ]);
1283
+ init_f2fs_rwsem(&fi->i_gc_rwsem[WRITE]);
1284
+ init_f2fs_rwsem(&fi->i_mmap_sem);
1285
+ init_f2fs_rwsem(&fi->i_xattr_sem);
10201286
10211287 /* Will be used by directory only */
10221288 fi->i_dir_level = F2FS_SB(sb)->dir_level;
....@@ -1148,18 +1414,10 @@
11481414 f2fs_inode_dirtied(inode, false);
11491415 }
11501416
1151
-static void f2fs_i_callback(struct rcu_head *head)
1417
+static void f2fs_free_inode(struct inode *inode)
11521418 {
1153
- struct inode *inode = container_of(head, struct inode, i_rcu);
1154
-
11551419 fscrypt_free_inode(inode);
1156
-
11571420 kmem_cache_free(f2fs_inode_cachep, F2FS_I(inode));
1158
-}
1159
-
1160
-static void f2fs_destroy_inode(struct inode *inode)
1161
-{
1162
- call_rcu(&inode->i_rcu, f2fs_i_callback);
11631421 }
11641422
11651423 static void destroy_percpu_info(struct f2fs_sb_info *sbi)
....@@ -1194,6 +1452,12 @@
11941452
11951453 /* prevent remaining shrinker jobs */
11961454 mutex_lock(&sbi->umount_mutex);
1455
+
1456
+ /*
1457
+ * flush all issued checkpoints and stop checkpoint issue thread.
1458
+ * after then, all checkpoints should be done by each process context.
1459
+ */
1460
+ f2fs_stop_ckpt_thread(sbi);
11971461
11981462 /*
11991463 * We don't need to do checkpoint when superblock is clean.
....@@ -1235,6 +1499,8 @@
12351499
12361500 f2fs_bug_on(sbi, sbi->fsync_node_num);
12371501
1502
+ f2fs_destroy_compress_inode(sbi);
1503
+
12381504 iput(sbi->node_inode);
12391505 sbi->node_inode = NULL;
12401506
....@@ -1258,23 +1524,24 @@
12581524 sb->s_fs_info = NULL;
12591525 if (sbi->s_chksum_driver)
12601526 crypto_free_shash(sbi->s_chksum_driver);
1261
- kvfree(sbi->raw_super);
1527
+ kfree(sbi->raw_super);
12621528
12631529 destroy_device_list(sbi);
1530
+ f2fs_destroy_page_array_cache(sbi);
12641531 f2fs_destroy_xattr_caches(sbi);
12651532 mempool_destroy(sbi->write_io_dummy);
12661533 #ifdef CONFIG_QUOTA
12671534 for (i = 0; i < MAXQUOTAS; i++)
1268
- kvfree(F2FS_OPTION(sbi).s_qf_names[i]);
1535
+ kfree(F2FS_OPTION(sbi).s_qf_names[i]);
12691536 #endif
1270
- fscrypt_free_dummy_context(&F2FS_OPTION(sbi).dummy_enc_ctx);
1537
+ fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy);
12711538 destroy_percpu_info(sbi);
12721539 for (i = 0; i < NR_PAGE_TYPE; i++)
12731540 kvfree(sbi->write_io[i]);
12741541 #ifdef CONFIG_UNICODE
12751542 utf8_unload(sb->s_encoding);
12761543 #endif
1277
- kvfree(sbi);
1544
+ kfree(sbi);
12781545 }
12791546
12801547 int f2fs_sync_fs(struct super_block *sb, int sync)
....@@ -1293,16 +1560,9 @@
12931560 return -EAGAIN;
12941561
12951562 if (sync) {
1296
- struct cp_control cpc;
1297
-
1298
- cpc.reason = __get_cp_reason(sbi);
1299
-
1563
+ err = f2fs_issue_checkpoint(sbi);
13001564 atomic_set(&sbi->no_cp_fsync_pages, 0);
1301
- down_write(&sbi->gc_lock);
1302
- err = f2fs_write_checkpoint(sbi, &cpc);
1303
- up_write(&sbi->gc_lock);
13041565 }
1305
- f2fs_trace_ios(NULL, 1);
13061566
13071567 return err;
13081568 }
....@@ -1319,11 +1579,18 @@
13191579 /* must be clean, since sync_filesystem() was already called */
13201580 if (is_sbi_flag_set(F2FS_SB(sb), SBI_IS_DIRTY))
13211581 return -EINVAL;
1582
+
1583
+ /* Let's flush checkpoints and stop the thread. */
1584
+ f2fs_flush_ckpt_thread(F2FS_SB(sb));
1585
+
1586
+ /* to avoid deadlock on f2fs_evict_inode->SB_FREEZE_FS */
1587
+ set_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING);
13221588 return 0;
13231589 }
13241590
13251591 static int f2fs_unfreeze(struct super_block *sb)
13261592 {
1593
+ clear_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING);
13271594 return 0;
13281595 }
13291596
....@@ -1416,8 +1683,7 @@
14161683 }
14171684
14181685 buf->f_namelen = F2FS_NAME_LEN;
1419
- buf->f_fsid.val[0] = (u32)id;
1420
- buf->f_fsid.val[1] = (u32)(id >> 32);
1686
+ buf->f_fsid = u64_to_fsid(id);
14211687
14221688 #ifdef CONFIG_QUOTA
14231689 if (is_inode_flag_set(dentry->d_inode, FI_PROJ_INHERIT) &&
....@@ -1465,6 +1731,7 @@
14651731 #endif
14661732 }
14671733
1734
+#ifdef CONFIG_F2FS_FS_COMPRESSION
14681735 static inline void f2fs_show_compress_options(struct seq_file *seq,
14691736 struct super_block *sb)
14701737 {
....@@ -1485,8 +1752,14 @@
14851752 case COMPRESS_ZSTD:
14861753 algtype = "zstd";
14871754 break;
1755
+ case COMPRESS_LZORLE:
1756
+ algtype = "lzo-rle";
1757
+ break;
14881758 }
14891759 seq_printf(seq, ",compress_algorithm=%s", algtype);
1760
+
1761
+ if (F2FS_OPTION(sbi).compress_level)
1762
+ seq_printf(seq, ":%d", F2FS_OPTION(sbi).compress_level);
14901763
14911764 seq_printf(seq, ",compress_log_size=%u",
14921765 F2FS_OPTION(sbi).compress_log_size);
....@@ -1495,7 +1768,19 @@
14951768 seq_printf(seq, ",compress_extension=%s",
14961769 F2FS_OPTION(sbi).extensions[i]);
14971770 }
1771
+
1772
+ if (F2FS_OPTION(sbi).compress_chksum)
1773
+ seq_puts(seq, ",compress_chksum");
1774
+
1775
+ if (F2FS_OPTION(sbi).compress_mode == COMPR_MODE_FS)
1776
+ seq_printf(seq, ",compress_mode=%s", "fs");
1777
+ else if (F2FS_OPTION(sbi).compress_mode == COMPR_MODE_USER)
1778
+ seq_printf(seq, ",compress_mode=%s", "user");
1779
+
1780
+ if (test_opt(sbi, COMPRESS_CACHE))
1781
+ seq_puts(seq, ",compress_cache");
14981782 }
1783
+#endif
14991784
15001785 static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
15011786 {
....@@ -1507,6 +1792,9 @@
15071792 seq_printf(seq, ",background_gc=%s", "on");
15081793 else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF)
15091794 seq_printf(seq, ",background_gc=%s", "off");
1795
+
1796
+ if (test_opt(sbi, GC_MERGE))
1797
+ seq_puts(seq, ",gc_merge");
15101798
15111799 if (test_opt(sbi, DISABLE_ROLL_FORWARD))
15121800 seq_puts(seq, ",disable_roll_forward");
....@@ -1555,10 +1843,12 @@
15551843 seq_puts(seq, ",nobarrier");
15561844 if (test_opt(sbi, FASTBOOT))
15571845 seq_puts(seq, ",fastboot");
1558
- if (test_opt(sbi, EXTENT_CACHE))
1846
+ if (test_opt(sbi, READ_EXTENT_CACHE))
15591847 seq_puts(seq, ",extent_cache");
15601848 else
15611849 seq_puts(seq, ",noextent_cache");
1850
+ if (test_opt(sbi, AGE_EXTENT_CACHE))
1851
+ seq_puts(seq, ",age_extent_cache");
15621852 if (test_opt(sbi, DATA_FLUSH))
15631853 seq_puts(seq, ",data_flush");
15641854
....@@ -1604,10 +1894,8 @@
16041894
16051895 fscrypt_show_test_dummy_encryption(seq, ',', sbi->sb);
16061896
1607
-#ifdef CONFIG_FS_ENCRYPTION
1608
- if (F2FS_OPTION(sbi).inlinecrypt)
1897
+ if (sbi->sb->s_flags & SB_INLINECRYPT)
16091898 seq_puts(seq, ",inlinecrypt");
1610
-#endif
16111899
16121900 if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_DEFAULT)
16131901 seq_printf(seq, ",alloc_mode=%s", "default");
....@@ -1617,6 +1905,10 @@
16171905 if (test_opt(sbi, DISABLE_CHECKPOINT))
16181906 seq_printf(seq, ",checkpoint=disable:%u",
16191907 F2FS_OPTION(sbi).unusable_cap);
1908
+ if (test_opt(sbi, MERGE_CHECKPOINT))
1909
+ seq_puts(seq, ",checkpoint_merge");
1910
+ else
1911
+ seq_puts(seq, ",nocheckpoint_merge");
16201912 if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_POSIX)
16211913 seq_printf(seq, ",fsync_mode=%s", "posix");
16221914 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT)
....@@ -1624,38 +1916,60 @@
16241916 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_NOBARRIER)
16251917 seq_printf(seq, ",fsync_mode=%s", "nobarrier");
16261918
1919
+#ifdef CONFIG_F2FS_FS_COMPRESSION
16271920 f2fs_show_compress_options(seq, sbi->sb);
1921
+#endif
1922
+
1923
+ if (test_opt(sbi, ATGC))
1924
+ seq_puts(seq, ",atgc");
1925
+
1926
+ if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_NORMAL)
1927
+ seq_printf(seq, ",memory=%s", "normal");
1928
+ else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW)
1929
+ seq_printf(seq, ",memory=%s", "low");
1930
+
16281931 return 0;
16291932 }
16301933
1631
-static void default_options(struct f2fs_sb_info *sbi)
1934
+static void default_options(struct f2fs_sb_info *sbi, bool remount)
16321935 {
16331936 /* init some FS parameters */
1634
- F2FS_OPTION(sbi).active_logs = NR_CURSEG_TYPE;
1937
+ if (!remount) {
1938
+ set_opt(sbi, READ_EXTENT_CACHE);
1939
+ clear_opt(sbi, DISABLE_CHECKPOINT);
1940
+
1941
+ if (f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi))
1942
+ set_opt(sbi, DISCARD);
1943
+ }
1944
+
1945
+ if (f2fs_sb_has_readonly(sbi))
1946
+ F2FS_OPTION(sbi).active_logs = NR_CURSEG_RO_TYPE;
1947
+ else
1948
+ F2FS_OPTION(sbi).active_logs = NR_CURSEG_PERSIST_TYPE;
1949
+
16351950 F2FS_OPTION(sbi).inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
16361951 F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF;
16371952 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT;
16381953 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX;
1639
-#ifdef CONFIG_FS_ENCRYPTION
1640
- F2FS_OPTION(sbi).inlinecrypt = false;
1641
-#endif
16421954 F2FS_OPTION(sbi).s_resuid = make_kuid(&init_user_ns, F2FS_DEF_RESUID);
16431955 F2FS_OPTION(sbi).s_resgid = make_kgid(&init_user_ns, F2FS_DEF_RESGID);
16441956 F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZ4;
16451957 F2FS_OPTION(sbi).compress_log_size = MIN_COMPRESS_LOG_SIZE;
16461958 F2FS_OPTION(sbi).compress_ext_cnt = 0;
1959
+ F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
16471960 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
1961
+ F2FS_OPTION(sbi).memory_mode = MEMORY_MODE_NORMAL;
1962
+
1963
+ sbi->sb->s_flags &= ~SB_INLINECRYPT;
16481964
16491965 set_opt(sbi, INLINE_XATTR);
16501966 set_opt(sbi, INLINE_DATA);
16511967 set_opt(sbi, INLINE_DENTRY);
1652
- set_opt(sbi, EXTENT_CACHE);
16531968 set_opt(sbi, NOHEAP);
1654
- clear_opt(sbi, DISABLE_CHECKPOINT);
1969
+ set_opt(sbi, MERGE_CHECKPOINT);
16551970 F2FS_OPTION(sbi).unusable_cap = 0;
16561971 sbi->sb->s_flags |= SB_LAZYTIME;
16571972 set_opt(sbi, FLUSH_MERGE);
1658
- set_opt(sbi, DISCARD);
16591973 if (f2fs_sb_has_blkzoned(sbi))
16601974 F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS;
16611975 else
....@@ -1689,11 +2003,16 @@
16892003 }
16902004 sbi->sb->s_flags |= SB_ACTIVE;
16912005
2006
+ /* check if we need more GC first */
2007
+ unusable = f2fs_get_unusable_blocks(sbi);
2008
+ if (!f2fs_disable_cp_again(sbi, unusable))
2009
+ goto skip_gc;
2010
+
16922011 f2fs_update_time(sbi, DISABLE_TIME);
16932012
16942013 while (!f2fs_time_over(sbi, DISABLE_TIME)) {
1695
- down_write(&sbi->gc_lock);
1696
- err = f2fs_gc(sbi, true, false, NULL_SEGNO);
2014
+ f2fs_down_write(&sbi->gc_lock);
2015
+ err = f2fs_gc(sbi, true, false, false, NULL_SEGNO);
16972016 if (err == -ENODATA) {
16982017 err = 0;
16992018 break;
....@@ -1704,7 +2023,7 @@
17042023
17052024 ret = sync_filesystem(sbi->sb);
17062025 if (ret || err) {
1707
- err = ret ? ret: err;
2026
+ err = ret ? ret : err;
17082027 goto restore_flag;
17092028 }
17102029
....@@ -1714,7 +2033,8 @@
17142033 goto restore_flag;
17152034 }
17162035
1717
- down_write(&sbi->gc_lock);
2036
+skip_gc:
2037
+ f2fs_down_write(&sbi->gc_lock);
17182038 cpc.reason = CP_PAUSE;
17192039 set_sbi_flag(sbi, SBI_CP_DISABLED);
17202040 err = f2fs_write_checkpoint(sbi, &cpc);
....@@ -1726,7 +2046,7 @@
17262046 spin_unlock(&sbi->stat_lock);
17272047
17282048 out_unlock:
1729
- up_write(&sbi->gc_lock);
2049
+ f2fs_up_write(&sbi->gc_lock);
17302050 restore_flag:
17312051 sbi->sb->s_flags = s_flags; /* Restore SB_RDONLY status */
17322052 return err;
....@@ -1734,17 +2054,29 @@
17342054
17352055 static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
17362056 {
1737
- /* we should flush all the data to keep data consistency */
1738
- sync_inodes_sb(sbi->sb);
2057
+ int retry = DEFAULT_RETRY_IO_COUNT;
17392058
1740
- down_write(&sbi->gc_lock);
2059
+ /* we should flush all the data to keep data consistency */
2060
+ do {
2061
+ sync_inodes_sb(sbi->sb);
2062
+ cond_resched();
2063
+ congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT);
2064
+ } while (get_pages(sbi, F2FS_DIRTY_DATA) && retry--);
2065
+
2066
+ if (unlikely(retry < 0))
2067
+ f2fs_warn(sbi, "checkpoint=enable has some unwritten data.");
2068
+
2069
+ f2fs_down_write(&sbi->gc_lock);
17412070 f2fs_dirty_to_prefree(sbi);
17422071
17432072 clear_sbi_flag(sbi, SBI_CP_DISABLED);
17442073 set_sbi_flag(sbi, SBI_IS_DIRTY);
1745
- up_write(&sbi->gc_lock);
2074
+ f2fs_up_write(&sbi->gc_lock);
17462075
17472076 f2fs_sync_fs(sbi->sb, 1);
2077
+
2078
+ /* Let's ensure there's no pending checkpoint anymore */
2079
+ f2fs_flush_ckpt_thread(sbi);
17482080 }
17492081
17502082 static int f2fs_remount(struct super_block *sb, int *flags, char *data)
....@@ -1753,11 +2085,15 @@
17532085 struct f2fs_mount_info org_mount_opt;
17542086 unsigned long old_sb_flags;
17552087 int err;
1756
- bool need_restart_gc = false;
1757
- bool need_stop_gc = false;
1758
- bool no_extent_cache = !test_opt(sbi, EXTENT_CACHE);
2088
+ bool need_restart_gc = false, need_stop_gc = false;
2089
+ bool need_restart_ckpt = false, need_stop_ckpt = false;
2090
+ bool need_restart_flush = false, need_stop_flush = false;
2091
+ bool no_read_extent_cache = !test_opt(sbi, READ_EXTENT_CACHE);
2092
+ bool no_age_extent_cache = !test_opt(sbi, AGE_EXTENT_CACHE);
17592093 bool disable_checkpoint = test_opt(sbi, DISABLE_CHECKPOINT);
17602094 bool no_io_align = !F2FS_IO_ALIGNED(sbi);
2095
+ bool no_atgc = !test_opt(sbi, ATGC);
2096
+ bool no_compress_cache = !test_opt(sbi, COMPRESS_CACHE);
17612097 bool checkpoint_changed;
17622098 #ifdef CONFIG_QUOTA
17632099 int i, j;
....@@ -1779,7 +2115,7 @@
17792115 GFP_KERNEL);
17802116 if (!org_mount_opt.s_qf_names[i]) {
17812117 for (j = 0; j < i; j++)
1782
- kvfree(org_mount_opt.s_qf_names[j]);
2118
+ kfree(org_mount_opt.s_qf_names[j]);
17832119 return -ENOMEM;
17842120 }
17852121 } else {
....@@ -1797,7 +2133,7 @@
17972133 clear_sbi_flag(sbi, SBI_NEED_SB_WRITE);
17982134 }
17992135
1800
- default_options(sbi);
2136
+ default_options(sbi, true);
18012137
18022138 /* parse mount options */
18032139 err = parse_options(sb, data, true);
....@@ -1812,6 +2148,11 @@
18122148 */
18132149 if (f2fs_readonly(sb) && (*flags & SB_RDONLY))
18142150 goto skip;
2151
+
2152
+ if (f2fs_sb_has_readonly(sbi) && !(*flags & SB_RDONLY)) {
2153
+ err = -EROFS;
2154
+ goto restore_opts;
2155
+ }
18152156
18162157 #ifdef CONFIG_QUOTA
18172158 if (!f2fs_readonly(sb) && (*flags & SB_RDONLY)) {
....@@ -1830,16 +2171,35 @@
18302171 }
18312172 }
18322173 #endif
2174
+ /* disallow enable atgc dynamically */
2175
+ if (no_atgc == !!test_opt(sbi, ATGC)) {
2176
+ err = -EINVAL;
2177
+ f2fs_warn(sbi, "switch atgc option is not allowed");
2178
+ goto restore_opts;
2179
+ }
2180
+
18332181 /* disallow enable/disable extent_cache dynamically */
1834
- if (no_extent_cache == !!test_opt(sbi, EXTENT_CACHE)) {
2182
+ if (no_read_extent_cache == !!test_opt(sbi, READ_EXTENT_CACHE)) {
18352183 err = -EINVAL;
18362184 f2fs_warn(sbi, "switch extent_cache option is not allowed");
2185
+ goto restore_opts;
2186
+ }
2187
+ /* disallow enable/disable age extent_cache dynamically */
2188
+ if (no_age_extent_cache == !!test_opt(sbi, AGE_EXTENT_CACHE)) {
2189
+ err = -EINVAL;
2190
+ f2fs_warn(sbi, "switch age_extent_cache option is not allowed");
18372191 goto restore_opts;
18382192 }
18392193
18402194 if (no_io_align == !!F2FS_IO_ALIGNED(sbi)) {
18412195 err = -EINVAL;
18422196 f2fs_warn(sbi, "switch io_bits option is not allowed");
2197
+ goto restore_opts;
2198
+ }
2199
+
2200
+ if (no_compress_cache == !!test_opt(sbi, COMPRESS_CACHE)) {
2201
+ err = -EINVAL;
2202
+ f2fs_warn(sbi, "switch compress_cache option is not allowed");
18432203 goto restore_opts;
18442204 }
18452205
....@@ -1855,7 +2215,8 @@
18552215 * option. Also sync the filesystem.
18562216 */
18572217 if ((*flags & SB_RDONLY) ||
1858
- F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF) {
2218
+ (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF &&
2219
+ !test_opt(sbi, GC_MERGE))) {
18592220 if (sbi->gc_thread) {
18602221 f2fs_stop_gc_thread(sbi);
18612222 need_restart_gc = true;
....@@ -1869,7 +2230,6 @@
18692230
18702231 if (*flags & SB_RDONLY ||
18712232 F2FS_OPTION(sbi).whint_mode != org_mount_opt.whint_mode) {
1872
- writeback_inodes_sb(sb, WB_REASON_SYNC);
18732233 sync_inodes_sb(sb);
18742234
18752235 set_sbi_flag(sbi, SBI_IS_DIRTY);
....@@ -1878,14 +2238,22 @@
18782238 clear_sbi_flag(sbi, SBI_IS_CLOSE);
18792239 }
18802240
1881
- if (checkpoint_changed) {
1882
- if (test_opt(sbi, DISABLE_CHECKPOINT)) {
1883
- err = f2fs_disable_checkpoint(sbi);
1884
- if (err)
1885
- goto restore_gc;
1886
- } else {
1887
- f2fs_enable_checkpoint(sbi);
2241
+ if ((*flags & SB_RDONLY) || test_opt(sbi, DISABLE_CHECKPOINT) ||
2242
+ !test_opt(sbi, MERGE_CHECKPOINT)) {
2243
+ f2fs_stop_ckpt_thread(sbi);
2244
+ need_restart_ckpt = true;
2245
+ } else {
2246
+ /* Flush if the prevous checkpoint, if exists. */
2247
+ f2fs_flush_ckpt_thread(sbi);
2248
+
2249
+ err = f2fs_start_ckpt_thread(sbi);
2250
+ if (err) {
2251
+ f2fs_err(sbi,
2252
+ "Failed to start F2FS issue_checkpoint_thread (%d)",
2253
+ err);
2254
+ goto restore_gc;
18882255 }
2256
+ need_stop_ckpt = true;
18892257 }
18902258
18912259 /*
....@@ -1895,16 +2263,29 @@
18952263 if ((*flags & SB_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) {
18962264 clear_opt(sbi, FLUSH_MERGE);
18972265 f2fs_destroy_flush_cmd_control(sbi, false);
2266
+ need_restart_flush = true;
18982267 } else {
18992268 err = f2fs_create_flush_cmd_control(sbi);
19002269 if (err)
1901
- goto restore_gc;
2270
+ goto restore_ckpt;
2271
+ need_stop_flush = true;
19022272 }
2273
+
2274
+ if (checkpoint_changed) {
2275
+ if (test_opt(sbi, DISABLE_CHECKPOINT)) {
2276
+ err = f2fs_disable_checkpoint(sbi);
2277
+ if (err)
2278
+ goto restore_flush;
2279
+ } else {
2280
+ f2fs_enable_checkpoint(sbi);
2281
+ }
2282
+ }
2283
+
19032284 skip:
19042285 #ifdef CONFIG_QUOTA
19052286 /* Release old quota file names */
19062287 for (i = 0; i < MAXQUOTAS; i++)
1907
- kvfree(org_mount_opt.s_qf_names[i]);
2288
+ kfree(org_mount_opt.s_qf_names[i]);
19082289 #endif
19092290 /* Update the POSIXACL Flag */
19102291 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
....@@ -1914,6 +2295,21 @@
19142295 adjust_unusable_cap_perc(sbi);
19152296 *flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME);
19162297 return 0;
2298
+restore_flush:
2299
+ if (need_restart_flush) {
2300
+ if (f2fs_create_flush_cmd_control(sbi))
2301
+ f2fs_warn(sbi, "background flush thread has stopped");
2302
+ } else if (need_stop_flush) {
2303
+ clear_opt(sbi, FLUSH_MERGE);
2304
+ f2fs_destroy_flush_cmd_control(sbi, false);
2305
+ }
2306
+restore_ckpt:
2307
+ if (need_restart_ckpt) {
2308
+ if (f2fs_start_ckpt_thread(sbi))
2309
+ f2fs_warn(sbi, "background ckpt thread has stopped");
2310
+ } else if (need_stop_ckpt) {
2311
+ f2fs_stop_ckpt_thread(sbi);
2312
+ }
19172313 restore_gc:
19182314 if (need_restart_gc) {
19192315 if (f2fs_start_gc_thread(sbi))
....@@ -1925,7 +2321,7 @@
19252321 #ifdef CONFIG_QUOTA
19262322 F2FS_OPTION(sbi).s_jquota_fmt = org_mount_opt.s_jquota_fmt;
19272323 for (i = 0; i < MAXQUOTAS; i++) {
1928
- kvfree(F2FS_OPTION(sbi).s_qf_names[i]);
2324
+ kfree(F2FS_OPTION(sbi).s_qf_names[i]);
19292325 F2FS_OPTION(sbi).s_qf_names[i] = org_mount_opt.s_qf_names[i];
19302326 }
19312327 #endif
....@@ -1947,7 +2343,6 @@
19472343 size_t toread;
19482344 loff_t i_size = i_size_read(inode);
19492345 struct page *page;
1950
- char *kaddr;
19512346
19522347 if (off > i_size)
19532348 return 0;
....@@ -1981,9 +2376,7 @@
19812376 return -EIO;
19822377 }
19832378
1984
- kaddr = kmap_atomic(page);
1985
- memcpy(data, kaddr + offset, tocopy);
1986
- kunmap_atomic(kaddr);
2379
+ memcpy_from_page(data, page, offset, tocopy);
19872380 f2fs_put_page(page, 1);
19882381
19892382 offset = 0;
....@@ -2005,7 +2398,6 @@
20052398 size_t towrite = len;
20062399 struct page *page;
20072400 void *fsdata = NULL;
2008
- char *kaddr;
20092401 int err = 0;
20102402 int tocopy;
20112403
....@@ -2025,10 +2417,7 @@
20252417 break;
20262418 }
20272419
2028
- kaddr = kmap_atomic(page);
2029
- memcpy(kaddr + offset, data, tocopy);
2030
- kunmap_atomic(kaddr);
2031
- flush_dcache_page(page);
2420
+ memcpy_to_page(page, offset, data, tocopy);
20322421
20332422 a_ops->write_end(NULL, mapping, off, tocopy, tocopy,
20342423 page, fsdata);
....@@ -2116,7 +2505,7 @@
21162505
21172506 /* Don't account quota for quota files to avoid recursion */
21182507 qf_inode->i_flags |= S_NOQUOTA;
2119
- err = dquot_enable(qf_inode, type, format_id, flags);
2508
+ err = dquot_load_quota_inode(qf_inode, type, format_id, flags);
21202509 iput(qf_inode);
21212510 return err;
21222511 }
....@@ -2159,64 +2548,78 @@
21592548 return 0;
21602549 }
21612550
2551
+static int f2fs_quota_sync_file(struct f2fs_sb_info *sbi, int type)
2552
+{
2553
+ struct quota_info *dqopt = sb_dqopt(sbi->sb);
2554
+ struct address_space *mapping = dqopt->files[type]->i_mapping;
2555
+ int ret = 0;
2556
+
2557
+ ret = dquot_writeback_dquots(sbi->sb, type);
2558
+ if (ret)
2559
+ goto out;
2560
+
2561
+ ret = filemap_fdatawrite(mapping);
2562
+ if (ret)
2563
+ goto out;
2564
+
2565
+ /* if we are using journalled quota */
2566
+ if (is_journalled_quota(sbi))
2567
+ goto out;
2568
+
2569
+ ret = filemap_fdatawait(mapping);
2570
+
2571
+ truncate_inode_pages(&dqopt->files[type]->i_data, 0);
2572
+out:
2573
+ if (ret)
2574
+ set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
2575
+ return ret;
2576
+}
2577
+
21622578 int f2fs_quota_sync(struct super_block *sb, int type)
21632579 {
21642580 struct f2fs_sb_info *sbi = F2FS_SB(sb);
21652581 struct quota_info *dqopt = sb_dqopt(sb);
21662582 int cnt;
2167
- int ret;
2168
-
2169
- /*
2170
- * do_quotactl
2171
- * f2fs_quota_sync
2172
- * down_read(quota_sem)
2173
- * dquot_writeback_dquots()
2174
- * f2fs_dquot_commit
2175
- * block_operation
2176
- * down_read(quota_sem)
2177
- */
2178
- f2fs_lock_op(sbi);
2179
-
2180
- down_read(&sbi->quota_sem);
2181
- ret = dquot_writeback_dquots(sb, type);
2182
- if (ret)
2183
- goto out;
2583
+ int ret = 0;
21842584
21852585 /*
21862586 * Now when everything is written we can discard the pagecache so
21872587 * that userspace sees the changes.
21882588 */
21892589 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
2190
- struct address_space *mapping;
21912590
21922591 if (type != -1 && cnt != type)
21932592 continue;
2593
+
21942594 if (!sb_has_quota_active(sb, cnt))
21952595 continue;
21962596
2197
- mapping = dqopt->files[cnt]->i_mapping;
2597
+ if (!f2fs_sb_has_quota_ino(sbi))
2598
+ inode_lock(dqopt->files[cnt]);
21982599
2199
- ret = filemap_fdatawrite(mapping);
2600
+ /*
2601
+ * do_quotactl
2602
+ * f2fs_quota_sync
2603
+ * f2fs_down_read(quota_sem)
2604
+ * dquot_writeback_dquots()
2605
+ * f2fs_dquot_commit
2606
+ * block_operation
2607
+ * f2fs_down_read(quota_sem)
2608
+ */
2609
+ f2fs_lock_op(sbi);
2610
+ f2fs_down_read(&sbi->quota_sem);
2611
+
2612
+ ret = f2fs_quota_sync_file(sbi, cnt);
2613
+
2614
+ f2fs_up_read(&sbi->quota_sem);
2615
+ f2fs_unlock_op(sbi);
2616
+
2617
+ if (!f2fs_sb_has_quota_ino(sbi))
2618
+ inode_unlock(dqopt->files[cnt]);
2619
+
22002620 if (ret)
2201
- goto out;
2202
-
2203
- /* if we are using journalled quota */
2204
- if (is_journalled_quota(sbi))
2205
- continue;
2206
-
2207
- ret = filemap_fdatawait(mapping);
2208
- if (ret)
2209
- set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
2210
-
2211
- inode_lock(dqopt->files[cnt]);
2212
- truncate_inode_pages(&dqopt->files[cnt]->i_data, 0);
2213
- inode_unlock(dqopt->files[cnt]);
2621
+ break;
22142622 }
2215
-out:
2216
- if (ret)
2217
- set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
2218
- up_read(&sbi->quota_sem);
2219
- f2fs_unlock_op(sbi);
22202623 return ret;
22212624 }
22222625
....@@ -2334,11 +2737,11 @@
23342737 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
23352738 int ret;
23362739
2337
- down_read_nested(&sbi->quota_sem, SINGLE_DEPTH_NESTING);
2740
+ f2fs_down_read_nested(&sbi->quota_sem, SINGLE_DEPTH_NESTING);
23382741 ret = dquot_commit(dquot);
23392742 if (ret < 0)
23402743 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
2341
- up_read(&sbi->quota_sem);
2744
+ f2fs_up_read(&sbi->quota_sem);
23422745 return ret;
23432746 }
23442747
....@@ -2347,11 +2750,11 @@
23472750 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
23482751 int ret;
23492752
2350
- down_read(&sbi->quota_sem);
2753
+ f2fs_down_read(&sbi->quota_sem);
23512754 ret = dquot_acquire(dquot);
23522755 if (ret < 0)
23532756 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
2354
- up_read(&sbi->quota_sem);
2757
+ f2fs_up_read(&sbi->quota_sem);
23552758 return ret;
23562759 }
23572760
....@@ -2430,8 +2833,8 @@
24302833
24312834 static const struct super_operations f2fs_sops = {
24322835 .alloc_inode = f2fs_alloc_inode,
2836
+ .free_inode = f2fs_free_inode,
24332837 .drop_inode = f2fs_drop_inode,
2434
- .destroy_inode = f2fs_destroy_inode,
24352838 .write_inode = f2fs_write_inode,
24362839 .dirty_inode = f2fs_dirty_inode,
24372840 .show_options = f2fs_show_options,
....@@ -2477,10 +2880,9 @@
24772880 ctx, len, fs_data, XATTR_CREATE);
24782881 }
24792882
2480
-static const union fscrypt_context *
2481
-f2fs_get_dummy_context(struct super_block *sb)
2883
+static const union fscrypt_policy *f2fs_get_dummy_policy(struct super_block *sb)
24822884 {
2483
- return F2FS_OPTION(F2FS_SB(sb)).dummy_enc_ctx.ctx;
2885
+ return F2FS_OPTION(F2FS_SB(sb)).dummy_enc_policy.policy;
24842886 }
24852887
24862888 static bool f2fs_has_stable_inodes(struct super_block *sb)
....@@ -2493,11 +2895,6 @@
24932895 {
24942896 *ino_bits_ret = 8 * sizeof(nid_t);
24952897 *lblk_bits_ret = 8 * sizeof(block_t);
2496
-}
2497
-
2498
-static bool f2fs_inline_crypt_enabled(struct super_block *sb)
2499
-{
2500
- return F2FS_OPTION(F2FS_SB(sb)).inlinecrypt;
25012898 }
25022899
25032900 static int f2fs_get_num_devices(struct super_block *sb)
....@@ -2523,12 +2920,11 @@
25232920 .key_prefix = "f2fs:",
25242921 .get_context = f2fs_get_context,
25252922 .set_context = f2fs_set_context,
2526
- .get_dummy_context = f2fs_get_dummy_context,
2923
+ .get_dummy_policy = f2fs_get_dummy_policy,
25272924 .empty_dir = f2fs_empty_dir,
25282925 .max_namelen = F2FS_NAME_LEN,
25292926 .has_stable_inodes = f2fs_has_stable_inodes,
25302927 .get_ino_and_lblk_bits = f2fs_get_ino_and_lblk_bits,
2531
- .inline_crypt_enabled = f2fs_inline_crypt_enabled,
25322928 .get_num_devices = f2fs_get_num_devices,
25332929 .get_devices = f2fs_get_devices,
25342930 };
....@@ -2579,10 +2975,10 @@
25792975 .get_parent = f2fs_get_parent,
25802976 };
25812977
2582
-static loff_t max_file_blocks(void)
2978
+loff_t max_file_blocks(struct inode *inode)
25832979 {
25842980 loff_t result = 0;
2585
- loff_t leaf_count = DEF_ADDRS_PER_BLOCK;
2981
+ loff_t leaf_count;
25862982
25872983 /*
25882984 * note: previously, result is equal to (DEF_ADDRS_PER_INODE -
....@@ -2590,6 +2986,11 @@
25902986 * space in inode.i_addr, it will be more safe to reassign
25912987 * result as zero.
25922988 */
2989
+
2990
+ if (inode && f2fs_compressed_file(inode))
2991
+ leaf_count = ADDRS_PER_BLOCK(inode);
2992
+ else
2993
+ leaf_count = DEF_ADDRS_PER_BLOCK;
25932994
25942995 /* two direct node blocks */
25952996 result += (leaf_count * 2);
....@@ -2681,10 +3082,8 @@
26813082 }
26823083
26833084 if (main_end_blkaddr > seg_end_blkaddr) {
2684
- f2fs_info(sbi, "Wrong MAIN_AREA boundary, start(%u) end(%u) block(%u)",
2685
- main_blkaddr,
2686
- segment0_blkaddr +
2687
- (segment_count << log_blocks_per_seg),
3085
+ f2fs_info(sbi, "Wrong MAIN_AREA boundary, start(%u) end(%llu) block(%u)",
3086
+ main_blkaddr, seg_end_blkaddr,
26883087 segment_count_main << log_blocks_per_seg);
26893088 return true;
26903089 } else if (main_end_blkaddr < seg_end_blkaddr) {
....@@ -2702,10 +3101,8 @@
27023101 err = __f2fs_commit_super(bh, NULL);
27033102 res = err ? "failed" : "done";
27043103 }
2705
- f2fs_info(sbi, "Fix alignment : %s, start(%u) end(%u) block(%u)",
2706
- res, main_blkaddr,
2707
- segment0_blkaddr +
2708
- (segment_count << log_blocks_per_seg),
3104
+ f2fs_info(sbi, "Fix alignment : %s, start(%u) end(%llu) block(%u)",
3105
+ res, main_blkaddr, seg_end_blkaddr,
27093106 segment_count_main << log_blocks_per_seg);
27103107 if (err)
27113108 return true;
....@@ -2716,11 +3113,10 @@
27163113 static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
27173114 struct buffer_head *bh)
27183115 {
2719
- block_t segment_count, segs_per_sec, secs_per_zone;
3116
+ block_t segment_count, segs_per_sec, secs_per_zone, segment_count_main;
27203117 block_t total_sections, blocks_per_seg;
27213118 struct f2fs_super_block *raw_super = (struct f2fs_super_block *)
27223119 (bh->b_data + F2FS_SUPER_OFFSET);
2723
- unsigned int blocksize;
27243120 size_t crc_offset = 0;
27253121 __u32 crc = 0;
27263122
....@@ -2746,18 +3142,11 @@
27463142 }
27473143 }
27483144
2749
- /* Currently, support only 4KB page cache size */
2750
- if (F2FS_BLKSIZE != PAGE_SIZE) {
2751
- f2fs_info(sbi, "Invalid page_cache_size (%lu), supports only 4KB",
2752
- PAGE_SIZE);
2753
- return -EFSCORRUPTED;
2754
- }
2755
-
27563145 /* Currently, support only 4KB block size */
2757
- blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);
2758
- if (blocksize != F2FS_BLKSIZE) {
2759
- f2fs_info(sbi, "Invalid blocksize (%u), supports only 4KB",
2760
- blocksize);
3146
+ if (le32_to_cpu(raw_super->log_blocksize) != F2FS_BLKSIZE_BITS) {
3147
+ f2fs_info(sbi, "Invalid log_blocksize (%u), supports only %u",
3148
+ le32_to_cpu(raw_super->log_blocksize),
3149
+ F2FS_BLKSIZE_BITS);
27613150 return -EFSCORRUPTED;
27623151 }
27633152
....@@ -2787,6 +3176,7 @@
27873176 }
27883177
27893178 segment_count = le32_to_cpu(raw_super->segment_count);
3179
+ segment_count_main = le32_to_cpu(raw_super->segment_count_main);
27903180 segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
27913181 secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
27923182 total_sections = le32_to_cpu(raw_super->section_count);
....@@ -2800,11 +3190,16 @@
28003190 return -EFSCORRUPTED;
28013191 }
28023192
2803
- if (total_sections > segment_count ||
2804
- total_sections < F2FS_MIN_SEGMENTS ||
3193
+ if (total_sections > segment_count_main || total_sections < 1 ||
28053194 segs_per_sec > segment_count || !segs_per_sec) {
28063195 f2fs_info(sbi, "Invalid segment/section count (%u, %u x %u)",
28073196 segment_count, total_sections, segs_per_sec);
3197
+ return -EFSCORRUPTED;
3198
+ }
3199
+
3200
+ if (segment_count_main != total_sections * segs_per_sec) {
3201
+ f2fs_info(sbi, "Invalid segment/section count (%u != %u * %u)",
3202
+ segment_count_main, total_sections, segs_per_sec);
28083203 return -EFSCORRUPTED;
28093204 }
28103205
....@@ -2833,6 +3228,12 @@
28333228 segment_count, dev_seg_count);
28343229 return -EFSCORRUPTED;
28353230 }
3231
+ } else {
3232
+ if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_BLKZONED) &&
3233
+ !bdev_is_zoned(sbi->sb->s_bdev)) {
3234
+ f2fs_info(sbi, "Zoned block device path is missing");
3235
+ return -EFSCORRUPTED;
3236
+ }
28363237 }
28373238
28383239 if (secs_per_zone > total_sections || !secs_per_zone) {
....@@ -2851,11 +3252,13 @@
28513252 return -EFSCORRUPTED;
28523253 }
28533254
2854
- if (le32_to_cpu(raw_super->cp_payload) >
2855
- (blocks_per_seg - F2FS_CP_PACKS)) {
2856
- f2fs_info(sbi, "Insane cp_payload (%u > %u)",
3255
+ if (le32_to_cpu(raw_super->cp_payload) >=
3256
+ (blocks_per_seg - F2FS_CP_PACKS -
3257
+ NR_CURSEG_PERSIST_TYPE)) {
3258
+ f2fs_info(sbi, "Insane cp_payload (%u >= %u)",
28573259 le32_to_cpu(raw_super->cp_payload),
2858
- blocks_per_seg - F2FS_CP_PACKS);
3260
+ blocks_per_seg - F2FS_CP_PACKS -
3261
+ NR_CURSEG_PERSIST_TYPE);
28593262 return -EFSCORRUPTED;
28603263 }
28613264
....@@ -2891,6 +3294,7 @@
28913294 unsigned int cp_pack_start_sum, cp_payload;
28923295 block_t user_block_count, valid_user_blocks;
28933296 block_t avail_node_count, valid_node_count;
3297
+ unsigned int nat_blocks, nat_bits_bytes, nat_bits_blocks;
28943298 int i, j;
28953299
28963300 total = le32_to_cpu(raw_super->segment_count);
....@@ -2908,14 +3312,15 @@
29083312 ovp_segments = le32_to_cpu(ckpt->overprov_segment_count);
29093313 reserved_segments = le32_to_cpu(ckpt->rsvd_segment_count);
29103314
2911
- if (unlikely(fsmeta < F2FS_MIN_SEGMENTS ||
3315
+ if (!f2fs_sb_has_readonly(sbi) &&
3316
+ unlikely(fsmeta < F2FS_MIN_META_SEGMENTS ||
29123317 ovp_segments == 0 || reserved_segments == 0)) {
29133318 f2fs_err(sbi, "Wrong layout: check mkfs.f2fs version");
29143319 return 1;
29153320 }
2916
-
29173321 user_block_count = le64_to_cpu(ckpt->user_block_count);
2918
- segment_count_main = le32_to_cpu(raw_super->segment_count_main);
3322
+ segment_count_main = le32_to_cpu(raw_super->segment_count_main) +
3323
+ (f2fs_sb_has_readonly(sbi) ? 1 : 0);
29193324 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
29203325 if (!user_block_count || user_block_count >=
29213326 segment_count_main << log_blocks_per_seg) {
....@@ -2946,6 +3351,10 @@
29463351 if (le32_to_cpu(ckpt->cur_node_segno[i]) >= main_segs ||
29473352 le16_to_cpu(ckpt->cur_node_blkoff[i]) >= blocks_per_seg)
29483353 return 1;
3354
+
3355
+ if (f2fs_sb_has_readonly(sbi))
3356
+ goto check_data;
3357
+
29493358 for (j = i + 1; j < NR_CURSEG_NODE_TYPE; j++) {
29503359 if (le32_to_cpu(ckpt->cur_node_segno[i]) ==
29513360 le32_to_cpu(ckpt->cur_node_segno[j])) {
....@@ -2956,10 +3365,15 @@
29563365 }
29573366 }
29583367 }
3368
+check_data:
29593369 for (i = 0; i < NR_CURSEG_DATA_TYPE; i++) {
29603370 if (le32_to_cpu(ckpt->cur_data_segno[i]) >= main_segs ||
29613371 le16_to_cpu(ckpt->cur_data_blkoff[i]) >= blocks_per_seg)
29623372 return 1;
3373
+
3374
+ if (f2fs_sb_has_readonly(sbi))
3375
+ goto skip_cross;
3376
+
29633377 for (j = i + 1; j < NR_CURSEG_DATA_TYPE; j++) {
29643378 if (le32_to_cpu(ckpt->cur_data_segno[i]) ==
29653379 le32_to_cpu(ckpt->cur_data_segno[j])) {
....@@ -2981,7 +3395,7 @@
29813395 }
29823396 }
29833397 }
2984
-
3398
+skip_cross:
29853399 sit_bitmap_size = le32_to_cpu(ckpt->sit_ver_bitmap_bytesize);
29863400 nat_bitmap_size = le32_to_cpu(ckpt->nat_ver_bitmap_bytesize);
29873401
....@@ -2996,7 +3410,7 @@
29963410 cp_payload = __cp_payload(sbi);
29973411 if (cp_pack_start_sum < cp_payload + 1 ||
29983412 cp_pack_start_sum > blocks_per_seg - 1 -
2999
- NR_CURSEG_TYPE) {
3413
+ NR_CURSEG_PERSIST_TYPE) {
30003414 f2fs_err(sbi, "Wrong cp_pack_start_sum: %u",
30013415 cp_pack_start_sum);
30023416 return 1;
....@@ -3008,6 +3422,17 @@
30083422 "please run fsck v1.13.0 or higher to repair, chksum_offset: %u, "
30093423 "fixed with patch: \"f2fs-tools: relocate chksum_offset for large_nat_bitmap feature\"",
30103424 le32_to_cpu(ckpt->checksum_offset));
3425
+ return 1;
3426
+ }
3427
+
3428
+ nat_blocks = nat_segs << log_blocks_per_seg;
3429
+ nat_bits_bytes = nat_blocks / BITS_PER_BYTE;
3430
+ nat_bits_blocks = F2FS_BLK_ALIGN((nat_bits_bytes << 1) + 8);
3431
+ if (__is_set_ckpt_flags(ckpt, CP_NAT_BITS_FLAG) &&
3432
+ (cp_payload + F2FS_CP_PACKS +
3433
+ NR_CURSEG_PERSIST_TYPE + nat_bits_blocks >= blocks_per_seg)) {
3434
+ f2fs_warn(sbi, "Insane cp_payload: %u, nat_bits_blocks: %u)",
3435
+ cp_payload, nat_bits_blocks);
30113436 return 1;
30123437 }
30133438
....@@ -3035,9 +3460,9 @@
30353460 sbi->total_node_count =
30363461 (le32_to_cpu(raw_super->segment_count_nat) / 2)
30373462 * sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK;
3038
- sbi->root_ino_num = le32_to_cpu(raw_super->root_ino);
3039
- sbi->node_ino_num = le32_to_cpu(raw_super->node_ino);
3040
- sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
3463
+ F2FS_ROOT_INO(sbi) = le32_to_cpu(raw_super->root_ino);
3464
+ F2FS_NODE_INO(sbi) = le32_to_cpu(raw_super->node_ino);
3465
+ F2FS_META_INO(sbi) = le32_to_cpu(raw_super->meta_ino);
30413466 sbi->cur_victim_sec = NULL_SECNO;
30423467 sbi->next_victim_seg[BG_GC] = NULL_SEGNO;
30433468 sbi->next_victim_seg[FG_GC] = NULL_SEGNO;
....@@ -3062,14 +3487,14 @@
30623487
30633488 INIT_LIST_HEAD(&sbi->s_list);
30643489 mutex_init(&sbi->umount_mutex);
3065
- init_rwsem(&sbi->io_order_lock);
3490
+ init_f2fs_rwsem(&sbi->io_order_lock);
30663491 spin_lock_init(&sbi->cp_lock);
30673492
30683493 sbi->dirty_device = 0;
30693494 spin_lock_init(&sbi->dev_lock);
30703495
3071
- init_rwsem(&sbi->sb_lock);
3072
- init_rwsem(&sbi->pin_sem);
3496
+ init_f2fs_rwsem(&sbi->sb_lock);
3497
+ init_f2fs_rwsem(&sbi->pin_sem);
30733498 }
30743499
30753500 static int init_percpu_info(struct f2fs_sb_info *sbi)
....@@ -3089,15 +3514,40 @@
30893514 }
30903515
30913516 #ifdef CONFIG_BLK_DEV_ZONED
3517
+
3518
+struct f2fs_report_zones_args {
3519
+ struct f2fs_sb_info *sbi;
3520
+ struct f2fs_dev_info *dev;
3521
+};
3522
+
3523
+static int f2fs_report_zone_cb(struct blk_zone *zone, unsigned int idx,
3524
+ void *data)
3525
+{
3526
+ struct f2fs_report_zones_args *rz_args = data;
3527
+ block_t unusable_blocks = (zone->len - zone->capacity) >>
3528
+ F2FS_LOG_SECTORS_PER_BLOCK;
3529
+
3530
+ if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
3531
+ return 0;
3532
+
3533
+ set_bit(idx, rz_args->dev->blkz_seq);
3534
+ if (!rz_args->sbi->unusable_blocks_per_sec) {
3535
+ rz_args->sbi->unusable_blocks_per_sec = unusable_blocks;
3536
+ return 0;
3537
+ }
3538
+ if (rz_args->sbi->unusable_blocks_per_sec != unusable_blocks) {
3539
+ f2fs_err(rz_args->sbi, "F2FS supports single zone capacity\n");
3540
+ return -EINVAL;
3541
+ }
3542
+ return 0;
3543
+}
3544
+
30923545 static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
30933546 {
30943547 struct block_device *bdev = FDEV(devi).bdev;
30953548 sector_t nr_sectors = bdev->bd_part->nr_sects;
3096
- sector_t sector = 0;
3097
- struct blk_zone *zones;
3098
- unsigned int i, nr_zones;
3099
- unsigned int n = 0;
3100
- int err = -EIO;
3549
+ struct f2fs_report_zones_args rep_zone_arg;
3550
+ int ret;
31013551
31023552 if (!f2fs_sb_has_blkzoned(sbi))
31033553 return 0;
....@@ -3122,40 +3572,14 @@
31223572 if (!FDEV(devi).blkz_seq)
31233573 return -ENOMEM;
31243574
3125
-#define F2FS_REPORT_NR_ZONES 4096
3575
+ rep_zone_arg.sbi = sbi;
3576
+ rep_zone_arg.dev = &FDEV(devi);
31263577
3127
- zones = f2fs_kzalloc(sbi,
3128
- array_size(F2FS_REPORT_NR_ZONES,
3129
- sizeof(struct blk_zone)),
3130
- GFP_KERNEL);
3131
- if (!zones)
3132
- return -ENOMEM;
3133
-
3134
- /* Get block zones type */
3135
- while (zones && sector < nr_sectors) {
3136
-
3137
- nr_zones = F2FS_REPORT_NR_ZONES;
3138
- err = blkdev_report_zones(bdev, sector,
3139
- zones, &nr_zones,
3140
- GFP_KERNEL);
3141
- if (err)
3142
- break;
3143
- if (!nr_zones) {
3144
- err = -EIO;
3145
- break;
3146
- }
3147
-
3148
- for (i = 0; i < nr_zones; i++) {
3149
- if (zones[i].type != BLK_ZONE_TYPE_CONVENTIONAL)
3150
- set_bit(n, FDEV(devi).blkz_seq);
3151
- sector += zones[i].len;
3152
- n++;
3153
- }
3154
- }
3155
-
3156
- kvfree(zones);
3157
-
3158
- return err;
3578
+ ret = blkdev_report_zones(bdev, 0, BLK_ALL_ZONES, f2fs_report_zone_cb,
3579
+ &rep_zone_arg);
3580
+ if (ret < 0)
3581
+ return ret;
3582
+ return 0;
31593583 }
31603584 #endif
31613585
....@@ -3210,7 +3634,7 @@
32103634
32113635 /* No valid superblock */
32123636 if (!*raw_super)
3213
- kvfree(super);
3637
+ kfree(super);
32143638 else
32153639 err = 0;
32163640
....@@ -3254,6 +3678,26 @@
32543678 err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi));
32553679 brelse(bh);
32563680 return err;
3681
+}
3682
+
3683
+void f2fs_handle_stop(struct f2fs_sb_info *sbi, unsigned char reason)
3684
+{
3685
+ struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
3686
+ int err;
3687
+
3688
+ f2fs_bug_on(sbi, reason >= MAX_STOP_REASON);
3689
+
3690
+ f2fs_down_write(&sbi->sb_lock);
3691
+
3692
+ if (raw_super->s_stop_reason[reason] < ((1 << BITS_PER_BYTE) - 1))
3693
+ raw_super->s_stop_reason[reason]++;
3694
+
3695
+ err = f2fs_commit_super(sbi, false);
3696
+ if (err)
3697
+ f2fs_err(sbi, "f2fs_commit_super fails to record reason:%u err:%d",
3698
+ reason, err);
3699
+
3700
+ f2fs_up_write(&sbi->sb_lock);
32573701 }
32583702
32593703 static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
....@@ -3319,7 +3763,7 @@
33193763 #ifdef CONFIG_BLK_DEV_ZONED
33203764 if (bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HM &&
33213765 !f2fs_sb_has_blkzoned(sbi)) {
3322
- f2fs_err(sbi, "Zoned block device feature not enabled\n");
3766
+ f2fs_err(sbi, "Zoned block device feature not enabled");
33233767 return -EINVAL;
33243768 }
33253769 if (bdev_zoned_model(FDEV(i).bdev) != BLK_ZONED_NONE) {
....@@ -3396,7 +3840,8 @@
33963840 if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
33973841 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
33983842 sm_i->dcc_info->discard_granularity = 1;
3399
- sm_i->ipu_policy = 1 << F2FS_IPU_FORCE;
3843
+ sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
3844
+ 1 << F2FS_IPU_HONOR_OPU_WRITE;
34003845 }
34013846
34023847 sbi->readdir_ra = 1;
....@@ -3455,19 +3900,7 @@
34553900 sbi->s_chksum_seed = f2fs_chksum(sbi, ~0, raw_super->uuid,
34563901 sizeof(raw_super->uuid));
34573902
3458
- /*
3459
- * The BLKZONED feature indicates that the drive was formatted with
3460
- * zone alignment optimization. This is optional for host-aware
3461
- * devices, but mandatory for host-managed zoned block devices.
3462
- */
3463
-#ifndef CONFIG_BLK_DEV_ZONED
3464
- if (f2fs_sb_has_blkzoned(sbi)) {
3465
- f2fs_err(sbi, "Zoned block device support is not enabled");
3466
- err = -EOPNOTSUPP;
3467
- goto free_sb_buf;
3468
- }
3469
-#endif
3470
- default_options(sbi);
3903
+ default_options(sbi, false);
34713904 /* parse mount options */
34723905 options = kstrdup((const char *)data, GFP_KERNEL);
34733906 if (data && !options) {
....@@ -3479,8 +3912,7 @@
34793912 if (err)
34803913 goto free_options;
34813914
3482
- sbi->max_file_blocks = max_file_blocks();
3483
- sb->s_maxbytes = sbi->max_file_blocks <<
3915
+ sb->s_maxbytes = max_file_blocks(NULL) <<
34843916 le32_to_cpu(raw_super->log_blocksize);
34853917 sb->s_max_links = F2FS_LINK_MAX;
34863918
....@@ -3519,11 +3951,11 @@
35193951
35203952 /* init f2fs-specific super block info */
35213953 sbi->valid_super_block = valid_super_block;
3522
- init_rwsem(&sbi->gc_lock);
3954
+ init_f2fs_rwsem(&sbi->gc_lock);
35233955 mutex_init(&sbi->writepages);
3524
- mutex_init(&sbi->cp_mutex);
3525
- init_rwsem(&sbi->node_write);
3526
- init_rwsem(&sbi->node_change);
3956
+ init_f2fs_rwsem(&sbi->cp_global_sem);
3957
+ init_f2fs_rwsem(&sbi->node_write);
3958
+ init_f2fs_rwsem(&sbi->node_change);
35273959
35283960 /* disallow all the data/node/meta page writes */
35293961 set_sbi_flag(sbi, SBI_POR_DOING);
....@@ -3535,7 +3967,7 @@
35353967 sbi->iostat_period_ms = DEFAULT_IOSTAT_PERIOD_MS;
35363968
35373969 for (i = 0; i < NR_PAGE_TYPE; i++) {
3538
- int n = (i == META) ? 1: NR_TEMP_TYPE;
3970
+ int n = (i == META) ? 1 : NR_TEMP_TYPE;
35393971 int j;
35403972
35413973 sbi->write_io[i] =
....@@ -3549,18 +3981,18 @@
35493981 }
35503982
35513983 for (j = HOT; j < n; j++) {
3552
- init_rwsem(&sbi->write_io[i][j].io_rwsem);
3984
+ init_f2fs_rwsem(&sbi->write_io[i][j].io_rwsem);
35533985 sbi->write_io[i][j].sbi = sbi;
35543986 sbi->write_io[i][j].bio = NULL;
35553987 spin_lock_init(&sbi->write_io[i][j].io_lock);
35563988 INIT_LIST_HEAD(&sbi->write_io[i][j].io_list);
35573989 INIT_LIST_HEAD(&sbi->write_io[i][j].bio_list);
3558
- init_rwsem(&sbi->write_io[i][j].bio_list_lock);
3990
+ init_f2fs_rwsem(&sbi->write_io[i][j].bio_list_lock);
35593991 }
35603992 }
35613993
3562
- init_rwsem(&sbi->cp_rwsem);
3563
- init_rwsem(&sbi->quota_sem);
3994
+ init_f2fs_rwsem(&sbi->cp_rwsem);
3995
+ init_f2fs_rwsem(&sbi->quota_sem);
35643996 init_waitqueue_head(&sbi->cp_wait);
35653997 init_sb_info(sbi);
35663998
....@@ -3581,13 +4013,16 @@
35814013 err = f2fs_init_xattr_caches(sbi);
35824014 if (err)
35834015 goto free_io_dummy;
4016
+ err = f2fs_init_page_array_cache(sbi);
4017
+ if (err)
4018
+ goto free_xattr_cache;
35844019
35854020 /* get an inode for meta space */
35864021 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
35874022 if (IS_ERR(sbi->meta_inode)) {
35884023 f2fs_err(sbi, "Failed to read F2FS meta data inode");
35894024 err = PTR_ERR(sbi->meta_inode);
3590
- goto free_xattr_cache;
4025
+ goto free_page_array_cache;
35914026 }
35924027
35934028 err = f2fs_get_valid_checkpoint(sbi);
....@@ -3644,6 +4079,19 @@
36444079
36454080 f2fs_init_fsync_node_info(sbi);
36464081
4082
+ /* setup checkpoint request control and start checkpoint issue thread */
4083
+ f2fs_init_ckpt_req_control(sbi);
4084
+ if (!f2fs_readonly(sb) && !test_opt(sbi, DISABLE_CHECKPOINT) &&
4085
+ test_opt(sbi, MERGE_CHECKPOINT)) {
4086
+ err = f2fs_start_ckpt_thread(sbi);
4087
+ if (err) {
4088
+ f2fs_err(sbi,
4089
+ "Failed to start F2FS issue_checkpoint_thread (%d)",
4090
+ err);
4091
+ goto stop_ckpt_thread;
4092
+ }
4093
+ }
4094
+
36474095 /* setup f2fs internal modules */
36484096 err = f2fs_build_segment_manager(sbi);
36494097 if (err) {
....@@ -3658,11 +4106,12 @@
36584106 goto free_nm;
36594107 }
36604108
4109
+ err = adjust_reserved_segment(sbi);
4110
+ if (err)
4111
+ goto free_nm;
4112
+
36614113 /* For write statistics */
3662
- if (sb->s_bdev->bd_part)
3663
- sbi->sectors_written_start =
3664
- (u64)part_stat_read(sb->s_bdev->bd_part,
3665
- sectors[STAT_WRITE]);
4114
+ sbi->sectors_written_start = f2fs_get_sectors_written(sbi);
36664115
36674116 /* Read accumulated write IO statistics if exists */
36684117 seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
....@@ -3706,9 +4155,13 @@
37064155 goto free_node_inode;
37074156 }
37084157
3709
- err = f2fs_register_sysfs(sbi);
4158
+ err = f2fs_init_compress_inode(sbi);
37104159 if (err)
37114160 goto free_root_inode;
4161
+
4162
+ err = f2fs_register_sysfs(sbi);
4163
+ if (err)
4164
+ goto free_compress_inode;
37124165
37134166 #ifdef CONFIG_QUOTA
37144167 /* Enable quota usage during mount */
....@@ -3735,9 +4188,15 @@
37354188 */
37364189 if (f2fs_hw_is_readonly(sbi)) {
37374190 if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {
3738
- err = -EROFS;
3739
- f2fs_err(sbi, "Need to recover fsync data, but write access unavailable");
3740
- goto free_meta;
4191
+ err = f2fs_recover_fsync_data(sbi, true);
4192
+ if (err > 0) {
4193
+ err = -EROFS;
4194
+ f2fs_err(sbi, "Need to recover fsync data, but "
4195
+ "write access unavailable, please try "
4196
+ "mount w/ disable_roll_forward or norecovery");
4197
+ }
4198
+ if (err < 0)
4199
+ goto free_meta;
37414200 }
37424201 f2fs_info(sbi, "write access unavailable, skipping recovery");
37434202 goto reset_checkpoint;
....@@ -3767,7 +4226,20 @@
37674226 goto free_meta;
37684227 }
37694228 }
4229
+
4230
+ /*
4231
+ * If the f2fs is not readonly and fsync data recovery succeeds,
4232
+ * check zoned block devices' write pointer consistency.
4233
+ */
4234
+ if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
4235
+ err = f2fs_check_write_pointer(sbi);
4236
+ if (err)
4237
+ goto free_meta;
4238
+ }
4239
+
37704240 reset_checkpoint:
4241
+ f2fs_init_inmem_curseg(sbi);
4242
+
37714243 /* f2fs_recover_fsync_data() cleared this already */
37724244 clear_sbi_flag(sbi, SBI_POR_DOING);
37734245
....@@ -3783,7 +4255,8 @@
37834255 * If filesystem is not mounted as read-only then
37844256 * do start the gc_thread.
37854257 */
3786
- if (F2FS_OPTION(sbi).bggc_mode != BGGC_MODE_OFF && !f2fs_readonly(sb)) {
4258
+ if ((F2FS_OPTION(sbi).bggc_mode != BGGC_MODE_OFF ||
4259
+ test_opt(sbi, GC_MERGE)) && !f2fs_readonly(sb)) {
37874260 /* After POR, we can run background GC thread.*/
37884261 err = f2fs_start_gc_thread(sbi);
37894262 if (err)
....@@ -3830,6 +4303,8 @@
38304303 /* evict some inodes being cached by GC */
38314304 evict_inodes(sb);
38324305 f2fs_unregister_sysfs(sbi);
4306
+free_compress_inode:
4307
+ f2fs_destroy_compress_inode(sbi);
38334308 free_root_inode:
38344309 dput(sb->s_root);
38354310 sb->s_root = NULL;
....@@ -3841,10 +4316,14 @@
38414316 free_stats:
38424317 f2fs_destroy_stats(sbi);
38434318 free_nm:
4319
+ /* stop discard thread before destroying node manager */
4320
+ f2fs_stop_discard_thread(sbi);
38444321 f2fs_destroy_node_manager(sbi);
38454322 free_sm:
38464323 f2fs_destroy_segment_manager(sbi);
38474324 f2fs_destroy_post_read_wq(sbi);
4325
+stop_ckpt_thread:
4326
+ f2fs_stop_ckpt_thread(sbi);
38484327 free_devices:
38494328 destroy_device_list(sbi);
38504329 kvfree(sbi->ckpt);
....@@ -3852,6 +4331,8 @@
38524331 make_bad_inode(sbi->meta_inode);
38534332 iput(sbi->meta_inode);
38544333 sbi->meta_inode = NULL;
4334
+free_page_array_cache:
4335
+ f2fs_destroy_page_array_cache(sbi);
38554336 free_xattr_cache:
38564337 f2fs_destroy_xattr_caches(sbi);
38574338 free_io_dummy:
....@@ -3864,20 +4345,21 @@
38644345
38654346 #ifdef CONFIG_UNICODE
38664347 utf8_unload(sb->s_encoding);
4348
+ sb->s_encoding = NULL;
38674349 #endif
38684350 free_options:
38694351 #ifdef CONFIG_QUOTA
38704352 for (i = 0; i < MAXQUOTAS; i++)
3871
- kvfree(F2FS_OPTION(sbi).s_qf_names[i]);
4353
+ kfree(F2FS_OPTION(sbi).s_qf_names[i]);
38724354 #endif
3873
- fscrypt_free_dummy_context(&F2FS_OPTION(sbi).dummy_enc_ctx);
4355
+ fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy);
38744356 kvfree(options);
38754357 free_sb_buf:
3876
- kvfree(raw_super);
4358
+ kfree(raw_super);
38774359 free_sbi:
38784360 if (sbi->s_chksum_driver)
38794361 crypto_free_shash(sbi->s_chksum_driver);
3880
- kvfree(sbi);
4362
+ kfree(sbi);
38814363
38824364 /* give only one another chance */
38834365 if (retry_cnt > 0 && skip_recovery) {
....@@ -3902,6 +4384,15 @@
39024384 set_sbi_flag(sbi, SBI_IS_CLOSE);
39034385 f2fs_stop_gc_thread(sbi);
39044386 f2fs_stop_discard_thread(sbi);
4387
+
4388
+#ifdef CONFIG_F2FS_FS_COMPRESSION
4389
+ /*
4390
+ * latter evict_inode() can bypass checking and invalidating
4391
+ * compress inode cache.
4392
+ */
4393
+ if (test_opt(sbi, COMPRESS_CACHE))
4394
+ truncate_inode_pages_final(COMPRESS_MAPPING(sbi));
4395
+#endif
39054396
39064397 if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) ||
39074398 !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {
....@@ -3956,8 +4447,6 @@
39564447 return -EINVAL;
39574448 }
39584449
3959
- f2fs_build_trace_ios();
3960
-
39614450 err = init_inodecache();
39624451 if (err)
39634452 goto fail;
....@@ -3970,12 +4459,18 @@
39704459 err = f2fs_create_checkpoint_caches();
39714460 if (err)
39724461 goto free_segment_manager_caches;
3973
- err = f2fs_create_extent_cache();
4462
+ err = f2fs_create_recovery_cache();
39744463 if (err)
39754464 goto free_checkpoint_caches;
3976
- err = f2fs_init_sysfs();
4465
+ err = f2fs_create_extent_cache();
4466
+ if (err)
4467
+ goto free_recovery_cache;
4468
+ err = f2fs_create_garbage_collection_cache();
39774469 if (err)
39784470 goto free_extent_cache;
4471
+ err = f2fs_init_sysfs();
4472
+ if (err)
4473
+ goto free_garbage_collection_cache;
39794474 err = register_shrinker(&f2fs_shrinker_info);
39804475 if (err)
39814476 goto free_sysfs;
....@@ -3995,7 +4490,17 @@
39954490 err = f2fs_init_compress_mempool();
39964491 if (err)
39974492 goto free_bioset;
4493
+ err = f2fs_init_compress_cache();
4494
+ if (err)
4495
+ goto free_compress_mempool;
4496
+ err = f2fs_create_casefold_cache();
4497
+ if (err)
4498
+ goto free_compress_cache;
39984499 return 0;
4500
+free_compress_cache:
4501
+ f2fs_destroy_compress_cache();
4502
+free_compress_mempool:
4503
+ f2fs_destroy_compress_mempool();
39994504 free_bioset:
40004505 f2fs_destroy_bioset();
40014506 free_bio_enrty_cache:
....@@ -4009,8 +4514,12 @@
40094514 unregister_shrinker(&f2fs_shrinker_info);
40104515 free_sysfs:
40114516 f2fs_exit_sysfs();
4517
+free_garbage_collection_cache:
4518
+ f2fs_destroy_garbage_collection_cache();
40124519 free_extent_cache:
40134520 f2fs_destroy_extent_cache();
4521
+free_recovery_cache:
4522
+ f2fs_destroy_recovery_cache();
40144523 free_checkpoint_caches:
40154524 f2fs_destroy_checkpoint_caches();
40164525 free_segment_manager_caches:
....@@ -4025,6 +4534,8 @@
40254534
40264535 static void __exit exit_f2fs_fs(void)
40274536 {
4537
+ f2fs_destroy_casefold_cache();
4538
+ f2fs_destroy_compress_cache();
40284539 f2fs_destroy_compress_mempool();
40294540 f2fs_destroy_bioset();
40304541 f2fs_destroy_bio_entry_cache();
....@@ -4033,12 +4544,13 @@
40334544 unregister_filesystem(&f2fs_fs_type);
40344545 unregister_shrinker(&f2fs_shrinker_info);
40354546 f2fs_exit_sysfs();
4547
+ f2fs_destroy_garbage_collection_cache();
40364548 f2fs_destroy_extent_cache();
4549
+ f2fs_destroy_recovery_cache();
40374550 f2fs_destroy_checkpoint_caches();
40384551 f2fs_destroy_segment_manager_caches();
40394552 f2fs_destroy_node_manager_caches();
40404553 destroy_inodecache();
4041
- f2fs_destroy_trace_ios();
40424554 }
40434555
40444556 module_init(init_f2fs_fs)
....@@ -4047,5 +4559,6 @@
40474559 MODULE_AUTHOR("Samsung Electronics's Praesto Team");
40484560 MODULE_DESCRIPTION("Flash Friendly File System");
40494561 MODULE_LICENSE("GPL");
4562
+MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
40504563 MODULE_SOFTDEP("pre: crc32");
40514564