Lines Matching full:sbi

68 int f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned long rate,  in f2fs_build_fault_attr()  argument
71 struct f2fs_fault_info *ffi = &F2FS_OPTION(sbi).fault_info; in f2fs_build_fault_attr()
89 f2fs_info(sbi, in f2fs_build_fault_attr()
271 void f2fs_printk(struct f2fs_sb_info *sbi, bool limit_rate, in f2fs_printk() argument
285 KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf); in f2fs_printk()
288 KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf); in f2fs_printk()
332 static inline void limit_reserve_root(struct f2fs_sb_info *sbi) in limit_reserve_root() argument
334 block_t limit = min((sbi->user_block_count >> 3), in limit_reserve_root()
335 sbi->user_block_count - sbi->reserved_blocks); in limit_reserve_root()
338 if (test_opt(sbi, RESERVE_ROOT) && in limit_reserve_root()
339 F2FS_OPTION(sbi).root_reserved_blocks > limit) { in limit_reserve_root()
340 F2FS_OPTION(sbi).root_reserved_blocks = limit; in limit_reserve_root()
341 f2fs_info(sbi, "Reduce reserved blocks for root = %u", in limit_reserve_root()
342 F2FS_OPTION(sbi).root_reserved_blocks); in limit_reserve_root()
344 if (!test_opt(sbi, RESERVE_ROOT) && in limit_reserve_root()
345 (!uid_eq(F2FS_OPTION(sbi).s_resuid, in limit_reserve_root()
347 !gid_eq(F2FS_OPTION(sbi).s_resgid, in limit_reserve_root()
349 f2fs_info(sbi, "Ignore s_resuid=%u, s_resgid=%u w/o reserve_root", in limit_reserve_root()
351 F2FS_OPTION(sbi).s_resuid), in limit_reserve_root()
353 F2FS_OPTION(sbi).s_resgid)); in limit_reserve_root()
356 static inline void adjust_unusable_cap_perc(struct f2fs_sb_info *sbi) in adjust_unusable_cap_perc() argument
358 if (!F2FS_OPTION(sbi).unusable_cap_perc) in adjust_unusable_cap_perc()
361 if (F2FS_OPTION(sbi).unusable_cap_perc == 100) in adjust_unusable_cap_perc()
362 F2FS_OPTION(sbi).unusable_cap = sbi->user_block_count; in adjust_unusable_cap_perc()
364 F2FS_OPTION(sbi).unusable_cap = (sbi->user_block_count / 100) * in adjust_unusable_cap_perc()
365 F2FS_OPTION(sbi).unusable_cap_perc; in adjust_unusable_cap_perc()
367 f2fs_info(sbi, "Adjust unusable cap for checkpoint=disable = %u / %u%%", in adjust_unusable_cap_perc()
368 F2FS_OPTION(sbi).unusable_cap, in adjust_unusable_cap_perc()
369 F2FS_OPTION(sbi).unusable_cap_perc); in adjust_unusable_cap_perc()
385 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_set_qf_name() local
389 if (sb_any_quota_loaded(sb) && !F2FS_OPTION(sbi).s_qf_names[qtype]) { in f2fs_set_qf_name()
390 f2fs_err(sbi, "Cannot change journaled quota options when quota turned on"); in f2fs_set_qf_name()
393 if (f2fs_sb_has_quota_ino(sbi)) { in f2fs_set_qf_name()
394 f2fs_info(sbi, "QUOTA feature is enabled, so ignore qf_name"); in f2fs_set_qf_name()
400 f2fs_err(sbi, "Not enough memory for storing quotafile name"); in f2fs_set_qf_name()
403 if (F2FS_OPTION(sbi).s_qf_names[qtype]) { in f2fs_set_qf_name()
404 if (strcmp(F2FS_OPTION(sbi).s_qf_names[qtype], qname) == 0) in f2fs_set_qf_name()
407 f2fs_err(sbi, "%s quota file already specified", in f2fs_set_qf_name()
412 f2fs_err(sbi, "quotafile must be on filesystem root"); in f2fs_set_qf_name()
415 F2FS_OPTION(sbi).s_qf_names[qtype] = qname; in f2fs_set_qf_name()
416 set_opt(sbi, QUOTA); in f2fs_set_qf_name()
425 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_clear_qf_name() local
427 if (sb_any_quota_loaded(sb) && F2FS_OPTION(sbi).s_qf_names[qtype]) { in f2fs_clear_qf_name()
428 f2fs_err(sbi, "Cannot change journaled quota options when quota turned on"); in f2fs_clear_qf_name()
431 kfree(F2FS_OPTION(sbi).s_qf_names[qtype]); in f2fs_clear_qf_name()
432 F2FS_OPTION(sbi).s_qf_names[qtype] = NULL; in f2fs_clear_qf_name()
436 static int f2fs_check_quota_options(struct f2fs_sb_info *sbi) in f2fs_check_quota_options() argument
443 if (test_opt(sbi, PRJQUOTA) && !f2fs_sb_has_project_quota(sbi)) { in f2fs_check_quota_options()
444 f2fs_err(sbi, "Project quota feature not enabled. Cannot enable project quota enforcement."); in f2fs_check_quota_options()
447 if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA] || in f2fs_check_quota_options()
448 F2FS_OPTION(sbi).s_qf_names[GRPQUOTA] || in f2fs_check_quota_options()
449 F2FS_OPTION(sbi).s_qf_names[PRJQUOTA]) { in f2fs_check_quota_options()
450 if (test_opt(sbi, USRQUOTA) && in f2fs_check_quota_options()
451 F2FS_OPTION(sbi).s_qf_names[USRQUOTA]) in f2fs_check_quota_options()
452 clear_opt(sbi, USRQUOTA); in f2fs_check_quota_options()
454 if (test_opt(sbi, GRPQUOTA) && in f2fs_check_quota_options()
455 F2FS_OPTION(sbi).s_qf_names[GRPQUOTA]) in f2fs_check_quota_options()
456 clear_opt(sbi, GRPQUOTA); in f2fs_check_quota_options()
458 if (test_opt(sbi, PRJQUOTA) && in f2fs_check_quota_options()
459 F2FS_OPTION(sbi).s_qf_names[PRJQUOTA]) in f2fs_check_quota_options()
460 clear_opt(sbi, PRJQUOTA); in f2fs_check_quota_options()
462 if (test_opt(sbi, GRPQUOTA) || test_opt(sbi, USRQUOTA) || in f2fs_check_quota_options()
463 test_opt(sbi, PRJQUOTA)) { in f2fs_check_quota_options()
464 f2fs_err(sbi, "old and new quota format mixing"); in f2fs_check_quota_options()
468 if (!F2FS_OPTION(sbi).s_jquota_fmt) { in f2fs_check_quota_options()
469 f2fs_err(sbi, "journaled quota format not specified"); in f2fs_check_quota_options()
474 if (f2fs_sb_has_quota_ino(sbi) && F2FS_OPTION(sbi).s_jquota_fmt) { in f2fs_check_quota_options()
475 f2fs_info(sbi, "QUOTA feature is enabled, so ignore jquota_fmt"); in f2fs_check_quota_options()
476 F2FS_OPTION(sbi).s_jquota_fmt = 0; in f2fs_check_quota_options()
487 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_set_test_dummy_encryption() local
493 &F2FS_OPTION(sbi).dummy_enc_policy; in f2fs_set_test_dummy_encryption()
497 f2fs_warn(sbi, "test_dummy_encryption option not supported"); in f2fs_set_test_dummy_encryption()
501 if (!f2fs_sb_has_encrypt(sbi)) { in f2fs_set_test_dummy_encryption()
502 f2fs_err(sbi, "Encrypt feature is off"); in f2fs_set_test_dummy_encryption()
513 f2fs_warn(sbi, "Can't set test_dummy_encryption on remount"); in f2fs_set_test_dummy_encryption()
520 f2fs_warn(sbi, in f2fs_set_test_dummy_encryption()
523 f2fs_warn(sbi, "Value of option \"%s\" is unrecognized", in f2fs_set_test_dummy_encryption()
526 f2fs_warn(sbi, "Error processing option \"%s\" [%d]", in f2fs_set_test_dummy_encryption()
530 f2fs_warn(sbi, "Test dummy encryption mode enabled"); in f2fs_set_test_dummy_encryption()
535 static bool is_compress_extension_exist(struct f2fs_sb_info *sbi, in is_compress_extension_exist() argument
543 ext = F2FS_OPTION(sbi).extensions; in is_compress_extension_exist()
544 ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; in is_compress_extension_exist()
546 ext = F2FS_OPTION(sbi).noextensions; in is_compress_extension_exist()
547 ext_cnt = F2FS_OPTION(sbi).nocompress_ext_cnt; in is_compress_extension_exist()
565 static int f2fs_test_compress_extension(struct f2fs_sb_info *sbi) in f2fs_test_compress_extension() argument
571 ext = F2FS_OPTION(sbi).extensions; in f2fs_test_compress_extension()
572 ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; in f2fs_test_compress_extension()
573 noext = F2FS_OPTION(sbi).noextensions; in f2fs_test_compress_extension()
574 noext_cnt = F2FS_OPTION(sbi).nocompress_ext_cnt; in f2fs_test_compress_extension()
581 f2fs_info(sbi, "Don't allow the nocompress extension specifies all files"); in f2fs_test_compress_extension()
586 …f2fs_info(sbi, "Don't allow the same extension %s appear in both compress and nocompress extension… in f2fs_test_compress_extension()
596 static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str) in f2fs_set_lz4hc_level() argument
602 F2FS_OPTION(sbi).compress_level = 0; in f2fs_set_lz4hc_level()
609 f2fs_info(sbi, "wrong format, e.g. <alg_name>:<compr_level>"); in f2fs_set_lz4hc_level()
616 f2fs_info(sbi, "invalid lz4hc compress level: %d", level); in f2fs_set_lz4hc_level()
620 F2FS_OPTION(sbi).compress_level = level; in f2fs_set_lz4hc_level()
624 F2FS_OPTION(sbi).compress_level = 0; in f2fs_set_lz4hc_level()
627 f2fs_info(sbi, "kernel doesn't support lz4hc compression"); in f2fs_set_lz4hc_level()
634 static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str) in f2fs_set_zstd_level() argument
640 F2FS_OPTION(sbi).compress_level = F2FS_ZSTD_DEFAULT_CLEVEL; in f2fs_set_zstd_level()
647 f2fs_info(sbi, "wrong format, e.g. <alg_name>:<compr_level>"); in f2fs_set_zstd_level()
655 f2fs_info(sbi, "do not support negative compress level: %d", level); in f2fs_set_zstd_level()
660 f2fs_info(sbi, "invalid zstd compress level: %d", level); in f2fs_set_zstd_level()
664 F2FS_OPTION(sbi).compress_level = level; in f2fs_set_zstd_level()
672 struct f2fs_sb_info *sbi = F2FS_SB(sb); in parse_options() local
707 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; in parse_options()
709 if (f2fs_sb_has_blkzoned(sbi)) { in parse_options()
710 f2fs_warn(sbi, "zoned devices need bggc"); in parse_options()
714 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_OFF; in parse_options()
716 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_SYNC; in parse_options()
724 set_opt(sbi, DISABLE_ROLL_FORWARD); in parse_options()
728 set_opt(sbi, NORECOVERY); in parse_options()
733 if (!f2fs_hw_support_discard(sbi)) { in parse_options()
734 f2fs_warn(sbi, "device does not support discard"); in parse_options()
737 set_opt(sbi, DISCARD); in parse_options()
740 if (f2fs_hw_should_discard(sbi)) { in parse_options()
741 f2fs_warn(sbi, "discard is required for zoned block devices"); in parse_options()
744 clear_opt(sbi, DISCARD); in parse_options()
748 f2fs_warn(sbi, "heap/no_heap options were deprecated"); in parse_options()
752 set_opt(sbi, XATTR_USER); in parse_options()
755 clear_opt(sbi, XATTR_USER); in parse_options()
758 set_opt(sbi, INLINE_XATTR); in parse_options()
761 clear_opt(sbi, INLINE_XATTR); in parse_options()
766 set_opt(sbi, INLINE_XATTR_SIZE); in parse_options()
767 F2FS_OPTION(sbi).inline_xattr_size = arg; in parse_options()
771 f2fs_info(sbi, "user_xattr options not supported"); in parse_options()
774 f2fs_info(sbi, "nouser_xattr options not supported"); in parse_options()
777 f2fs_info(sbi, "inline_xattr options not supported"); in parse_options()
780 f2fs_info(sbi, "noinline_xattr options not supported"); in parse_options()
785 set_opt(sbi, POSIX_ACL); in parse_options()
788 clear_opt(sbi, POSIX_ACL); in parse_options()
792 f2fs_info(sbi, "acl options not supported"); in parse_options()
795 f2fs_info(sbi, "noacl options not supported"); in parse_options()
804 F2FS_OPTION(sbi).active_logs = arg; in parse_options()
807 set_opt(sbi, DISABLE_EXT_IDENTIFY); in parse_options()
810 set_opt(sbi, INLINE_DATA); in parse_options()
813 set_opt(sbi, INLINE_DENTRY); in parse_options()
816 clear_opt(sbi, INLINE_DENTRY); in parse_options()
819 set_opt(sbi, FLUSH_MERGE); in parse_options()
822 clear_opt(sbi, FLUSH_MERGE); in parse_options()
825 set_opt(sbi, NOBARRIER); in parse_options()
828 clear_opt(sbi, NOBARRIER); in parse_options()
831 set_opt(sbi, FASTBOOT); in parse_options()
834 set_opt(sbi, READ_EXTENT_CACHE); in parse_options()
837 clear_opt(sbi, READ_EXTENT_CACHE); in parse_options()
840 clear_opt(sbi, INLINE_DATA); in parse_options()
843 set_opt(sbi, DATA_FLUSH); in parse_options()
848 if (test_opt(sbi, RESERVE_ROOT)) { in parse_options()
849 f2fs_info(sbi, "Preserve previous reserve_root=%u", in parse_options()
850 F2FS_OPTION(sbi).root_reserved_blocks); in parse_options()
852 F2FS_OPTION(sbi).root_reserved_blocks = arg; in parse_options()
853 set_opt(sbi, RESERVE_ROOT); in parse_options()
861 f2fs_err(sbi, "Invalid uid value %d", arg); in parse_options()
864 F2FS_OPTION(sbi).s_resuid = uid; in parse_options()
871 f2fs_err(sbi, "Invalid gid value %d", arg); in parse_options()
874 F2FS_OPTION(sbi).s_resgid = gid; in parse_options()
882 F2FS_OPTION(sbi).fs_mode = FS_MODE_ADAPTIVE; in parse_options()
884 F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS; in parse_options()
886 F2FS_OPTION(sbi).fs_mode = FS_MODE_FRAGMENT_SEG; in parse_options()
888 F2FS_OPTION(sbi).fs_mode = FS_MODE_FRAGMENT_BLK; in parse_options()
899 if (f2fs_build_fault_attr(sbi, arg, in parse_options()
902 set_opt(sbi, FAULT_INJECTION); in parse_options()
908 if (f2fs_build_fault_attr(sbi, 0, arg)) in parse_options()
910 set_opt(sbi, FAULT_INJECTION); in parse_options()
914 f2fs_info(sbi, "fault_injection options not supported"); in parse_options()
918 f2fs_info(sbi, "fault_type options not supported"); in parse_options()
924 set_opt(sbi, USRQUOTA); in parse_options()
927 set_opt(sbi, GRPQUOTA); in parse_options()
930 set_opt(sbi, PRJQUOTA); in parse_options()
963 F2FS_OPTION(sbi).s_jquota_fmt = QFMT_VFS_OLD; in parse_options()
966 F2FS_OPTION(sbi).s_jquota_fmt = QFMT_VFS_V0; in parse_options()
969 F2FS_OPTION(sbi).s_jquota_fmt = QFMT_VFS_V1; in parse_options()
972 clear_opt(sbi, QUOTA); in parse_options()
973 clear_opt(sbi, USRQUOTA); in parse_options()
974 clear_opt(sbi, GRPQUOTA); in parse_options()
975 clear_opt(sbi, PRJQUOTA); in parse_options()
992 f2fs_info(sbi, "quota operations not supported"); in parse_options()
1001 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT; in parse_options()
1003 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE; in parse_options()
1015 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX; in parse_options()
1017 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_STRICT; in parse_options()
1019 F2FS_OPTION(sbi).fsync_mode = in parse_options()
1037 f2fs_info(sbi, "inline encryption not supported"); in parse_options()
1045 F2FS_OPTION(sbi).unusable_cap_perc = arg; in parse_options()
1046 set_opt(sbi, DISABLE_CHECKPOINT); in parse_options()
1051 F2FS_OPTION(sbi).unusable_cap = arg; in parse_options()
1052 set_opt(sbi, DISABLE_CHECKPOINT); in parse_options()
1055 set_opt(sbi, DISABLE_CHECKPOINT); in parse_options()
1058 clear_opt(sbi, DISABLE_CHECKPOINT); in parse_options()
1061 set_opt(sbi, MERGE_CHECKPOINT); in parse_options()
1064 clear_opt(sbi, MERGE_CHECKPOINT); in parse_options()
1068 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
1069 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
1077 F2FS_OPTION(sbi).compress_level = 0; in parse_options()
1078 F2FS_OPTION(sbi).compress_algorithm = in parse_options()
1081 f2fs_info(sbi, "kernel doesn't support lzo compression"); in parse_options()
1085 ret = f2fs_set_lz4hc_level(sbi, name); in parse_options()
1090 F2FS_OPTION(sbi).compress_algorithm = in parse_options()
1093 f2fs_info(sbi, "kernel doesn't support lz4 compression"); in parse_options()
1097 ret = f2fs_set_zstd_level(sbi, name); in parse_options()
1102 F2FS_OPTION(sbi).compress_algorithm = in parse_options()
1105 f2fs_info(sbi, "kernel doesn't support zstd compression"); in parse_options()
1109 F2FS_OPTION(sbi).compress_level = 0; in parse_options()
1110 F2FS_OPTION(sbi).compress_algorithm = in parse_options()
1113 f2fs_info(sbi, "kernel doesn't support lzorle compression"); in parse_options()
1122 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
1123 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
1130 f2fs_err(sbi, in parse_options()
1134 F2FS_OPTION(sbi).compress_log_size = arg; in parse_options()
1137 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
1138 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
1145 ext = F2FS_OPTION(sbi).extensions; in parse_options()
1146 ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; in parse_options()
1150 f2fs_err(sbi, in parse_options()
1156 if (is_compress_extension_exist(sbi, name, true)) { in parse_options()
1162 F2FS_OPTION(sbi).compress_ext_cnt++; in parse_options()
1166 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
1167 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
1174 noext = F2FS_OPTION(sbi).noextensions; in parse_options()
1175 noext_cnt = F2FS_OPTION(sbi).nocompress_ext_cnt; in parse_options()
1179 f2fs_err(sbi, in parse_options()
1185 if (is_compress_extension_exist(sbi, name, false)) { in parse_options()
1191 F2FS_OPTION(sbi).nocompress_ext_cnt++; in parse_options()
1195 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
1196 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
1199 F2FS_OPTION(sbi).compress_chksum = true; in parse_options()
1202 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
1203 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
1210 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS; in parse_options()
1212 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_USER; in parse_options()
1220 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
1221 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
1224 set_opt(sbi, COMPRESS_CACHE); in parse_options()
1234 f2fs_info(sbi, "compression options not supported"); in parse_options()
1238 set_opt(sbi, ATGC); in parse_options()
1241 set_opt(sbi, GC_MERGE); in parse_options()
1244 clear_opt(sbi, GC_MERGE); in parse_options()
1251 F2FS_OPTION(sbi).discard_unit = in parse_options()
1254 F2FS_OPTION(sbi).discard_unit = in parse_options()
1257 F2FS_OPTION(sbi).discard_unit = in parse_options()
1270 F2FS_OPTION(sbi).memory_mode = in parse_options()
1273 F2FS_OPTION(sbi).memory_mode = in parse_options()
1282 set_opt(sbi, AGE_EXTENT_CACHE); in parse_options()
1289 F2FS_OPTION(sbi).errors = in parse_options()
1292 F2FS_OPTION(sbi).errors = in parse_options()
1295 F2FS_OPTION(sbi).errors = in parse_options()
1304 f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value", in parse_options()
1311 if (f2fs_check_quota_options(sbi)) in parse_options()
1314 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sbi->sb)) { in parse_options()
1315 f2fs_info(sbi, "Filesystem with quota feature cannot be mounted RDWR without CONFIG_QUOTA"); in parse_options()
1318 if (f2fs_sb_has_project_quota(sbi) && !f2fs_readonly(sbi->sb)) { in parse_options()
1319 …f2fs_err(sbi, "Filesystem with project quota feature cannot be mounted RDWR without CONFIG_QUOTA"); in parse_options()
1324 if (!IS_ENABLED(CONFIG_UNICODE) && f2fs_sb_has_casefold(sbi)) { in parse_options()
1325 f2fs_err(sbi, in parse_options()
1335 if (f2fs_sb_has_blkzoned(sbi)) { in parse_options()
1337 if (F2FS_OPTION(sbi).discard_unit != in parse_options()
1339 …f2fs_info(sbi, "Zoned block device doesn't need small discard, set discard_unit=section by default… in parse_options()
1340 F2FS_OPTION(sbi).discard_unit = in parse_options()
1344 if (F2FS_OPTION(sbi).fs_mode != FS_MODE_LFS) { in parse_options()
1345 f2fs_info(sbi, "Only lfs mode is allowed with zoned block device feature"); in parse_options()
1349 f2fs_err(sbi, "Zoned block device support is not enabled"); in parse_options()
1355 if (f2fs_test_compress_extension(sbi)) { in parse_options()
1356 f2fs_err(sbi, "invalid compress or nocompress extension"); in parse_options()
1361 if (test_opt(sbi, INLINE_XATTR_SIZE)) { in parse_options()
1364 if (!f2fs_sb_has_extra_attr(sbi) || in parse_options()
1365 !f2fs_sb_has_flexible_inline_xattr(sbi)) { in parse_options()
1366 f2fs_err(sbi, "extra_attr or flexible_inline_xattr feature is off"); in parse_options()
1369 if (!test_opt(sbi, INLINE_XATTR)) { in parse_options()
1370 f2fs_err(sbi, "inline_xattr_size option should be set with inline_xattr option"); in parse_options()
1377 if (F2FS_OPTION(sbi).inline_xattr_size < min_size || in parse_options()
1378 F2FS_OPTION(sbi).inline_xattr_size > max_size) { in parse_options()
1379 f2fs_err(sbi, "inline xattr size is out of range: %d ~ %d", in parse_options()
1385 if (test_opt(sbi, ATGC) && f2fs_lfs_mode(sbi)) { in parse_options()
1386 f2fs_err(sbi, "LFS is not compatible with ATGC"); in parse_options()
1390 if (f2fs_is_readonly(sbi) && test_opt(sbi, FLUSH_MERGE)) { in parse_options()
1391 f2fs_err(sbi, "FLUSH_MERGE not compatible with readonly mode"); in parse_options()
1395 if (f2fs_sb_has_readonly(sbi) && !f2fs_readonly(sbi->sb)) { in parse_options()
1396 f2fs_err(sbi, "Allow to mount readonly mode only"); in parse_options()
1434 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_drop_inode() local
1441 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) { in f2fs_drop_inode()
1442 if (inode->i_ino == F2FS_NODE_INO(sbi) || in f2fs_drop_inode()
1443 inode->i_ino == F2FS_META_INO(sbi)) { in f2fs_drop_inode()
1492 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_inode_dirtied() local
1495 spin_lock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_dirtied()
1500 stat_inc_dirty_inode(sbi, DIRTY_META); in f2fs_inode_dirtied()
1504 &sbi->inode_list[DIRTY_META]); in f2fs_inode_dirtied()
1505 inc_page_count(sbi, F2FS_DIRTY_IMETA); in f2fs_inode_dirtied()
1507 spin_unlock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_dirtied()
1513 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_inode_synced() local
1515 spin_lock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_synced()
1517 spin_unlock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_synced()
1522 dec_page_count(sbi, F2FS_DIRTY_IMETA); in f2fs_inode_synced()
1527 spin_unlock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_synced()
1537 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_dirty_inode() local
1539 if (inode->i_ino == F2FS_NODE_INO(sbi) || in f2fs_dirty_inode()
1540 inode->i_ino == F2FS_META_INO(sbi)) in f2fs_dirty_inode()
1555 static void destroy_percpu_info(struct f2fs_sb_info *sbi) in destroy_percpu_info() argument
1557 percpu_counter_destroy(&sbi->total_valid_inode_count); in destroy_percpu_info()
1558 percpu_counter_destroy(&sbi->rf_node_block_count); in destroy_percpu_info()
1559 percpu_counter_destroy(&sbi->alloc_valid_block_count); in destroy_percpu_info()
1562 static void destroy_device_list(struct f2fs_sb_info *sbi) in destroy_device_list() argument
1566 for (i = 0; i < sbi->s_ndevs; i++) { in destroy_device_list()
1573 kvfree(sbi->devs); in destroy_device_list()
1578 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_put_super() local
1584 f2fs_unregister_sysfs(sbi); in f2fs_put_super()
1589 mutex_lock(&sbi->umount_mutex); in f2fs_put_super()
1595 f2fs_stop_ckpt_thread(sbi); in f2fs_put_super()
1602 if ((is_sbi_flag_set(sbi, SBI_IS_DIRTY) || in f2fs_put_super()
1603 !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG))) { in f2fs_put_super()
1607 stat_inc_cp_call_count(sbi, TOTAL_CALL); in f2fs_put_super()
1608 err = f2fs_write_checkpoint(sbi, &cpc); in f2fs_put_super()
1612 done = f2fs_issue_discard_timeout(sbi); in f2fs_put_super()
1613 if (f2fs_realtime_discard_enable(sbi) && !sbi->discard_blks && done) { in f2fs_put_super()
1617 stat_inc_cp_call_count(sbi, TOTAL_CALL); in f2fs_put_super()
1618 err = f2fs_write_checkpoint(sbi, &cpc); in f2fs_put_super()
1625 f2fs_release_ino_entry(sbi, true); in f2fs_put_super()
1627 f2fs_leave_shrinker(sbi); in f2fs_put_super()
1628 mutex_unlock(&sbi->umount_mutex); in f2fs_put_super()
1631 f2fs_flush_merged_writes(sbi); in f2fs_put_super()
1633 f2fs_wait_on_all_pages(sbi, F2FS_WB_CP_DATA); in f2fs_put_super()
1635 if (err || f2fs_cp_error(sbi)) { in f2fs_put_super()
1636 truncate_inode_pages_final(NODE_MAPPING(sbi)); in f2fs_put_super()
1637 truncate_inode_pages_final(META_MAPPING(sbi)); in f2fs_put_super()
1641 if (!get_pages(sbi, i)) in f2fs_put_super()
1643 f2fs_err(sbi, "detect filesystem reference count leak during " in f2fs_put_super()
1644 "umount, type: %d, count: %lld", i, get_pages(sbi, i)); in f2fs_put_super()
1645 f2fs_bug_on(sbi, 1); in f2fs_put_super()
1648 f2fs_bug_on(sbi, sbi->fsync_node_num); in f2fs_put_super()
1650 f2fs_destroy_compress_inode(sbi); in f2fs_put_super()
1652 iput(sbi->node_inode); in f2fs_put_super()
1653 sbi->node_inode = NULL; in f2fs_put_super()
1655 iput(sbi->meta_inode); in f2fs_put_super()
1656 sbi->meta_inode = NULL; in f2fs_put_super()
1662 f2fs_destroy_stats(sbi); in f2fs_put_super()
1665 f2fs_destroy_node_manager(sbi); in f2fs_put_super()
1666 f2fs_destroy_segment_manager(sbi); in f2fs_put_super()
1668 /* flush s_error_work before sbi destroy */ in f2fs_put_super()
1669 flush_work(&sbi->s_error_work); in f2fs_put_super()
1671 f2fs_destroy_post_read_wq(sbi); in f2fs_put_super()
1673 kvfree(sbi->ckpt); in f2fs_put_super()
1675 if (sbi->s_chksum_driver) in f2fs_put_super()
1676 crypto_free_shash(sbi->s_chksum_driver); in f2fs_put_super()
1677 kfree(sbi->raw_super); in f2fs_put_super()
1679 f2fs_destroy_page_array_cache(sbi); in f2fs_put_super()
1680 f2fs_destroy_xattr_caches(sbi); in f2fs_put_super()
1683 kfree(F2FS_OPTION(sbi).s_qf_names[i]); in f2fs_put_super()
1685 fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy); in f2fs_put_super()
1686 destroy_percpu_info(sbi); in f2fs_put_super()
1687 f2fs_destroy_iostat(sbi); in f2fs_put_super()
1689 kvfree(sbi->write_io[i]); in f2fs_put_super()
1697 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_sync_fs() local
1700 if (unlikely(f2fs_cp_error(sbi))) in f2fs_sync_fs()
1702 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) in f2fs_sync_fs()
1707 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) in f2fs_sync_fs()
1711 stat_inc_cp_call_count(sbi, TOTAL_CALL); in f2fs_sync_fs()
1712 err = f2fs_issue_checkpoint(sbi); in f2fs_sync_fs()
1793 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_statfs() local
1799 total_count = le64_to_cpu(sbi->raw_super->block_count); in f2fs_statfs()
1800 start_count = le32_to_cpu(sbi->raw_super->segment0_blkaddr); in f2fs_statfs()
1802 buf->f_bsize = sbi->blocksize; in f2fs_statfs()
1806 spin_lock(&sbi->stat_lock); in f2fs_statfs()
1808 user_block_count = sbi->user_block_count; in f2fs_statfs()
1809 total_valid_node_count = valid_node_count(sbi); in f2fs_statfs()
1810 avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM; in f2fs_statfs()
1811 buf->f_bfree = user_block_count - valid_user_blocks(sbi) - in f2fs_statfs()
1812 sbi->current_reserved_blocks; in f2fs_statfs()
1814 if (unlikely(buf->f_bfree <= sbi->unusable_block_count)) in f2fs_statfs()
1817 buf->f_bfree -= sbi->unusable_block_count; in f2fs_statfs()
1818 spin_unlock(&sbi->stat_lock); in f2fs_statfs()
1820 if (buf->f_bfree > F2FS_OPTION(sbi).root_reserved_blocks) in f2fs_statfs()
1822 F2FS_OPTION(sbi).root_reserved_blocks; in f2fs_statfs()
1851 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_show_quota_options() local
1853 if (F2FS_OPTION(sbi).s_jquota_fmt) { in f2fs_show_quota_options()
1856 switch (F2FS_OPTION(sbi).s_jquota_fmt) { in f2fs_show_quota_options()
1870 if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA]) in f2fs_show_quota_options()
1872 F2FS_OPTION(sbi).s_qf_names[USRQUOTA]); in f2fs_show_quota_options()
1874 if (F2FS_OPTION(sbi).s_qf_names[GRPQUOTA]) in f2fs_show_quota_options()
1876 F2FS_OPTION(sbi).s_qf_names[GRPQUOTA]); in f2fs_show_quota_options()
1878 if (F2FS_OPTION(sbi).s_qf_names[PRJQUOTA]) in f2fs_show_quota_options()
1880 F2FS_OPTION(sbi).s_qf_names[PRJQUOTA]); in f2fs_show_quota_options()
1888 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_show_compress_options() local
1892 if (!f2fs_sb_has_compression(sbi)) in f2fs_show_compress_options()
1895 switch (F2FS_OPTION(sbi).compress_algorithm) { in f2fs_show_compress_options()
1911 if (F2FS_OPTION(sbi).compress_level) in f2fs_show_compress_options()
1912 seq_printf(seq, ":%d", F2FS_OPTION(sbi).compress_level); in f2fs_show_compress_options()
1915 F2FS_OPTION(sbi).compress_log_size); in f2fs_show_compress_options()
1917 for (i = 0; i < F2FS_OPTION(sbi).compress_ext_cnt; i++) { in f2fs_show_compress_options()
1919 F2FS_OPTION(sbi).extensions[i]); in f2fs_show_compress_options()
1922 for (i = 0; i < F2FS_OPTION(sbi).nocompress_ext_cnt; i++) { in f2fs_show_compress_options()
1924 F2FS_OPTION(sbi).noextensions[i]); in f2fs_show_compress_options()
1927 if (F2FS_OPTION(sbi).compress_chksum) in f2fs_show_compress_options()
1930 if (F2FS_OPTION(sbi).compress_mode == COMPR_MODE_FS) in f2fs_show_compress_options()
1932 else if (F2FS_OPTION(sbi).compress_mode == COMPR_MODE_USER) in f2fs_show_compress_options()
1935 if (test_opt(sbi, COMPRESS_CACHE)) in f2fs_show_compress_options()
1942 struct f2fs_sb_info *sbi = F2FS_SB(root->d_sb); in f2fs_show_options() local
1944 if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC) in f2fs_show_options()
1946 else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_ON) in f2fs_show_options()
1948 else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF) in f2fs_show_options()
1951 if (test_opt(sbi, GC_MERGE)) in f2fs_show_options()
1956 if (test_opt(sbi, DISABLE_ROLL_FORWARD)) in f2fs_show_options()
1958 if (test_opt(sbi, NORECOVERY)) in f2fs_show_options()
1960 if (test_opt(sbi, DISCARD)) { in f2fs_show_options()
1962 if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_BLOCK) in f2fs_show_options()
1964 else if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SEGMENT) in f2fs_show_options()
1966 else if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SECTION) in f2fs_show_options()
1972 if (test_opt(sbi, XATTR_USER)) in f2fs_show_options()
1976 if (test_opt(sbi, INLINE_XATTR)) in f2fs_show_options()
1980 if (test_opt(sbi, INLINE_XATTR_SIZE)) in f2fs_show_options()
1982 F2FS_OPTION(sbi).inline_xattr_size); in f2fs_show_options()
1985 if (test_opt(sbi, POSIX_ACL)) in f2fs_show_options()
1990 if (test_opt(sbi, DISABLE_EXT_IDENTIFY)) in f2fs_show_options()
1992 if (test_opt(sbi, INLINE_DATA)) in f2fs_show_options()
1996 if (test_opt(sbi, INLINE_DENTRY)) in f2fs_show_options()
2000 if (test_opt(sbi, FLUSH_MERGE)) in f2fs_show_options()
2004 if (test_opt(sbi, NOBARRIER)) in f2fs_show_options()
2008 if (test_opt(sbi, FASTBOOT)) in f2fs_show_options()
2010 if (test_opt(sbi, READ_EXTENT_CACHE)) in f2fs_show_options()
2014 if (test_opt(sbi, AGE_EXTENT_CACHE)) in f2fs_show_options()
2016 if (test_opt(sbi, DATA_FLUSH)) in f2fs_show_options()
2020 if (F2FS_OPTION(sbi).fs_mode == FS_MODE_ADAPTIVE) in f2fs_show_options()
2022 else if (F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS) in f2fs_show_options()
2024 else if (F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_SEG) in f2fs_show_options()
2026 else if (F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_BLK) in f2fs_show_options()
2028 seq_printf(seq, ",active_logs=%u", F2FS_OPTION(sbi).active_logs); in f2fs_show_options()
2029 if (test_opt(sbi, RESERVE_ROOT)) in f2fs_show_options()
2031 F2FS_OPTION(sbi).root_reserved_blocks, in f2fs_show_options()
2033 F2FS_OPTION(sbi).s_resuid), in f2fs_show_options()
2035 F2FS_OPTION(sbi).s_resgid)); in f2fs_show_options()
2037 if (test_opt(sbi, FAULT_INJECTION)) { in f2fs_show_options()
2039 F2FS_OPTION(sbi).fault_info.inject_rate); in f2fs_show_options()
2041 F2FS_OPTION(sbi).fault_info.inject_type); in f2fs_show_options()
2045 if (test_opt(sbi, QUOTA)) in f2fs_show_options()
2047 if (test_opt(sbi, USRQUOTA)) in f2fs_show_options()
2049 if (test_opt(sbi, GRPQUOTA)) in f2fs_show_options()
2051 if (test_opt(sbi, PRJQUOTA)) in f2fs_show_options()
2054 f2fs_show_quota_options(seq, sbi->sb); in f2fs_show_options()
2056 fscrypt_show_test_dummy_encryption(seq, ',', sbi->sb); in f2fs_show_options()
2058 if (sbi->sb->s_flags & SB_INLINECRYPT) in f2fs_show_options()
2061 if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_DEFAULT) in f2fs_show_options()
2063 else if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_REUSE) in f2fs_show_options()
2066 if (test_opt(sbi, DISABLE_CHECKPOINT)) in f2fs_show_options()
2068 F2FS_OPTION(sbi).unusable_cap); in f2fs_show_options()
2069 if (test_opt(sbi, MERGE_CHECKPOINT)) in f2fs_show_options()
2073 if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_POSIX) in f2fs_show_options()
2075 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT) in f2fs_show_options()
2077 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_NOBARRIER) in f2fs_show_options()
2081 f2fs_show_compress_options(seq, sbi->sb); in f2fs_show_options()
2084 if (test_opt(sbi, ATGC)) in f2fs_show_options()
2087 if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_NORMAL) in f2fs_show_options()
2089 else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW) in f2fs_show_options()
2092 if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_READONLY) in f2fs_show_options()
2094 else if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_CONTINUE) in f2fs_show_options()
2096 else if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_PANIC) in f2fs_show_options()
2102 static void default_options(struct f2fs_sb_info *sbi, bool remount) in default_options() argument
2106 set_opt(sbi, READ_EXTENT_CACHE); in default_options()
2107 clear_opt(sbi, DISABLE_CHECKPOINT); in default_options()
2109 if (f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi)) in default_options()
2110 set_opt(sbi, DISCARD); in default_options()
2112 if (f2fs_sb_has_blkzoned(sbi)) in default_options()
2113 F2FS_OPTION(sbi).discard_unit = DISCARD_UNIT_SECTION; in default_options()
2115 F2FS_OPTION(sbi).discard_unit = DISCARD_UNIT_BLOCK; in default_options()
2118 if (f2fs_sb_has_readonly(sbi)) in default_options()
2119 F2FS_OPTION(sbi).active_logs = NR_CURSEG_RO_TYPE; in default_options()
2121 F2FS_OPTION(sbi).active_logs = NR_CURSEG_PERSIST_TYPE; in default_options()
2123 F2FS_OPTION(sbi).inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS; in default_options()
2124 if (le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count_main) <= in default_options()
2126 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE; in default_options()
2128 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT; in default_options()
2129 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX; in default_options()
2130 F2FS_OPTION(sbi).s_resuid = make_kuid(&init_user_ns, F2FS_DEF_RESUID); in default_options()
2131 F2FS_OPTION(sbi).s_resgid = make_kgid(&init_user_ns, F2FS_DEF_RESGID); in default_options()
2132 if (f2fs_sb_has_compression(sbi)) { in default_options()
2133 F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZ4; in default_options()
2134 F2FS_OPTION(sbi).compress_log_size = MIN_COMPRESS_LOG_SIZE; in default_options()
2135 F2FS_OPTION(sbi).compress_ext_cnt = 0; in default_options()
2136 F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS; in default_options()
2138 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; in default_options()
2139 F2FS_OPTION(sbi).memory_mode = MEMORY_MODE_NORMAL; in default_options()
2140 F2FS_OPTION(sbi).errors = MOUNT_ERRORS_CONTINUE; in default_options()
2142 set_opt(sbi, INLINE_XATTR); in default_options()
2143 set_opt(sbi, INLINE_DATA); in default_options()
2144 set_opt(sbi, INLINE_DENTRY); in default_options()
2145 set_opt(sbi, MERGE_CHECKPOINT); in default_options()
2146 F2FS_OPTION(sbi).unusable_cap = 0; in default_options()
2147 sbi->sb->s_flags |= SB_LAZYTIME; in default_options()
2148 if (!f2fs_is_readonly(sbi)) in default_options()
2149 set_opt(sbi, FLUSH_MERGE); in default_options()
2150 if (f2fs_sb_has_blkzoned(sbi)) in default_options()
2151 F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS; in default_options()
2153 F2FS_OPTION(sbi).fs_mode = FS_MODE_ADAPTIVE; in default_options()
2156 set_opt(sbi, XATTR_USER); in default_options()
2159 set_opt(sbi, POSIX_ACL); in default_options()
2162 f2fs_build_fault_attr(sbi, 0, 0); in default_options()
2169 static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi) in f2fs_disable_checkpoint() argument
2171 unsigned int s_flags = sbi->sb->s_flags; in f2fs_disable_checkpoint()
2173 unsigned int gc_mode = sbi->gc_mode; in f2fs_disable_checkpoint()
2179 f2fs_err(sbi, "checkpoint=disable on readonly fs"); in f2fs_disable_checkpoint()
2182 sbi->sb->s_flags |= SB_ACTIVE; in f2fs_disable_checkpoint()
2185 unusable = f2fs_get_unusable_blocks(sbi); in f2fs_disable_checkpoint()
2186 if (!f2fs_disable_cp_again(sbi, unusable)) in f2fs_disable_checkpoint()
2189 f2fs_update_time(sbi, DISABLE_TIME); in f2fs_disable_checkpoint()
2191 sbi->gc_mode = GC_URGENT_HIGH; in f2fs_disable_checkpoint()
2193 while (!f2fs_time_over(sbi, DISABLE_TIME)) { in f2fs_disable_checkpoint()
2202 f2fs_down_write(&sbi->gc_lock); in f2fs_disable_checkpoint()
2203 stat_inc_gc_call_count(sbi, FOREGROUND); in f2fs_disable_checkpoint()
2204 err = f2fs_gc(sbi, &gc_control); in f2fs_disable_checkpoint()
2213 ret = sync_filesystem(sbi->sb); in f2fs_disable_checkpoint()
2219 unusable = f2fs_get_unusable_blocks(sbi); in f2fs_disable_checkpoint()
2220 if (f2fs_disable_cp_again(sbi, unusable)) { in f2fs_disable_checkpoint()
2226 f2fs_down_write(&sbi->gc_lock); in f2fs_disable_checkpoint()
2228 set_sbi_flag(sbi, SBI_CP_DISABLED); in f2fs_disable_checkpoint()
2229 stat_inc_cp_call_count(sbi, TOTAL_CALL); in f2fs_disable_checkpoint()
2230 err = f2fs_write_checkpoint(sbi, &cpc); in f2fs_disable_checkpoint()
2234 spin_lock(&sbi->stat_lock); in f2fs_disable_checkpoint()
2235 sbi->unusable_block_count = unusable; in f2fs_disable_checkpoint()
2236 spin_unlock(&sbi->stat_lock); in f2fs_disable_checkpoint()
2239 f2fs_up_write(&sbi->gc_lock); in f2fs_disable_checkpoint()
2241 sbi->gc_mode = gc_mode; in f2fs_disable_checkpoint()
2242 sbi->sb->s_flags = s_flags; /* Restore SB_RDONLY status */ in f2fs_disable_checkpoint()
2246 static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi) in f2fs_enable_checkpoint() argument
2252 sync_inodes_sb(sbi->sb); in f2fs_enable_checkpoint()
2254 } while (get_pages(sbi, F2FS_DIRTY_DATA) && retry--); in f2fs_enable_checkpoint()
2257 f2fs_warn(sbi, "checkpoint=enable has some unwritten data."); in f2fs_enable_checkpoint()
2259 f2fs_down_write(&sbi->gc_lock); in f2fs_enable_checkpoint()
2260 f2fs_dirty_to_prefree(sbi); in f2fs_enable_checkpoint()
2262 clear_sbi_flag(sbi, SBI_CP_DISABLED); in f2fs_enable_checkpoint()
2263 set_sbi_flag(sbi, SBI_IS_DIRTY); in f2fs_enable_checkpoint()
2264 f2fs_up_write(&sbi->gc_lock); in f2fs_enable_checkpoint()
2266 f2fs_sync_fs(sbi->sb, 1); in f2fs_enable_checkpoint()
2269 f2fs_flush_ckpt_thread(sbi); in f2fs_enable_checkpoint()
2274 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_remount() local
2282 bool no_read_extent_cache = !test_opt(sbi, READ_EXTENT_CACHE); in f2fs_remount()
2283 bool no_age_extent_cache = !test_opt(sbi, AGE_EXTENT_CACHE); in f2fs_remount()
2284 bool enable_checkpoint = !test_opt(sbi, DISABLE_CHECKPOINT); in f2fs_remount()
2285 bool no_atgc = !test_opt(sbi, ATGC); in f2fs_remount()
2286 bool no_discard = !test_opt(sbi, DISCARD); in f2fs_remount()
2287 bool no_compress_cache = !test_opt(sbi, COMPRESS_CACHE); in f2fs_remount()
2288 bool block_unit_discard = f2fs_block_unit_discard(sbi); in f2fs_remount()
2297 org_mount_opt = sbi->mount_opt; in f2fs_remount()
2301 org_mount_opt.s_jquota_fmt = F2FS_OPTION(sbi).s_jquota_fmt; in f2fs_remount()
2303 if (F2FS_OPTION(sbi).s_qf_names[i]) { in f2fs_remount()
2305 kstrdup(F2FS_OPTION(sbi).s_qf_names[i], in f2fs_remount()
2319 if (!(*flags & SB_RDONLY) && is_sbi_flag_set(sbi, SBI_NEED_SB_WRITE)) { in f2fs_remount()
2320 err = f2fs_commit_super(sbi, false); in f2fs_remount()
2321 f2fs_info(sbi, "Try to recover all the superblocks, ret: %d", in f2fs_remount()
2324 clear_sbi_flag(sbi, SBI_NEED_SB_WRITE); in f2fs_remount()
2327 default_options(sbi, true); in f2fs_remount()
2335 if (f2fs_sb_has_blkzoned(sbi) && in f2fs_remount()
2336 sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { in f2fs_remount()
2337 f2fs_err(sbi, in f2fs_remount()
2339 sbi->max_open_zones, F2FS_OPTION(sbi).active_logs); in f2fs_remount()
2346 flush_work(&sbi->s_error_work); in f2fs_remount()
2355 if (f2fs_dev_is_readonly(sbi) && !(*flags & SB_RDONLY)) { in f2fs_remount()
2370 } else if (f2fs_sb_has_quota_ino(sbi)) { in f2fs_remount()
2377 if (f2fs_lfs_mode(sbi) && !IS_F2FS_IPU_DISABLE(sbi)) { in f2fs_remount()
2379 f2fs_warn(sbi, "LFS is not compatible with IPU"); in f2fs_remount()
2384 if (no_atgc == !!test_opt(sbi, ATGC)) { in f2fs_remount()
2386 f2fs_warn(sbi, "switch atgc option is not allowed"); in f2fs_remount()
2391 if (no_read_extent_cache == !!test_opt(sbi, READ_EXTENT_CACHE)) { in f2fs_remount()
2393 f2fs_warn(sbi, "switch extent_cache option is not allowed"); in f2fs_remount()
2397 if (no_age_extent_cache == !!test_opt(sbi, AGE_EXTENT_CACHE)) { in f2fs_remount()
2399 f2fs_warn(sbi, "switch age_extent_cache option is not allowed"); in f2fs_remount()
2403 if (no_compress_cache == !!test_opt(sbi, COMPRESS_CACHE)) { in f2fs_remount()
2405 f2fs_warn(sbi, "switch compress_cache option is not allowed"); in f2fs_remount()
2409 if (block_unit_discard != f2fs_block_unit_discard(sbi)) { in f2fs_remount()
2411 f2fs_warn(sbi, "switch discard_unit option is not allowed"); in f2fs_remount()
2415 if ((*flags & SB_RDONLY) && test_opt(sbi, DISABLE_CHECKPOINT)) { in f2fs_remount()
2417 f2fs_warn(sbi, "disabling checkpoint not compatible with read-only"); in f2fs_remount()
2427 (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF && in f2fs_remount()
2428 !test_opt(sbi, GC_MERGE))) { in f2fs_remount()
2429 if (sbi->gc_thread) { in f2fs_remount()
2430 f2fs_stop_gc_thread(sbi); in f2fs_remount()
2433 } else if (!sbi->gc_thread) { in f2fs_remount()
2434 err = f2fs_start_gc_thread(sbi); in f2fs_remount()
2443 set_sbi_flag(sbi, SBI_IS_DIRTY); in f2fs_remount()
2444 set_sbi_flag(sbi, SBI_IS_CLOSE); in f2fs_remount()
2446 clear_sbi_flag(sbi, SBI_IS_CLOSE); in f2fs_remount()
2453 if ((*flags & SB_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) { in f2fs_remount()
2454 clear_opt(sbi, FLUSH_MERGE); in f2fs_remount()
2455 f2fs_destroy_flush_cmd_control(sbi, false); in f2fs_remount()
2458 err = f2fs_create_flush_cmd_control(sbi); in f2fs_remount()
2464 if (no_discard == !!test_opt(sbi, DISCARD)) { in f2fs_remount()
2465 if (test_opt(sbi, DISCARD)) { in f2fs_remount()
2466 err = f2fs_start_discard_thread(sbi); in f2fs_remount()
2471 f2fs_stop_discard_thread(sbi); in f2fs_remount()
2472 f2fs_issue_discard_timeout(sbi); in f2fs_remount()
2477 if (enable_checkpoint == !!test_opt(sbi, DISABLE_CHECKPOINT)) { in f2fs_remount()
2478 if (test_opt(sbi, DISABLE_CHECKPOINT)) { in f2fs_remount()
2479 err = f2fs_disable_checkpoint(sbi); in f2fs_remount()
2484 f2fs_enable_checkpoint(sbi); in f2fs_remount()
2494 if ((*flags & SB_RDONLY) || test_opt(sbi, DISABLE_CHECKPOINT) || in f2fs_remount()
2495 !test_opt(sbi, MERGE_CHECKPOINT)) { in f2fs_remount()
2496 f2fs_stop_ckpt_thread(sbi); in f2fs_remount()
2499 f2fs_flush_ckpt_thread(sbi); in f2fs_remount()
2501 err = f2fs_start_ckpt_thread(sbi); in f2fs_remount()
2503 f2fs_err(sbi, in f2fs_remount()
2518 (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0); in f2fs_remount()
2520 limit_reserve_root(sbi); in f2fs_remount()
2521 adjust_unusable_cap_perc(sbi); in f2fs_remount()
2526 f2fs_enable_checkpoint(sbi); in f2fs_remount()
2528 if (f2fs_disable_checkpoint(sbi)) in f2fs_remount()
2529 f2fs_warn(sbi, "checkpoint has not been disabled"); in f2fs_remount()
2533 if (f2fs_start_discard_thread(sbi)) in f2fs_remount()
2534 f2fs_warn(sbi, "discard has been stopped"); in f2fs_remount()
2536 f2fs_stop_discard_thread(sbi); in f2fs_remount()
2540 if (f2fs_create_flush_cmd_control(sbi)) in f2fs_remount()
2541 f2fs_warn(sbi, "background flush thread has stopped"); in f2fs_remount()
2543 clear_opt(sbi, FLUSH_MERGE); in f2fs_remount()
2544 f2fs_destroy_flush_cmd_control(sbi, false); in f2fs_remount()
2548 if (f2fs_start_gc_thread(sbi)) in f2fs_remount()
2549 f2fs_warn(sbi, "background gc thread has stopped"); in f2fs_remount()
2551 f2fs_stop_gc_thread(sbi); in f2fs_remount()
2555 F2FS_OPTION(sbi).s_jquota_fmt = org_mount_opt.s_jquota_fmt; in f2fs_remount()
2557 kfree(F2FS_OPTION(sbi).s_qf_names[i]); in f2fs_remount()
2558 F2FS_OPTION(sbi).s_qf_names[i] = org_mount_opt.s_qf_names[i]; in f2fs_remount()
2561 sbi->mount_opt = org_mount_opt; in f2fs_remount()
2572 static bool f2fs_need_recovery(struct f2fs_sb_info *sbi) in f2fs_need_recovery() argument
2575 if (is_set_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG)) in f2fs_need_recovery()
2578 if (test_opt(sbi, DISABLE_ROLL_FORWARD)) in f2fs_need_recovery()
2580 if (test_opt(sbi, NORECOVERY)) in f2fs_need_recovery()
2582 return !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG); in f2fs_need_recovery()
2585 static bool f2fs_recover_quota_begin(struct f2fs_sb_info *sbi) in f2fs_recover_quota_begin() argument
2587 bool readonly = f2fs_readonly(sbi->sb); in f2fs_recover_quota_begin()
2589 if (!f2fs_need_recovery(sbi)) in f2fs_recover_quota_begin()
2593 if (f2fs_hw_is_readonly(sbi)) in f2fs_recover_quota_begin()
2597 sbi->sb->s_flags &= ~SB_RDONLY; in f2fs_recover_quota_begin()
2598 set_sbi_flag(sbi, SBI_IS_WRITABLE); in f2fs_recover_quota_begin()
2605 return f2fs_enable_quota_files(sbi, readonly); in f2fs_recover_quota_begin()
2608 static void f2fs_recover_quota_end(struct f2fs_sb_info *sbi, in f2fs_recover_quota_end() argument
2612 f2fs_quota_off_umount(sbi->sb); in f2fs_recover_quota_end()
2614 if (is_sbi_flag_set(sbi, SBI_IS_WRITABLE)) { in f2fs_recover_quota_end()
2615 clear_sbi_flag(sbi, SBI_IS_WRITABLE); in f2fs_recover_quota_end()
2616 sbi->sb->s_flags |= SB_RDONLY; in f2fs_recover_quota_end()
2740 static int f2fs_quota_on_mount(struct f2fs_sb_info *sbi, int type) in f2fs_quota_on_mount() argument
2742 if (is_set_ckpt_flags(sbi, CP_QUOTA_NEED_FSCK_FLAG)) { in f2fs_quota_on_mount()
2743 f2fs_err(sbi, "quota sysfile may be corrupted, skip loading it"); in f2fs_quota_on_mount()
2747 return dquot_quota_on_mount(sbi->sb, F2FS_OPTION(sbi).s_qf_names[type], in f2fs_quota_on_mount()
2748 F2FS_OPTION(sbi).s_jquota_fmt, type); in f2fs_quota_on_mount()
2751 int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly) in f2fs_enable_quota_files() argument
2756 if (f2fs_sb_has_quota_ino(sbi) && rdonly) { in f2fs_enable_quota_files()
2757 err = f2fs_enable_quotas(sbi->sb); in f2fs_enable_quota_files()
2759 f2fs_err(sbi, "Cannot turn on quota_ino: %d", err); in f2fs_enable_quota_files()
2766 if (F2FS_OPTION(sbi).s_qf_names[i]) { in f2fs_enable_quota_files()
2767 err = f2fs_quota_on_mount(sbi, i); in f2fs_enable_quota_files()
2772 f2fs_err(sbi, "Cannot turn on quotas: %d on %d", in f2fs_enable_quota_files()
2816 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_enable_quotas() local
2820 test_opt(sbi, USRQUOTA), in f2fs_enable_quotas()
2821 test_opt(sbi, GRPQUOTA), in f2fs_enable_quotas()
2822 test_opt(sbi, PRJQUOTA), in f2fs_enable_quotas()
2826 f2fs_err(sbi, "quota file may be corrupted, skip loading it"); in f2fs_enable_quotas()
2839 f2fs_err(sbi, "Failed to enable quota tracking (type=%d, err=%d). Please run fsck to fix.", in f2fs_enable_quotas()
2852 static int f2fs_quota_sync_file(struct f2fs_sb_info *sbi, int type) in f2fs_quota_sync_file() argument
2854 struct quota_info *dqopt = sb_dqopt(sbi->sb); in f2fs_quota_sync_file()
2858 ret = dquot_writeback_dquots(sbi->sb, type); in f2fs_quota_sync_file()
2867 if (is_journalled_quota(sbi)) in f2fs_quota_sync_file()
2875 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_quota_sync_file()
2881 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_quota_sync() local
2898 if (!f2fs_sb_has_quota_ino(sbi)) in f2fs_quota_sync()
2910 f2fs_lock_op(sbi); in f2fs_quota_sync()
2911 f2fs_down_read(&sbi->quota_sem); in f2fs_quota_sync()
2913 ret = f2fs_quota_sync_file(sbi, cnt); in f2fs_quota_sync()
2915 f2fs_up_read(&sbi->quota_sem); in f2fs_quota_sync()
2916 f2fs_unlock_op(sbi); in f2fs_quota_sync()
2918 if (!f2fs_sb_has_quota_ino(sbi)) in f2fs_quota_sync()
2997 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_quota_off() local
3007 if (is_journalled_quota(sbi)) in f2fs_quota_off()
3008 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_quota_off()
3049 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb); in f2fs_dquot_commit() local
3052 f2fs_down_read_nested(&sbi->quota_sem, SINGLE_DEPTH_NESTING); in f2fs_dquot_commit()
3055 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_dquot_commit()
3056 f2fs_up_read(&sbi->quota_sem); in f2fs_dquot_commit()
3062 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb); in f2fs_dquot_acquire() local
3065 f2fs_down_read(&sbi->quota_sem); in f2fs_dquot_acquire()
3068 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_dquot_acquire()
3069 f2fs_up_read(&sbi->quota_sem); in f2fs_dquot_acquire()
3075 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb); in f2fs_dquot_release() local
3079 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_dquot_release()
3086 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_dquot_mark_dquot_dirty() local
3090 if (is_journalled_quota(sbi)) in f2fs_dquot_mark_dquot_dirty()
3091 set_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH); in f2fs_dquot_mark_dquot_dirty()
3098 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_dquot_commit_info() local
3102 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_dquot_commit_info()
3184 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_set_context() local
3192 if (f2fs_sb_has_lost_found(sbi) && in f2fs_set_context()
3193 inode->i_ino == F2FS_ROOT_INO(sbi)) in f2fs_set_context()
3214 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_get_devices() local
3218 if (!f2fs_is_multi_device(sbi)) in f2fs_get_devices()
3221 devs = kmalloc_array(sbi->s_ndevs, sizeof(*devs), GFP_KERNEL); in f2fs_get_devices()
3225 for (i = 0; i < sbi->s_ndevs; i++) in f2fs_get_devices()
3227 *num_devs = sbi->s_ndevs; in f2fs_get_devices()
3248 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_nfs_get_inode() local
3251 if (f2fs_check_nid_range(sbi, ino)) in f2fs_nfs_get_inode()
3330 static int __f2fs_commit_super(struct f2fs_sb_info *sbi, struct folio *folio, in __f2fs_commit_super() argument
3341 memcpy(F2FS_SUPER_BLOCK(folio, index), F2FS_RAW_SUPER(sbi), in __f2fs_commit_super()
3348 bio = bio_alloc(sbi->sb->s_bdev, 1, opf, GFP_NOFS); in __f2fs_commit_super()
3354 f2fs_bug_on(sbi, 1); in __f2fs_commit_super()
3362 static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi, in sanity_check_area_boundary() argument
3366 struct super_block *sb = sbi->sb; in sanity_check_area_boundary()
3386 f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)", in sanity_check_area_boundary()
3393 f2fs_info(sbi, "Wrong CP boundary, start(%u) end(%u) blocks(%u)", in sanity_check_area_boundary()
3401 f2fs_info(sbi, "Wrong SIT boundary, start(%u) end(%u) blocks(%u)", in sanity_check_area_boundary()
3409 f2fs_info(sbi, "Wrong NAT boundary, start(%u) end(%u) blocks(%u)", in sanity_check_area_boundary()
3417 f2fs_info(sbi, "Wrong SSA boundary, start(%u) end(%u) blocks(%u)", in sanity_check_area_boundary()
3424 f2fs_info(sbi, "Wrong MAIN_AREA boundary, start(%u) end(%llu) block(%u)", in sanity_check_area_boundary()
3436 if (f2fs_readonly(sb) || f2fs_hw_is_readonly(sbi)) { in sanity_check_area_boundary()
3437 set_sbi_flag(sbi, SBI_NEED_SB_WRITE); in sanity_check_area_boundary()
3440 err = __f2fs_commit_super(sbi, folio, index, false); in sanity_check_area_boundary()
3443 f2fs_info(sbi, "Fix alignment : %s, start(%u) end(%llu) block(%u)", in sanity_check_area_boundary()
3452 static int sanity_check_raw_super(struct f2fs_sb_info *sbi, in sanity_check_raw_super() argument
3462 f2fs_info(sbi, "Magic Mismatch, valid(0x%x) - read(0x%x)", in sanity_check_raw_super()
3472 f2fs_info(sbi, "Invalid SB checksum offset: %zu", in sanity_check_raw_super()
3477 if (!f2fs_crc_valid(sbi, crc, raw_super, crc_offset)) { in sanity_check_raw_super()
3478 f2fs_info(sbi, "Invalid SB checksum value: %u", crc); in sanity_check_raw_super()
3485 f2fs_info(sbi, "Invalid log_blocksize (%u), supports only %u", in sanity_check_raw_super()
3493 f2fs_info(sbi, "Invalid log blocks per segment (%u)", in sanity_check_raw_super()
3503 f2fs_info(sbi, "Invalid log sectorsize (%u)", in sanity_check_raw_super()
3510 f2fs_info(sbi, "Invalid log sectors per block(%u) log sectorsize(%u)", in sanity_check_raw_super()
3527 f2fs_info(sbi, "Invalid segment count (%u)", segment_count); in sanity_check_raw_super()
3533 f2fs_info(sbi, "Invalid segment/section count (%u, %u x %u)", in sanity_check_raw_super()
3539 f2fs_info(sbi, "Invalid segment/section count (%u != %u * %u)", in sanity_check_raw_super()
3545 f2fs_info(sbi, "Small segment_count (%u < %u * %u)", in sanity_check_raw_super()
3551 f2fs_info(sbi, "Wrong segment_count / block_count (%u > %llu)", in sanity_check_raw_super()
3565 f2fs_info(sbi, "Segment count (%u) mismatch with total segments from devices (%u)", in sanity_check_raw_super()
3571 !bdev_is_zoned(sbi->sb->s_bdev)) { in sanity_check_raw_super()
3572 f2fs_info(sbi, "Zoned block device path is missing"); in sanity_check_raw_super()
3578 f2fs_info(sbi, "Wrong secs_per_zone / total_sections (%u, %u)", in sanity_check_raw_super()
3586 f2fs_info(sbi, "Corrupted extension count (%u + %u > %u)", in sanity_check_raw_super()
3596 f2fs_info(sbi, "Insane cp_payload (%u >= %u)", in sanity_check_raw_super()
3607 f2fs_info(sbi, "Invalid Fs Meta Ino: node(%u) meta(%u) root(%u)", in sanity_check_raw_super()
3615 if (sanity_check_area_boundary(sbi, folio, index)) in sanity_check_raw_super()
3621 int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) in f2fs_sanity_check_ckpt() argument
3624 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); in f2fs_sanity_check_ckpt()
3625 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); in f2fs_sanity_check_ckpt()
3653 if (!f2fs_sb_has_readonly(sbi) && in f2fs_sanity_check_ckpt()
3656 f2fs_err(sbi, "Wrong layout: check mkfs.f2fs version"); in f2fs_sanity_check_ckpt()
3661 (f2fs_sb_has_readonly(sbi) ? 1 : 0); in f2fs_sanity_check_ckpt()
3665 f2fs_err(sbi, "Wrong user_block_count: %u", in f2fs_sanity_check_ckpt()
3672 f2fs_err(sbi, "Wrong valid_user_blocks: %u, user_block_count: %u", in f2fs_sanity_check_ckpt()
3678 avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM; in f2fs_sanity_check_ckpt()
3680 f2fs_err(sbi, "Wrong valid_node_count: %u, avail_node_count: %u", in f2fs_sanity_check_ckpt()
3686 blocks_per_seg = BLKS_PER_SEG(sbi); in f2fs_sanity_check_ckpt()
3693 if (f2fs_sb_has_readonly(sbi)) in f2fs_sanity_check_ckpt()
3699 f2fs_err(sbi, "Node segment (%u, %u) has the same segno: %u", in f2fs_sanity_check_ckpt()
3712 if (f2fs_sb_has_readonly(sbi)) in f2fs_sanity_check_ckpt()
3718 f2fs_err(sbi, "Data segment (%u, %u) has the same segno: %u", in f2fs_sanity_check_ckpt()
3729 f2fs_err(sbi, "Node segment (%u) and Data segment (%u) has the same segno: %u", in f2fs_sanity_check_ckpt()
3742 f2fs_err(sbi, "Wrong bitmap size: sit: %u, nat:%u", in f2fs_sanity_check_ckpt()
3747 cp_pack_start_sum = __start_sum_addr(sbi); in f2fs_sanity_check_ckpt()
3748 cp_payload = __cp_payload(sbi); in f2fs_sanity_check_ckpt()
3752 f2fs_err(sbi, "Wrong cp_pack_start_sum: %u", in f2fs_sanity_check_ckpt()
3759 f2fs_warn(sbi, "using deprecated layout of large_nat_bitmap, " in f2fs_sanity_check_ckpt()
3772 f2fs_warn(sbi, "Insane cp_payload: %u, nat_bits_blocks: %u)", in f2fs_sanity_check_ckpt()
3777 if (unlikely(f2fs_cp_error(sbi))) { in f2fs_sanity_check_ckpt()
3778 f2fs_err(sbi, "A bug case: need to run fsck"); in f2fs_sanity_check_ckpt()
3784 static void init_sb_info(struct f2fs_sb_info *sbi) in init_sb_info() argument
3786 struct f2fs_super_block *raw_super = sbi->raw_super; in init_sb_info()
3789 sbi->log_sectors_per_block = in init_sb_info()
3791 sbi->log_blocksize = le32_to_cpu(raw_super->log_blocksize); in init_sb_info()
3792 sbi->blocksize = BIT(sbi->log_blocksize); in init_sb_info()
3793 sbi->log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg); in init_sb_info()
3794 sbi->blocks_per_seg = BIT(sbi->log_blocks_per_seg); in init_sb_info()
3795 sbi->segs_per_sec = le32_to_cpu(raw_super->segs_per_sec); in init_sb_info()
3796 sbi->secs_per_zone = le32_to_cpu(raw_super->secs_per_zone); in init_sb_info()
3797 sbi->total_sections = le32_to_cpu(raw_super->section_count); in init_sb_info()
3798 sbi->total_node_count = SEGS_TO_BLKS(sbi, in init_sb_info()
3801 F2FS_ROOT_INO(sbi) = le32_to_cpu(raw_super->root_ino); in init_sb_info()
3802 F2FS_NODE_INO(sbi) = le32_to_cpu(raw_super->node_ino); in init_sb_info()
3803 F2FS_META_INO(sbi) = le32_to_cpu(raw_super->meta_ino); in init_sb_info()
3804 sbi->cur_victim_sec = NULL_SECNO; in init_sb_info()
3805 sbi->gc_mode = GC_NORMAL; in init_sb_info()
3806 sbi->next_victim_seg[BG_GC] = NULL_SEGNO; in init_sb_info()
3807 sbi->next_victim_seg[FG_GC] = NULL_SEGNO; in init_sb_info()
3808 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH; in init_sb_info()
3809 sbi->migration_granularity = SEGS_PER_SEC(sbi); in init_sb_info()
3810 sbi->migration_window_granularity = f2fs_sb_has_blkzoned(sbi) ? in init_sb_info()
3811 DEF_MIGRATION_WINDOW_GRANULARITY_ZONED : SEGS_PER_SEC(sbi); in init_sb_info()
3812 sbi->seq_file_ra_mul = MIN_RA_MUL; in init_sb_info()
3813 sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE; in init_sb_info()
3814 sbi->max_fragment_hole = DEF_FRAGMENT_SIZE; in init_sb_info()
3815 spin_lock_init(&sbi->gc_remaining_trials_lock); in init_sb_info()
3816 atomic64_set(&sbi->current_atomic_write, 0); in init_sb_info()
3818 sbi->dir_level = DEF_DIR_LEVEL; in init_sb_info()
3819 sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL; in init_sb_info()
3820 sbi->interval_time[REQ_TIME] = DEF_IDLE_INTERVAL; in init_sb_info()
3821 sbi->interval_time[DISCARD_TIME] = DEF_IDLE_INTERVAL; in init_sb_info()
3822 sbi->interval_time[GC_TIME] = DEF_IDLE_INTERVAL; in init_sb_info()
3823 sbi->interval_time[DISABLE_TIME] = DEF_DISABLE_INTERVAL; in init_sb_info()
3824 sbi->interval_time[UMOUNT_DISCARD_TIMEOUT] = in init_sb_info()
3826 clear_sbi_flag(sbi, SBI_NEED_FSCK); in init_sb_info()
3829 atomic_set(&sbi->nr_pages[i], 0); in init_sb_info()
3832 atomic_set(&sbi->wb_sync_req[i], 0); in init_sb_info()
3834 INIT_LIST_HEAD(&sbi->s_list); in init_sb_info()
3835 mutex_init(&sbi->umount_mutex); in init_sb_info()
3836 init_f2fs_rwsem(&sbi->io_order_lock); in init_sb_info()
3837 spin_lock_init(&sbi->cp_lock); in init_sb_info()
3839 sbi->dirty_device = 0; in init_sb_info()
3840 spin_lock_init(&sbi->dev_lock); in init_sb_info()
3842 init_f2fs_rwsem(&sbi->sb_lock); in init_sb_info()
3843 init_f2fs_rwsem(&sbi->pin_sem); in init_sb_info()
3846 static int init_percpu_info(struct f2fs_sb_info *sbi) in init_percpu_info() argument
3850 err = percpu_counter_init(&sbi->alloc_valid_block_count, 0, GFP_KERNEL); in init_percpu_info()
3854 err = percpu_counter_init(&sbi->rf_node_block_count, 0, GFP_KERNEL); in init_percpu_info()
3858 err = percpu_counter_init(&sbi->total_valid_inode_count, 0, in init_percpu_info()
3865 percpu_counter_destroy(&sbi->rf_node_block_count); in init_percpu_info()
3867 percpu_counter_destroy(&sbi->alloc_valid_block_count); in init_percpu_info()
3874 struct f2fs_sb_info *sbi; member
3889 if (!rz_args->sbi->unusable_blocks_per_sec) { in f2fs_report_zone_cb()
3890 rz_args->sbi->unusable_blocks_per_sec = unusable_blocks; in f2fs_report_zone_cb()
3893 if (rz_args->sbi->unusable_blocks_per_sec != unusable_blocks) { in f2fs_report_zone_cb()
3894 f2fs_err(rz_args->sbi, "F2FS supports single zone capacity\n"); in f2fs_report_zone_cb()
3900 static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) in init_blkz_info() argument
3909 if (!f2fs_sb_has_blkzoned(sbi)) in init_blkz_info()
3914 if (max_open_zones && (max_open_zones < sbi->max_open_zones)) in init_blkz_info()
3915 sbi->max_open_zones = max_open_zones; in init_blkz_info()
3916 if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { in init_blkz_info()
3917 f2fs_err(sbi, in init_blkz_info()
3919 sbi->max_open_zones, F2FS_OPTION(sbi).active_logs); in init_blkz_info()
3925 if (sbi->blocks_per_blkz && sbi->blocks_per_blkz != in init_blkz_info()
3928 sbi->blocks_per_blkz = SECTOR_TO_BLOCK(zone_sectors); in init_blkz_info()
3930 sbi->blocks_per_blkz); in init_blkz_info()
3934 FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi, in init_blkz_info()
3941 rep_zone_arg.sbi = sbi; in init_blkz_info()
3958 static int read_raw_super_block(struct f2fs_sb_info *sbi, in read_raw_super_block() argument
3962 struct super_block *sb = sbi->sb; in read_raw_super_block()
3975 f2fs_err(sbi, "Unable to read %dth superblock", in read_raw_super_block()
3983 err = sanity_check_raw_super(sbi, folio, block); in read_raw_super_block()
3985 f2fs_err(sbi, "Can't find valid F2FS filesystem in %dth superblock", in read_raw_super_block()
4010 int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) in f2fs_commit_super() argument
4017 if ((recover && f2fs_readonly(sbi->sb)) || in f2fs_commit_super()
4018 f2fs_hw_is_readonly(sbi)) { in f2fs_commit_super()
4019 set_sbi_flag(sbi, SBI_NEED_SB_WRITE); in f2fs_commit_super()
4024 if (!recover && f2fs_sb_has_sb_chksum(sbi)) { in f2fs_commit_super()
4025 crc = f2fs_crc32(sbi, F2FS_RAW_SUPER(sbi), in f2fs_commit_super()
4027 F2FS_RAW_SUPER(sbi)->crc = cpu_to_le32(crc); in f2fs_commit_super()
4031 index = sbi->valid_super_block ? 0 : 1; in f2fs_commit_super()
4032 folio = read_mapping_folio(sbi->sb->s_bdev->bd_mapping, index, NULL); in f2fs_commit_super()
4035 err = __f2fs_commit_super(sbi, folio, index, true); in f2fs_commit_super()
4043 index = sbi->valid_super_block; in f2fs_commit_super()
4044 folio = read_mapping_folio(sbi->sb->s_bdev->bd_mapping, index, NULL); in f2fs_commit_super()
4047 err = __f2fs_commit_super(sbi, folio, index, true); in f2fs_commit_super()
4052 static void save_stop_reason(struct f2fs_sb_info *sbi, unsigned char reason) in save_stop_reason() argument
4056 spin_lock_irqsave(&sbi->error_lock, flags); in save_stop_reason()
4057 if (sbi->stop_reason[reason] < GENMASK(BITS_PER_BYTE - 1, 0)) in save_stop_reason()
4058 sbi->stop_reason[reason]++; in save_stop_reason()
4059 spin_unlock_irqrestore(&sbi->error_lock, flags); in save_stop_reason()
4062 static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi) in f2fs_record_stop_reason() argument
4064 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); in f2fs_record_stop_reason()
4068 f2fs_down_write(&sbi->sb_lock); in f2fs_record_stop_reason()
4070 spin_lock_irqsave(&sbi->error_lock, flags); in f2fs_record_stop_reason()
4071 if (sbi->error_dirty) { in f2fs_record_stop_reason()
4072 memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors, in f2fs_record_stop_reason()
4074 sbi->error_dirty = false; in f2fs_record_stop_reason()
4076 memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON); in f2fs_record_stop_reason()
4077 spin_unlock_irqrestore(&sbi->error_lock, flags); in f2fs_record_stop_reason()
4079 err = f2fs_commit_super(sbi, false); in f2fs_record_stop_reason()
4081 f2fs_up_write(&sbi->sb_lock); in f2fs_record_stop_reason()
4083 f2fs_err_ratelimited(sbi, in f2fs_record_stop_reason()
4088 void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag) in f2fs_save_errors() argument
4092 spin_lock_irqsave(&sbi->error_lock, flags); in f2fs_save_errors()
4093 if (!test_bit(flag, (unsigned long *)sbi->errors)) { in f2fs_save_errors()
4094 set_bit(flag, (unsigned long *)sbi->errors); in f2fs_save_errors()
4095 sbi->error_dirty = true; in f2fs_save_errors()
4097 spin_unlock_irqrestore(&sbi->error_lock, flags); in f2fs_save_errors()
4100 static bool f2fs_update_errors(struct f2fs_sb_info *sbi) in f2fs_update_errors() argument
4105 spin_lock_irqsave(&sbi->error_lock, flags); in f2fs_update_errors()
4106 if (sbi->error_dirty) { in f2fs_update_errors()
4107 memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors, in f2fs_update_errors()
4109 sbi->error_dirty = false; in f2fs_update_errors()
4112 spin_unlock_irqrestore(&sbi->error_lock, flags); in f2fs_update_errors()
4117 static void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error) in f2fs_record_errors() argument
4121 f2fs_down_write(&sbi->sb_lock); in f2fs_record_errors()
4123 if (!f2fs_update_errors(sbi)) in f2fs_record_errors()
4126 err = f2fs_commit_super(sbi, false); in f2fs_record_errors()
4128 f2fs_err_ratelimited(sbi, in f2fs_record_errors()
4132 f2fs_up_write(&sbi->sb_lock); in f2fs_record_errors()
4135 void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error) in f2fs_handle_error() argument
4137 f2fs_save_errors(sbi, error); in f2fs_handle_error()
4138 f2fs_record_errors(sbi, error); in f2fs_handle_error()
4141 void f2fs_handle_error_async(struct f2fs_sb_info *sbi, unsigned char error) in f2fs_handle_error_async() argument
4143 f2fs_save_errors(sbi, error); in f2fs_handle_error_async()
4145 if (!sbi->error_dirty) in f2fs_handle_error_async()
4147 if (!test_bit(error, (unsigned long *)sbi->errors)) in f2fs_handle_error_async()
4149 schedule_work(&sbi->s_error_work); in f2fs_handle_error_async()
4158 void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason, in f2fs_handle_critical_error() argument
4161 struct super_block *sb = sbi->sb; in f2fs_handle_critical_error()
4164 F2FS_OPTION(sbi).errors == MOUNT_ERRORS_CONTINUE; in f2fs_handle_critical_error()
4166 set_ckpt_flags(sbi, CP_ERROR_FLAG); in f2fs_handle_critical_error()
4168 if (!f2fs_hw_is_readonly(sbi)) { in f2fs_handle_critical_error()
4169 save_stop_reason(sbi, reason); in f2fs_handle_critical_error()
4172 schedule_work(&sbi->s_error_work); in f2fs_handle_critical_error()
4174 f2fs_record_stop_reason(sbi); in f2fs_handle_critical_error()
4182 if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_PANIC && in f2fs_handle_critical_error()
4184 !is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)) in f2fs_handle_critical_error()
4189 set_sbi_flag(sbi, SBI_IS_SHUTDOWN); in f2fs_handle_critical_error()
4197 f2fs_warn(sbi, "Stopped filesystem due to reason: %d", reason); in f2fs_handle_critical_error()
4201 f2fs_warn(sbi, "Remounting filesystem read-only"); in f2fs_handle_critical_error()
4214 struct f2fs_sb_info *sbi = container_of(work, in f2fs_record_error_work() local
4217 f2fs_record_stop_reason(sbi); in f2fs_record_error_work()
4220 static int f2fs_scan_devices(struct f2fs_sb_info *sbi) in f2fs_scan_devices() argument
4222 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); in f2fs_scan_devices()
4225 blk_mode_t mode = sb_open_mode(sbi->sb->s_flags); in f2fs_scan_devices()
4230 if (!bdev_is_zoned(sbi->sb->s_bdev)) in f2fs_scan_devices()
4239 sbi->devs = f2fs_kzalloc(sbi, in f2fs_scan_devices()
4243 if (!sbi->devs) in f2fs_scan_devices()
4246 logical_blksize = bdev_logical_block_size(sbi->sb->s_bdev); in f2fs_scan_devices()
4247 sbi->aligned_blksize = true; in f2fs_scan_devices()
4249 sbi->max_open_zones = UINT_MAX; in f2fs_scan_devices()
4250 sbi->blkzone_alloc_policy = BLKZONE_ALLOC_PRIOR_SEQ; in f2fs_scan_devices()
4255 FDEV(0).bdev_file = sbi->sb->s_bdev_file; in f2fs_scan_devices()
4267 SEGS_TO_BLKS(sbi, in f2fs_scan_devices()
4273 SEGS_TO_BLKS(sbi, in f2fs_scan_devices()
4276 FDEV(i).path, mode, sbi->sb, NULL); in f2fs_scan_devices()
4284 sbi->s_ndevs = i + 1; in f2fs_scan_devices()
4287 sbi->aligned_blksize = false; in f2fs_scan_devices()
4291 if (!f2fs_sb_has_blkzoned(sbi)) { in f2fs_scan_devices()
4292 f2fs_err(sbi, "Zoned block device feature not enabled"); in f2fs_scan_devices()
4295 if (init_blkz_info(sbi, i)) { in f2fs_scan_devices()
4296 f2fs_err(sbi, "Failed to initialize F2FS blkzone information"); in f2fs_scan_devices()
4301 f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: Host-managed)", in f2fs_scan_devices()
4308 f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x", in f2fs_scan_devices()
4316 static int f2fs_setup_casefold(struct f2fs_sb_info *sbi) in f2fs_setup_casefold() argument
4319 if (f2fs_sb_has_casefold(sbi) && !sbi->sb->s_encoding) { in f2fs_setup_casefold()
4324 encoding_info = f2fs_sb_read_encoding(sbi->raw_super); in f2fs_setup_casefold()
4326 f2fs_err(sbi, in f2fs_setup_casefold()
4331 encoding_flags = le16_to_cpu(sbi->raw_super->s_encoding_flags); in f2fs_setup_casefold()
4334 f2fs_err(sbi, in f2fs_setup_casefold()
4344 f2fs_info(sbi, "Using encoding defined by superblock: " in f2fs_setup_casefold()
4351 sbi->sb->s_encoding = encoding; in f2fs_setup_casefold()
4352 sbi->sb->s_encoding_flags = encoding_flags; in f2fs_setup_casefold()
4355 if (f2fs_sb_has_casefold(sbi)) { in f2fs_setup_casefold()
4356 f2fs_err(sbi, "Filesystem with casefold feature cannot be mounted without CONFIG_UNICODE"); in f2fs_setup_casefold()
4363 static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi) in f2fs_tuning_parameters() argument
4366 if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) { in f2fs_tuning_parameters()
4367 if (f2fs_block_unit_discard(sbi)) in f2fs_tuning_parameters()
4368 SM_I(sbi)->dcc_info->discard_granularity = in f2fs_tuning_parameters()
4370 if (!f2fs_lfs_mode(sbi)) in f2fs_tuning_parameters()
4371 SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) | in f2fs_tuning_parameters()
4375 sbi->readdir_ra = true; in f2fs_tuning_parameters()
4380 struct f2fs_sb_info *sbi; in f2fs_fill_super() local
4400 sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL); in f2fs_fill_super()
4401 if (!sbi) in f2fs_fill_super()
4404 sbi->sb = sb; in f2fs_fill_super()
4407 init_f2fs_rwsem(&sbi->gc_lock); in f2fs_fill_super()
4408 mutex_init(&sbi->writepages); in f2fs_fill_super()
4409 init_f2fs_rwsem(&sbi->cp_global_sem); in f2fs_fill_super()
4410 init_f2fs_rwsem(&sbi->node_write); in f2fs_fill_super()
4411 init_f2fs_rwsem(&sbi->node_change); in f2fs_fill_super()
4412 spin_lock_init(&sbi->stat_lock); in f2fs_fill_super()
4413 init_f2fs_rwsem(&sbi->cp_rwsem); in f2fs_fill_super()
4414 init_f2fs_rwsem(&sbi->quota_sem); in f2fs_fill_super()
4415 init_waitqueue_head(&sbi->cp_wait); in f2fs_fill_super()
4416 spin_lock_init(&sbi->error_lock); in f2fs_fill_super()
4419 INIT_LIST_HEAD(&sbi->inode_list[i]); in f2fs_fill_super()
4420 spin_lock_init(&sbi->inode_lock[i]); in f2fs_fill_super()
4422 mutex_init(&sbi->flush_lock); in f2fs_fill_super()
4425 sbi->s_chksum_driver = crypto_alloc_shash("crc32", 0, 0); in f2fs_fill_super()
4426 if (IS_ERR(sbi->s_chksum_driver)) { in f2fs_fill_super()
4427 f2fs_err(sbi, "Cannot load crc32 driver."); in f2fs_fill_super()
4428 err = PTR_ERR(sbi->s_chksum_driver); in f2fs_fill_super()
4429 sbi->s_chksum_driver = NULL; in f2fs_fill_super()
4435 f2fs_err(sbi, "unable to set blocksize"); in f2fs_fill_super()
4439 err = read_raw_super_block(sbi, &raw_super, &valid_super_block, in f2fs_fill_super()
4444 sb->s_fs_info = sbi; in f2fs_fill_super()
4445 sbi->raw_super = raw_super; in f2fs_fill_super()
4447 INIT_WORK(&sbi->s_error_work, f2fs_record_error_work); in f2fs_fill_super()
4448 memcpy(sbi->errors, raw_super->s_errors, MAX_F2FS_ERRORS); in f2fs_fill_super()
4449 memcpy(sbi->stop_reason, raw_super->s_stop_reason, MAX_STOP_REASON); in f2fs_fill_super()
4452 if (f2fs_sb_has_inode_chksum(sbi)) in f2fs_fill_super()
4453 sbi->s_chksum_seed = f2fs_chksum(sbi, ~0, raw_super->uuid, in f2fs_fill_super()
4456 default_options(sbi, false); in f2fs_fill_super()
4472 err = f2fs_setup_casefold(sbi); in f2fs_fill_super()
4481 if (f2fs_sb_has_quota_ino(sbi)) { in f2fs_fill_super()
4483 if (f2fs_qf_ino(sbi->sb, i)) in f2fs_fill_super()
4484 sbi->nquota_files++; in f2fs_fill_super()
4501 (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0); in f2fs_fill_super()
4507 sbi->valid_super_block = valid_super_block; in f2fs_fill_super()
4510 set_sbi_flag(sbi, SBI_POR_DOING); in f2fs_fill_super()
4512 err = f2fs_init_write_merge_io(sbi); in f2fs_fill_super()
4516 init_sb_info(sbi); in f2fs_fill_super()
4518 err = f2fs_init_iostat(sbi); in f2fs_fill_super()
4522 err = init_percpu_info(sbi); in f2fs_fill_super()
4526 /* init per sbi slab cache */ in f2fs_fill_super()
4527 err = f2fs_init_xattr_caches(sbi); in f2fs_fill_super()
4530 err = f2fs_init_page_array_cache(sbi); in f2fs_fill_super()
4535 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi)); in f2fs_fill_super()
4536 if (IS_ERR(sbi->meta_inode)) { in f2fs_fill_super()
4537 f2fs_err(sbi, "Failed to read F2FS meta data inode"); in f2fs_fill_super()
4538 err = PTR_ERR(sbi->meta_inode); in f2fs_fill_super()
4542 err = f2fs_get_valid_checkpoint(sbi); in f2fs_fill_super()
4544 f2fs_err(sbi, "Failed to get valid F2FS checkpoint"); in f2fs_fill_super()
4548 if (__is_set_ckpt_flags(F2FS_CKPT(sbi), CP_QUOTA_NEED_FSCK_FLAG)) in f2fs_fill_super()
4549 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_fill_super()
4550 if (__is_set_ckpt_flags(F2FS_CKPT(sbi), CP_DISABLED_QUICK_FLAG)) { in f2fs_fill_super()
4551 set_sbi_flag(sbi, SBI_CP_DISABLED_QUICK); in f2fs_fill_super()
4552 sbi->interval_time[DISABLE_TIME] = DEF_DISABLE_QUICK_INTERVAL; in f2fs_fill_super()
4555 if (__is_set_ckpt_flags(F2FS_CKPT(sbi), CP_FSCK_FLAG)) in f2fs_fill_super()
4556 set_sbi_flag(sbi, SBI_NEED_FSCK); in f2fs_fill_super()
4559 err = f2fs_scan_devices(sbi); in f2fs_fill_super()
4561 f2fs_err(sbi, "Failed to find devices"); in f2fs_fill_super()
4565 err = f2fs_init_post_read_wq(sbi); in f2fs_fill_super()
4567 f2fs_err(sbi, "Failed to initialize post read workqueue"); in f2fs_fill_super()
4571 sbi->total_valid_node_count = in f2fs_fill_super()
4572 le32_to_cpu(sbi->ckpt->valid_node_count); in f2fs_fill_super()
4573 percpu_counter_set(&sbi->total_valid_inode_count, in f2fs_fill_super()
4574 le32_to_cpu(sbi->ckpt->valid_inode_count)); in f2fs_fill_super()
4575 sbi->user_block_count = le64_to_cpu(sbi->ckpt->user_block_count); in f2fs_fill_super()
4576 sbi->total_valid_block_count = in f2fs_fill_super()
4577 le64_to_cpu(sbi->ckpt->valid_block_count); in f2fs_fill_super()
4578 sbi->last_valid_block_count = sbi->total_valid_block_count; in f2fs_fill_super()
4579 sbi->reserved_blocks = 0; in f2fs_fill_super()
4580 sbi->current_reserved_blocks = 0; in f2fs_fill_super()
4581 limit_reserve_root(sbi); in f2fs_fill_super()
4582 adjust_unusable_cap_perc(sbi); in f2fs_fill_super()
4584 f2fs_init_extent_cache_info(sbi); in f2fs_fill_super()
4586 f2fs_init_ino_entry_info(sbi); in f2fs_fill_super()
4588 f2fs_init_fsync_node_info(sbi); in f2fs_fill_super()
4591 f2fs_init_ckpt_req_control(sbi); in f2fs_fill_super()
4592 if (!f2fs_readonly(sb) && !test_opt(sbi, DISABLE_CHECKPOINT) && in f2fs_fill_super()
4593 test_opt(sbi, MERGE_CHECKPOINT)) { in f2fs_fill_super()
4594 err = f2fs_start_ckpt_thread(sbi); in f2fs_fill_super()
4596 f2fs_err(sbi, in f2fs_fill_super()
4604 err = f2fs_build_segment_manager(sbi); in f2fs_fill_super()
4606 f2fs_err(sbi, "Failed to initialize F2FS segment manager (%d)", in f2fs_fill_super()
4610 err = f2fs_build_node_manager(sbi); in f2fs_fill_super()
4612 f2fs_err(sbi, "Failed to initialize F2FS node manager (%d)", in f2fs_fill_super()
4618 sbi->sectors_written_start = f2fs_get_sectors_written(sbi); in f2fs_fill_super()
4621 seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE); in f2fs_fill_super()
4622 if (__exist_node_summaries(sbi)) in f2fs_fill_super()
4623 sbi->kbytes_written = in f2fs_fill_super()
4626 f2fs_build_gc_manager(sbi); in f2fs_fill_super()
4628 err = f2fs_build_stats(sbi); in f2fs_fill_super()
4633 sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi)); in f2fs_fill_super()
4634 if (IS_ERR(sbi->node_inode)) { in f2fs_fill_super()
4635 f2fs_err(sbi, "Failed to read node inode"); in f2fs_fill_super()
4636 err = PTR_ERR(sbi->node_inode); in f2fs_fill_super()
4641 root = f2fs_iget(sb, F2FS_ROOT_INO(sbi)); in f2fs_fill_super()
4643 f2fs_err(sbi, "Failed to read root inode"); in f2fs_fill_super()
4661 err = f2fs_init_compress_inode(sbi); in f2fs_fill_super()
4665 err = f2fs_register_sysfs(sbi); in f2fs_fill_super()
4671 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) { in f2fs_fill_super()
4674 f2fs_err(sbi, "Cannot turn on quotas: error %d", err); in f2fs_fill_super()
4677 quota_enabled = f2fs_recover_quota_begin(sbi); in f2fs_fill_super()
4680 err = f2fs_recover_orphan_inodes(sbi); in f2fs_fill_super()
4684 if (unlikely(is_set_ckpt_flags(sbi, CP_DISABLED_FLAG))) in f2fs_fill_super()
4688 if (!test_opt(sbi, DISABLE_ROLL_FORWARD) && in f2fs_fill_super()
4689 !test_opt(sbi, NORECOVERY)) { in f2fs_fill_super()
4694 if (f2fs_hw_is_readonly(sbi)) { in f2fs_fill_super()
4695 if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { in f2fs_fill_super()
4696 err = f2fs_recover_fsync_data(sbi, true); in f2fs_fill_super()
4699 f2fs_err(sbi, "Need to recover fsync data, but " in f2fs_fill_super()
4706 f2fs_info(sbi, "write access unavailable, skipping recovery"); in f2fs_fill_super()
4711 set_sbi_flag(sbi, SBI_NEED_FSCK); in f2fs_fill_super()
4716 err = f2fs_recover_fsync_data(sbi, false); in f2fs_fill_super()
4721 f2fs_err(sbi, "Cannot recover all fsync data errno=%d", in f2fs_fill_super()
4726 err = f2fs_recover_fsync_data(sbi, true); in f2fs_fill_super()
4730 f2fs_err(sbi, "Need to recover fsync data"); in f2fs_fill_super()
4736 f2fs_recover_quota_end(sbi, quota_enabled); in f2fs_fill_super()
4743 if (f2fs_sb_has_blkzoned(sbi) && !f2fs_readonly(sb)) { in f2fs_fill_super()
4746 f2fs_notice(sbi, "Checking entire write pointers"); in f2fs_fill_super()
4747 err2 = f2fs_check_write_pointer(sbi); in f2fs_fill_super()
4754 err = f2fs_init_inmem_curseg(sbi); in f2fs_fill_super()
4759 clear_sbi_flag(sbi, SBI_POR_DOING); in f2fs_fill_super()
4761 if (test_opt(sbi, DISABLE_CHECKPOINT)) { in f2fs_fill_super()
4762 err = f2fs_disable_checkpoint(sbi); in f2fs_fill_super()
4765 } else if (is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)) { in f2fs_fill_super()
4766 f2fs_enable_checkpoint(sbi); in f2fs_fill_super()
4773 if ((F2FS_OPTION(sbi).bggc_mode != BGGC_MODE_OFF || in f2fs_fill_super()
4774 test_opt(sbi, GC_MERGE)) && !f2fs_readonly(sb)) { in f2fs_fill_super()
4776 err = f2fs_start_gc_thread(sbi); in f2fs_fill_super()
4784 err = f2fs_commit_super(sbi, true); in f2fs_fill_super()
4785 f2fs_info(sbi, "Try to recover %dth superblock, ret: %d", in f2fs_fill_super()
4786 sbi->valid_super_block ? 1 : 2, err); in f2fs_fill_super()
4789 f2fs_join_shrinker(sbi); in f2fs_fill_super()
4791 f2fs_tuning_parameters(sbi); in f2fs_fill_super()
4793 f2fs_notice(sbi, "Mounted with checkpoint version = %llx", in f2fs_fill_super()
4794 cur_cp_version(F2FS_CKPT(sbi))); in f2fs_fill_super()
4795 f2fs_update_time(sbi, CP_TIME); in f2fs_fill_super()
4796 f2fs_update_time(sbi, REQ_TIME); in f2fs_fill_super()
4797 clear_sbi_flag(sbi, SBI_CP_DISABLED_QUICK); in f2fs_fill_super()
4802 sync_filesystem(sbi->sb); in f2fs_fill_super()
4808 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) in f2fs_fill_super()
4809 f2fs_quota_off_umount(sbi->sb); in f2fs_fill_super()
4817 truncate_inode_pages_final(META_MAPPING(sbi)); in f2fs_fill_super()
4820 f2fs_unregister_sysfs(sbi); in f2fs_fill_super()
4822 f2fs_destroy_compress_inode(sbi); in f2fs_fill_super()
4827 f2fs_release_ino_entry(sbi, true); in f2fs_fill_super()
4828 truncate_inode_pages_final(NODE_MAPPING(sbi)); in f2fs_fill_super()
4829 iput(sbi->node_inode); in f2fs_fill_super()
4830 sbi->node_inode = NULL; in f2fs_fill_super()
4832 f2fs_destroy_stats(sbi); in f2fs_fill_super()
4835 f2fs_stop_discard_thread(sbi); in f2fs_fill_super()
4836 f2fs_destroy_node_manager(sbi); in f2fs_fill_super()
4838 f2fs_destroy_segment_manager(sbi); in f2fs_fill_super()
4840 f2fs_stop_ckpt_thread(sbi); in f2fs_fill_super()
4841 /* flush s_error_work before sbi destroy */ in f2fs_fill_super()
4842 flush_work(&sbi->s_error_work); in f2fs_fill_super()
4843 f2fs_destroy_post_read_wq(sbi); in f2fs_fill_super()
4845 destroy_device_list(sbi); in f2fs_fill_super()
4846 kvfree(sbi->ckpt); in f2fs_fill_super()
4848 make_bad_inode(sbi->meta_inode); in f2fs_fill_super()
4849 iput(sbi->meta_inode); in f2fs_fill_super()
4850 sbi->meta_inode = NULL; in f2fs_fill_super()
4852 f2fs_destroy_page_array_cache(sbi); in f2fs_fill_super()
4854 f2fs_destroy_xattr_caches(sbi); in f2fs_fill_super()
4856 destroy_percpu_info(sbi); in f2fs_fill_super()
4858 f2fs_destroy_iostat(sbi); in f2fs_fill_super()
4861 kvfree(sbi->write_io[i]); in f2fs_fill_super()
4870 kfree(F2FS_OPTION(sbi).s_qf_names[i]); in f2fs_fill_super()
4872 fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy); in f2fs_fill_super()
4877 if (sbi->s_chksum_driver) in f2fs_fill_super()
4878 crypto_free_shash(sbi->s_chksum_driver); in f2fs_fill_super()
4879 kfree(sbi); in f2fs_fill_super()
4899 struct f2fs_sb_info *sbi = F2FS_SB(sb); in kill_f2fs_super() local
4902 set_sbi_flag(sbi, SBI_IS_CLOSE); in kill_f2fs_super()
4903 f2fs_stop_gc_thread(sbi); in kill_f2fs_super()
4904 f2fs_stop_discard_thread(sbi); in kill_f2fs_super()
4911 if (test_opt(sbi, COMPRESS_CACHE)) in kill_f2fs_super()
4912 truncate_inode_pages_final(COMPRESS_MAPPING(sbi)); in kill_f2fs_super()
4915 if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) || in kill_f2fs_super()
4916 !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { in kill_f2fs_super()
4920 stat_inc_cp_call_count(sbi, TOTAL_CALL); in kill_f2fs_super()
4921 f2fs_write_checkpoint(sbi, &cpc); in kill_f2fs_super()
4924 if (is_sbi_flag_set(sbi, SBI_IS_RECOVERED) && f2fs_readonly(sb)) in kill_f2fs_super()
4929 if (sbi) { in kill_f2fs_super()
4930 destroy_device_list(sbi); in kill_f2fs_super()
4931 kfree(sbi); in kill_f2fs_super()