• Home
  • Raw
  • Download

Lines Matching full:sb

68 static void ext4_update_super(struct super_block *sb);
69 static int ext4_commit_super(struct super_block *sb);
70 static int ext4_mark_recovery_complete(struct super_block *sb,
72 static int ext4_clear_journal_err(struct super_block *sb,
74 static int ext4_sync_fs(struct super_block *sb, int wait);
75 static int ext4_remount(struct super_block *sb, int *flags, char *data);
77 static int ext4_unfreeze(struct super_block *sb);
78 static int ext4_freeze(struct super_block *sb);
81 static inline int ext2_feature_set_ok(struct super_block *sb);
82 static inline int ext3_feature_set_ok(struct super_block *sb);
83 static int ext4_feature_set_ok(struct super_block *sb, int readonly);
85 static void ext4_unregister_li_request(struct super_block *sb);
87 static struct inode *ext4_get_journal_inode(struct super_block *sb,
128 #define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type) argument
130 #define IS_EXT2_SB(sb) (0) argument
143 #define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) argument
206 static struct buffer_head *__ext4_sb_bread_gfp(struct super_block *sb, in __ext4_sb_bread_gfp() argument
213 bh = sb_getblk_gfp(sb, block, gfp); in __ext4_sb_bread_gfp()
227 struct buffer_head *ext4_sb_bread(struct super_block *sb, sector_t block, in ext4_sb_bread() argument
230 return __ext4_sb_bread_gfp(sb, block, op_flags, __GFP_MOVABLE); in ext4_sb_bread()
233 struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb, in ext4_sb_bread_unmovable() argument
236 return __ext4_sb_bread_gfp(sb, block, 0, 0); in ext4_sb_bread_unmovable()
239 void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block) in ext4_sb_breadahead_unmovable() argument
241 struct buffer_head *bh = sb_getblk_gfp(sb, block, 0); in ext4_sb_breadahead_unmovable()
250 static int ext4_verify_csum_type(struct super_block *sb, in ext4_verify_csum_type() argument
253 if (!ext4_has_feature_metadata_csum(sb)) in ext4_verify_csum_type()
259 static __le32 ext4_superblock_csum(struct super_block *sb, in ext4_superblock_csum() argument
262 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_superblock_csum()
271 static int ext4_superblock_csum_verify(struct super_block *sb, in ext4_superblock_csum_verify() argument
274 if (!ext4_has_metadata_csum(sb)) in ext4_superblock_csum_verify()
277 return es->s_checksum == ext4_superblock_csum(sb, es); in ext4_superblock_csum_verify()
280 void ext4_superblock_csum_set(struct super_block *sb) in ext4_superblock_csum_set() argument
282 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in ext4_superblock_csum_set()
284 if (!ext4_has_metadata_csum(sb)) in ext4_superblock_csum_set()
287 es->s_checksum = ext4_superblock_csum(sb, es); in ext4_superblock_csum_set()
290 ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, in ext4_block_bitmap() argument
294 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_block_bitmap()
298 ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, in ext4_inode_bitmap() argument
302 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_inode_bitmap()
306 ext4_fsblk_t ext4_inode_table(struct super_block *sb, in ext4_inode_table() argument
310 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_inode_table()
314 __u32 ext4_free_group_clusters(struct super_block *sb, in ext4_free_group_clusters() argument
318 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_free_group_clusters()
322 __u32 ext4_free_inodes_count(struct super_block *sb, in ext4_free_inodes_count() argument
326 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_free_inodes_count()
330 __u32 ext4_used_dirs_count(struct super_block *sb, in ext4_used_dirs_count() argument
334 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_used_dirs_count()
338 __u32 ext4_itable_unused_count(struct super_block *sb, in ext4_itable_unused_count() argument
342 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_itable_unused_count()
346 void ext4_block_bitmap_set(struct super_block *sb, in ext4_block_bitmap_set() argument
350 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_block_bitmap_set()
354 void ext4_inode_bitmap_set(struct super_block *sb, in ext4_inode_bitmap_set() argument
358 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_inode_bitmap_set()
362 void ext4_inode_table_set(struct super_block *sb, in ext4_inode_table_set() argument
366 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_inode_table_set()
370 void ext4_free_group_clusters_set(struct super_block *sb, in ext4_free_group_clusters_set() argument
374 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_free_group_clusters_set()
378 void ext4_free_inodes_set(struct super_block *sb, in ext4_free_inodes_set() argument
382 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_free_inodes_set()
386 void ext4_used_dirs_set(struct super_block *sb, in ext4_used_dirs_set() argument
390 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_used_dirs_set()
394 void ext4_itable_unused_set(struct super_block *sb, in ext4_itable_unused_set() argument
398 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_itable_unused_set()
428 static int block_device_ejected(struct super_block *sb) in block_device_ejected() argument
430 struct inode *bd_inode = sb->s_bdev->bd_inode; in block_device_ejected()
438 struct super_block *sb = journal->j_private; in ext4_journal_commit_callback() local
439 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_journal_commit_callback()
445 ext4_process_freed_data(sb, txn->t_tid); in ext4_journal_commit_callback()
453 jce->jce_func(sb, jce, error); in ext4_journal_commit_callback()
584 static void save_error_info(struct super_block *sb, int error, in save_error_info() argument
588 struct ext4_sb_info *sbi = EXT4_SB(sb); in save_error_info()
633 static void ext4_handle_error(struct super_block *sb, bool force_ro, int error, in ext4_handle_error() argument
637 journal_t *journal = EXT4_SB(sb)->s_journal; in ext4_handle_error()
638 bool continue_fs = !force_ro && test_opt(sb, ERRORS_CONT); in ext4_handle_error()
640 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; in ext4_handle_error()
641 if (test_opt(sb, WARN_ON_ERROR)) in ext4_handle_error()
644 if (!continue_fs && !sb_rdonly(sb)) { in ext4_handle_error()
645 ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED); in ext4_handle_error()
650 if (!bdev_read_only(sb->s_bdev)) { in ext4_handle_error()
651 save_error_info(sb, error, ino, block, func, line); in ext4_handle_error()
658 * here in that case, just update the sb directly as the last in ext4_handle_error()
662 !ext4_test_mount_flag(sb, EXT4_MF_JOURNAL_DESTROY)) in ext4_handle_error()
663 schedule_work(&EXT4_SB(sb)->s_error_work); in ext4_handle_error()
665 ext4_commit_super(sb); in ext4_handle_error()
673 if (test_opt(sb, ERRORS_PANIC) && !system_going_down()) { in ext4_handle_error()
675 sb->s_id); in ext4_handle_error()
678 if (sb_rdonly(sb) || continue_fs) in ext4_handle_error()
681 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); in ext4_handle_error()
685 * sb->s_umount semaphore and setting it without proper remount in ext4_handle_error()
700 * through the journal to avoid collisions of other journalled sb in flush_stashed_error_work()
732 * Write through journal failed. Write sb directly to get error info in flush_stashed_error_work()
738 #define ext4_error_ratelimit(sb) \ argument
739 ___ratelimit(&(EXT4_SB(sb)->s_err_ratelimit_state), \
742 void __ext4_error(struct super_block *sb, const char *function, in __ext4_error() argument
749 if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) in __ext4_error()
752 trace_ext4_error(sb, function, line); in __ext4_error()
753 if (ext4_error_ratelimit(sb)) { in __ext4_error()
759 sb->s_id, function, line, current->comm, &vaf); in __ext4_error()
762 ext4_handle_error(sb, force_ro, error, 0, block, function, line); in __ext4_error()
834 const char *ext4_decode_error(struct super_block *sb, int errno, in ext4_decode_error() argument
853 if (!sb || (EXT4_SB(sb)->s_journal && in ext4_decode_error()
854 EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT)) in ext4_decode_error()
877 void __ext4_std_error(struct super_block *sb, const char *function, in __ext4_std_error() argument
883 if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) in __ext4_std_error()
889 if (errno == -EROFS && journal_current_handle() == NULL && sb_rdonly(sb)) in __ext4_std_error()
892 if (ext4_error_ratelimit(sb)) { in __ext4_std_error()
893 errstr = ext4_decode_error(sb, errno, nbuf); in __ext4_std_error()
895 sb->s_id, function, line, errstr); in __ext4_std_error()
898 ext4_handle_error(sb, false, -errno, 0, 0, function, line); in __ext4_std_error()
901 void __ext4_msg(struct super_block *sb, in __ext4_msg() argument
907 atomic_inc(&EXT4_SB(sb)->s_msg_count); in __ext4_msg()
908 if (!___ratelimit(&(EXT4_SB(sb)->s_msg_ratelimit_state), "EXT4-fs")) in __ext4_msg()
914 printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf); in __ext4_msg()
918 static int ext4_warning_ratelimit(struct super_block *sb) in ext4_warning_ratelimit() argument
920 atomic_inc(&EXT4_SB(sb)->s_warning_count); in ext4_warning_ratelimit()
921 return ___ratelimit(&(EXT4_SB(sb)->s_warning_ratelimit_state), in ext4_warning_ratelimit()
925 void __ext4_warning(struct super_block *sb, const char *function, in __ext4_warning() argument
931 if (!ext4_warning_ratelimit(sb)) in __ext4_warning()
938 sb->s_id, function, line, &vaf); in __ext4_warning()
961 struct super_block *sb, ext4_group_t grp, in __ext4_grp_locked_error() argument
970 if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) in __ext4_grp_locked_error()
973 trace_ext4_error(sb, function, line); in __ext4_grp_locked_error()
974 if (ext4_error_ratelimit(sb)) { in __ext4_grp_locked_error()
979 sb->s_id, function, line, grp); in __ext4_grp_locked_error()
989 if (test_opt(sb, ERRORS_CONT)) { in __ext4_grp_locked_error()
990 if (test_opt(sb, WARN_ON_ERROR)) in __ext4_grp_locked_error()
992 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; in __ext4_grp_locked_error()
993 if (!bdev_read_only(sb->s_bdev)) { in __ext4_grp_locked_error()
994 save_error_info(sb, EFSCORRUPTED, ino, block, function, in __ext4_grp_locked_error()
996 schedule_work(&EXT4_SB(sb)->s_error_work); in __ext4_grp_locked_error()
1000 ext4_unlock_group(sb, grp); in __ext4_grp_locked_error()
1001 ext4_handle_error(sb, false, EFSCORRUPTED, ino, block, function, line); in __ext4_grp_locked_error()
1013 ext4_lock_group(sb, grp); in __ext4_grp_locked_error()
1017 void ext4_mark_group_bitmap_corrupted(struct super_block *sb, in ext4_mark_group_bitmap_corrupted() argument
1021 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_mark_group_bitmap_corrupted()
1022 struct ext4_group_info *grp = ext4_get_group_info(sb, group); in ext4_mark_group_bitmap_corrupted()
1023 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL); in ext4_mark_group_bitmap_corrupted()
1042 count = ext4_free_inodes_count(sb, gdp); in ext4_mark_group_bitmap_corrupted()
1049 void ext4_update_dynamic_rev(struct super_block *sb) in ext4_update_dynamic_rev() argument
1051 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in ext4_update_dynamic_rev()
1056 ext4_warning(sb, in ext4_update_dynamic_rev()
1077 static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb) in ext4_blkdev_get() argument
1081 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); in ext4_blkdev_get()
1087 ext4_msg(sb, KERN_ERR, in ext4_blkdev_get()
1122 static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi) in dump_orphan_list() argument
1126 ext4_msg(sb, KERN_ERR, "sb orphan head is %d", in dump_orphan_list()
1141 static int ext4_quota_off(struct super_block *sb, int type);
1143 static inline void ext4_quota_off_umount(struct super_block *sb) in ext4_quota_off_umount() argument
1149 ext4_quota_off(sb, type); in ext4_quota_off_umount()
1156 static inline char *get_qf_name(struct super_block *sb, in get_qf_name() argument
1161 lockdep_is_held(&sb->s_umount)); in get_qf_name()
1164 static inline void ext4_quota_off_umount(struct super_block *sb) in ext4_quota_off_umount() argument
1169 static void ext4_put_super(struct super_block *sb) in ext4_put_super() argument
1171 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_put_super()
1188 ext4_unregister_sysfs(sb); in ext4_put_super()
1190 ext4_unregister_li_request(sb); in ext4_put_super()
1191 ext4_quota_off_umount(sb); in ext4_put_super()
1198 ext4_abort(sb, -err, "Couldn't clean up the journal"); in ext4_put_super()
1206 ext4_release_system_zone(sb); in ext4_put_super()
1207 ext4_mb_release(sb); in ext4_put_super()
1208 ext4_ext_release(sb); in ext4_put_super()
1210 if (!sb_rdonly(sb) && !aborted) { in ext4_put_super()
1211 ext4_clear_feature_journal_needs_recovery(sb); in ext4_put_super()
1214 if (!sb_rdonly(sb)) in ext4_put_super()
1215 ext4_commit_super(sb); in ext4_put_super()
1237 kfree(get_qf_name(sb, sbi, i)); in ext4_put_super()
1245 dump_orphan_list(sb, sbi); in ext4_put_super()
1248 sync_blockdev(sb->s_bdev); in ext4_put_super()
1249 invalidate_bdev(sb->s_bdev); in ext4_put_super()
1250 if (sbi->s_journal_bdev && sbi->s_journal_bdev != sb->s_bdev) { in ext4_put_super()
1264 sb->s_fs_info = NULL; in ext4_put_super()
1277 utf8_unload(sb->s_encoding); in ext4_put_super()
1287 static struct inode *ext4_alloc_inode(struct super_block *sb) in ext4_alloc_inode() argument
1420 static struct inode *ext4_nfs_get_inode(struct super_block *sb, in ext4_nfs_get_inode() argument
1429 inode = ext4_iget(sb, ino, EXT4_IGET_HANDLE); in ext4_nfs_get_inode()
1440 static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, in ext4_fh_to_dentry() argument
1443 return generic_fh_to_dentry(sb, fid, fh_len, fh_type, in ext4_fh_to_dentry()
1447 static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, in ext4_fh_to_parent() argument
1450 return generic_fh_to_parent(sb, fid, fh_len, fh_type, in ext4_fh_to_parent()
1558 static const union fscrypt_policy *ext4_get_dummy_policy(struct super_block *sb) in ext4_get_dummy_policy() argument
1560 return EXT4_SB(sb)->s_dummy_enc_policy.policy; in ext4_get_dummy_policy()
1563 static bool ext4_has_stable_inodes(struct super_block *sb) in ext4_has_stable_inodes() argument
1565 return ext4_has_feature_stable_inodes(sb); in ext4_has_stable_inodes()
1568 static void ext4_get_ino_and_lblk_bits(struct super_block *sb, in ext4_get_ino_and_lblk_bits() argument
1571 *ino_bits_ret = 8 * sizeof(EXT4_SB(sb)->s_es->s_inodes_count); in ext4_get_ino_and_lblk_bits()
1595 static int ext4_write_info(struct super_block *sb, int type);
1596 static int ext4_quota_on(struct super_block *sb, int type, int format_id,
1598 static int ext4_quota_on_mount(struct super_block *sb, int type);
1599 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
1601 static ssize_t ext4_quota_write(struct super_block *sb, int type,
1603 static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
1605 static int ext4_enable_quotas(struct super_block *sb);
1706 {Opt_sb, "sb=%u"},
1805 if (!options || strncmp(options, "sb=", 3) != 0) in get_sb_block()
1812 printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n", in get_sb_block()
1829 static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) in set_qf_name() argument
1831 struct ext4_sb_info *sbi = EXT4_SB(sb); in set_qf_name()
1832 char *qname, *old_qname = get_qf_name(sb, sbi, qtype); in set_qf_name()
1835 if (sb_any_quota_loaded(sb) && !old_qname) { in set_qf_name()
1836 ext4_msg(sb, KERN_ERR, in set_qf_name()
1841 if (ext4_has_feature_quota(sb)) { in set_qf_name()
1842 ext4_msg(sb, KERN_INFO, "Journaled quota options " in set_qf_name()
1848 ext4_msg(sb, KERN_ERR, in set_qf_name()
1856 ext4_msg(sb, KERN_ERR, in set_qf_name()
1862 ext4_msg(sb, KERN_ERR, in set_qf_name()
1867 set_opt(sb, QUOTA); in set_qf_name()
1874 static int clear_qf_name(struct super_block *sb, int qtype) in clear_qf_name() argument
1877 struct ext4_sb_info *sbi = EXT4_SB(sb); in clear_qf_name()
1878 char *old_qname = get_qf_name(sb, sbi, qtype); in clear_qf_name()
1880 if (sb_any_quota_loaded(sb) && old_qname) { in clear_qf_name()
1881 ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options" in clear_qf_name()
2051 static int ext4_set_test_dummy_encryption(struct super_block *sb, in ext4_set_test_dummy_encryption() argument
2057 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_set_test_dummy_encryption()
2060 if (!ext4_has_feature_encrypt(sb)) { in ext4_set_test_dummy_encryption()
2061 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2073 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2077 err = fscrypt_set_test_dummy_encryption(sb, arg->from, in ext4_set_test_dummy_encryption()
2081 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2084 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2087 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2092 ext4_msg(sb, KERN_WARNING, "Test dummy encryption mode enabled"); in ext4_set_test_dummy_encryption()
2095 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2102 static int handle_mount_opt(struct super_block *sb, char *opt, int token, in handle_mount_opt() argument
2106 struct ext4_sb_info *sbi = EXT4_SB(sb); in handle_mount_opt()
2114 return set_qf_name(sb, USRQUOTA, &args[0]); in handle_mount_opt()
2116 return set_qf_name(sb, GRPQUOTA, &args[0]); in handle_mount_opt()
2118 return clear_qf_name(sb, USRQUOTA); in handle_mount_opt()
2120 return clear_qf_name(sb, GRPQUOTA); in handle_mount_opt()
2125 ext4_msg(sb, KERN_WARNING, deprecated_msg, opt, "3.5"); in handle_mount_opt()
2130 ext4_msg(sb, KERN_WARNING, "Ignoring removed %s option", opt); in handle_mount_opt()
2133 ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED); in handle_mount_opt()
2136 sb->s_flags |= SB_I_VERSION; in handle_mount_opt()
2139 sb->s_flags |= SB_LAZYTIME; in handle_mount_opt()
2142 sb->s_flags &= ~SB_LAZYTIME; in handle_mount_opt()
2146 sb->s_flags |= SB_INLINECRYPT; in handle_mount_opt()
2148 ext4_msg(sb, KERN_ERR, "inline encryption not supported"); in handle_mount_opt()
2158 ext4_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" " in handle_mount_opt()
2163 if ((m->flags & MOPT_NO_EXT2) && IS_EXT2_SB(sb)) { in handle_mount_opt()
2164 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2168 if ((m->flags & MOPT_NO_EXT3) && IS_EXT3_SB(sb)) { in handle_mount_opt()
2169 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2180 set_opt2(sb, EXPLICIT_DELALLOC); in handle_mount_opt()
2182 set_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM); in handle_mount_opt()
2187 clear_opt(sb, ERRORS_MASK); in handle_mount_opt()
2188 if (token == Opt_noquota && sb_any_quota_loaded(sb)) { in handle_mount_opt()
2189 ext4_msg(sb, KERN_ERR, "Cannot change quota " in handle_mount_opt()
2195 ext4_msg(sb, KERN_ERR, "%s option not supported", opt); in handle_mount_opt()
2200 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2211 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2222 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2229 set_opt(sb, INIT_INODE_TABLE); in handle_mount_opt()
2244 ext4_msg(sb, KERN_ERR, "Invalid uid value %d", arg); in handle_mount_opt()
2251 ext4_msg(sb, KERN_ERR, "Invalid gid value %d", arg); in handle_mount_opt()
2257 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2269 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2275 ext4_msg(sb, KERN_ERR, "error: could not dup " in handle_mount_opt()
2282 ext4_msg(sb, KERN_ERR, "error: could not find " in handle_mount_opt()
2290 ext4_msg(sb, KERN_ERR, "error: journal path %s " in handle_mount_opt()
2302 ext4_msg(sb, KERN_ERR, "Invalid journal IO priority" in handle_mount_opt()
2309 return ext4_set_test_dummy_encryption(sb, opt, &args[0], in handle_mount_opt()
2314 …ext4_msg(sb, KERN_WARNING, "Remounting file system with no journal so ignoring journalled data opt… in handle_mount_opt()
2315 else if (test_opt(sb, DATA_FLAGS) != m->mount_opt) { in handle_mount_opt()
2316 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2321 clear_opt(sb, DATA_FLAGS); in handle_mount_opt()
2326 if (sb_any_quota_loaded(sb) && in handle_mount_opt()
2328 ext4_msg(sb, KERN_ERR, "Cannot change journaled " in handle_mount_opt()
2332 if (ext4_has_feature_quota(sb)) { in handle_mount_opt()
2333 ext4_msg(sb, KERN_INFO, in handle_mount_opt()
2350 ext4_msg(sb, KERN_ERR, "can't change " in handle_mount_opt()
2355 (test_opt(sb, DATA_FLAGS) == in handle_mount_opt()
2357 ext4_msg(sb, KERN_ERR, "can't mount with " in handle_mount_opt()
2361 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
2387 ext4_msg(sb, KERN_INFO, "dax option not supported"); in handle_mount_opt()
2402 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
2422 static int parse_options(char *options, struct super_block *sb, in parse_options() argument
2427 struct ext4_sb_info __maybe_unused *sbi = EXT4_SB(sb); in parse_options()
2444 if (handle_mount_opt(sb, p, token, args, journal_devnum, in parse_options()
2454 if (test_opt(sb, PRJQUOTA) && !ext4_has_feature_project(sb)) { in parse_options()
2455 ext4_msg(sb, KERN_ERR, "Project quota feature not enabled. " in parse_options()
2459 usr_qf_name = get_qf_name(sb, sbi, USRQUOTA); in parse_options()
2460 grp_qf_name = get_qf_name(sb, sbi, GRPQUOTA); in parse_options()
2462 if (test_opt(sb, USRQUOTA) && usr_qf_name) in parse_options()
2463 clear_opt(sb, USRQUOTA); in parse_options()
2465 if (test_opt(sb, GRPQUOTA) && grp_qf_name) in parse_options()
2466 clear_opt(sb, GRPQUOTA); in parse_options()
2468 if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { in parse_options()
2469 ext4_msg(sb, KERN_ERR, "old and new quota " in parse_options()
2475 ext4_msg(sb, KERN_ERR, "journaled quota format " in parse_options()
2481 if (test_opt(sb, DIOREAD_NOLOCK)) { in parse_options()
2485 ext4_msg(sb, KERN_WARNING, "Warning: mounting with an " in parse_options()
2493 struct super_block *sb) in ext4_show_quota_options() argument
2496 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_show_quota_options()
2540 * - if the per-sb default is different from the global default
2542 static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, in _ext4_show_options() argument
2545 struct ext4_sb_info *sbi = EXT4_SB(sb); in _ext4_show_options()
2555 SEQ_OPTS_PRINT("sb=%llu", sbi->s_sb_block); in _ext4_show_options()
2580 if (test_opt(sb, ERRORS_RO) && def_errors != EXT4_ERRORS_RO) in _ext4_show_options()
2582 if (test_opt(sb, ERRORS_CONT) && def_errors != EXT4_ERRORS_CONTINUE) in _ext4_show_options()
2584 if (test_opt(sb, ERRORS_PANIC) && def_errors != EXT4_ERRORS_PANIC) in _ext4_show_options()
2592 if (sb->s_flags & SB_I_VERSION) in _ext4_show_options()
2598 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) in _ext4_show_options()
2600 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) in _ext4_show_options()
2602 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA) in _ext4_show_options()
2610 if (test_opt(sb, INIT_INODE_TABLE) && (nodefs || in _ext4_show_options()
2615 if (test_opt(sb, DATA_ERR_ABORT)) in _ext4_show_options()
2618 fscrypt_show_test_dummy_encryption(seq, sep, sb); in _ext4_show_options()
2620 if (sb->s_flags & SB_INLINECRYPT) in _ext4_show_options()
2623 if (test_opt(sb, DAX_ALWAYS)) { in _ext4_show_options()
2624 if (IS_EXT2_SB(sb)) in _ext4_show_options()
2628 } else if (test_opt2(sb, DAX_NEVER)) { in _ext4_show_options()
2630 } else if (test_opt2(sb, DAX_INODE)) { in _ext4_show_options()
2633 ext4_show_quota_options(seq, sb); in _ext4_show_options()
2644 struct super_block *sb = seq->private; in ext4_seq_options_show() local
2647 seq_puts(seq, sb_rdonly(sb) ? "ro" : "rw"); in ext4_seq_options_show()
2648 rc = _ext4_show_options(seq, sb, 1); in ext4_seq_options_show()
2653 static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, in ext4_setup_super() argument
2656 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_setup_super()
2660 ext4_msg(sb, KERN_ERR, "revision level too high, " in ext4_setup_super()
2668 ext4_msg(sb, KERN_WARNING, "warning: mounting unchecked fs, " in ext4_setup_super()
2671 ext4_msg(sb, KERN_WARNING, in ext4_setup_super()
2677 ext4_msg(sb, KERN_WARNING, in ext4_setup_super()
2683 ext4_msg(sb, KERN_WARNING, in ext4_setup_super()
2693 ext4_set_feature_journal_needs_recovery(sb); in ext4_setup_super()
2695 err = ext4_commit_super(sb); in ext4_setup_super()
2697 if (test_opt(sb, DEBUG)) in ext4_setup_super()
2700 sb->s_blocksize, in ext4_setup_super()
2702 EXT4_BLOCKS_PER_GROUP(sb), in ext4_setup_super()
2703 EXT4_INODES_PER_GROUP(sb), in ext4_setup_super()
2706 cleancache_init_fs(sb); in ext4_setup_super()
2710 int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup) in ext4_alloc_flex_bg_array() argument
2712 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_alloc_flex_bg_array()
2726 ext4_msg(sb, KERN_ERR, in ext4_alloc_flex_bg_array()
2738 ext4_msg(sb, KERN_ERR, in ext4_alloc_flex_bg_array()
2757 static int ext4_fill_flex_info(struct super_block *sb) in ext4_fill_flex_info() argument
2759 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_fill_flex_info()
2771 err = ext4_alloc_flex_bg_array(sb, sbi->s_groups_count); in ext4_fill_flex_info()
2776 gdp = ext4_get_group_desc(sb, i, NULL); in ext4_fill_flex_info()
2780 atomic_add(ext4_free_inodes_count(sb, gdp), &fg->free_inodes); in ext4_fill_flex_info()
2781 atomic64_add(ext4_free_group_clusters(sb, gdp), in ext4_fill_flex_info()
2783 atomic_add(ext4_used_dirs_count(sb, gdp), &fg->used_dirs); in ext4_fill_flex_info()
2791 static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum() argument
2797 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_group_desc_csum()
2819 if (!ext4_has_feature_gdt_csum(sb)) in ext4_group_desc_csum()
2827 if (ext4_has_feature_64bit(sb) && offset < sbi->s_desc_size) in ext4_group_desc_csum()
2835 int ext4_group_desc_csum_verify(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum_verify() argument
2838 if (ext4_has_group_desc_csum(sb) && in ext4_group_desc_csum_verify()
2839 (gdp->bg_checksum != ext4_group_desc_csum(sb, block_group, gdp))) in ext4_group_desc_csum_verify()
2845 void ext4_group_desc_csum_set(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum_set() argument
2848 if (!ext4_has_group_desc_csum(sb)) in ext4_group_desc_csum_set()
2850 gdp->bg_checksum = ext4_group_desc_csum(sb, block_group, gdp); in ext4_group_desc_csum_set()
2854 static int ext4_check_descriptors(struct super_block *sb, in ext4_check_descriptors() argument
2858 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_check_descriptors()
2861 ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0); in ext4_check_descriptors()
2868 if (ext4_has_feature_flex_bg(sb)) in ext4_check_descriptors()
2874 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, NULL); in ext4_check_descriptors()
2880 (EXT4_BLOCKS_PER_GROUP(sb) - 1); in ext4_check_descriptors()
2886 block_bitmap = ext4_block_bitmap(sb, gdp); in ext4_check_descriptors()
2888 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2891 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2896 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2899 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2903 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2908 inode_bitmap = ext4_inode_bitmap(sb, gdp); in ext4_check_descriptors()
2910 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2913 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2918 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2921 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2925 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2930 inode_table = ext4_inode_table(sb, gdp); in ext4_check_descriptors()
2932 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2935 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2940 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2943 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2948 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2953 ext4_lock_group(sb, i); in ext4_check_descriptors()
2954 if (!ext4_group_desc_csum_verify(sb, i, gdp)) { in ext4_check_descriptors()
2955 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2957 i, le16_to_cpu(ext4_group_desc_csum(sb, i, in ext4_check_descriptors()
2959 if (!sb_rdonly(sb)) { in ext4_check_descriptors()
2960 ext4_unlock_group(sb, i); in ext4_check_descriptors()
2964 ext4_unlock_group(sb, i); in ext4_check_descriptors()
2966 first_block += EXT4_BLOCKS_PER_GROUP(sb); in ext4_check_descriptors()
2990 static void ext4_orphan_cleanup(struct super_block *sb, in ext4_orphan_cleanup() argument
2993 unsigned int s_flags = sb->s_flags; in ext4_orphan_cleanup()
3004 if (bdev_read_only(sb->s_bdev)) { in ext4_orphan_cleanup()
3005 ext4_msg(sb, KERN_ERR, "write access " in ext4_orphan_cleanup()
3011 if (!ext4_feature_set_ok(sb, 0)) { in ext4_orphan_cleanup()
3012 ext4_msg(sb, KERN_INFO, "Skipping orphan cleanup due to " in ext4_orphan_cleanup()
3017 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) { in ext4_orphan_cleanup()
3020 ext4_msg(sb, KERN_INFO, "Errors on filesystem, " in ext4_orphan_cleanup()
3029 ext4_msg(sb, KERN_INFO, "orphan cleanup on readonly fs"); in ext4_orphan_cleanup()
3030 sb->s_flags &= ~SB_RDONLY; in ext4_orphan_cleanup()
3037 if (ext4_has_feature_quota(sb) && (s_flags & SB_RDONLY)) { in ext4_orphan_cleanup()
3038 int ret = ext4_enable_quotas(sb); in ext4_orphan_cleanup()
3043 ext4_msg(sb, KERN_ERR, in ext4_orphan_cleanup()
3049 if (EXT4_SB(sb)->s_qf_names[i]) { in ext4_orphan_cleanup()
3050 int ret = ext4_quota_on_mount(sb, i); in ext4_orphan_cleanup()
3055 ext4_msg(sb, KERN_ERR, in ext4_orphan_cleanup()
3069 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) { in ext4_orphan_cleanup()
3075 inode = ext4_orphan_get(sb, le32_to_cpu(es->s_last_orphan)); in ext4_orphan_cleanup()
3081 list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); in ext4_orphan_cleanup()
3084 if (test_opt(sb, DEBUG)) in ext4_orphan_cleanup()
3085 ext4_msg(sb, KERN_DEBUG, in ext4_orphan_cleanup()
3105 if (test_opt(sb, DEBUG)) in ext4_orphan_cleanup()
3106 ext4_msg(sb, KERN_DEBUG, in ext4_orphan_cleanup()
3119 ext4_msg(sb, KERN_INFO, "%d orphan inode%s deleted", in ext4_orphan_cleanup()
3122 ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up", in ext4_orphan_cleanup()
3128 if (sb_dqopt(sb)->files[i]) in ext4_orphan_cleanup()
3129 dquot_quota_off(sb, i); in ext4_orphan_cleanup()
3133 sb->s_flags = s_flags; /* Restore SB_RDONLY status */ in ext4_orphan_cleanup()
3244 static ext4_fsblk_t descriptor_loc(struct super_block *sb, in descriptor_loc() argument
3247 struct ext4_sb_info *sbi = EXT4_SB(sb); in descriptor_loc()
3253 if (!ext4_has_feature_meta_bg(sb) || nr < first_meta_bg) in descriptor_loc()
3256 if (ext4_bg_has_super(sb, bg)) in descriptor_loc()
3265 if (sb->s_blocksize == 1024 && nr == 0 && in descriptor_loc()
3269 return (has_super + ext4_group_first_block_no(sb, bg)); in descriptor_loc()
3315 static int ext4_feature_set_ok(struct super_block *sb, int readonly) in ext4_feature_set_ok() argument
3317 if (ext4_has_unknown_ext4_incompat_features(sb)) { in ext4_feature_set_ok()
3318 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
3321 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & in ext4_feature_set_ok()
3327 if (ext4_has_feature_casefold(sb)) { in ext4_feature_set_ok()
3328 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
3338 if (ext4_has_feature_readonly(sb)) { in ext4_feature_set_ok()
3339 ext4_msg(sb, KERN_INFO, "filesystem is read-only"); in ext4_feature_set_ok()
3340 sb->s_flags |= SB_RDONLY; in ext4_feature_set_ok()
3345 if (ext4_has_unknown_ext4_ro_compat_features(sb)) { in ext4_feature_set_ok()
3346 ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of " in ext4_feature_set_ok()
3348 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & in ext4_feature_set_ok()
3352 if (ext4_has_feature_bigalloc(sb) && !ext4_has_feature_extents(sb)) { in ext4_feature_set_ok()
3353 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
3360 if (!readonly && (ext4_has_feature_quota(sb) || in ext4_feature_set_ok()
3361 ext4_has_feature_project(sb))) { in ext4_feature_set_ok()
3362 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
3377 struct super_block *sb = sbi->s_sb; in print_daily_error_info() local
3382 ext4_msg(sb, KERN_NOTICE, "error count since last fsck: %u", in print_daily_error_info()
3386 sb->s_id, in print_daily_error_info()
3401 sb->s_id, in print_daily_error_info()
3421 struct super_block *sb = elr->lr_super; in ext4_run_li_request() local
3422 ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count; in ext4_run_li_request()
3429 elr->lr_next_group = ext4_mb_prefetch(sb, group, in ext4_run_li_request()
3430 EXT4_SB(sb)->s_mb_prefetch, &prefetch_ios); in ext4_run_li_request()
3432 ext4_mb_prefetch_fini(sb, elr->lr_next_group, in ext4_run_li_request()
3434 trace_ext4_prefetch_bitmaps(sb, group, elr->lr_next_group, in ext4_run_li_request()
3439 !sb_rdonly(sb) && test_opt(sb, INIT_INODE_TABLE)) { in ext4_run_li_request()
3449 gdp = ext4_get_group_desc(sb, group, NULL); in ext4_run_li_request()
3464 ret = ext4_init_inode_table(sb, group, in ext4_run_li_request()
3466 trace_ext4_lazy_itable_init(sb, group); in ext4_run_li_request()
3491 static void ext4_unregister_li_request(struct super_block *sb) in ext4_unregister_li_request() argument
3500 ext4_remove_li_request(EXT4_SB(sb)->s_li_request); in ext4_unregister_li_request()
3550 * We hold sb->s_umount, sb can not in ext4_lazyinit_thread()
3656 static ext4_group_t ext4_has_uninit_itable(struct super_block *sb) in ext4_has_uninit_itable() argument
3658 ext4_group_t group, ngroups = EXT4_SB(sb)->s_groups_count; in ext4_has_uninit_itable()
3661 if (!ext4_has_group_desc_csum(sb)) in ext4_has_uninit_itable()
3665 gdp = ext4_get_group_desc(sb, group, NULL); in ext4_has_uninit_itable()
3694 static struct ext4_li_request *ext4_li_request_new(struct super_block *sb, in ext4_li_request_new() argument
3703 elr->lr_super = sb; in ext4_li_request_new()
3705 if (test_opt(sb, PREFETCH_BLOCK_BITMAPS)) in ext4_li_request_new()
3722 int ext4_register_li_request(struct super_block *sb, in ext4_register_li_request() argument
3725 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_register_li_request()
3740 if (!test_opt(sb, PREFETCH_BLOCK_BITMAPS) && in ext4_register_li_request()
3741 (first_not_zeroed == ngroups || sb_rdonly(sb) || in ext4_register_li_request()
3742 !test_opt(sb, INIT_INODE_TABLE))) in ext4_register_li_request()
3745 elr = ext4_li_request_new(sb, first_not_zeroed); in ext4_register_li_request()
3797 static int set_journal_csum_feature_set(struct super_block *sb) in set_journal_csum_feature_set() argument
3801 struct ext4_sb_info *sbi = EXT4_SB(sb); in set_journal_csum_feature_set()
3803 if (ext4_has_metadata_csum(sb)) { in set_journal_csum_feature_set()
3817 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in set_journal_csum_feature_set()
3822 } else if (test_opt(sb, JOURNAL_CHECKSUM)) { in set_journal_csum_feature_set()
3851 static int count_overhead(struct super_block *sb, ext4_group_t grp, in count_overhead() argument
3854 struct ext4_sb_info *sbi = EXT4_SB(sb); in count_overhead()
3857 ext4_group_t i, ngroups = ext4_get_groups_count(sb); in count_overhead()
3859 int has_super = ext4_bg_has_super(sb, grp); in count_overhead()
3861 if (!ext4_has_feature_bigalloc(sb)) in count_overhead()
3862 return (has_super + ext4_bg_num_gdb(sb, grp) + in count_overhead()
3867 (grp * EXT4_BLOCKS_PER_GROUP(sb)); in count_overhead()
3868 last_block = first_block + EXT4_BLOCKS_PER_GROUP(sb) - 1; in count_overhead()
3870 gdp = ext4_get_group_desc(sb, i, NULL); in count_overhead()
3871 b = ext4_block_bitmap(sb, gdp); in count_overhead()
3876 b = ext4_inode_bitmap(sb, gdp); in count_overhead()
3881 b = ext4_inode_table(sb, gdp); in count_overhead()
3891 if (ext4_bg_has_super(sb, grp)) { in count_overhead()
3895 j = ext4_bg_num_gdb(sb, grp); in count_overhead()
3896 if (s + j > EXT4_BLOCKS_PER_GROUP(sb)) { in count_overhead()
3897 ext4_error(sb, "Invalid number of block group " in count_overhead()
3899 j = EXT4_BLOCKS_PER_GROUP(sb) - s; in count_overhead()
3907 return EXT4_CLUSTERS_PER_GROUP(sb) - in count_overhead()
3908 ext4_count_free(buf, EXT4_CLUSTERS_PER_GROUP(sb) / 8); in count_overhead()
3914 int ext4_calculate_overhead(struct super_block *sb) in ext4_calculate_overhead() argument
3916 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_calculate_overhead()
3920 ext4_group_t i, ngroups = ext4_get_groups_count(sb); in ext4_calculate_overhead()
3944 blks = count_overhead(sb, i, buf); in ext4_calculate_overhead()
3957 else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) { in ext4_calculate_overhead()
3959 j_inode = ext4_get_journal_inode(sb, j_inum); in ext4_calculate_overhead()
3961 j_blocks = j_inode->i_size >> sb->s_blocksize_bits; in ext4_calculate_overhead()
3965 ext4_msg(sb, KERN_ERR, "can't get journal size"); in ext4_calculate_overhead()
3974 static void ext4_set_resv_clusters(struct super_block *sb) in ext4_set_resv_clusters() argument
3977 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_set_resv_clusters()
3985 if (!ext4_has_feature_extents(sb)) in ext4_set_resv_clusters()
4004 static int ext4_fill_super(struct super_block *sb, void *data, int silent) in ext4_fill_super() argument
4006 struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev); in ext4_fill_super()
4039 sb->s_fs_info = sbi; in ext4_fill_super()
4040 sbi->s_sb = sb; in ext4_fill_super()
4043 if (sb->s_bdev->bd_part) in ext4_fill_super()
4045 part_stat_read(sb->s_bdev->bd_part, sectors[STAT_WRITE]); in ext4_fill_super()
4048 strreplace(sb->s_id, '/', '!'); in ext4_fill_super()
4052 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); in ext4_fill_super()
4054 ext4_msg(sb, KERN_ERR, "unable to set blocksize"); in ext4_fill_super()
4069 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); in ext4_fill_super()
4071 ext4_msg(sb, KERN_ERR, "unable to read superblock"); in ext4_fill_super()
4082 sb->s_magic = le16_to_cpu(es->s_magic); in ext4_fill_super()
4083 if (sb->s_magic != EXT4_SUPER_MAGIC) in ext4_fill_super()
4088 if (ext4_has_feature_metadata_csum(sb) && in ext4_fill_super()
4089 ext4_has_feature_gdt_csum(sb)) in ext4_fill_super()
4090 ext4_warning(sb, "metadata_csum and uninit_bg are " in ext4_fill_super()
4094 if (!ext4_verify_csum_type(sb, es)) { in ext4_fill_super()
4095 ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " in ext4_fill_super()
4104 ext4_msg(sb, KERN_ERR, "Cannot load crc32c driver."); in ext4_fill_super()
4111 if (!ext4_superblock_csum_verify(sb, es)) { in ext4_fill_super()
4112 ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " in ext4_fill_super()
4120 if (ext4_has_feature_csum_seed(sb)) in ext4_fill_super()
4122 else if (ext4_has_metadata_csum(sb) || ext4_has_feature_ea_inode(sb)) in ext4_fill_super()
4128 set_opt(sb, INIT_INODE_TABLE); in ext4_fill_super()
4130 set_opt(sb, DEBUG); in ext4_fill_super()
4132 set_opt(sb, GRPID); in ext4_fill_super()
4134 set_opt(sb, NO_UID32); in ext4_fill_super()
4136 set_opt(sb, XATTR_USER); in ext4_fill_super()
4138 set_opt(sb, POSIX_ACL); in ext4_fill_super()
4140 if (ext4_has_feature_fast_commit(sb)) in ext4_fill_super()
4141 set_opt2(sb, JOURNAL_FAST_COMMIT); in ext4_fill_super()
4143 if (ext4_has_metadata_csum(sb)) in ext4_fill_super()
4144 set_opt(sb, JOURNAL_CHECKSUM); in ext4_fill_super()
4147 set_opt(sb, JOURNAL_DATA); in ext4_fill_super()
4149 set_opt(sb, ORDERED_DATA); in ext4_fill_super()
4151 set_opt(sb, WRITEBACK_DATA); in ext4_fill_super()
4154 set_opt(sb, ERRORS_PANIC); in ext4_fill_super()
4156 set_opt(sb, ERRORS_CONT); in ext4_fill_super()
4158 set_opt(sb, ERRORS_RO); in ext4_fill_super()
4160 set_opt(sb, BLOCK_VALIDITY); in ext4_fill_super()
4162 set_opt(sb, DISCARD); in ext4_fill_super()
4171 set_opt(sb, BARRIER); in ext4_fill_super()
4177 if (!IS_EXT3_SB(sb) && !IS_EXT2_SB(sb) && in ext4_fill_super()
4179 set_opt(sb, DELALLOC); in ext4_fill_super()
4189 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4196 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4205 set_opt(sb, DIOREAD_NOLOCK); in ext4_fill_super()
4214 ext4_msg(sb, KERN_ERR, "invalid first ino: %u", in ext4_fill_super()
4221 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4224 ext4_msg(sb, KERN_ERR, "blocksize: %d", blocksize); in ext4_fill_super()
4235 sb->s_time_gran = 1; in ext4_fill_super()
4236 sb->s_time_max = EXT4_EXTRA_TIMESTAMP_MAX; in ext4_fill_super()
4238 sb->s_time_gran = NSEC_PER_SEC; in ext4_fill_super()
4239 sb->s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX; in ext4_fill_super()
4241 sb->s_time_min = EXT4_TIMESTAMP_MIN; in ext4_fill_super()
4246 if (ext4_has_feature_extra_isize(sb)) { in ext4_fill_super()
4252 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4261 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4276 if (!parse_options(s_mount_opts, sb, &journal_devnum, in ext4_fill_super()
4278 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4285 if (!parse_options((char *) data, sb, &journal_devnum, in ext4_fill_super()
4290 if (ext4_has_feature_casefold(sb) && !sb->s_encoding) { in ext4_fill_super()
4295 if (ext4_has_feature_encrypt(sb)) { in ext4_fill_super()
4296 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4303 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4310 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4317 ext4_msg(sb, KERN_INFO,"Using encoding defined by superblock: " in ext4_fill_super()
4321 sb->s_encoding = encoding; in ext4_fill_super()
4322 sb->s_encoding_flags = encoding_flags; in ext4_fill_super()
4326 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { in ext4_fill_super()
4329 clear_opt(sb, DIOREAD_NOLOCK); in ext4_fill_super()
4330 clear_opt2(sb, JOURNAL_FAST_COMMIT); in ext4_fill_super()
4331 if (test_opt2(sb, EXPLICIT_DELALLOC)) { in ext4_fill_super()
4332 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4336 if (test_opt(sb, DAX_ALWAYS)) { in ext4_fill_super()
4337 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4341 if (ext4_has_feature_encrypt(sb)) { in ext4_fill_super()
4342 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4346 if (test_opt(sb, DELALLOC)) in ext4_fill_super()
4347 clear_opt(sb, DELALLOC); in ext4_fill_super()
4349 sb->s_iflags |= SB_I_CGROUPWB; in ext4_fill_super()
4352 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext4_fill_super()
4353 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); in ext4_fill_super()
4356 (ext4_has_compat_features(sb) || in ext4_fill_super()
4357 ext4_has_ro_compat_features(sb) || in ext4_fill_super()
4358 ext4_has_incompat_features(sb))) in ext4_fill_super()
4359 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4364 set_opt2(sb, HURD_COMPAT); in ext4_fill_super()
4365 if (ext4_has_feature_64bit(sb)) { in ext4_fill_super()
4366 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4375 if (ext4_has_feature_ea_inode(sb)) { in ext4_fill_super()
4376 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4382 if (IS_EXT2_SB(sb)) { in ext4_fill_super()
4383 if (ext2_feature_set_ok(sb)) in ext4_fill_super()
4384 ext4_msg(sb, KERN_INFO, "mounting ext2 file system " in ext4_fill_super()
4391 if (silent && ext4_feature_set_ok(sb, sb_rdonly(sb))) in ext4_fill_super()
4393 ext4_msg(sb, KERN_ERR, "couldn't mount as ext2 due " in ext4_fill_super()
4399 if (IS_EXT3_SB(sb)) { in ext4_fill_super()
4400 if (ext3_feature_set_ok(sb)) in ext4_fill_super()
4401 ext4_msg(sb, KERN_INFO, "mounting ext3 file system " in ext4_fill_super()
4408 if (silent && ext4_feature_set_ok(sb, sb_rdonly(sb))) in ext4_fill_super()
4410 ext4_msg(sb, KERN_ERR, "couldn't mount as ext3 due " in ext4_fill_super()
4421 if (!ext4_feature_set_ok(sb, (sb_rdonly(sb)))) in ext4_fill_super()
4425 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4431 if (bdev_dax_supported(sb->s_bdev, blocksize)) in ext4_fill_super()
4435 if (ext4_has_feature_inline_data(sb)) { in ext4_fill_super()
4436 ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" in ext4_fill_super()
4441 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4447 if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) { in ext4_fill_super()
4448 ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d", in ext4_fill_super()
4453 if (sb->s_blocksize != blocksize) { in ext4_fill_super()
4461 if (!sb_set_blocksize(sb, blocksize)) { in ext4_fill_super()
4462 ext4_msg(sb, KERN_ERR, "bad block size %d", in ext4_fill_super()
4470 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); in ext4_fill_super()
4472 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4481 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4487 has_huge_files = ext4_has_feature_huge_file(sb); in ext4_fill_super()
4488 sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits, in ext4_fill_super()
4490 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files); in ext4_fill_super()
4493 if (ext4_has_feature_64bit(sb)) { in ext4_fill_super()
4497 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4508 sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); in ext4_fill_super()
4513 ext4_msg(sb, KERN_ERR, "invalid inodes per group: %lu\n", in ext4_fill_super()
4519 sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb); in ext4_fill_super()
4522 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); in ext4_fill_super()
4523 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); in ext4_fill_super()
4528 if (ext4_has_feature_dir_index(sb)) { in ext4_fill_super()
4534 if (!sb_rdonly(sb)) in ext4_fill_super()
4539 if (!sb_rdonly(sb)) in ext4_fill_super()
4548 if (ext4_has_feature_bigalloc(sb)) { in ext4_fill_super()
4550 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4560 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4567 ext4_msg(sb, KERN_ERR, "blocks per group (%lu) and " in ext4_fill_super()
4575 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4581 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4593 set_opt2(sb, STD_GROUP_SIZE); in ext4_fill_super()
4599 err = generic_check_addressable(sb->s_blocksize_bits, in ext4_fill_super()
4602 ext4_msg(sb, KERN_ERR, "filesystem" in ext4_fill_super()
4607 if (EXT4_BLOCKS_PER_GROUP(sb) == 0) in ext4_fill_super()
4611 blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; in ext4_fill_super()
4613 ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu " in ext4_fill_super()
4624 ext4_msg(sb, KERN_WARNING, "bad geometry: first data " in ext4_fill_super()
4632 ext4_msg(sb, KERN_WARNING, "bad geometry: first data " in ext4_fill_super()
4639 EXT4_BLOCKS_PER_GROUP(sb) - 1); in ext4_fill_super()
4640 do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); in ext4_fill_super()
4641 if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) { in ext4_fill_super()
4642 ext4_msg(sb, KERN_WARNING, "groups count too large: %llu " in ext4_fill_super()
4647 EXT4_BLOCKS_PER_GROUP(sb)); in ext4_fill_super()
4652 (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb))); in ext4_fill_super()
4655 ext4_msg(sb, KERN_ERR, "inodes count not valid: %u vs %llu", in ext4_fill_super()
4661 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / in ext4_fill_super()
4662 EXT4_DESC_PER_BLOCK(sb); in ext4_fill_super()
4663 if (ext4_has_feature_meta_bg(sb)) { in ext4_fill_super()
4665 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4677 ext4_msg(sb, KERN_ERR, "not enough memory"); in ext4_fill_super()
4686 block = descriptor_loc(sb, logical_sb_block, i); in ext4_fill_super()
4687 ext4_sb_breadahead_unmovable(sb, block); in ext4_fill_super()
4693 block = descriptor_loc(sb, logical_sb_block, i); in ext4_fill_super()
4694 bh = ext4_sb_bread_unmovable(sb, block); in ext4_fill_super()
4696 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4708 if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { in ext4_fill_super()
4709 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); in ext4_fill_super()
4728 sb->s_op = &ext4_sops; in ext4_fill_super()
4729 sb->s_export_op = &ext4_export_ops; in ext4_fill_super()
4730 sb->s_xattr = ext4_xattr_handlers; in ext4_fill_super()
4732 sb->s_cop = &ext4_cryptops; in ext4_fill_super()
4735 sb->s_vop = &ext4_verityops; in ext4_fill_super()
4738 sb->dq_op = &ext4_quota_operations; in ext4_fill_super()
4739 if (ext4_has_feature_quota(sb)) in ext4_fill_super()
4740 sb->s_qcop = &dquot_quotactl_sysfile_ops; in ext4_fill_super()
4742 sb->s_qcop = &ext4_qctl_operations; in ext4_fill_super()
4743 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; in ext4_fill_super()
4745 memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid)); in ext4_fill_super()
4760 ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); in ext4_fill_super()
4761 ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING); in ext4_fill_super()
4772 sb->s_root = NULL; in ext4_fill_super()
4775 ext4_has_feature_journal_needs_recovery(sb)); in ext4_fill_super()
4777 if (ext4_has_feature_mmp(sb) && !sb_rdonly(sb)) { in ext4_fill_super()
4778 err = ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)); in ext4_fill_super()
4787 if (!test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) { in ext4_fill_super()
4788 err = ext4_load_journal(sb, es, journal_devnum); in ext4_fill_super()
4791 } else if (test_opt(sb, NOLOAD) && !sb_rdonly(sb) && in ext4_fill_super()
4792 ext4_has_feature_journal_needs_recovery(sb)) { in ext4_fill_super()
4793 ext4_msg(sb, KERN_ERR, "required journal recovery " in ext4_fill_super()
4798 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_fill_super()
4799 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4804 if (test_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM)) { in ext4_fill_super()
4805 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4810 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4817 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4822 clear_opt(sb, JOURNAL_CHECKSUM); in ext4_fill_super()
4823 clear_opt(sb, DATA_FLAGS); in ext4_fill_super()
4824 clear_opt2(sb, JOURNAL_FAST_COMMIT); in ext4_fill_super()
4830 if (ext4_has_feature_64bit(sb) && in ext4_fill_super()
4831 !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, in ext4_fill_super()
4833 ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature"); in ext4_fill_super()
4837 if (!set_journal_csum_feature_set(sb)) { in ext4_fill_super()
4838 ext4_msg(sb, KERN_ERR, "Failed to set journal checksum " in ext4_fill_super()
4843 if (test_opt2(sb, JOURNAL_FAST_COMMIT) && in ext4_fill_super()
4844 !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, in ext4_fill_super()
4846 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4853 switch (test_opt(sb, DATA_FLAGS)) { in ext4_fill_super()
4861 set_opt(sb, ORDERED_DATA); in ext4_fill_super()
4864 set_opt(sb, JOURNAL_DATA); in ext4_fill_super()
4873 ext4_msg(sb, KERN_ERR, "Journal does not support " in ext4_fill_super()
4881 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA && in ext4_fill_super()
4882 test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_fill_super()
4883 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4896 if (!test_opt(sb, NO_MBCACHE)) { in ext4_fill_super()
4899 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4904 if (ext4_has_feature_ea_inode(sb)) { in ext4_fill_super()
4907 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4914 if (ext4_has_feature_verity(sb) && blocksize != PAGE_SIZE) { in ext4_fill_super()
4915 ext4_msg(sb, KERN_ERR, "Unsupported blocksize for fs-verity"); in ext4_fill_super()
4932 if (!ext4_has_feature_bigalloc(sb)) in ext4_fill_super()
4935 err = ext4_calculate_overhead(sb); in ext4_fill_super()
4944 EXT4_SB(sb)->rsv_conversion_wq = in ext4_fill_super()
4946 if (!EXT4_SB(sb)->rsv_conversion_wq) { in ext4_fill_super()
4957 root = ext4_iget(sb, EXT4_ROOT_INO, EXT4_IGET_SPECIAL); in ext4_fill_super()
4959 ext4_msg(sb, KERN_ERR, "get root inode failed"); in ext4_fill_super()
4965 ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); in ext4_fill_super()
4971 if (sb->s_encoding) in ext4_fill_super()
4972 sb->s_d_op = &ext4_dentry_ops; in ext4_fill_super()
4975 sb->s_root = d_make_root(root); in ext4_fill_super()
4976 if (!sb->s_root) { in ext4_fill_super()
4977 ext4_msg(sb, KERN_ERR, "get root dentry failed"); in ext4_fill_super()
4982 ret = ext4_setup_super(sb, es, sb_rdonly(sb)); in ext4_fill_super()
4984 sb->s_flags |= SB_RDONLY; in ext4_fill_super()
4989 ext4_set_resv_clusters(sb); in ext4_fill_super()
4991 if (test_opt(sb, BLOCK_VALIDITY)) { in ext4_fill_super()
4992 err = ext4_setup_system_zone(sb); in ext4_fill_super()
4994 ext4_msg(sb, KERN_ERR, "failed to initialize system " in ext4_fill_super()
4999 ext4_fc_replay_cleanup(sb); in ext4_fill_super()
5001 ext4_ext_init(sb); in ext4_fill_super()
5002 err = ext4_mb_init(sb); in ext4_fill_super()
5004 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", in ext4_fill_super()
5017 block = ext4_count_free_clusters(sb); in ext4_fill_super()
5023 unsigned long freei = ext4_count_free_inodes(sb); in ext4_fill_super()
5035 ext4_superblock_csum_set(sb); in ext4_fill_super()
5038 ext4_count_dirs(sb), GFP_KERNEL); in ext4_fill_super()
5049 ext4_msg(sb, KERN_ERR, "insufficient memory"); in ext4_fill_super()
5053 if (ext4_has_feature_flex_bg(sb)) in ext4_fill_super()
5054 if (!ext4_fill_flex_info(sb)) { in ext4_fill_super()
5055 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
5062 err = ext4_register_li_request(sb, first_not_zeroed); in ext4_fill_super()
5066 err = ext4_register_sysfs(sb); in ext4_fill_super()
5072 if (ext4_has_feature_quota(sb) && !sb_rdonly(sb)) { in ext4_fill_super()
5073 err = ext4_enable_quotas(sb); in ext4_fill_super()
5083 errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err, in ext4_fill_super()
5085 sb->s_bdev->bd_super = sb; in ext4_fill_super()
5086 EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; in ext4_fill_super()
5087 ext4_orphan_cleanup(sb, es); in ext4_fill_super()
5088 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; in ext4_fill_super()
5090 ext4_msg(sb, KERN_INFO, "recovery complete"); in ext4_fill_super()
5091 err = ext4_mark_recovery_complete(sb, es); in ext4_fill_super()
5095 if (EXT4_SB(sb)->s_journal) { in ext4_fill_super()
5096 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) in ext4_fill_super()
5098 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) in ext4_fill_super()
5105 if (test_opt(sb, DISCARD)) { in ext4_fill_super()
5106 struct request_queue *q = bdev_get_queue(sb->s_bdev); in ext4_fill_super()
5108 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
5114 ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " in ext4_fill_super()
5135 ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem"); in ext4_fill_super()
5139 ext4_unregister_sysfs(sb); in ext4_fill_super()
5142 ext4_unregister_li_request(sb); in ext4_fill_super()
5144 ext4_mb_release(sb); in ext4_fill_super()
5160 ext4_ext_release(sb); in ext4_fill_super()
5161 ext4_release_system_zone(sb); in ext4_fill_super()
5163 dput(sb->s_root); in ext4_fill_super()
5164 sb->s_root = NULL; in ext4_fill_super()
5166 ext4_msg(sb, KERN_ERR, "mount failed"); in ext4_fill_super()
5167 if (EXT4_SB(sb)->rsv_conversion_wq) in ext4_fill_super()
5168 destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); in ext4_fill_super()
5199 utf8_unload(sb->s_encoding); in ext4_fill_super()
5204 kfree(get_qf_name(sb, sbi, i)); in ext4_fill_super()
5211 invalidate_bdev(sb->s_bdev); in ext4_fill_super()
5212 sb->s_fs_info = NULL; in ext4_fill_super()
5226 static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) in ext4_init_journal_params() argument
5228 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_init_journal_params()
5233 ext4_fc_init(sb, journal); in ext4_init_journal_params()
5236 if (test_opt(sb, BARRIER)) in ext4_init_journal_params()
5240 if (test_opt(sb, DATA_ERR_ABORT)) in ext4_init_journal_params()
5247 static struct inode *ext4_get_journal_inode(struct super_block *sb, in ext4_get_journal_inode() argument
5257 journal_inode = ext4_iget(sb, journal_inum, EXT4_IGET_SPECIAL); in ext4_get_journal_inode()
5259 ext4_msg(sb, KERN_ERR, "no journal found"); in ext4_get_journal_inode()
5265 ext4_msg(sb, KERN_ERR, "journal inode is deleted"); in ext4_get_journal_inode()
5272 ext4_msg(sb, KERN_ERR, "invalid journal inode"); in ext4_get_journal_inode()
5279 static journal_t *ext4_get_journal(struct super_block *sb, in ext4_get_journal() argument
5285 if (WARN_ON_ONCE(!ext4_has_feature_journal(sb))) in ext4_get_journal()
5288 journal_inode = ext4_get_journal_inode(sb, journal_inum); in ext4_get_journal()
5294 ext4_msg(sb, KERN_ERR, "Could not load journal inode"); in ext4_get_journal()
5298 journal->j_private = sb; in ext4_get_journal()
5299 ext4_init_journal_params(sb, journal); in ext4_get_journal()
5303 static journal_t *ext4_get_dev_journal(struct super_block *sb, in ext4_get_dev_journal() argument
5316 if (WARN_ON_ONCE(!ext4_has_feature_journal(sb))) in ext4_get_dev_journal()
5319 bdev = ext4_blkdev_get(j_dev, sb); in ext4_get_dev_journal()
5323 blocksize = sb->s_blocksize; in ext4_get_dev_journal()
5326 ext4_msg(sb, KERN_ERR, in ext4_get_dev_journal()
5335 ext4_msg(sb, KERN_ERR, "couldn't read superblock of " in ext4_get_dev_journal()
5344 ext4_msg(sb, KERN_ERR, "external journal has " in ext4_get_dev_journal()
5352 es->s_checksum != ext4_superblock_csum(sb, es)) { in ext4_get_dev_journal()
5353 ext4_msg(sb, KERN_ERR, "external journal has " in ext4_get_dev_journal()
5359 if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { in ext4_get_dev_journal()
5360 ext4_msg(sb, KERN_ERR, "journal UUID does not match"); in ext4_get_dev_journal()
5369 journal = jbd2_journal_init_dev(bdev, sb->s_bdev, in ext4_get_dev_journal()
5372 ext4_msg(sb, KERN_ERR, "failed to create device journal"); in ext4_get_dev_journal()
5375 journal->j_private = sb; in ext4_get_dev_journal()
5377 ext4_msg(sb, KERN_ERR, "I/O error on journal device"); in ext4_get_dev_journal()
5381 ext4_msg(sb, KERN_ERR, "External journal has more than one " in ext4_get_dev_journal()
5386 EXT4_SB(sb)->s_journal_bdev = bdev; in ext4_get_dev_journal()
5387 ext4_init_journal_params(sb, journal); in ext4_get_dev_journal()
5391 ext4_journal_destroy(EXT4_SB(sb), journal); in ext4_get_dev_journal()
5397 static int ext4_load_journal(struct super_block *sb, in ext4_load_journal() argument
5408 if (WARN_ON_ONCE(!ext4_has_feature_journal(sb))) in ext4_load_journal()
5413 ext4_msg(sb, KERN_INFO, "external journal device major/minor " in ext4_load_journal()
5420 ext4_msg(sb, KERN_ERR, in ext4_load_journal()
5426 journal = ext4_get_journal(sb, journal_inum); in ext4_load_journal()
5430 journal = ext4_get_dev_journal(sb, journal_dev); in ext4_load_journal()
5436 really_read_only = bdev_read_only(sb->s_bdev) | journal_dev_ro; in ext4_load_journal()
5438 if (journal_dev_ro && !sb_rdonly(sb)) { in ext4_load_journal()
5439 ext4_msg(sb, KERN_ERR, in ext4_load_journal()
5450 if (ext4_has_feature_journal_needs_recovery(sb)) { in ext4_load_journal()
5451 if (sb_rdonly(sb)) { in ext4_load_journal()
5452 ext4_msg(sb, KERN_INFO, "INFO: recovery " in ext4_load_journal()
5455 ext4_msg(sb, KERN_ERR, "write access " in ext4_load_journal()
5461 ext4_msg(sb, KERN_INFO, "write access will " in ext4_load_journal()
5467 ext4_msg(sb, KERN_INFO, "barriers disabled"); in ext4_load_journal()
5469 if (!ext4_has_feature_journal_needs_recovery(sb)) in ext4_load_journal()
5484 ext4_msg(sb, KERN_ERR, "error loading journal"); in ext4_load_journal()
5488 EXT4_SB(sb)->s_journal = journal; in ext4_load_journal()
5489 err = ext4_clear_journal_err(sb, es); in ext4_load_journal()
5491 ext4_journal_destroy(EXT4_SB(sb), journal); in ext4_load_journal()
5498 ext4_commit_super(sb); in ext4_load_journal()
5503 ext4_commit_super(sb); in ext4_load_journal()
5509 ext4_journal_destroy(EXT4_SB(sb), journal); in ext4_load_journal()
5513 /* Copy state of EXT4_SB(sb) into buffer for on-disk superblock */
5514 static void ext4_update_super(struct super_block *sb) in ext4_update_super() argument
5516 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_update_super()
5531 if (!(sb->s_flags & SB_RDONLY)) in ext4_update_super()
5533 if (sb->s_bdev->bd_part) in ext4_update_super()
5536 ((part_stat_read(sb->s_bdev->bd_part, in ext4_update_super()
5589 ext4_superblock_csum_set(sb); in ext4_update_super()
5593 static int ext4_commit_super(struct super_block *sb) in ext4_commit_super() argument
5595 struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; in ext4_commit_super()
5600 if (block_device_ejected(sb)) in ext4_commit_super()
5603 ext4_update_super(sb); in ext4_commit_super()
5614 ext4_msg(sb, KERN_ERR, "previous I/O error to " in ext4_commit_super()
5622 REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0)); in ext4_commit_super()
5624 ext4_msg(sb, KERN_ERR, "I/O error while writing " in ext4_commit_super()
5637 static int ext4_mark_recovery_complete(struct super_block *sb, in ext4_mark_recovery_complete() argument
5641 journal_t *journal = EXT4_SB(sb)->s_journal; in ext4_mark_recovery_complete()
5643 if (!ext4_has_feature_journal(sb)) { in ext4_mark_recovery_complete()
5645 ext4_error(sb, "Journal got removed while the fs was " in ext4_mark_recovery_complete()
5656 if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) { in ext4_mark_recovery_complete()
5657 ext4_clear_feature_journal_needs_recovery(sb); in ext4_mark_recovery_complete()
5658 ext4_commit_super(sb); in ext4_mark_recovery_complete()
5670 static int ext4_clear_journal_err(struct super_block *sb, in ext4_clear_journal_err() argument
5677 if (!ext4_has_feature_journal(sb)) { in ext4_clear_journal_err()
5678 ext4_error(sb, "Journal got removed while the fs was mounted!"); in ext4_clear_journal_err()
5682 journal = EXT4_SB(sb)->s_journal; in ext4_clear_journal_err()
5693 errstr = ext4_decode_error(sb, j_errno, nbuf); in ext4_clear_journal_err()
5694 ext4_warning(sb, "Filesystem error recorded " in ext4_clear_journal_err()
5696 ext4_warning(sb, "Marking fs in need of filesystem check."); in ext4_clear_journal_err()
5698 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; in ext4_clear_journal_err()
5700 ext4_commit_super(sb); in ext4_clear_journal_err()
5712 int ext4_force_commit(struct super_block *sb) in ext4_force_commit() argument
5716 if (sb_rdonly(sb)) in ext4_force_commit()
5719 journal = EXT4_SB(sb)->s_journal; in ext4_force_commit()
5723 static int ext4_sync_fs(struct super_block *sb, int wait) in ext4_sync_fs() argument
5728 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_sync_fs()
5733 trace_ext4_sync_fs(sb, wait); in ext4_sync_fs()
5739 dquot_writeback_dquots(sb, -1); in ext4_sync_fs()
5756 } else if (wait && test_opt(sb, BARRIER)) in ext4_sync_fs()
5760 err = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL); in ext4_sync_fs()
5776 static int ext4_freeze(struct super_block *sb) in ext4_freeze() argument
5781 if (sb_rdonly(sb)) in ext4_freeze()
5784 journal = EXT4_SB(sb)->s_journal; in ext4_freeze()
5799 ext4_clear_feature_journal_needs_recovery(sb); in ext4_freeze()
5802 error = ext4_commit_super(sb); in ext4_freeze()
5814 static int ext4_unfreeze(struct super_block *sb) in ext4_unfreeze() argument
5816 if (sb_rdonly(sb) || ext4_forced_shutdown(EXT4_SB(sb))) in ext4_unfreeze()
5819 if (EXT4_SB(sb)->s_journal) { in ext4_unfreeze()
5821 ext4_set_feature_journal_needs_recovery(sb); in ext4_unfreeze()
5824 ext4_commit_super(sb); in ext4_unfreeze()
5844 static int ext4_remount(struct super_block *sb, int *flags, char *data) in ext4_remount() argument
5847 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_remount()
5864 old_sb_flags = sb->s_flags; in ext4_remount()
5876 char *qf_name = get_qf_name(sb, sbi, i); in ext4_remount()
5897 sb->s_flags = (sb->s_flags & ~vfs_flags) | (*flags & vfs_flags); in ext4_remount()
5899 if (!parse_options(data, sb, NULL, &journal_ioprio, 1)) { in ext4_remount()
5905 test_opt(sb, JOURNAL_CHECKSUM)) { in ext4_remount()
5906 ext4_msg(sb, KERN_ERR, "changing journal_checksum " in ext4_remount()
5911 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { in ext4_remount()
5912 if (test_opt2(sb, EXPLICIT_DELALLOC)) { in ext4_remount()
5913 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5918 if (test_opt(sb, DIOREAD_NOLOCK)) { in ext4_remount()
5919 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5924 } else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) { in ext4_remount()
5925 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_remount()
5926 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5934 ext4_msg(sb, KERN_ERR, "can't enable nombcache during remount"); in ext4_remount()
5939 if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) in ext4_remount()
5940 ext4_abort(sb, EXT4_ERR_ESHUTDOWN, "Abort forced by user"); in ext4_remount()
5942 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext4_remount()
5943 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); in ext4_remount()
5948 ext4_init_journal_params(sb, sbi->s_journal); in ext4_remount()
5955 if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) { in ext4_remount()
5956 if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) { in ext4_remount()
5962 err = sync_filesystem(sb); in ext4_remount()
5965 err = dquot_suspend(sb, -1); in ext4_remount()
5973 sb->s_flags |= SB_RDONLY; in ext4_remount()
5989 ext4_mark_recovery_complete(sb, es); in ext4_remount()
5993 if (ext4_has_feature_readonly(sb) || in ext4_remount()
5994 !ext4_feature_set_ok(sb, 0)) { in ext4_remount()
6004 ext4_get_group_desc(sb, g, NULL); in ext4_remount()
6006 if (!ext4_group_desc_csum_verify(sb, g, gdp)) { in ext4_remount()
6007 ext4_msg(sb, KERN_ERR, in ext4_remount()
6009 g, le16_to_cpu(ext4_group_desc_csum(sb, g, gdp)), in ext4_remount()
6022 ext4_msg(sb, KERN_WARNING, "Couldn't " in ext4_remount()
6037 err = ext4_clear_journal_err(sb, es); in ext4_remount()
6044 err = ext4_setup_super(sb, es, 0); in ext4_remount()
6048 sb->s_flags &= ~SB_RDONLY; in ext4_remount()
6049 if (ext4_has_feature_mmp(sb)) { in ext4_remount()
6050 err = ext4_multi_mount_protect(sb, in ext4_remount()
6066 if (test_opt(sb, BLOCK_VALIDITY) && !sbi->s_system_blks) { in ext4_remount()
6067 err = ext4_setup_system_zone(sb); in ext4_remount()
6073 err = ext4_commit_super(sb); in ext4_remount()
6080 if (sb_any_quota_suspended(sb)) in ext4_remount()
6081 dquot_resume(sb, -1); in ext4_remount()
6082 else if (ext4_has_feature_quota(sb)) { in ext4_remount()
6083 err = ext4_enable_quotas(sb); in ext4_remount()
6092 if (!test_opt(sb, BLOCK_VALIDITY) && sbi->s_system_blks) in ext4_remount()
6093 ext4_release_system_zone(sb); in ext4_remount()
6099 if (sb_rdonly(sb) || !test_opt(sb, INIT_INODE_TABLE)) in ext4_remount()
6100 ext4_unregister_li_request(sb); in ext4_remount()
6103 first_not_zeroed = ext4_has_uninit_itable(sb); in ext4_remount()
6104 ext4_register_li_request(sb, first_not_zeroed); in ext4_remount()
6107 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) in ext4_remount()
6115 *flags = (*flags & ~vfs_flags) | (sb->s_flags & vfs_flags); in ext4_remount()
6117 ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data); in ext4_remount()
6126 if ((sb->s_flags & SB_RDONLY) && !(old_sb_flags & SB_RDONLY) && in ext4_remount()
6127 sb_any_quota_suspended(sb)) in ext4_remount()
6128 dquot_resume(sb, -1); in ext4_remount()
6129 sb->s_flags = old_sb_flags; in ext4_remount()
6137 if (!test_opt(sb, BLOCK_VALIDITY) && sbi->s_system_blks) in ext4_remount()
6138 ext4_release_system_zone(sb); in ext4_remount()
6142 to_free[i] = get_qf_name(sb, sbi, i); in ext4_remount()
6149 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) in ext4_remount()
6156 static int ext4_statfs_project(struct super_block *sb, in ext4_statfs_project() argument
6165 dquot = dqget(sb, qid); in ext4_statfs_project()
6172 limit >>= sb->s_blocksize_bits; in ext4_statfs_project()
6176 dquot->dq_dqb.dqb_rsvspace) >> sb->s_blocksize_bits; in ext4_statfs_project()
6200 struct super_block *sb = dentry->d_sb; in ext4_statfs() local
6201 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_statfs()
6208 if (!test_opt(sb, MINIX_DF)) in ext4_statfs()
6212 buf->f_bsize = sb->s_blocksize; in ext4_statfs()
6231 sb_has_quota_limits_enabled(sb, PRJQUOTA)) in ext4_statfs()
6232 ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf); in ext4_statfs()
6304 struct super_block *sb = dquot->dq_sb; in ext4_mark_dquot_dirty() local
6305 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_mark_dquot_dirty()
6308 if (ext4_has_feature_quota(sb) || in ext4_mark_dquot_dirty()
6317 static int ext4_write_info(struct super_block *sb, int type) in ext4_write_info() argument
6323 handle = ext4_journal_start_sb(sb, EXT4_HT_QUOTA, 2); in ext4_write_info()
6326 ret = dquot_commit_info(sb, type); in ext4_write_info()
6337 static int ext4_quota_on_mount(struct super_block *sb, int type) in ext4_quota_on_mount() argument
6339 return dquot_quota_on_mount(sb, get_qf_name(sb, EXT4_SB(sb), type), in ext4_quota_on_mount()
6340 EXT4_SB(sb)->s_jquota_fmt, type); in ext4_quota_on_mount()
6360 static int ext4_quota_on(struct super_block *sb, int type, int format_id, in ext4_quota_on() argument
6365 if (!test_opt(sb, QUOTA)) in ext4_quota_on()
6369 if (path->dentry->d_sb != sb) in ext4_quota_on()
6377 if (EXT4_SB(sb)->s_qf_names[type]) { in ext4_quota_on()
6379 if (path->dentry->d_parent != sb->s_root) in ext4_quota_on()
6380 ext4_msg(sb, KERN_WARNING, in ext4_quota_on()
6383 sb_dqopt(sb)->flags |= DQUOT_NOLIST_DIRTY; in ext4_quota_on()
6389 sb_dqopt(sb)->flags &= ~DQUOT_NOLIST_DIRTY; in ext4_quota_on()
6396 if (EXT4_SB(sb)->s_journal && in ext4_quota_on()
6402 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); in ext4_quota_on()
6403 err = jbd2_journal_flush(EXT4_SB(sb)->s_journal); in ext4_quota_on()
6404 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); in ext4_quota_on()
6410 err = dquot_quota_on(sb, type, format_id, path); in ext4_quota_on()
6432 dquot_quota_off(sb, type); in ext4_quota_on()
6454 static int ext4_quota_enable(struct super_block *sb, int type, int format_id, in ext4_quota_enable() argument
6460 le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), in ext4_quota_enable()
6461 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum), in ext4_quota_enable()
6462 le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum) in ext4_quota_enable()
6465 BUG_ON(!ext4_has_feature_quota(sb)); in ext4_quota_enable()
6471 ext4_error(sb, "Bad quota inum: %lu, type: %d", in ext4_quota_enable()
6476 qf_inode = ext4_iget(sb, qf_inums[type], EXT4_IGET_SPECIAL); in ext4_quota_enable()
6478 ext4_error(sb, "Bad quota inode: %lu, type: %d", in ext4_quota_enable()
6495 static int ext4_enable_quotas(struct super_block *sb) in ext4_enable_quotas() argument
6499 le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), in ext4_enable_quotas()
6500 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum), in ext4_enable_quotas()
6501 le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum) in ext4_enable_quotas()
6504 test_opt(sb, USRQUOTA), in ext4_enable_quotas()
6505 test_opt(sb, GRPQUOTA), in ext4_enable_quotas()
6506 test_opt(sb, PRJQUOTA), in ext4_enable_quotas()
6509 sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE | DQUOT_NOLIST_DIRTY; in ext4_enable_quotas()
6512 err = ext4_quota_enable(sb, type, QFMT_VFS_V1, in ext4_enable_quotas()
6516 ext4_warning(sb, in ext4_enable_quotas()
6524 inode = sb_dqopt(sb)->files[type]; in ext4_enable_quotas()
6527 dquot_quota_off(sb, type); in ext4_enable_quotas()
6542 static int ext4_quota_off(struct super_block *sb, int type) in ext4_quota_off() argument
6544 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_off()
6550 if (test_opt(sb, DELALLOC)) in ext4_quota_off()
6551 sync_filesystem(sb); in ext4_quota_off()
6556 err = dquot_quota_off(sb, type); in ext4_quota_off()
6557 if (err || ext4_has_feature_quota(sb)) in ext4_quota_off()
6583 return dquot_quota_off(sb, type); in ext4_quota_off()
6590 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, in ext4_quota_read() argument
6593 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_read()
6594 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); in ext4_quota_read()
6595 int offset = off & (sb->s_blocksize - 1); in ext4_quota_read()
6607 tocopy = sb->s_blocksize - offset < toread ? in ext4_quota_read()
6608 sb->s_blocksize - offset : toread; in ext4_quota_read()
6627 static ssize_t ext4_quota_write(struct super_block *sb, int type, in ext4_quota_write() argument
6630 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_write()
6631 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); in ext4_quota_write()
6632 int err = 0, err2 = 0, offset = off & (sb->s_blocksize - 1); in ext4_quota_write()
6638 ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" in ext4_quota_write()
6647 if (sb->s_blocksize - offset < len) { in ext4_quota_write()
6648 ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" in ext4_quota_write()
6708 static inline int ext2_feature_set_ok(struct super_block *sb) in ext2_feature_set_ok() argument
6710 if (ext4_has_unknown_ext2_incompat_features(sb)) in ext2_feature_set_ok()
6712 if (sb_rdonly(sb)) in ext2_feature_set_ok()
6714 if (ext4_has_unknown_ext2_ro_compat_features(sb)) in ext2_feature_set_ok()
6721 static inline int ext2_feature_set_ok(struct super_block *sb) { return 0; } in ext2_feature_set_ok() argument
6737 static inline int ext3_feature_set_ok(struct super_block *sb) in ext3_feature_set_ok() argument
6739 if (ext4_has_unknown_ext3_incompat_features(sb)) in ext3_feature_set_ok()
6741 if (!ext4_has_feature_journal(sb)) in ext3_feature_set_ok()
6743 if (sb_rdonly(sb)) in ext3_feature_set_ok()
6745 if (ext4_has_unknown_ext3_ro_compat_features(sb)) in ext3_feature_set_ok()