Lines Matching refs:sbi

61 void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,  in f2fs_build_fault_attr()  argument
64 struct f2fs_fault_info *ffi = &F2FS_OPTION(sbi).fault_info; in f2fs_build_fault_attr()
221 void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...) in f2fs_printk() argument
233 KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf); in f2fs_printk()
268 static inline void limit_reserve_root(struct f2fs_sb_info *sbi) in limit_reserve_root() argument
270 block_t limit = min((sbi->user_block_count << 1) / 1000, in limit_reserve_root()
271 sbi->user_block_count - sbi->reserved_blocks); in limit_reserve_root()
274 if (test_opt(sbi, RESERVE_ROOT) && in limit_reserve_root()
275 F2FS_OPTION(sbi).root_reserved_blocks > limit) { in limit_reserve_root()
276 F2FS_OPTION(sbi).root_reserved_blocks = limit; in limit_reserve_root()
277 f2fs_info(sbi, "Reduce reserved blocks for root = %u", in limit_reserve_root()
278 F2FS_OPTION(sbi).root_reserved_blocks); in limit_reserve_root()
280 if (!test_opt(sbi, RESERVE_ROOT) && in limit_reserve_root()
281 (!uid_eq(F2FS_OPTION(sbi).s_resuid, in limit_reserve_root()
283 !gid_eq(F2FS_OPTION(sbi).s_resgid, in limit_reserve_root()
285 f2fs_info(sbi, "Ignore s_resuid=%u, s_resgid=%u w/o reserve_root", in limit_reserve_root()
287 F2FS_OPTION(sbi).s_resuid), in limit_reserve_root()
289 F2FS_OPTION(sbi).s_resgid)); in limit_reserve_root()
292 static inline void adjust_unusable_cap_perc(struct f2fs_sb_info *sbi) in adjust_unusable_cap_perc() argument
294 if (!F2FS_OPTION(sbi).unusable_cap_perc) in adjust_unusable_cap_perc()
297 if (F2FS_OPTION(sbi).unusable_cap_perc == 100) in adjust_unusable_cap_perc()
298 F2FS_OPTION(sbi).unusable_cap = sbi->user_block_count; in adjust_unusable_cap_perc()
300 F2FS_OPTION(sbi).unusable_cap = (sbi->user_block_count / 100) * in adjust_unusable_cap_perc()
301 F2FS_OPTION(sbi).unusable_cap_perc; in adjust_unusable_cap_perc()
303 f2fs_info(sbi, "Adjust unusable cap for checkpoint=disable = %u / %u%%", in adjust_unusable_cap_perc()
304 F2FS_OPTION(sbi).unusable_cap, in adjust_unusable_cap_perc()
305 F2FS_OPTION(sbi).unusable_cap_perc); in adjust_unusable_cap_perc()
321 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_set_qf_name() local
325 if (sb_any_quota_loaded(sb) && !F2FS_OPTION(sbi).s_qf_names[qtype]) { in f2fs_set_qf_name()
326 f2fs_err(sbi, "Cannot change journaled quota options when quota turned on"); in f2fs_set_qf_name()
329 if (f2fs_sb_has_quota_ino(sbi)) { in f2fs_set_qf_name()
330 f2fs_info(sbi, "QUOTA feature is enabled, so ignore qf_name"); in f2fs_set_qf_name()
336 f2fs_err(sbi, "Not enough memory for storing quotafile name"); in f2fs_set_qf_name()
339 if (F2FS_OPTION(sbi).s_qf_names[qtype]) { in f2fs_set_qf_name()
340 if (strcmp(F2FS_OPTION(sbi).s_qf_names[qtype], qname) == 0) in f2fs_set_qf_name()
343 f2fs_err(sbi, "%s quota file already specified", in f2fs_set_qf_name()
348 f2fs_err(sbi, "quotafile must be on filesystem root"); in f2fs_set_qf_name()
351 F2FS_OPTION(sbi).s_qf_names[qtype] = qname; in f2fs_set_qf_name()
352 set_opt(sbi, QUOTA); in f2fs_set_qf_name()
361 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_clear_qf_name() local
363 if (sb_any_quota_loaded(sb) && F2FS_OPTION(sbi).s_qf_names[qtype]) { in f2fs_clear_qf_name()
364 f2fs_err(sbi, "Cannot change journaled quota options when quota turned on"); in f2fs_clear_qf_name()
367 kfree(F2FS_OPTION(sbi).s_qf_names[qtype]); in f2fs_clear_qf_name()
368 F2FS_OPTION(sbi).s_qf_names[qtype] = NULL; in f2fs_clear_qf_name()
372 static int f2fs_check_quota_options(struct f2fs_sb_info *sbi) in f2fs_check_quota_options() argument
379 if (test_opt(sbi, PRJQUOTA) && !f2fs_sb_has_project_quota(sbi)) { in f2fs_check_quota_options()
380 f2fs_err(sbi, "Project quota feature not enabled. Cannot enable project quota enforcement."); in f2fs_check_quota_options()
383 if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA] || in f2fs_check_quota_options()
384 F2FS_OPTION(sbi).s_qf_names[GRPQUOTA] || in f2fs_check_quota_options()
385 F2FS_OPTION(sbi).s_qf_names[PRJQUOTA]) { in f2fs_check_quota_options()
386 if (test_opt(sbi, USRQUOTA) && in f2fs_check_quota_options()
387 F2FS_OPTION(sbi).s_qf_names[USRQUOTA]) in f2fs_check_quota_options()
388 clear_opt(sbi, USRQUOTA); in f2fs_check_quota_options()
390 if (test_opt(sbi, GRPQUOTA) && in f2fs_check_quota_options()
391 F2FS_OPTION(sbi).s_qf_names[GRPQUOTA]) in f2fs_check_quota_options()
392 clear_opt(sbi, GRPQUOTA); in f2fs_check_quota_options()
394 if (test_opt(sbi, PRJQUOTA) && in f2fs_check_quota_options()
395 F2FS_OPTION(sbi).s_qf_names[PRJQUOTA]) in f2fs_check_quota_options()
396 clear_opt(sbi, PRJQUOTA); in f2fs_check_quota_options()
398 if (test_opt(sbi, GRPQUOTA) || test_opt(sbi, USRQUOTA) || in f2fs_check_quota_options()
399 test_opt(sbi, PRJQUOTA)) { in f2fs_check_quota_options()
400 f2fs_err(sbi, "old and new quota format mixing"); in f2fs_check_quota_options()
404 if (!F2FS_OPTION(sbi).s_jquota_fmt) { in f2fs_check_quota_options()
405 f2fs_err(sbi, "journaled quota format not specified"); in f2fs_check_quota_options()
410 if (f2fs_sb_has_quota_ino(sbi) && F2FS_OPTION(sbi).s_jquota_fmt) { in f2fs_check_quota_options()
411 f2fs_info(sbi, "QUOTA feature is enabled, so ignore jquota_fmt"); in f2fs_check_quota_options()
412 F2FS_OPTION(sbi).s_jquota_fmt = 0; in f2fs_check_quota_options()
423 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_set_test_dummy_encryption() local
427 if (!f2fs_sb_has_encrypt(sbi)) { in f2fs_set_test_dummy_encryption()
428 f2fs_err(sbi, "Encrypt feature is off"); in f2fs_set_test_dummy_encryption()
438 if (is_remount && !F2FS_OPTION(sbi).dummy_enc_policy.policy) { in f2fs_set_test_dummy_encryption()
439 f2fs_warn(sbi, "Can't set test_dummy_encryption on remount"); in f2fs_set_test_dummy_encryption()
443 sb, arg->from, &F2FS_OPTION(sbi).dummy_enc_policy); in f2fs_set_test_dummy_encryption()
446 f2fs_warn(sbi, in f2fs_set_test_dummy_encryption()
449 f2fs_warn(sbi, "Value of option \"%s\" is unrecognized", in f2fs_set_test_dummy_encryption()
452 f2fs_warn(sbi, "Error processing option \"%s\" [%d]", in f2fs_set_test_dummy_encryption()
456 f2fs_warn(sbi, "Test dummy encryption mode enabled"); in f2fs_set_test_dummy_encryption()
458 f2fs_warn(sbi, "Test dummy encryption mount option ignored"); in f2fs_set_test_dummy_encryption()
465 struct f2fs_sb_info *sbi = F2FS_SB(sb); in parse_options() local
498 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; in parse_options()
500 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_OFF; in parse_options()
502 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_SYNC; in parse_options()
510 set_opt(sbi, DISABLE_ROLL_FORWARD); in parse_options()
514 set_opt(sbi, NORECOVERY); in parse_options()
519 set_opt(sbi, DISCARD); in parse_options()
522 if (f2fs_sb_has_blkzoned(sbi)) { in parse_options()
523 f2fs_warn(sbi, "discard is required for zoned block devices"); in parse_options()
526 clear_opt(sbi, DISCARD); in parse_options()
529 set_opt(sbi, NOHEAP); in parse_options()
532 clear_opt(sbi, NOHEAP); in parse_options()
536 set_opt(sbi, XATTR_USER); in parse_options()
539 clear_opt(sbi, XATTR_USER); in parse_options()
542 set_opt(sbi, INLINE_XATTR); in parse_options()
545 clear_opt(sbi, INLINE_XATTR); in parse_options()
550 set_opt(sbi, INLINE_XATTR_SIZE); in parse_options()
551 F2FS_OPTION(sbi).inline_xattr_size = arg; in parse_options()
555 f2fs_info(sbi, "user_xattr options not supported"); in parse_options()
558 f2fs_info(sbi, "nouser_xattr options not supported"); in parse_options()
561 f2fs_info(sbi, "inline_xattr options not supported"); in parse_options()
564 f2fs_info(sbi, "noinline_xattr options not supported"); in parse_options()
569 set_opt(sbi, POSIX_ACL); in parse_options()
572 clear_opt(sbi, POSIX_ACL); in parse_options()
576 f2fs_info(sbi, "acl options not supported"); in parse_options()
579 f2fs_info(sbi, "noacl options not supported"); in parse_options()
588 F2FS_OPTION(sbi).active_logs = arg; in parse_options()
591 set_opt(sbi, DISABLE_EXT_IDENTIFY); in parse_options()
594 set_opt(sbi, INLINE_DATA); in parse_options()
597 set_opt(sbi, INLINE_DENTRY); in parse_options()
600 clear_opt(sbi, INLINE_DENTRY); in parse_options()
603 set_opt(sbi, FLUSH_MERGE); in parse_options()
606 clear_opt(sbi, FLUSH_MERGE); in parse_options()
609 set_opt(sbi, NOBARRIER); in parse_options()
612 set_opt(sbi, FASTBOOT); in parse_options()
615 set_opt(sbi, EXTENT_CACHE); in parse_options()
618 clear_opt(sbi, EXTENT_CACHE); in parse_options()
621 clear_opt(sbi, INLINE_DATA); in parse_options()
624 set_opt(sbi, DATA_FLUSH); in parse_options()
629 if (test_opt(sbi, RESERVE_ROOT)) { in parse_options()
630 f2fs_info(sbi, "Preserve previous reserve_root=%u", in parse_options()
631 F2FS_OPTION(sbi).root_reserved_blocks); in parse_options()
633 F2FS_OPTION(sbi).root_reserved_blocks = arg; in parse_options()
634 set_opt(sbi, RESERVE_ROOT); in parse_options()
642 f2fs_err(sbi, "Invalid uid value %d", arg); in parse_options()
645 F2FS_OPTION(sbi).s_resuid = uid; in parse_options()
652 f2fs_err(sbi, "Invalid gid value %d", arg); in parse_options()
655 F2FS_OPTION(sbi).s_resgid = gid; in parse_options()
663 if (f2fs_sb_has_blkzoned(sbi)) { in parse_options()
664 f2fs_warn(sbi, "adaptive mode is not allowed with zoned block device feature"); in parse_options()
668 F2FS_OPTION(sbi).fs_mode = FS_MODE_ADAPTIVE; in parse_options()
670 F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS; in parse_options()
681 f2fs_warn(sbi, "Not support %d, larger than %d", in parse_options()
685 F2FS_OPTION(sbi).write_io_size_bits = arg; in parse_options()
691 f2fs_build_fault_attr(sbi, arg, F2FS_ALL_FAULT_TYPE); in parse_options()
692 set_opt(sbi, FAULT_INJECTION); in parse_options()
698 f2fs_build_fault_attr(sbi, 0, arg); in parse_options()
699 set_opt(sbi, FAULT_INJECTION); in parse_options()
703 f2fs_info(sbi, "fault_injection options not supported"); in parse_options()
707 f2fs_info(sbi, "fault_type options not supported"); in parse_options()
719 set_opt(sbi, USRQUOTA); in parse_options()
722 set_opt(sbi, GRPQUOTA); in parse_options()
725 set_opt(sbi, PRJQUOTA); in parse_options()
758 F2FS_OPTION(sbi).s_jquota_fmt = QFMT_VFS_OLD; in parse_options()
761 F2FS_OPTION(sbi).s_jquota_fmt = QFMT_VFS_V0; in parse_options()
764 F2FS_OPTION(sbi).s_jquota_fmt = QFMT_VFS_V1; in parse_options()
767 clear_opt(sbi, QUOTA); in parse_options()
768 clear_opt(sbi, USRQUOTA); in parse_options()
769 clear_opt(sbi, GRPQUOTA); in parse_options()
770 clear_opt(sbi, PRJQUOTA); in parse_options()
787 f2fs_info(sbi, "quota operations not supported"); in parse_options()
795 F2FS_OPTION(sbi).whint_mode = WHINT_MODE_USER; in parse_options()
797 F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF; in parse_options()
799 F2FS_OPTION(sbi).whint_mode = WHINT_MODE_FS; in parse_options()
812 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT; in parse_options()
814 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE; in parse_options()
826 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX; in parse_options()
828 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_STRICT; in parse_options()
830 F2FS_OPTION(sbi).fsync_mode = in parse_options()
848 f2fs_info(sbi, "inline encryption not supported"); in parse_options()
856 F2FS_OPTION(sbi).unusable_cap_perc = arg; in parse_options()
857 set_opt(sbi, DISABLE_CHECKPOINT); in parse_options()
862 F2FS_OPTION(sbi).unusable_cap = arg; in parse_options()
863 set_opt(sbi, DISABLE_CHECKPOINT); in parse_options()
866 set_opt(sbi, DISABLE_CHECKPOINT); in parse_options()
869 clear_opt(sbi, DISABLE_CHECKPOINT); in parse_options()
873 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
874 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
881 F2FS_OPTION(sbi).compress_algorithm = in parse_options()
884 F2FS_OPTION(sbi).compress_algorithm = in parse_options()
887 F2FS_OPTION(sbi).compress_algorithm = in parse_options()
890 F2FS_OPTION(sbi).compress_algorithm = in parse_options()
899 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
900 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
907 f2fs_err(sbi, in parse_options()
911 F2FS_OPTION(sbi).compress_log_size = arg; in parse_options()
914 if (!f2fs_sb_has_compression(sbi)) { in parse_options()
915 f2fs_info(sbi, "Image doesn't support compression"); in parse_options()
922 ext = F2FS_OPTION(sbi).extensions; in parse_options()
923 ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; in parse_options()
927 f2fs_err(sbi, in parse_options()
934 F2FS_OPTION(sbi).compress_ext_cnt++; in parse_options()
941 f2fs_info(sbi, "compression options not supported"); in parse_options()
945 set_opt(sbi, ATGC); in parse_options()
948 f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value", in parse_options()
954 if (f2fs_check_quota_options(sbi)) in parse_options()
957 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sbi->sb)) { in parse_options()
958 f2fs_info(sbi, "Filesystem with quota feature cannot be mounted RDWR without CONFIG_QUOTA"); in parse_options()
961 if (f2fs_sb_has_project_quota(sbi) && !f2fs_readonly(sbi->sb)) { in parse_options()
962 …f2fs_err(sbi, "Filesystem with project quota feature cannot be mounted RDWR without CONFIG_QUOTA"); in parse_options()
967 if (f2fs_sb_has_casefold(sbi)) { in parse_options()
968 f2fs_err(sbi, in parse_options()
979 if (f2fs_sb_has_blkzoned(sbi)) { in parse_options()
980 f2fs_err(sbi, "Zoned block device support is not enabled"); in parse_options()
985 if (F2FS_IO_SIZE_BITS(sbi) && !f2fs_lfs_mode(sbi)) { in parse_options()
986 f2fs_err(sbi, "Should set mode=lfs with %uKB-sized IO", in parse_options()
987 F2FS_IO_SIZE_KB(sbi)); in parse_options()
991 if (test_opt(sbi, INLINE_XATTR_SIZE)) { in parse_options()
994 if (!f2fs_sb_has_extra_attr(sbi) || in parse_options()
995 !f2fs_sb_has_flexible_inline_xattr(sbi)) { in parse_options()
996 f2fs_err(sbi, "extra_attr or flexible_inline_xattr feature is off"); in parse_options()
999 if (!test_opt(sbi, INLINE_XATTR)) { in parse_options()
1000 f2fs_err(sbi, "inline_xattr_size option should be set with inline_xattr option"); in parse_options()
1007 if (F2FS_OPTION(sbi).inline_xattr_size < min_size || in parse_options()
1008 F2FS_OPTION(sbi).inline_xattr_size > max_size) { in parse_options()
1009 f2fs_err(sbi, "inline xattr size is out of range: %d ~ %d", in parse_options()
1015 if (test_opt(sbi, DISABLE_CHECKPOINT) && f2fs_lfs_mode(sbi)) { in parse_options()
1016 f2fs_err(sbi, "LFS not compatible with checkpoint=disable\n"); in parse_options()
1023 if (F2FS_OPTION(sbi).active_logs != NR_CURSEG_TYPE) in parse_options()
1024 F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF; in parse_options()
1063 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_drop_inode() local
1070 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) { in f2fs_drop_inode()
1071 if (inode->i_ino == F2FS_NODE_INO(sbi) || in f2fs_drop_inode()
1072 inode->i_ino == F2FS_META_INO(sbi)) { in f2fs_drop_inode()
1125 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_inode_dirtied() local
1128 spin_lock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_dirtied()
1133 stat_inc_dirty_inode(sbi, DIRTY_META); in f2fs_inode_dirtied()
1137 &sbi->inode_list[DIRTY_META]); in f2fs_inode_dirtied()
1138 inc_page_count(sbi, F2FS_DIRTY_IMETA); in f2fs_inode_dirtied()
1140 spin_unlock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_dirtied()
1146 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_inode_synced() local
1148 spin_lock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_synced()
1150 spin_unlock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_synced()
1155 dec_page_count(sbi, F2FS_DIRTY_IMETA); in f2fs_inode_synced()
1160 spin_unlock(&sbi->inode_lock[DIRTY_META]); in f2fs_inode_synced()
1170 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_dirty_inode() local
1172 if (inode->i_ino == F2FS_NODE_INO(sbi) || in f2fs_dirty_inode()
1173 inode->i_ino == F2FS_META_INO(sbi)) in f2fs_dirty_inode()
1191 static void destroy_percpu_info(struct f2fs_sb_info *sbi) in destroy_percpu_info() argument
1193 percpu_counter_destroy(&sbi->alloc_valid_block_count); in destroy_percpu_info()
1194 percpu_counter_destroy(&sbi->total_valid_inode_count); in destroy_percpu_info()
1197 static void destroy_device_list(struct f2fs_sb_info *sbi) in destroy_device_list() argument
1201 for (i = 0; i < sbi->s_ndevs; i++) { in destroy_device_list()
1208 kvfree(sbi->devs); in destroy_device_list()
1213 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_put_super() local
1218 f2fs_unregister_sysfs(sbi); in f2fs_put_super()
1223 mutex_lock(&sbi->umount_mutex); in f2fs_put_super()
1230 if ((is_sbi_flag_set(sbi, SBI_IS_DIRTY) || in f2fs_put_super()
1231 !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG))) { in f2fs_put_super()
1235 f2fs_write_checkpoint(sbi, &cpc); in f2fs_put_super()
1239 dropped = f2fs_issue_discard_timeout(sbi); in f2fs_put_super()
1241 if ((f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi)) && in f2fs_put_super()
1242 !sbi->discard_blks && !dropped) { in f2fs_put_super()
1246 f2fs_write_checkpoint(sbi, &cpc); in f2fs_put_super()
1253 f2fs_release_ino_entry(sbi, true); in f2fs_put_super()
1255 f2fs_leave_shrinker(sbi); in f2fs_put_super()
1256 mutex_unlock(&sbi->umount_mutex); in f2fs_put_super()
1259 f2fs_flush_merged_writes(sbi); in f2fs_put_super()
1261 f2fs_wait_on_all_pages(sbi, F2FS_WB_CP_DATA); in f2fs_put_super()
1263 f2fs_bug_on(sbi, sbi->fsync_node_num); in f2fs_put_super()
1265 iput(sbi->node_inode); in f2fs_put_super()
1266 sbi->node_inode = NULL; in f2fs_put_super()
1268 iput(sbi->meta_inode); in f2fs_put_super()
1269 sbi->meta_inode = NULL; in f2fs_put_super()
1275 f2fs_destroy_stats(sbi); in f2fs_put_super()
1278 f2fs_destroy_node_manager(sbi); in f2fs_put_super()
1279 f2fs_destroy_segment_manager(sbi); in f2fs_put_super()
1281 f2fs_destroy_post_read_wq(sbi); in f2fs_put_super()
1283 kvfree(sbi->ckpt); in f2fs_put_super()
1286 if (sbi->s_chksum_driver) in f2fs_put_super()
1287 crypto_free_shash(sbi->s_chksum_driver); in f2fs_put_super()
1288 kfree(sbi->raw_super); in f2fs_put_super()
1290 destroy_device_list(sbi); in f2fs_put_super()
1291 f2fs_destroy_page_array_cache(sbi); in f2fs_put_super()
1292 f2fs_destroy_xattr_caches(sbi); in f2fs_put_super()
1293 mempool_destroy(sbi->write_io_dummy); in f2fs_put_super()
1296 kfree(F2FS_OPTION(sbi).s_qf_names[i]); in f2fs_put_super()
1298 fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy); in f2fs_put_super()
1299 destroy_percpu_info(sbi); in f2fs_put_super()
1301 kvfree(sbi->write_io[i]); in f2fs_put_super()
1305 kfree(sbi); in f2fs_put_super()
1310 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_sync_fs() local
1313 if (unlikely(f2fs_cp_error(sbi))) in f2fs_sync_fs()
1315 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) in f2fs_sync_fs()
1320 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) in f2fs_sync_fs()
1326 cpc.reason = __get_cp_reason(sbi); in f2fs_sync_fs()
1328 down_write(&sbi->gc_lock); in f2fs_sync_fs()
1329 err = f2fs_write_checkpoint(sbi, &cpc); in f2fs_sync_fs()
1330 up_write(&sbi->gc_lock); in f2fs_sync_fs()
1405 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_statfs() local
1410 total_count = le64_to_cpu(sbi->raw_super->block_count); in f2fs_statfs()
1411 user_block_count = sbi->user_block_count; in f2fs_statfs()
1412 start_count = le32_to_cpu(sbi->raw_super->segment0_blkaddr); in f2fs_statfs()
1414 buf->f_bsize = sbi->blocksize; in f2fs_statfs()
1417 buf->f_bfree = user_block_count - valid_user_blocks(sbi) - in f2fs_statfs()
1418 sbi->current_reserved_blocks; in f2fs_statfs()
1420 spin_lock(&sbi->stat_lock); in f2fs_statfs()
1421 if (unlikely(buf->f_bfree <= sbi->unusable_block_count)) in f2fs_statfs()
1424 buf->f_bfree -= sbi->unusable_block_count; in f2fs_statfs()
1425 spin_unlock(&sbi->stat_lock); in f2fs_statfs()
1427 if (buf->f_bfree > F2FS_OPTION(sbi).root_reserved_blocks) in f2fs_statfs()
1429 F2FS_OPTION(sbi).root_reserved_blocks; in f2fs_statfs()
1433 avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM; in f2fs_statfs()
1440 buf->f_ffree = min(avail_node_count - valid_node_count(sbi), in f2fs_statfs()
1460 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_show_quota_options() local
1462 if (F2FS_OPTION(sbi).s_jquota_fmt) { in f2fs_show_quota_options()
1465 switch (F2FS_OPTION(sbi).s_jquota_fmt) { in f2fs_show_quota_options()
1479 if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA]) in f2fs_show_quota_options()
1481 F2FS_OPTION(sbi).s_qf_names[USRQUOTA]); in f2fs_show_quota_options()
1483 if (F2FS_OPTION(sbi).s_qf_names[GRPQUOTA]) in f2fs_show_quota_options()
1485 F2FS_OPTION(sbi).s_qf_names[GRPQUOTA]); in f2fs_show_quota_options()
1487 if (F2FS_OPTION(sbi).s_qf_names[PRJQUOTA]) in f2fs_show_quota_options()
1489 F2FS_OPTION(sbi).s_qf_names[PRJQUOTA]); in f2fs_show_quota_options()
1496 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_show_compress_options() local
1500 if (!f2fs_sb_has_compression(sbi)) in f2fs_show_compress_options()
1503 switch (F2FS_OPTION(sbi).compress_algorithm) { in f2fs_show_compress_options()
1520 F2FS_OPTION(sbi).compress_log_size); in f2fs_show_compress_options()
1522 for (i = 0; i < F2FS_OPTION(sbi).compress_ext_cnt; i++) { in f2fs_show_compress_options()
1524 F2FS_OPTION(sbi).extensions[i]); in f2fs_show_compress_options()
1530 struct f2fs_sb_info *sbi = F2FS_SB(root->d_sb); in f2fs_show_options() local
1532 if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC) in f2fs_show_options()
1534 else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_ON) in f2fs_show_options()
1536 else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF) in f2fs_show_options()
1539 if (test_opt(sbi, DISABLE_ROLL_FORWARD)) in f2fs_show_options()
1541 if (test_opt(sbi, NORECOVERY)) in f2fs_show_options()
1543 if (test_opt(sbi, DISCARD)) in f2fs_show_options()
1547 if (test_opt(sbi, NOHEAP)) in f2fs_show_options()
1552 if (test_opt(sbi, XATTR_USER)) in f2fs_show_options()
1556 if (test_opt(sbi, INLINE_XATTR)) in f2fs_show_options()
1560 if (test_opt(sbi, INLINE_XATTR_SIZE)) in f2fs_show_options()
1562 F2FS_OPTION(sbi).inline_xattr_size); in f2fs_show_options()
1565 if (test_opt(sbi, POSIX_ACL)) in f2fs_show_options()
1570 if (test_opt(sbi, DISABLE_EXT_IDENTIFY)) in f2fs_show_options()
1572 if (test_opt(sbi, INLINE_DATA)) in f2fs_show_options()
1576 if (test_opt(sbi, INLINE_DENTRY)) in f2fs_show_options()
1580 if (!f2fs_readonly(sbi->sb) && test_opt(sbi, FLUSH_MERGE)) in f2fs_show_options()
1582 if (test_opt(sbi, NOBARRIER)) in f2fs_show_options()
1584 if (test_opt(sbi, FASTBOOT)) in f2fs_show_options()
1586 if (test_opt(sbi, EXTENT_CACHE)) in f2fs_show_options()
1590 if (test_opt(sbi, DATA_FLUSH)) in f2fs_show_options()
1594 if (F2FS_OPTION(sbi).fs_mode == FS_MODE_ADAPTIVE) in f2fs_show_options()
1596 else if (F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS) in f2fs_show_options()
1598 seq_printf(seq, ",active_logs=%u", F2FS_OPTION(sbi).active_logs); in f2fs_show_options()
1599 if (test_opt(sbi, RESERVE_ROOT)) in f2fs_show_options()
1601 F2FS_OPTION(sbi).root_reserved_blocks, in f2fs_show_options()
1603 F2FS_OPTION(sbi).s_resuid), in f2fs_show_options()
1605 F2FS_OPTION(sbi).s_resgid)); in f2fs_show_options()
1606 if (F2FS_IO_SIZE_BITS(sbi)) in f2fs_show_options()
1608 F2FS_OPTION(sbi).write_io_size_bits); in f2fs_show_options()
1610 if (test_opt(sbi, FAULT_INJECTION)) { in f2fs_show_options()
1612 F2FS_OPTION(sbi).fault_info.inject_rate); in f2fs_show_options()
1614 F2FS_OPTION(sbi).fault_info.inject_type); in f2fs_show_options()
1618 if (test_opt(sbi, QUOTA)) in f2fs_show_options()
1620 if (test_opt(sbi, USRQUOTA)) in f2fs_show_options()
1622 if (test_opt(sbi, GRPQUOTA)) in f2fs_show_options()
1624 if (test_opt(sbi, PRJQUOTA)) in f2fs_show_options()
1627 f2fs_show_quota_options(seq, sbi->sb); in f2fs_show_options()
1628 if (F2FS_OPTION(sbi).whint_mode == WHINT_MODE_USER) in f2fs_show_options()
1630 else if (F2FS_OPTION(sbi).whint_mode == WHINT_MODE_FS) in f2fs_show_options()
1633 fscrypt_show_test_dummy_encryption(seq, ',', sbi->sb); in f2fs_show_options()
1635 if (sbi->sb->s_flags & SB_INLINECRYPT) in f2fs_show_options()
1638 if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_DEFAULT) in f2fs_show_options()
1640 else if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_REUSE) in f2fs_show_options()
1643 if (test_opt(sbi, DISABLE_CHECKPOINT)) in f2fs_show_options()
1645 F2FS_OPTION(sbi).unusable_cap); in f2fs_show_options()
1646 if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_POSIX) in f2fs_show_options()
1648 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT) in f2fs_show_options()
1650 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_NOBARRIER) in f2fs_show_options()
1654 f2fs_show_compress_options(seq, sbi->sb); in f2fs_show_options()
1657 if (test_opt(sbi, ATGC)) in f2fs_show_options()
1662 static void default_options(struct f2fs_sb_info *sbi) in default_options() argument
1665 F2FS_OPTION(sbi).active_logs = NR_CURSEG_PERSIST_TYPE; in default_options()
1666 F2FS_OPTION(sbi).inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS; in default_options()
1667 F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF; in default_options()
1668 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT; in default_options()
1669 F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX; in default_options()
1670 F2FS_OPTION(sbi).s_resuid = make_kuid(&init_user_ns, F2FS_DEF_RESUID); in default_options()
1671 F2FS_OPTION(sbi).s_resgid = make_kgid(&init_user_ns, F2FS_DEF_RESGID); in default_options()
1672 F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZ4; in default_options()
1673 F2FS_OPTION(sbi).compress_log_size = MIN_COMPRESS_LOG_SIZE; in default_options()
1674 F2FS_OPTION(sbi).compress_ext_cnt = 0; in default_options()
1675 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; in default_options()
1677 sbi->sb->s_flags &= ~SB_INLINECRYPT; in default_options()
1679 set_opt(sbi, INLINE_XATTR); in default_options()
1680 set_opt(sbi, INLINE_DATA); in default_options()
1681 set_opt(sbi, INLINE_DENTRY); in default_options()
1682 set_opt(sbi, EXTENT_CACHE); in default_options()
1683 set_opt(sbi, NOHEAP); in default_options()
1684 clear_opt(sbi, DISABLE_CHECKPOINT); in default_options()
1685 F2FS_OPTION(sbi).unusable_cap = 0; in default_options()
1686 sbi->sb->s_flags |= SB_LAZYTIME; in default_options()
1687 set_opt(sbi, FLUSH_MERGE); in default_options()
1688 set_opt(sbi, DISCARD); in default_options()
1689 if (f2fs_sb_has_blkzoned(sbi)) in default_options()
1690 F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS; in default_options()
1692 F2FS_OPTION(sbi).fs_mode = FS_MODE_ADAPTIVE; in default_options()
1695 set_opt(sbi, XATTR_USER); in default_options()
1698 set_opt(sbi, POSIX_ACL); in default_options()
1701 f2fs_build_fault_attr(sbi, 0, 0); in default_options()
1708 static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi) in f2fs_disable_checkpoint() argument
1710 unsigned int s_flags = sbi->sb->s_flags; in f2fs_disable_checkpoint()
1717 f2fs_err(sbi, "checkpoint=disable on readonly fs"); in f2fs_disable_checkpoint()
1720 sbi->sb->s_flags |= SB_ACTIVE; in f2fs_disable_checkpoint()
1722 f2fs_update_time(sbi, DISABLE_TIME); in f2fs_disable_checkpoint()
1724 while (!f2fs_time_over(sbi, DISABLE_TIME)) { in f2fs_disable_checkpoint()
1725 down_write(&sbi->gc_lock); in f2fs_disable_checkpoint()
1726 err = f2fs_gc(sbi, true, false, NULL_SEGNO); in f2fs_disable_checkpoint()
1735 ret = sync_filesystem(sbi->sb); in f2fs_disable_checkpoint()
1741 unusable = f2fs_get_unusable_blocks(sbi); in f2fs_disable_checkpoint()
1742 if (f2fs_disable_cp_again(sbi, unusable)) { in f2fs_disable_checkpoint()
1747 down_write(&sbi->gc_lock); in f2fs_disable_checkpoint()
1749 set_sbi_flag(sbi, SBI_CP_DISABLED); in f2fs_disable_checkpoint()
1750 err = f2fs_write_checkpoint(sbi, &cpc); in f2fs_disable_checkpoint()
1754 spin_lock(&sbi->stat_lock); in f2fs_disable_checkpoint()
1755 sbi->unusable_block_count = unusable; in f2fs_disable_checkpoint()
1756 spin_unlock(&sbi->stat_lock); in f2fs_disable_checkpoint()
1759 up_write(&sbi->gc_lock); in f2fs_disable_checkpoint()
1761 sbi->sb->s_flags = s_flags; /* Restore SB_RDONLY status */ in f2fs_disable_checkpoint()
1765 static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi) in f2fs_enable_checkpoint() argument
1767 down_write(&sbi->gc_lock); in f2fs_enable_checkpoint()
1768 f2fs_dirty_to_prefree(sbi); in f2fs_enable_checkpoint()
1770 clear_sbi_flag(sbi, SBI_CP_DISABLED); in f2fs_enable_checkpoint()
1771 set_sbi_flag(sbi, SBI_IS_DIRTY); in f2fs_enable_checkpoint()
1772 up_write(&sbi->gc_lock); in f2fs_enable_checkpoint()
1774 f2fs_sync_fs(sbi->sb, 1); in f2fs_enable_checkpoint()
1779 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_remount() local
1785 bool no_extent_cache = !test_opt(sbi, EXTENT_CACHE); in f2fs_remount()
1786 bool disable_checkpoint = test_opt(sbi, DISABLE_CHECKPOINT); in f2fs_remount()
1787 bool no_io_align = !F2FS_IO_ALIGNED(sbi); in f2fs_remount()
1788 bool no_atgc = !test_opt(sbi, ATGC); in f2fs_remount()
1798 org_mount_opt = sbi->mount_opt; in f2fs_remount()
1802 org_mount_opt.s_jquota_fmt = F2FS_OPTION(sbi).s_jquota_fmt; in f2fs_remount()
1804 if (F2FS_OPTION(sbi).s_qf_names[i]) { in f2fs_remount()
1806 kstrdup(F2FS_OPTION(sbi).s_qf_names[i], in f2fs_remount()
1820 if (!(*flags & SB_RDONLY) && is_sbi_flag_set(sbi, SBI_NEED_SB_WRITE)) { in f2fs_remount()
1821 err = f2fs_commit_super(sbi, false); in f2fs_remount()
1822 f2fs_info(sbi, "Try to recover all the superblocks, ret: %d", in f2fs_remount()
1825 clear_sbi_flag(sbi, SBI_NEED_SB_WRITE); in f2fs_remount()
1828 default_options(sbi); in f2fs_remount()
1835 disable_checkpoint != test_opt(sbi, DISABLE_CHECKPOINT); in f2fs_remount()
1854 } else if (f2fs_sb_has_quota_ino(sbi)) { in f2fs_remount()
1862 if (no_atgc == !!test_opt(sbi, ATGC)) { in f2fs_remount()
1864 f2fs_warn(sbi, "switch atgc option is not allowed"); in f2fs_remount()
1869 if (no_extent_cache == !!test_opt(sbi, EXTENT_CACHE)) { in f2fs_remount()
1871 f2fs_warn(sbi, "switch extent_cache option is not allowed"); in f2fs_remount()
1875 if (no_io_align == !!F2FS_IO_ALIGNED(sbi)) { in f2fs_remount()
1877 f2fs_warn(sbi, "switch io_bits option is not allowed"); in f2fs_remount()
1881 if ((*flags & SB_RDONLY) && test_opt(sbi, DISABLE_CHECKPOINT)) { in f2fs_remount()
1883 f2fs_warn(sbi, "disabling checkpoint not compatible with read-only"); in f2fs_remount()
1893 F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF) { in f2fs_remount()
1894 if (sbi->gc_thread) { in f2fs_remount()
1895 f2fs_stop_gc_thread(sbi); in f2fs_remount()
1898 } else if (!sbi->gc_thread) { in f2fs_remount()
1899 err = f2fs_start_gc_thread(sbi); in f2fs_remount()
1906 F2FS_OPTION(sbi).whint_mode != org_mount_opt.whint_mode) { in f2fs_remount()
1910 set_sbi_flag(sbi, SBI_IS_DIRTY); in f2fs_remount()
1911 set_sbi_flag(sbi, SBI_IS_CLOSE); in f2fs_remount()
1913 clear_sbi_flag(sbi, SBI_IS_CLOSE); in f2fs_remount()
1917 if (test_opt(sbi, DISABLE_CHECKPOINT)) { in f2fs_remount()
1918 err = f2fs_disable_checkpoint(sbi); in f2fs_remount()
1922 f2fs_enable_checkpoint(sbi); in f2fs_remount()
1930 if ((*flags & SB_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) { in f2fs_remount()
1931 clear_opt(sbi, FLUSH_MERGE); in f2fs_remount()
1932 f2fs_destroy_flush_cmd_control(sbi, false); in f2fs_remount()
1934 err = f2fs_create_flush_cmd_control(sbi); in f2fs_remount()
1946 (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0); in f2fs_remount()
1948 limit_reserve_root(sbi); in f2fs_remount()
1949 adjust_unusable_cap_perc(sbi); in f2fs_remount()
1954 if (f2fs_start_gc_thread(sbi)) in f2fs_remount()
1955 f2fs_warn(sbi, "background gc thread has stopped"); in f2fs_remount()
1957 f2fs_stop_gc_thread(sbi); in f2fs_remount()
1961 F2FS_OPTION(sbi).s_jquota_fmt = org_mount_opt.s_jquota_fmt; in f2fs_remount()
1963 kfree(F2FS_OPTION(sbi).s_qf_names[i]); in f2fs_remount()
1964 F2FS_OPTION(sbi).s_qf_names[i] = org_mount_opt.s_qf_names[i]; in f2fs_remount()
1967 sbi->mount_opt = org_mount_opt; in f2fs_remount()
2094 static int f2fs_quota_on_mount(struct f2fs_sb_info *sbi, int type) in f2fs_quota_on_mount() argument
2096 if (is_set_ckpt_flags(sbi, CP_QUOTA_NEED_FSCK_FLAG)) { in f2fs_quota_on_mount()
2097 f2fs_err(sbi, "quota sysfile may be corrupted, skip loading it"); in f2fs_quota_on_mount()
2101 return dquot_quota_on_mount(sbi->sb, F2FS_OPTION(sbi).s_qf_names[type], in f2fs_quota_on_mount()
2102 F2FS_OPTION(sbi).s_jquota_fmt, type); in f2fs_quota_on_mount()
2105 int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly) in f2fs_enable_quota_files() argument
2110 if (f2fs_sb_has_quota_ino(sbi) && rdonly) { in f2fs_enable_quota_files()
2111 err = f2fs_enable_quotas(sbi->sb); in f2fs_enable_quota_files()
2113 f2fs_err(sbi, "Cannot turn on quota_ino: %d", err); in f2fs_enable_quota_files()
2120 if (F2FS_OPTION(sbi).s_qf_names[i]) { in f2fs_enable_quota_files()
2121 err = f2fs_quota_on_mount(sbi, i); in f2fs_enable_quota_files()
2126 f2fs_err(sbi, "Cannot turn on quotas: %d on %d", in f2fs_enable_quota_files()
2161 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_enable_quotas() local
2165 test_opt(sbi, USRQUOTA), in f2fs_enable_quotas()
2166 test_opt(sbi, GRPQUOTA), in f2fs_enable_quotas()
2167 test_opt(sbi, PRJQUOTA), in f2fs_enable_quotas()
2171 f2fs_err(sbi, "quota file may be corrupted, skip loading it"); in f2fs_enable_quotas()
2184 f2fs_err(sbi, "Failed to enable quota tracking (type=%d, err=%d). Please run fsck to fix.", in f2fs_enable_quotas()
2199 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_quota_sync() local
2213 f2fs_lock_op(sbi); in f2fs_quota_sync()
2215 down_read(&sbi->quota_sem); in f2fs_quota_sync()
2239 if (is_journalled_quota(sbi)) in f2fs_quota_sync()
2253 up_read(&sbi->quota_sem); in f2fs_quota_sync()
2254 f2fs_unlock_op(sbi); in f2fs_quota_sync()
2317 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_quota_off() local
2327 if (is_journalled_quota(sbi)) in f2fs_quota_off()
2328 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_quota_off()
2369 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb); in f2fs_dquot_commit() local
2372 down_read_nested(&sbi->quota_sem, SINGLE_DEPTH_NESTING); in f2fs_dquot_commit()
2375 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_dquot_commit()
2376 up_read(&sbi->quota_sem); in f2fs_dquot_commit()
2382 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb); in f2fs_dquot_acquire() local
2385 down_read(&sbi->quota_sem); in f2fs_dquot_acquire()
2388 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_dquot_acquire()
2389 up_read(&sbi->quota_sem); in f2fs_dquot_acquire()
2395 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb); in f2fs_dquot_release() local
2399 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_dquot_release()
2406 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_dquot_mark_dquot_dirty() local
2410 if (is_journalled_quota(sbi)) in f2fs_dquot_mark_dquot_dirty()
2411 set_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH); in f2fs_dquot_mark_dquot_dirty()
2418 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_dquot_commit_info() local
2422 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_dquot_commit_info()
2498 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_set_context() local
2506 if (f2fs_sb_has_lost_found(sbi) && in f2fs_set_context()
2507 inode->i_ino == F2FS_ROOT_INO(sbi)) in f2fs_set_context()
2534 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_get_num_devices() local
2536 if (f2fs_is_multi_device(sbi)) in f2fs_get_num_devices()
2537 return sbi->s_ndevs; in f2fs_get_num_devices()
2544 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_get_devices() local
2547 for (i = 0; i < sbi->s_ndevs; i++) in f2fs_get_devices()
2568 struct f2fs_sb_info *sbi = F2FS_SB(sb); in f2fs_nfs_get_inode() local
2571 if (f2fs_check_nid_range(sbi, ino)) in f2fs_nfs_get_inode()
2649 static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi, in sanity_check_area_boundary() argument
2654 struct super_block *sb = sbi->sb; in sanity_check_area_boundary()
2674 f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)", in sanity_check_area_boundary()
2681 f2fs_info(sbi, "Wrong CP boundary, start(%u) end(%u) blocks(%u)", in sanity_check_area_boundary()
2689 f2fs_info(sbi, "Wrong SIT boundary, start(%u) end(%u) blocks(%u)", in sanity_check_area_boundary()
2697 f2fs_info(sbi, "Wrong NAT boundary, start(%u) end(%u) blocks(%u)", in sanity_check_area_boundary()
2705 f2fs_info(sbi, "Wrong SSA boundary, start(%u) end(%u) blocks(%u)", in sanity_check_area_boundary()
2712 f2fs_info(sbi, "Wrong MAIN_AREA boundary, start(%u) end(%llu) block(%u)", in sanity_check_area_boundary()
2725 set_sbi_flag(sbi, SBI_NEED_SB_WRITE); in sanity_check_area_boundary()
2731 f2fs_info(sbi, "Fix alignment : %s, start(%u) end(%llu) block(%u)", in sanity_check_area_boundary()
2740 static int sanity_check_raw_super(struct f2fs_sb_info *sbi, in sanity_check_raw_super() argument
2752 f2fs_info(sbi, "Magic Mismatch, valid(0x%x) - read(0x%x)", in sanity_check_raw_super()
2762 f2fs_info(sbi, "Invalid SB checksum offset: %zu", in sanity_check_raw_super()
2767 if (!f2fs_crc_valid(sbi, crc, raw_super, crc_offset)) { in sanity_check_raw_super()
2768 f2fs_info(sbi, "Invalid SB checksum value: %u", crc); in sanity_check_raw_super()
2775 f2fs_info(sbi, "Invalid page_cache_size (%lu), supports only 4KB", in sanity_check_raw_super()
2783 f2fs_info(sbi, "Invalid blocksize (%u), supports only 4KB", in sanity_check_raw_super()
2790 f2fs_info(sbi, "Invalid log blocks per segment (%u)", in sanity_check_raw_super()
2800 f2fs_info(sbi, "Invalid log sectorsize (%u)", in sanity_check_raw_super()
2807 f2fs_info(sbi, "Invalid log sectors per block(%u) log sectorsize(%u)", in sanity_check_raw_super()
2824 f2fs_info(sbi, "Invalid segment count (%u)", segment_count); in sanity_check_raw_super()
2830 f2fs_info(sbi, "Invalid segment/section count (%u, %u x %u)", in sanity_check_raw_super()
2836 f2fs_info(sbi, "Invalid segment/section count (%u != %u * %u)", in sanity_check_raw_super()
2842 f2fs_info(sbi, "Small segment_count (%u < %u * %u)", in sanity_check_raw_super()
2848 f2fs_info(sbi, "Wrong segment_count / block_count (%u > %llu)", in sanity_check_raw_super()
2862 f2fs_info(sbi, "Segment count (%u) mismatch with total segments from devices (%u)", in sanity_check_raw_super()
2868 !bdev_is_zoned(sbi->sb->s_bdev)) { in sanity_check_raw_super()
2869 f2fs_info(sbi, "Zoned block device path is missing"); in sanity_check_raw_super()
2875 f2fs_info(sbi, "Wrong secs_per_zone / total_sections (%u, %u)", in sanity_check_raw_super()
2883 f2fs_info(sbi, "Corrupted extension count (%u + %u > %u)", in sanity_check_raw_super()
2892 f2fs_info(sbi, "Insane cp_payload (%u > %u)", in sanity_check_raw_super()
2902 f2fs_info(sbi, "Invalid Fs Meta Ino: node(%u) meta(%u) root(%u)", in sanity_check_raw_super()
2910 if (sanity_check_area_boundary(sbi, bh)) in sanity_check_raw_super()
2916 int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) in f2fs_sanity_check_ckpt() argument
2919 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); in f2fs_sanity_check_ckpt()
2920 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); in f2fs_sanity_check_ckpt()
2949 f2fs_err(sbi, "Wrong layout: check mkfs.f2fs version"); in f2fs_sanity_check_ckpt()
2958 f2fs_err(sbi, "Wrong user_block_count: %u", in f2fs_sanity_check_ckpt()
2965 f2fs_err(sbi, "Wrong valid_user_blocks: %u, user_block_count: %u", in f2fs_sanity_check_ckpt()
2971 avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM; in f2fs_sanity_check_ckpt()
2973 f2fs_err(sbi, "Wrong valid_node_count: %u, avail_node_count: %u", in f2fs_sanity_check_ckpt()
2979 blocks_per_seg = sbi->blocks_per_seg; in f2fs_sanity_check_ckpt()
2988 f2fs_err(sbi, "Node segment (%u, %u) has the same segno: %u", in f2fs_sanity_check_ckpt()
3002 f2fs_err(sbi, "Data segment (%u, %u) has the same segno: %u", in f2fs_sanity_check_ckpt()
3013 f2fs_err(sbi, "Node segment (%u) and Data segment (%u) has the same segno: %u", in f2fs_sanity_check_ckpt()
3026 f2fs_err(sbi, "Wrong bitmap size: sit: %u, nat:%u", in f2fs_sanity_check_ckpt()
3031 cp_pack_start_sum = __start_sum_addr(sbi); in f2fs_sanity_check_ckpt()
3032 cp_payload = __cp_payload(sbi); in f2fs_sanity_check_ckpt()
3036 f2fs_err(sbi, "Wrong cp_pack_start_sum: %u", in f2fs_sanity_check_ckpt()
3043 f2fs_warn(sbi, "using deprecated layout of large_nat_bitmap, " in f2fs_sanity_check_ckpt()
3050 if (unlikely(f2fs_cp_error(sbi))) { in f2fs_sanity_check_ckpt()
3051 f2fs_err(sbi, "A bug case: need to run fsck"); in f2fs_sanity_check_ckpt()
3057 static void init_sb_info(struct f2fs_sb_info *sbi) in init_sb_info() argument
3059 struct f2fs_super_block *raw_super = sbi->raw_super; in init_sb_info()
3062 sbi->log_sectors_per_block = in init_sb_info()
3064 sbi->log_blocksize = le32_to_cpu(raw_super->log_blocksize); in init_sb_info()
3065 sbi->blocksize = 1 << sbi->log_blocksize; in init_sb_info()
3066 sbi->log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg); in init_sb_info()
3067 sbi->blocks_per_seg = 1 << sbi->log_blocks_per_seg; in init_sb_info()
3068 sbi->segs_per_sec = le32_to_cpu(raw_super->segs_per_sec); in init_sb_info()
3069 sbi->secs_per_zone = le32_to_cpu(raw_super->secs_per_zone); in init_sb_info()
3070 sbi->total_sections = le32_to_cpu(raw_super->section_count); in init_sb_info()
3071 sbi->total_node_count = in init_sb_info()
3073 * sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK; in init_sb_info()
3074 sbi->root_ino_num = le32_to_cpu(raw_super->root_ino); in init_sb_info()
3075 sbi->node_ino_num = le32_to_cpu(raw_super->node_ino); in init_sb_info()
3076 sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino); in init_sb_info()
3077 sbi->cur_victim_sec = NULL_SECNO; in init_sb_info()
3078 sbi->next_victim_seg[BG_GC] = NULL_SEGNO; in init_sb_info()
3079 sbi->next_victim_seg[FG_GC] = NULL_SEGNO; in init_sb_info()
3080 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH; in init_sb_info()
3081 sbi->migration_granularity = sbi->segs_per_sec; in init_sb_info()
3083 sbi->dir_level = DEF_DIR_LEVEL; in init_sb_info()
3084 sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL; in init_sb_info()
3085 sbi->interval_time[REQ_TIME] = DEF_IDLE_INTERVAL; in init_sb_info()
3086 sbi->interval_time[DISCARD_TIME] = DEF_IDLE_INTERVAL; in init_sb_info()
3087 sbi->interval_time[GC_TIME] = DEF_IDLE_INTERVAL; in init_sb_info()
3088 sbi->interval_time[DISABLE_TIME] = DEF_DISABLE_INTERVAL; in init_sb_info()
3089 sbi->interval_time[UMOUNT_DISCARD_TIMEOUT] = in init_sb_info()
3091 clear_sbi_flag(sbi, SBI_NEED_FSCK); in init_sb_info()
3094 atomic_set(&sbi->nr_pages[i], 0); in init_sb_info()
3097 atomic_set(&sbi->wb_sync_req[i], 0); in init_sb_info()
3099 INIT_LIST_HEAD(&sbi->s_list); in init_sb_info()
3100 mutex_init(&sbi->umount_mutex); in init_sb_info()
3101 init_rwsem(&sbi->io_order_lock); in init_sb_info()
3102 spin_lock_init(&sbi->cp_lock); in init_sb_info()
3104 sbi->dirty_device = 0; in init_sb_info()
3105 spin_lock_init(&sbi->dev_lock); in init_sb_info()
3107 init_rwsem(&sbi->sb_lock); in init_sb_info()
3108 init_rwsem(&sbi->pin_sem); in init_sb_info()
3111 static int init_percpu_info(struct f2fs_sb_info *sbi) in init_percpu_info() argument
3115 err = percpu_counter_init(&sbi->alloc_valid_block_count, 0, GFP_KERNEL); in init_percpu_info()
3119 err = percpu_counter_init(&sbi->total_valid_inode_count, 0, in init_percpu_info()
3122 percpu_counter_destroy(&sbi->alloc_valid_block_count); in init_percpu_info()
3151 static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) in init_blkz_info() argument
3158 if (!f2fs_sb_has_blkzoned(sbi)) in init_blkz_info()
3161 if (sbi->blocks_per_blkz && sbi->blocks_per_blkz != in init_blkz_info()
3164 sbi->blocks_per_blkz = SECTOR_TO_BLOCK(bdev_zone_sectors(bdev)); in init_blkz_info()
3165 if (sbi->log_blocks_per_blkz && sbi->log_blocks_per_blkz != in init_blkz_info()
3166 __ilog2_u32(sbi->blocks_per_blkz)) in init_blkz_info()
3168 sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz); in init_blkz_info()
3170 sbi->log_blocks_per_blkz; in init_blkz_info()
3174 FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi, in init_blkz_info()
3182 FDEV(devi).zone_capacity_blocks = f2fs_kzalloc(sbi, in init_blkz_info()
3211 static int read_raw_super_block(struct f2fs_sb_info *sbi, in read_raw_super_block() argument
3215 struct super_block *sb = sbi->sb; in read_raw_super_block()
3228 f2fs_err(sbi, "Unable to read %dth superblock", in read_raw_super_block()
3236 err = sanity_check_raw_super(sbi, bh); in read_raw_super_block()
3238 f2fs_err(sbi, "Can't find valid F2FS filesystem in %dth superblock", in read_raw_super_block()
3263 int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) in f2fs_commit_super() argument
3269 if ((recover && f2fs_readonly(sbi->sb)) || in f2fs_commit_super()
3270 bdev_read_only(sbi->sb->s_bdev)) { in f2fs_commit_super()
3271 set_sbi_flag(sbi, SBI_NEED_SB_WRITE); in f2fs_commit_super()
3276 if (!recover && f2fs_sb_has_sb_chksum(sbi)) { in f2fs_commit_super()
3277 crc = f2fs_crc32(sbi, F2FS_RAW_SUPER(sbi), in f2fs_commit_super()
3279 F2FS_RAW_SUPER(sbi)->crc = cpu_to_le32(crc); in f2fs_commit_super()
3283 bh = sb_bread(sbi->sb, sbi->valid_super_block ? 0 : 1); in f2fs_commit_super()
3286 err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi)); in f2fs_commit_super()
3294 bh = sb_bread(sbi->sb, sbi->valid_super_block); in f2fs_commit_super()
3297 err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi)); in f2fs_commit_super()
3302 static int f2fs_scan_devices(struct f2fs_sb_info *sbi) in f2fs_scan_devices() argument
3304 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); in f2fs_scan_devices()
3310 if (!bdev_is_zoned(sbi->sb->s_bdev)) in f2fs_scan_devices()
3319 sbi->devs = f2fs_kzalloc(sbi, in f2fs_scan_devices()
3323 if (!sbi->devs) in f2fs_scan_devices()
3334 blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, in f2fs_scan_devices()
3335 sbi->sb->s_mode, sbi->sb->s_type); in f2fs_scan_devices()
3345 sbi->log_blocks_per_seg) - 1 + in f2fs_scan_devices()
3351 sbi->log_blocks_per_seg) - 1; in f2fs_scan_devices()
3354 sbi->sb->s_mode, sbi->sb->s_type); in f2fs_scan_devices()
3360 sbi->s_ndevs = i + 1; in f2fs_scan_devices()
3364 !f2fs_sb_has_blkzoned(sbi)) { in f2fs_scan_devices()
3365 f2fs_err(sbi, "Zoned block device feature not enabled\n"); in f2fs_scan_devices()
3369 if (init_blkz_info(sbi, i)) { in f2fs_scan_devices()
3370 f2fs_err(sbi, "Failed to initialize F2FS blkzone information"); in f2fs_scan_devices()
3375 f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: %s)", in f2fs_scan_devices()
3384 f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x", in f2fs_scan_devices()
3389 f2fs_info(sbi, in f2fs_scan_devices()
3390 "IO Block Size: %8d KB", F2FS_IO_SIZE_KB(sbi)); in f2fs_scan_devices()
3394 static int f2fs_setup_casefold(struct f2fs_sb_info *sbi) in f2fs_setup_casefold() argument
3397 if (f2fs_sb_has_casefold(sbi) && !sbi->sb->s_encoding) { in f2fs_setup_casefold()
3402 if (f2fs_sb_has_encrypt(sbi)) { in f2fs_setup_casefold()
3403 f2fs_err(sbi, in f2fs_setup_casefold()
3408 if (f2fs_sb_read_encoding(sbi->raw_super, &encoding_info, in f2fs_setup_casefold()
3410 f2fs_err(sbi, in f2fs_setup_casefold()
3417 f2fs_err(sbi, in f2fs_setup_casefold()
3424 f2fs_info(sbi, "Using encoding defined by superblock: " in f2fs_setup_casefold()
3428 sbi->sb->s_encoding = encoding; in f2fs_setup_casefold()
3429 sbi->sb->s_encoding_flags = encoding_flags; in f2fs_setup_casefold()
3430 sbi->sb->s_d_op = &f2fs_dentry_ops; in f2fs_setup_casefold()
3433 if (f2fs_sb_has_casefold(sbi)) { in f2fs_setup_casefold()
3434 f2fs_err(sbi, "Filesystem with casefold feature cannot be mounted without CONFIG_UNICODE"); in f2fs_setup_casefold()
3441 static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi) in f2fs_tuning_parameters() argument
3443 struct f2fs_sm_info *sm_i = SM_I(sbi); in f2fs_tuning_parameters()
3447 F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE; in f2fs_tuning_parameters()
3452 sbi->readdir_ra = 1; in f2fs_tuning_parameters()
3457 struct f2fs_sb_info *sbi; in f2fs_fill_super() local
3474 sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL); in f2fs_fill_super()
3475 if (!sbi) in f2fs_fill_super()
3478 sbi->sb = sb; in f2fs_fill_super()
3481 sbi->s_chksum_driver = crypto_alloc_shash("crc32", 0, 0); in f2fs_fill_super()
3482 if (IS_ERR(sbi->s_chksum_driver)) { in f2fs_fill_super()
3483 f2fs_err(sbi, "Cannot load crc32 driver."); in f2fs_fill_super()
3484 err = PTR_ERR(sbi->s_chksum_driver); in f2fs_fill_super()
3485 sbi->s_chksum_driver = NULL; in f2fs_fill_super()
3491 f2fs_err(sbi, "unable to set blocksize"); in f2fs_fill_super()
3495 err = read_raw_super_block(sbi, &raw_super, &valid_super_block, in f2fs_fill_super()
3500 sb->s_fs_info = sbi; in f2fs_fill_super()
3501 sbi->raw_super = raw_super; in f2fs_fill_super()
3504 if (f2fs_sb_has_inode_chksum(sbi)) in f2fs_fill_super()
3505 sbi->s_chksum_seed = f2fs_chksum(sbi, ~0, raw_super->uuid, in f2fs_fill_super()
3508 default_options(sbi); in f2fs_fill_super()
3520 sbi->max_file_blocks = max_file_blocks(); in f2fs_fill_super()
3521 sb->s_maxbytes = sbi->max_file_blocks << in f2fs_fill_super()
3525 err = f2fs_setup_casefold(sbi); in f2fs_fill_super()
3534 if (f2fs_sb_has_quota_ino(sbi)) { in f2fs_fill_super()
3536 if (f2fs_qf_ino(sbi->sb, i)) in f2fs_fill_super()
3537 sbi->nquota_files++; in f2fs_fill_super()
3554 (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0); in f2fs_fill_super()
3559 sbi->valid_super_block = valid_super_block; in f2fs_fill_super()
3560 init_rwsem(&sbi->gc_lock); in f2fs_fill_super()
3561 mutex_init(&sbi->writepages); in f2fs_fill_super()
3562 mutex_init(&sbi->cp_mutex); in f2fs_fill_super()
3563 init_rwsem(&sbi->node_write); in f2fs_fill_super()
3564 init_rwsem(&sbi->node_change); in f2fs_fill_super()
3567 set_sbi_flag(sbi, SBI_POR_DOING); in f2fs_fill_super()
3568 spin_lock_init(&sbi->stat_lock); in f2fs_fill_super()
3571 spin_lock_init(&sbi->iostat_lock); in f2fs_fill_super()
3572 sbi->iostat_enable = false; in f2fs_fill_super()
3573 sbi->iostat_period_ms = DEFAULT_IOSTAT_PERIOD_MS; in f2fs_fill_super()
3579 sbi->write_io[i] = in f2fs_fill_super()
3580 f2fs_kmalloc(sbi, in f2fs_fill_super()
3584 if (!sbi->write_io[i]) { in f2fs_fill_super()
3590 init_rwsem(&sbi->write_io[i][j].io_rwsem); in f2fs_fill_super()
3591 sbi->write_io[i][j].sbi = sbi; in f2fs_fill_super()
3592 sbi->write_io[i][j].bio = NULL; in f2fs_fill_super()
3593 spin_lock_init(&sbi->write_io[i][j].io_lock); in f2fs_fill_super()
3594 INIT_LIST_HEAD(&sbi->write_io[i][j].io_list); in f2fs_fill_super()
3595 INIT_LIST_HEAD(&sbi->write_io[i][j].bio_list); in f2fs_fill_super()
3596 init_rwsem(&sbi->write_io[i][j].bio_list_lock); in f2fs_fill_super()
3600 init_rwsem(&sbi->cp_rwsem); in f2fs_fill_super()
3601 init_rwsem(&sbi->quota_sem); in f2fs_fill_super()
3602 init_waitqueue_head(&sbi->cp_wait); in f2fs_fill_super()
3603 init_sb_info(sbi); in f2fs_fill_super()
3605 err = init_percpu_info(sbi); in f2fs_fill_super()
3609 if (F2FS_IO_ALIGNED(sbi)) { in f2fs_fill_super()
3610 sbi->write_io_dummy = in f2fs_fill_super()
3611 mempool_create_page_pool(2 * (F2FS_IO_SIZE(sbi) - 1), 0); in f2fs_fill_super()
3612 if (!sbi->write_io_dummy) { in f2fs_fill_super()
3619 err = f2fs_init_xattr_caches(sbi); in f2fs_fill_super()
3622 err = f2fs_init_page_array_cache(sbi); in f2fs_fill_super()
3627 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi)); in f2fs_fill_super()
3628 if (IS_ERR(sbi->meta_inode)) { in f2fs_fill_super()
3629 f2fs_err(sbi, "Failed to read F2FS meta data inode"); in f2fs_fill_super()
3630 err = PTR_ERR(sbi->meta_inode); in f2fs_fill_super()
3634 err = f2fs_get_valid_checkpoint(sbi); in f2fs_fill_super()
3636 f2fs_err(sbi, "Failed to get valid F2FS checkpoint"); in f2fs_fill_super()
3640 if (__is_set_ckpt_flags(F2FS_CKPT(sbi), CP_QUOTA_NEED_FSCK_FLAG)) in f2fs_fill_super()
3641 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); in f2fs_fill_super()
3642 if (__is_set_ckpt_flags(F2FS_CKPT(sbi), CP_DISABLED_QUICK_FLAG)) { in f2fs_fill_super()
3643 set_sbi_flag(sbi, SBI_CP_DISABLED_QUICK); in f2fs_fill_super()
3644 sbi->interval_time[DISABLE_TIME] = DEF_DISABLE_QUICK_INTERVAL; in f2fs_fill_super()
3647 if (__is_set_ckpt_flags(F2FS_CKPT(sbi), CP_FSCK_FLAG)) in f2fs_fill_super()
3648 set_sbi_flag(sbi, SBI_NEED_FSCK); in f2fs_fill_super()
3651 err = f2fs_scan_devices(sbi); in f2fs_fill_super()
3653 f2fs_err(sbi, "Failed to find devices"); in f2fs_fill_super()
3657 err = f2fs_init_post_read_wq(sbi); in f2fs_fill_super()
3659 f2fs_err(sbi, "Failed to initialize post read workqueue"); in f2fs_fill_super()
3663 sbi->total_valid_node_count = in f2fs_fill_super()
3664 le32_to_cpu(sbi->ckpt->valid_node_count); in f2fs_fill_super()
3665 percpu_counter_set(&sbi->total_valid_inode_count, in f2fs_fill_super()
3666 le32_to_cpu(sbi->ckpt->valid_inode_count)); in f2fs_fill_super()
3667 sbi->user_block_count = le64_to_cpu(sbi->ckpt->user_block_count); in f2fs_fill_super()
3668 sbi->total_valid_block_count = in f2fs_fill_super()
3669 le64_to_cpu(sbi->ckpt->valid_block_count); in f2fs_fill_super()
3670 sbi->last_valid_block_count = sbi->total_valid_block_count; in f2fs_fill_super()
3671 sbi->reserved_blocks = 0; in f2fs_fill_super()
3672 sbi->current_reserved_blocks = 0; in f2fs_fill_super()
3673 limit_reserve_root(sbi); in f2fs_fill_super()
3674 adjust_unusable_cap_perc(sbi); in f2fs_fill_super()
3677 INIT_LIST_HEAD(&sbi->inode_list[i]); in f2fs_fill_super()
3678 spin_lock_init(&sbi->inode_lock[i]); in f2fs_fill_super()
3680 mutex_init(&sbi->flush_lock); in f2fs_fill_super()
3682 f2fs_init_extent_cache_info(sbi); in f2fs_fill_super()
3684 f2fs_init_ino_entry_info(sbi); in f2fs_fill_super()
3686 f2fs_init_fsync_node_info(sbi); in f2fs_fill_super()
3689 err = f2fs_build_segment_manager(sbi); in f2fs_fill_super()
3691 f2fs_err(sbi, "Failed to initialize F2FS segment manager (%d)", in f2fs_fill_super()
3695 err = f2fs_build_node_manager(sbi); in f2fs_fill_super()
3697 f2fs_err(sbi, "Failed to initialize F2FS node manager (%d)", in f2fs_fill_super()
3704 sbi->sectors_written_start = in f2fs_fill_super()
3709 seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE); in f2fs_fill_super()
3710 if (__exist_node_summaries(sbi)) in f2fs_fill_super()
3711 sbi->kbytes_written = in f2fs_fill_super()
3714 f2fs_build_gc_manager(sbi); in f2fs_fill_super()
3716 err = f2fs_build_stats(sbi); in f2fs_fill_super()
3721 sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi)); in f2fs_fill_super()
3722 if (IS_ERR(sbi->node_inode)) { in f2fs_fill_super()
3723 f2fs_err(sbi, "Failed to read node inode"); in f2fs_fill_super()
3724 err = PTR_ERR(sbi->node_inode); in f2fs_fill_super()
3729 root = f2fs_iget(sb, F2FS_ROOT_INO(sbi)); in f2fs_fill_super()
3731 f2fs_err(sbi, "Failed to read root inode"); in f2fs_fill_super()
3748 err = f2fs_register_sysfs(sbi); in f2fs_fill_super()
3754 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) { in f2fs_fill_super()
3757 f2fs_err(sbi, "Cannot turn on quotas: error %d", err); in f2fs_fill_super()
3761 err = f2fs_recover_orphan_inodes(sbi); in f2fs_fill_super()
3765 if (unlikely(is_set_ckpt_flags(sbi, CP_DISABLED_FLAG))) in f2fs_fill_super()
3769 if (!test_opt(sbi, DISABLE_ROLL_FORWARD) && in f2fs_fill_super()
3770 !test_opt(sbi, NORECOVERY)) { in f2fs_fill_super()
3775 if (f2fs_hw_is_readonly(sbi)) { in f2fs_fill_super()
3776 if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { in f2fs_fill_super()
3778 f2fs_err(sbi, "Need to recover fsync data, but write access unavailable"); in f2fs_fill_super()
3781 f2fs_info(sbi, "write access unavailable, skipping recovery"); in f2fs_fill_super()
3786 set_sbi_flag(sbi, SBI_NEED_FSCK); in f2fs_fill_super()
3791 err = f2fs_recover_fsync_data(sbi, false); in f2fs_fill_super()
3796 f2fs_err(sbi, "Cannot recover all fsync data errno=%d", in f2fs_fill_super()
3801 err = f2fs_recover_fsync_data(sbi, true); in f2fs_fill_super()
3805 f2fs_err(sbi, "Need to recover fsync data"); in f2fs_fill_super()
3814 if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) { in f2fs_fill_super()
3815 err = f2fs_check_write_pointer(sbi); in f2fs_fill_super()
3821 f2fs_init_inmem_curseg(sbi); in f2fs_fill_super()
3824 clear_sbi_flag(sbi, SBI_POR_DOING); in f2fs_fill_super()
3826 if (test_opt(sbi, DISABLE_CHECKPOINT)) { in f2fs_fill_super()
3827 err = f2fs_disable_checkpoint(sbi); in f2fs_fill_super()
3830 } else if (is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)) { in f2fs_fill_super()
3831 f2fs_enable_checkpoint(sbi); in f2fs_fill_super()
3838 if (F2FS_OPTION(sbi).bggc_mode != BGGC_MODE_OFF && !f2fs_readonly(sb)) { in f2fs_fill_super()
3840 err = f2fs_start_gc_thread(sbi); in f2fs_fill_super()
3848 err = f2fs_commit_super(sbi, true); in f2fs_fill_super()
3849 f2fs_info(sbi, "Try to recover %dth superblock, ret: %d", in f2fs_fill_super()
3850 sbi->valid_super_block ? 1 : 2, err); in f2fs_fill_super()
3853 f2fs_join_shrinker(sbi); in f2fs_fill_super()
3855 f2fs_tuning_parameters(sbi); in f2fs_fill_super()
3857 f2fs_notice(sbi, "Mounted with checkpoint version = %llx", in f2fs_fill_super()
3858 cur_cp_version(F2FS_CKPT(sbi))); in f2fs_fill_super()
3859 f2fs_update_time(sbi, CP_TIME); in f2fs_fill_super()
3860 f2fs_update_time(sbi, REQ_TIME); in f2fs_fill_super()
3861 clear_sbi_flag(sbi, SBI_CP_DISABLED_QUICK); in f2fs_fill_super()
3866 sync_filesystem(sbi->sb); in f2fs_fill_super()
3872 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) in f2fs_fill_super()
3873 f2fs_quota_off_umount(sbi->sb); in f2fs_fill_super()
3881 truncate_inode_pages_final(META_MAPPING(sbi)); in f2fs_fill_super()
3884 f2fs_unregister_sysfs(sbi); in f2fs_fill_super()
3889 f2fs_release_ino_entry(sbi, true); in f2fs_fill_super()
3890 truncate_inode_pages_final(NODE_MAPPING(sbi)); in f2fs_fill_super()
3891 iput(sbi->node_inode); in f2fs_fill_super()
3892 sbi->node_inode = NULL; in f2fs_fill_super()
3894 f2fs_destroy_stats(sbi); in f2fs_fill_super()
3896 f2fs_destroy_node_manager(sbi); in f2fs_fill_super()
3898 f2fs_destroy_segment_manager(sbi); in f2fs_fill_super()
3899 f2fs_destroy_post_read_wq(sbi); in f2fs_fill_super()
3901 destroy_device_list(sbi); in f2fs_fill_super()
3902 kvfree(sbi->ckpt); in f2fs_fill_super()
3904 make_bad_inode(sbi->meta_inode); in f2fs_fill_super()
3905 iput(sbi->meta_inode); in f2fs_fill_super()
3906 sbi->meta_inode = NULL; in f2fs_fill_super()
3908 f2fs_destroy_page_array_cache(sbi); in f2fs_fill_super()
3910 f2fs_destroy_xattr_caches(sbi); in f2fs_fill_super()
3912 mempool_destroy(sbi->write_io_dummy); in f2fs_fill_super()
3914 destroy_percpu_info(sbi); in f2fs_fill_super()
3917 kvfree(sbi->write_io[i]); in f2fs_fill_super()
3925 kfree(F2FS_OPTION(sbi).s_qf_names[i]); in f2fs_fill_super()
3927 fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy); in f2fs_fill_super()
3932 if (sbi->s_chksum_driver) in f2fs_fill_super()
3933 crypto_free_shash(sbi->s_chksum_driver); in f2fs_fill_super()
3934 kfree(sbi); in f2fs_fill_super()
3954 struct f2fs_sb_info *sbi = F2FS_SB(sb); in kill_f2fs_super() local
3956 set_sbi_flag(sbi, SBI_IS_CLOSE); in kill_f2fs_super()
3957 f2fs_stop_gc_thread(sbi); in kill_f2fs_super()
3958 f2fs_stop_discard_thread(sbi); in kill_f2fs_super()
3960 if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) || in kill_f2fs_super()
3961 !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { in kill_f2fs_super()
3965 f2fs_write_checkpoint(sbi, &cpc); in kill_f2fs_super()
3968 if (is_sbi_flag_set(sbi, SBI_IS_RECOVERED) && f2fs_readonly(sb)) in kill_f2fs_super()