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);
84 static void ext4_unregister_li_request(struct super_block *sb);
86 static struct inode *ext4_get_journal_inode(struct super_block *sb,
125 #define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type) argument
127 #define IS_EXT2_SB(sb) (0) argument
140 #define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) argument
210 static struct buffer_head *__ext4_sb_bread_gfp(struct super_block *sb, in __ext4_sb_bread_gfp() argument
217 bh = sb_getblk_gfp(sb, block, gfp); in __ext4_sb_bread_gfp()
231 struct buffer_head *ext4_sb_bread(struct super_block *sb, sector_t block, in ext4_sb_bread() argument
234 return __ext4_sb_bread_gfp(sb, block, op_flags, __GFP_MOVABLE); in ext4_sb_bread()
237 struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb, in ext4_sb_bread_unmovable() argument
240 return __ext4_sb_bread_gfp(sb, block, 0, 0); in ext4_sb_bread_unmovable()
243 void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block) in ext4_sb_breadahead_unmovable() argument
245 struct buffer_head *bh = sb_getblk_gfp(sb, block, 0); in ext4_sb_breadahead_unmovable()
253 static int ext4_verify_csum_type(struct super_block *sb, in ext4_verify_csum_type() argument
256 if (!ext4_has_feature_metadata_csum(sb)) in ext4_verify_csum_type()
262 static __le32 ext4_superblock_csum(struct super_block *sb, in ext4_superblock_csum() argument
265 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_superblock_csum()
274 static int ext4_superblock_csum_verify(struct super_block *sb, in ext4_superblock_csum_verify() argument
277 if (!ext4_has_metadata_csum(sb)) in ext4_superblock_csum_verify()
280 return es->s_checksum == ext4_superblock_csum(sb, es); in ext4_superblock_csum_verify()
283 void ext4_superblock_csum_set(struct super_block *sb) in ext4_superblock_csum_set() argument
285 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in ext4_superblock_csum_set()
287 if (!ext4_has_metadata_csum(sb)) in ext4_superblock_csum_set()
290 es->s_checksum = ext4_superblock_csum(sb, es); in ext4_superblock_csum_set()
293 ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, in ext4_block_bitmap() argument
297 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_block_bitmap()
301 ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, in ext4_inode_bitmap() argument
305 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_inode_bitmap()
309 ext4_fsblk_t ext4_inode_table(struct super_block *sb, in ext4_inode_table() argument
313 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_inode_table()
317 __u32 ext4_free_group_clusters(struct super_block *sb, in ext4_free_group_clusters() argument
321 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_free_group_clusters()
325 __u32 ext4_free_inodes_count(struct super_block *sb, in ext4_free_inodes_count() argument
329 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_free_inodes_count()
333 __u32 ext4_used_dirs_count(struct super_block *sb, in ext4_used_dirs_count() argument
337 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_used_dirs_count()
341 __u32 ext4_itable_unused_count(struct super_block *sb, in ext4_itable_unused_count() argument
345 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_itable_unused_count()
349 void ext4_block_bitmap_set(struct super_block *sb, in ext4_block_bitmap_set() argument
353 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_block_bitmap_set()
357 void ext4_inode_bitmap_set(struct super_block *sb, in ext4_inode_bitmap_set() argument
361 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_inode_bitmap_set()
365 void ext4_inode_table_set(struct super_block *sb, in ext4_inode_table_set() argument
369 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_inode_table_set()
373 void ext4_free_group_clusters_set(struct super_block *sb, in ext4_free_group_clusters_set() argument
377 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_free_group_clusters_set()
381 void ext4_free_inodes_set(struct super_block *sb, in ext4_free_inodes_set() argument
385 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_free_inodes_set()
389 void ext4_used_dirs_set(struct super_block *sb, in ext4_used_dirs_set() argument
393 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_used_dirs_set()
397 void ext4_itable_unused_set(struct super_block *sb, in ext4_itable_unused_set() argument
401 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_itable_unused_set()
431 static int block_device_ejected(struct super_block *sb) in block_device_ejected() argument
433 struct inode *bd_inode = sb->s_bdev->bd_inode; in block_device_ejected()
441 struct super_block *sb = journal->j_private; in ext4_journal_commit_callback() local
442 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_journal_commit_callback()
448 ext4_process_freed_data(sb, txn->t_tid); in ext4_journal_commit_callback()
456 jce->jce_func(sb, jce, error); in ext4_journal_commit_callback()
587 static void save_error_info(struct super_block *sb, int error, in save_error_info() argument
591 struct ext4_sb_info *sbi = EXT4_SB(sb); in save_error_info()
636 static void ext4_handle_error(struct super_block *sb, bool force_ro, int error, in ext4_handle_error() argument
640 journal_t *journal = EXT4_SB(sb)->s_journal; in ext4_handle_error()
641 bool continue_fs = !force_ro && test_opt(sb, ERRORS_CONT); in ext4_handle_error()
643 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; in ext4_handle_error()
644 if (test_opt(sb, WARN_ON_ERROR)) in ext4_handle_error()
647 if (!continue_fs && !sb_rdonly(sb)) { in ext4_handle_error()
648 ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED); in ext4_handle_error()
653 if (!bdev_read_only(sb->s_bdev)) { in ext4_handle_error()
654 save_error_info(sb, error, ino, block, func, line); in ext4_handle_error()
662 schedule_work(&EXT4_SB(sb)->s_error_work); in ext4_handle_error()
664 ext4_commit_super(sb); in ext4_handle_error()
672 if (test_opt(sb, ERRORS_PANIC) && !system_going_down()) { in ext4_handle_error()
674 sb->s_id); in ext4_handle_error()
677 if (sb_rdonly(sb) || continue_fs) in ext4_handle_error()
680 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); in ext4_handle_error()
686 sb->s_flags |= SB_RDONLY; in ext4_handle_error()
698 * through the journal to avoid collisions of other journalled sb in flush_stashed_error_work()
731 * 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()
1040 count = ext4_free_inodes_count(sb, gdp); in ext4_mark_group_bitmap_corrupted()
1047 void ext4_update_dynamic_rev(struct super_block *sb) in ext4_update_dynamic_rev() argument
1049 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in ext4_update_dynamic_rev()
1054 ext4_warning(sb, in ext4_update_dynamic_rev()
1075 static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb) in ext4_blkdev_get() argument
1079 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); in ext4_blkdev_get()
1085 ext4_msg(sb, KERN_ERR, in ext4_blkdev_get()
1114 static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi) in dump_orphan_list() argument
1118 ext4_msg(sb, KERN_ERR, "sb orphan head is %d", in dump_orphan_list()
1133 static int ext4_quota_off(struct super_block *sb, int type);
1135 static inline void ext4_quota_off_umount(struct super_block *sb) in ext4_quota_off_umount() argument
1141 ext4_quota_off(sb, type); in ext4_quota_off_umount()
1148 static inline char *get_qf_name(struct super_block *sb, in get_qf_name() argument
1153 lockdep_is_held(&sb->s_umount)); in get_qf_name()
1156 static inline void ext4_quota_off_umount(struct super_block *sb) in ext4_quota_off_umount() argument
1161 static void ext4_put_super(struct super_block *sb) in ext4_put_super() argument
1163 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_put_super()
1170 ext4_unregister_li_request(sb); in ext4_put_super()
1171 ext4_quota_off_umount(sb); in ext4_put_super()
1175 ext4_release_orphan_info(sb); in ext4_put_super()
1182 ext4_unregister_sysfs(sb); in ext4_put_super()
1189 ext4_abort(sb, -err, "Couldn't clean up the journal"); in ext4_put_super()
1195 ext4_release_system_zone(sb); in ext4_put_super()
1196 ext4_mb_release(sb); in ext4_put_super()
1197 ext4_ext_release(sb); in ext4_put_super()
1199 if (!sb_rdonly(sb) && !aborted) { in ext4_put_super()
1200 ext4_clear_feature_journal_needs_recovery(sb); in ext4_put_super()
1201 ext4_clear_feature_orphan_present(sb); in ext4_put_super()
1204 if (!sb_rdonly(sb)) in ext4_put_super()
1205 ext4_commit_super(sb); in ext4_put_super()
1227 kfree(get_qf_name(sb, sbi, i)); in ext4_put_super()
1235 dump_orphan_list(sb, sbi); in ext4_put_super()
1238 sync_blockdev(sb->s_bdev); in ext4_put_super()
1239 invalidate_bdev(sb->s_bdev); in ext4_put_super()
1240 if (sbi->s_journal_bdev && sbi->s_journal_bdev != sb->s_bdev) { in ext4_put_super()
1260 sb->s_fs_info = NULL; in ext4_put_super()
1273 utf8_unload(sb->s_encoding); in ext4_put_super()
1283 static struct inode *ext4_alloc_inode(struct super_block *sb) in ext4_alloc_inode() argument
1414 static struct inode *ext4_nfs_get_inode(struct super_block *sb, in ext4_nfs_get_inode() argument
1423 inode = ext4_iget(sb, ino, EXT4_IGET_HANDLE); in ext4_nfs_get_inode()
1434 static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, in ext4_fh_to_dentry() argument
1437 return generic_fh_to_dentry(sb, fid, fh_len, fh_type, in ext4_fh_to_dentry()
1441 static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, in ext4_fh_to_parent() argument
1444 return generic_fh_to_parent(sb, fid, fh_len, fh_type, in ext4_fh_to_parent()
1552 static const union fscrypt_policy *ext4_get_dummy_policy(struct super_block *sb) in ext4_get_dummy_policy() argument
1554 return EXT4_SB(sb)->s_dummy_enc_policy.policy; in ext4_get_dummy_policy()
1557 static bool ext4_has_stable_inodes(struct super_block *sb) in ext4_has_stable_inodes() argument
1559 return ext4_has_feature_stable_inodes(sb); in ext4_has_stable_inodes()
1562 static void ext4_get_ino_and_lblk_bits(struct super_block *sb, in ext4_get_ino_and_lblk_bits() argument
1565 *ino_bits_ret = 8 * sizeof(EXT4_SB(sb)->s_es->s_inodes_count); in ext4_get_ino_and_lblk_bits()
1589 static int ext4_write_info(struct super_block *sb, int type);
1590 static int ext4_quota_on(struct super_block *sb, int type, int format_id,
1592 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
1594 static ssize_t ext4_quota_write(struct super_block *sb, int type,
1596 static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
1698 {Opt_sb, "sb=%u"},
1799 if (!options || strncmp(options, "sb=", 3) != 0) in get_sb_block()
1806 printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n", in get_sb_block()
1825 static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) in set_qf_name() argument
1827 struct ext4_sb_info *sbi = EXT4_SB(sb); in set_qf_name()
1828 char *qname, *old_qname = get_qf_name(sb, sbi, qtype); in set_qf_name()
1831 if (sb_any_quota_loaded(sb) && !old_qname) { in set_qf_name()
1832 ext4_msg(sb, KERN_ERR, in set_qf_name()
1837 if (ext4_has_feature_quota(sb)) { in set_qf_name()
1838 ext4_msg(sb, KERN_INFO, "Journaled quota options " in set_qf_name()
1844 ext4_msg(sb, KERN_ERR, in set_qf_name()
1852 ext4_msg(sb, KERN_ERR, in set_qf_name()
1858 ext4_msg(sb, KERN_ERR, in set_qf_name()
1863 set_opt(sb, QUOTA); in set_qf_name()
1870 static int clear_qf_name(struct super_block *sb, int qtype) in clear_qf_name() argument
1873 struct ext4_sb_info *sbi = EXT4_SB(sb); in clear_qf_name()
1874 char *old_qname = get_qf_name(sb, sbi, qtype); in clear_qf_name()
1876 if (sb_any_quota_loaded(sb) && old_qname) { in clear_qf_name()
1877 ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options" in clear_qf_name()
2047 static int ext4_set_test_dummy_encryption(struct super_block *sb, in ext4_set_test_dummy_encryption() argument
2053 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_set_test_dummy_encryption()
2063 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2067 err = fscrypt_set_test_dummy_encryption(sb, arg->from, in ext4_set_test_dummy_encryption()
2071 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2074 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2077 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2082 ext4_msg(sb, KERN_WARNING, "Test dummy encryption mode enabled"); in ext4_set_test_dummy_encryption()
2084 ext4_msg(sb, KERN_WARNING, in ext4_set_test_dummy_encryption()
2096 static int handle_mount_opt(struct super_block *sb, char *opt, int token, in handle_mount_opt() argument
2100 struct ext4_sb_info *sbi = EXT4_SB(sb); in handle_mount_opt()
2108 return set_qf_name(sb, USRQUOTA, &args[0]); in handle_mount_opt()
2110 return set_qf_name(sb, GRPQUOTA, &args[0]); in handle_mount_opt()
2112 return clear_qf_name(sb, USRQUOTA); in handle_mount_opt()
2114 return clear_qf_name(sb, GRPQUOTA); in handle_mount_opt()
2119 ext4_msg(sb, KERN_WARNING, deprecated_msg, opt, "3.5"); in handle_mount_opt()
2124 ext4_msg(sb, KERN_WARNING, "Ignoring removed %s option", opt); in handle_mount_opt()
2127 ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED); in handle_mount_opt()
2130 sb->s_flags |= SB_I_VERSION; in handle_mount_opt()
2133 sb->s_flags |= SB_LAZYTIME; in handle_mount_opt()
2136 sb->s_flags &= ~SB_LAZYTIME; in handle_mount_opt()
2140 sb->s_flags |= SB_INLINECRYPT; in handle_mount_opt()
2142 ext4_msg(sb, KERN_ERR, "inline encryption not supported"); in handle_mount_opt()
2152 ext4_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" " in handle_mount_opt()
2157 if ((m->flags & MOPT_NO_EXT2) && IS_EXT2_SB(sb)) { in handle_mount_opt()
2158 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2162 if ((m->flags & MOPT_NO_EXT3) && IS_EXT3_SB(sb)) { in handle_mount_opt()
2163 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2174 set_opt2(sb, EXPLICIT_DELALLOC); in handle_mount_opt()
2176 set_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM); in handle_mount_opt()
2181 clear_opt(sb, ERRORS_MASK); in handle_mount_opt()
2182 if (token == Opt_noquota && sb_any_quota_loaded(sb)) { in handle_mount_opt()
2183 ext4_msg(sb, KERN_ERR, "Cannot change quota " in handle_mount_opt()
2189 ext4_msg(sb, KERN_ERR, "%s option not supported", opt); in handle_mount_opt()
2194 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2205 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2216 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2223 set_opt(sb, INIT_INODE_TABLE); in handle_mount_opt()
2238 ext4_msg(sb, KERN_ERR, "Invalid uid value %d", arg); in handle_mount_opt()
2245 ext4_msg(sb, KERN_ERR, "Invalid gid value %d", arg); in handle_mount_opt()
2251 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2263 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2269 ext4_msg(sb, KERN_ERR, "error: could not dup " in handle_mount_opt()
2276 ext4_msg(sb, KERN_ERR, "error: could not find " in handle_mount_opt()
2284 ext4_msg(sb, KERN_ERR, "error: journal path %s " in handle_mount_opt()
2296 ext4_msg(sb, KERN_ERR, "Invalid journal IO priority" in handle_mount_opt()
2303 return ext4_set_test_dummy_encryption(sb, opt, &args[0], in handle_mount_opt()
2308 …ext4_msg(sb, KERN_WARNING, "Remounting file system with no journal so ignoring journalled data opt… in handle_mount_opt()
2309 else if (test_opt(sb, DATA_FLAGS) != m->mount_opt) { in handle_mount_opt()
2310 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
2315 clear_opt(sb, DATA_FLAGS); in handle_mount_opt()
2320 if (sb_any_quota_loaded(sb) && in handle_mount_opt()
2322 ext4_msg(sb, KERN_ERR, "Cannot change journaled " in handle_mount_opt()
2326 if (ext4_has_feature_quota(sb)) { in handle_mount_opt()
2327 ext4_msg(sb, KERN_INFO, in handle_mount_opt()
2344 ext4_msg(sb, KERN_ERR, "can't change " in handle_mount_opt()
2349 (test_opt(sb, DATA_FLAGS) == in handle_mount_opt()
2351 ext4_msg(sb, KERN_ERR, "can't mount with " in handle_mount_opt()
2355 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
2381 ext4_msg(sb, KERN_INFO, "dax option not supported"); in handle_mount_opt()
2392 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
2403 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
2423 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, ret_opts, 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()
2694 if (ext4_has_feature_orphan_file(sb)) in ext4_setup_super()
2695 ext4_set_feature_orphan_present(sb); in ext4_setup_super()
2698 err = ext4_commit_super(sb); in ext4_setup_super()
2700 if (test_opt(sb, DEBUG)) in ext4_setup_super()
2703 sb->s_blocksize, in ext4_setup_super()
2705 EXT4_BLOCKS_PER_GROUP(sb), in ext4_setup_super()
2706 EXT4_INODES_PER_GROUP(sb), in ext4_setup_super()
2709 cleancache_init_fs(sb); in ext4_setup_super()
2713 int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup) in ext4_alloc_flex_bg_array() argument
2715 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_alloc_flex_bg_array()
2729 ext4_msg(sb, KERN_ERR, in ext4_alloc_flex_bg_array()
2741 ext4_msg(sb, KERN_ERR, in ext4_alloc_flex_bg_array()
2760 static int ext4_fill_flex_info(struct super_block *sb) in ext4_fill_flex_info() argument
2762 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_fill_flex_info()
2774 err = ext4_alloc_flex_bg_array(sb, sbi->s_groups_count); in ext4_fill_flex_info()
2779 gdp = ext4_get_group_desc(sb, i, NULL); in ext4_fill_flex_info()
2783 atomic_add(ext4_free_inodes_count(sb, gdp), &fg->free_inodes); in ext4_fill_flex_info()
2784 atomic64_add(ext4_free_group_clusters(sb, gdp), in ext4_fill_flex_info()
2786 atomic_add(ext4_used_dirs_count(sb, gdp), &fg->used_dirs); in ext4_fill_flex_info()
2794 static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum() argument
2800 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_group_desc_csum()
2822 if (!ext4_has_feature_gdt_csum(sb)) in ext4_group_desc_csum()
2830 if (ext4_has_feature_64bit(sb) && in ext4_group_desc_csum()
2840 int ext4_group_desc_csum_verify(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum_verify() argument
2843 if (ext4_has_group_desc_csum(sb) && in ext4_group_desc_csum_verify()
2844 (gdp->bg_checksum != ext4_group_desc_csum(sb, block_group, gdp))) in ext4_group_desc_csum_verify()
2850 void ext4_group_desc_csum_set(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum_set() argument
2853 if (!ext4_has_group_desc_csum(sb)) in ext4_group_desc_csum_set()
2855 gdp->bg_checksum = ext4_group_desc_csum(sb, block_group, gdp); in ext4_group_desc_csum_set()
2859 static int ext4_check_descriptors(struct super_block *sb, in ext4_check_descriptors() argument
2863 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_check_descriptors()
2866 ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0); in ext4_check_descriptors()
2873 if (ext4_has_feature_flex_bg(sb)) in ext4_check_descriptors()
2879 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, NULL); in ext4_check_descriptors()
2885 (EXT4_BLOCKS_PER_GROUP(sb) - 1); in ext4_check_descriptors()
2891 block_bitmap = ext4_block_bitmap(sb, gdp); in ext4_check_descriptors()
2893 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2896 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2901 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2904 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2908 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2913 inode_bitmap = ext4_inode_bitmap(sb, gdp); in ext4_check_descriptors()
2915 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2918 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2923 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2926 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2930 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2935 inode_table = ext4_inode_table(sb, gdp); in ext4_check_descriptors()
2937 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2940 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2945 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2948 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2953 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2958 ext4_lock_group(sb, i); in ext4_check_descriptors()
2959 if (!ext4_group_desc_csum_verify(sb, i, gdp)) { in ext4_check_descriptors()
2960 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2962 i, le16_to_cpu(ext4_group_desc_csum(sb, i, in ext4_check_descriptors()
2964 if (!sb_rdonly(sb)) { in ext4_check_descriptors()
2965 ext4_unlock_group(sb, i); in ext4_check_descriptors()
2969 ext4_unlock_group(sb, i); in ext4_check_descriptors()
2971 first_block += EXT4_BLOCKS_PER_GROUP(sb); in ext4_check_descriptors()
3086 static ext4_fsblk_t descriptor_loc(struct super_block *sb, in descriptor_loc() argument
3089 struct ext4_sb_info *sbi = EXT4_SB(sb); in descriptor_loc()
3095 if (!ext4_has_feature_meta_bg(sb) || nr < first_meta_bg) in descriptor_loc()
3098 if (ext4_bg_has_super(sb, bg)) in descriptor_loc()
3107 if (sb->s_blocksize == 1024 && nr == 0 && in descriptor_loc()
3111 return (has_super + ext4_group_first_block_no(sb, bg)); in descriptor_loc()
3157 int ext4_feature_set_ok(struct super_block *sb, int readonly) in ext4_feature_set_ok() argument
3159 if (ext4_has_unknown_ext4_incompat_features(sb)) { in ext4_feature_set_ok()
3160 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
3163 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & in ext4_feature_set_ok()
3169 if (ext4_has_feature_casefold(sb)) { in ext4_feature_set_ok()
3170 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
3180 if (ext4_has_feature_readonly(sb)) { in ext4_feature_set_ok()
3181 ext4_msg(sb, KERN_INFO, "filesystem is read-only"); in ext4_feature_set_ok()
3182 sb->s_flags |= SB_RDONLY; in ext4_feature_set_ok()
3187 if (ext4_has_unknown_ext4_ro_compat_features(sb)) { in ext4_feature_set_ok()
3188 ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of " in ext4_feature_set_ok()
3190 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & in ext4_feature_set_ok()
3194 if (ext4_has_feature_bigalloc(sb) && !ext4_has_feature_extents(sb)) { in ext4_feature_set_ok()
3195 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
3202 if (!readonly && (ext4_has_feature_quota(sb) || in ext4_feature_set_ok()
3203 ext4_has_feature_project(sb))) { in ext4_feature_set_ok()
3204 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
3219 struct super_block *sb = sbi->s_sb; in print_daily_error_info() local
3224 ext4_msg(sb, KERN_NOTICE, "error count since last fsck: %u", in print_daily_error_info()
3228 sb->s_id, in print_daily_error_info()
3243 sb->s_id, in print_daily_error_info()
3263 struct super_block *sb = elr->lr_super; in ext4_run_li_request() local
3264 ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count; in ext4_run_li_request()
3271 elr->lr_next_group = ext4_mb_prefetch(sb, group, in ext4_run_li_request()
3272 EXT4_SB(sb)->s_mb_prefetch, &prefetch_ios); in ext4_run_li_request()
3274 ext4_mb_prefetch_fini(sb, elr->lr_next_group, in ext4_run_li_request()
3276 trace_ext4_prefetch_bitmaps(sb, group, elr->lr_next_group, in ext4_run_li_request()
3281 !sb_rdonly(sb) && test_opt(sb, INIT_INODE_TABLE)) { in ext4_run_li_request()
3291 gdp = ext4_get_group_desc(sb, group, NULL); in ext4_run_li_request()
3306 ret = ext4_init_inode_table(sb, group, in ext4_run_li_request()
3308 trace_ext4_lazy_itable_init(sb, group); in ext4_run_li_request()
3334 static void ext4_unregister_li_request(struct super_block *sb) in ext4_unregister_li_request() argument
3343 ext4_remove_li_request(EXT4_SB(sb)->s_li_request); in ext4_unregister_li_request()
3392 * We hold sb->s_umount, sb can not in ext4_lazyinit_thread()
3498 static ext4_group_t ext4_has_uninit_itable(struct super_block *sb) in ext4_has_uninit_itable() argument
3500 ext4_group_t group, ngroups = EXT4_SB(sb)->s_groups_count; in ext4_has_uninit_itable()
3503 if (!ext4_has_group_desc_csum(sb)) in ext4_has_uninit_itable()
3507 gdp = ext4_get_group_desc(sb, group, NULL); in ext4_has_uninit_itable()
3536 static struct ext4_li_request *ext4_li_request_new(struct super_block *sb, in ext4_li_request_new() argument
3545 elr->lr_super = sb; in ext4_li_request_new()
3547 if (test_opt(sb, NO_PREFETCH_BLOCK_BITMAPS)) { in ext4_li_request_new()
3564 int ext4_register_li_request(struct super_block *sb, in ext4_register_li_request() argument
3567 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_register_li_request()
3582 if (test_opt(sb, NO_PREFETCH_BLOCK_BITMAPS) && in ext4_register_li_request()
3583 (first_not_zeroed == ngroups || sb_rdonly(sb) || in ext4_register_li_request()
3584 !test_opt(sb, INIT_INODE_TABLE))) in ext4_register_li_request()
3587 elr = ext4_li_request_new(sb, first_not_zeroed); in ext4_register_li_request()
3639 static int set_journal_csum_feature_set(struct super_block *sb) in set_journal_csum_feature_set() argument
3643 struct ext4_sb_info *sbi = EXT4_SB(sb); in set_journal_csum_feature_set()
3645 if (ext4_has_metadata_csum(sb)) { in set_journal_csum_feature_set()
3659 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in set_journal_csum_feature_set()
3664 } else if (test_opt(sb, JOURNAL_CHECKSUM)) { in set_journal_csum_feature_set()
3693 static int count_overhead(struct super_block *sb, ext4_group_t grp, in count_overhead() argument
3696 struct ext4_sb_info *sbi = EXT4_SB(sb); in count_overhead()
3699 ext4_group_t i, ngroups = ext4_get_groups_count(sb); in count_overhead()
3702 if (!ext4_has_feature_bigalloc(sb)) in count_overhead()
3703 return (ext4_bg_has_super(sb, grp) + ext4_bg_num_gdb(sb, grp) + in count_overhead()
3707 (grp * EXT4_BLOCKS_PER_GROUP(sb)); in count_overhead()
3708 last_block = first_block + EXT4_BLOCKS_PER_GROUP(sb) - 1; in count_overhead()
3710 gdp = ext4_get_group_desc(sb, i, NULL); in count_overhead()
3711 b = ext4_block_bitmap(sb, gdp); in count_overhead()
3716 b = ext4_inode_bitmap(sb, gdp); in count_overhead()
3721 b = ext4_inode_table(sb, gdp); in count_overhead()
3731 if (ext4_bg_has_super(sb, grp)) { in count_overhead()
3735 j = ext4_bg_num_gdb(sb, grp); in count_overhead()
3736 if (s + j > EXT4_BLOCKS_PER_GROUP(sb)) { in count_overhead()
3737 ext4_error(sb, "Invalid number of block group " in count_overhead()
3739 j = EXT4_BLOCKS_PER_GROUP(sb) - s; in count_overhead()
3747 return EXT4_CLUSTERS_PER_GROUP(sb) - in count_overhead()
3748 ext4_count_free(buf, EXT4_CLUSTERS_PER_GROUP(sb) / 8); in count_overhead()
3754 int ext4_calculate_overhead(struct super_block *sb) in ext4_calculate_overhead() argument
3756 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_calculate_overhead()
3760 ext4_group_t i, ngroups = ext4_get_groups_count(sb); in ext4_calculate_overhead()
3784 blks = count_overhead(sb, i, buf); in ext4_calculate_overhead()
3797 else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) { in ext4_calculate_overhead()
3799 j_inode = ext4_get_journal_inode(sb, j_inum); in ext4_calculate_overhead()
3801 j_blocks = j_inode->i_size >> sb->s_blocksize_bits; in ext4_calculate_overhead()
3805 ext4_msg(sb, KERN_ERR, "can't get journal size"); in ext4_calculate_overhead()
3814 static void ext4_set_resv_clusters(struct super_block *sb) in ext4_set_resv_clusters() argument
3817 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_set_resv_clusters()
3825 if (!ext4_has_feature_extents(sb)) in ext4_set_resv_clusters()
3844 static const char *ext4_quota_mode(struct super_block *sb) in ext4_quota_mode() argument
3847 if (!ext4_quota_capable(sb)) in ext4_quota_mode()
3850 if (EXT4_SB(sb)->s_journal && ext4_is_quota_journalled(sb)) in ext4_quota_mode()
3859 static void ext4_setup_csum_trigger(struct super_block *sb, in ext4_setup_csum_trigger() argument
3867 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_setup_csum_trigger()
3869 sbi->s_journal_triggers[type].sb = sb; in ext4_setup_csum_trigger()
3873 static int ext4_fill_super(struct super_block *sb, void *data, int silent) in ext4_fill_super() argument
3875 struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev); in ext4_fill_super()
3912 sb->s_fs_info = sbi; in ext4_fill_super()
3913 sbi->s_sb = sb; in ext4_fill_super()
3917 part_stat_read(sb->s_bdev, sectors[STAT_WRITE]); in ext4_fill_super()
3920 strreplace(sb->s_id, '/', '!'); in ext4_fill_super()
3924 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); in ext4_fill_super()
3926 ext4_msg(sb, KERN_ERR, "unable to set blocksize"); in ext4_fill_super()
3941 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); in ext4_fill_super()
3943 ext4_msg(sb, KERN_ERR, "unable to read superblock"); in ext4_fill_super()
3953 sb->s_magic = le16_to_cpu(es->s_magic); in ext4_fill_super()
3954 if (sb->s_magic != EXT4_SUPER_MAGIC) in ext4_fill_super()
3959 if (ext4_has_feature_metadata_csum(sb) && in ext4_fill_super()
3960 ext4_has_feature_gdt_csum(sb)) in ext4_fill_super()
3961 ext4_warning(sb, "metadata_csum and uninit_bg are " in ext4_fill_super()
3965 if (!ext4_verify_csum_type(sb, es)) { in ext4_fill_super()
3966 ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " in ext4_fill_super()
3971 ext4_setup_csum_trigger(sb, EXT4_JTR_ORPHAN_FILE, in ext4_fill_super()
3977 ext4_msg(sb, KERN_ERR, "Cannot load crc32c driver."); in ext4_fill_super()
3984 if (!ext4_superblock_csum_verify(sb, es)) { in ext4_fill_super()
3985 ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " in ext4_fill_super()
3993 if (ext4_has_feature_csum_seed(sb)) in ext4_fill_super()
3995 else if (ext4_has_metadata_csum(sb) || ext4_has_feature_ea_inode(sb)) in ext4_fill_super()
4001 set_opt(sb, INIT_INODE_TABLE); in ext4_fill_super()
4003 set_opt(sb, DEBUG); in ext4_fill_super()
4005 set_opt(sb, GRPID); in ext4_fill_super()
4007 set_opt(sb, NO_UID32); in ext4_fill_super()
4009 set_opt(sb, XATTR_USER); in ext4_fill_super()
4011 set_opt(sb, POSIX_ACL); in ext4_fill_super()
4013 if (ext4_has_feature_fast_commit(sb)) in ext4_fill_super()
4014 set_opt2(sb, JOURNAL_FAST_COMMIT); in ext4_fill_super()
4016 if (ext4_has_metadata_csum(sb)) in ext4_fill_super()
4017 set_opt(sb, JOURNAL_CHECKSUM); in ext4_fill_super()
4020 set_opt(sb, JOURNAL_DATA); in ext4_fill_super()
4022 set_opt(sb, ORDERED_DATA); in ext4_fill_super()
4024 set_opt(sb, WRITEBACK_DATA); in ext4_fill_super()
4027 set_opt(sb, ERRORS_PANIC); in ext4_fill_super()
4029 set_opt(sb, ERRORS_CONT); in ext4_fill_super()
4031 set_opt(sb, ERRORS_RO); in ext4_fill_super()
4033 set_opt(sb, BLOCK_VALIDITY); in ext4_fill_super()
4035 set_opt(sb, DISCARD); in ext4_fill_super()
4044 set_opt(sb, BARRIER); in ext4_fill_super()
4050 if (!IS_EXT3_SB(sb) && !IS_EXT2_SB(sb) && in ext4_fill_super()
4052 set_opt(sb, DELALLOC); in ext4_fill_super()
4062 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4069 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4078 set_opt(sb, DIOREAD_NOLOCK); in ext4_fill_super()
4087 ext4_msg(sb, KERN_ERR, "invalid first ino: %u", in ext4_fill_super()
4094 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4097 ext4_msg(sb, KERN_ERR, "blocksize: %d", blocksize); in ext4_fill_super()
4108 sb->s_time_gran = 1; in ext4_fill_super()
4109 sb->s_time_max = EXT4_EXTRA_TIMESTAMP_MAX; in ext4_fill_super()
4111 sb->s_time_gran = NSEC_PER_SEC; in ext4_fill_super()
4112 sb->s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX; in ext4_fill_super()
4114 sb->s_time_min = EXT4_TIMESTAMP_MIN; in ext4_fill_super()
4119 if (ext4_has_feature_extra_isize(sb)) { in ext4_fill_super()
4125 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4134 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4149 if (!parse_options(s_mount_opts, sb, &parsed_opts, 0)) { in ext4_fill_super()
4150 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4157 if (!parse_options((char *) data, sb, &parsed_opts, 0)) in ext4_fill_super()
4161 if (ext4_has_feature_casefold(sb) && !sb->s_encoding) { in ext4_fill_super()
4168 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4175 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4182 ext4_msg(sb, KERN_INFO,"Using encoding defined by superblock: " in ext4_fill_super()
4186 sb->s_encoding = encoding; in ext4_fill_super()
4187 sb->s_encoding_flags = encoding_flags; in ext4_fill_super()
4191 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { in ext4_fill_super()
4194 clear_opt(sb, DIOREAD_NOLOCK); in ext4_fill_super()
4195 clear_opt2(sb, JOURNAL_FAST_COMMIT); in ext4_fill_super()
4196 if (test_opt2(sb, EXPLICIT_DELALLOC)) { in ext4_fill_super()
4197 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4201 if (test_opt(sb, DAX_ALWAYS)) { in ext4_fill_super()
4202 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4206 if (ext4_has_feature_encrypt(sb)) { in ext4_fill_super()
4207 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4211 if (test_opt(sb, DELALLOC)) in ext4_fill_super()
4212 clear_opt(sb, DELALLOC); in ext4_fill_super()
4214 sb->s_iflags |= SB_I_CGROUPWB; in ext4_fill_super()
4217 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext4_fill_super()
4218 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); in ext4_fill_super()
4221 (ext4_has_compat_features(sb) || in ext4_fill_super()
4222 ext4_has_ro_compat_features(sb) || in ext4_fill_super()
4223 ext4_has_incompat_features(sb))) in ext4_fill_super()
4224 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4229 set_opt2(sb, HURD_COMPAT); in ext4_fill_super()
4230 if (ext4_has_feature_64bit(sb)) { in ext4_fill_super()
4231 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4240 if (ext4_has_feature_ea_inode(sb)) { in ext4_fill_super()
4241 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4247 if (IS_EXT2_SB(sb)) { in ext4_fill_super()
4248 if (ext2_feature_set_ok(sb)) in ext4_fill_super()
4249 ext4_msg(sb, KERN_INFO, "mounting ext2 file system " in ext4_fill_super()
4256 if (silent && ext4_feature_set_ok(sb, sb_rdonly(sb))) in ext4_fill_super()
4258 ext4_msg(sb, KERN_ERR, "couldn't mount as ext2 due " in ext4_fill_super()
4264 if (IS_EXT3_SB(sb)) { in ext4_fill_super()
4265 if (ext3_feature_set_ok(sb)) in ext4_fill_super()
4266 ext4_msg(sb, KERN_INFO, "mounting ext3 file system " in ext4_fill_super()
4273 if (silent && ext4_feature_set_ok(sb, sb_rdonly(sb))) in ext4_fill_super()
4275 ext4_msg(sb, KERN_ERR, "couldn't mount as ext3 due " in ext4_fill_super()
4286 if (!ext4_feature_set_ok(sb, (sb_rdonly(sb)))) in ext4_fill_super()
4290 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4296 if (dax_supported(dax_dev, sb->s_bdev, blocksize, 0, in ext4_fill_super()
4297 bdev_nr_sectors(sb->s_bdev))) in ext4_fill_super()
4301 if (ext4_has_feature_inline_data(sb)) { in ext4_fill_super()
4302 ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" in ext4_fill_super()
4307 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4313 if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) { in ext4_fill_super()
4314 ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d", in ext4_fill_super()
4319 if (sb->s_blocksize != blocksize) { in ext4_fill_super()
4327 if (!sb_set_blocksize(sb, blocksize)) { in ext4_fill_super()
4328 ext4_msg(sb, KERN_ERR, "bad block size %d", in ext4_fill_super()
4336 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); in ext4_fill_super()
4338 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4347 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4353 has_huge_files = ext4_has_feature_huge_file(sb); in ext4_fill_super()
4354 sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits, in ext4_fill_super()
4356 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files); in ext4_fill_super()
4359 if (ext4_has_feature_64bit(sb)) { in ext4_fill_super()
4363 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4374 sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); in ext4_fill_super()
4379 ext4_msg(sb, KERN_ERR, "invalid inodes per group: %lu\n", in ext4_fill_super()
4385 sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb); in ext4_fill_super()
4388 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); in ext4_fill_super()
4389 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); in ext4_fill_super()
4394 if (ext4_has_feature_dir_index(sb)) { in ext4_fill_super()
4400 if (!sb_rdonly(sb)) in ext4_fill_super()
4405 if (!sb_rdonly(sb)) in ext4_fill_super()
4414 if (ext4_has_feature_bigalloc(sb)) { in ext4_fill_super()
4416 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4426 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4433 ext4_msg(sb, KERN_ERR, "blocks per group (%lu) and " in ext4_fill_super()
4441 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4447 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4459 set_opt2(sb, STD_GROUP_SIZE); in ext4_fill_super()
4465 err = generic_check_addressable(sb->s_blocksize_bits, in ext4_fill_super()
4468 ext4_msg(sb, KERN_ERR, "filesystem" in ext4_fill_super()
4473 if (EXT4_BLOCKS_PER_GROUP(sb) == 0) in ext4_fill_super()
4477 blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; in ext4_fill_super()
4479 ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu " in ext4_fill_super()
4490 ext4_msg(sb, KERN_WARNING, "bad geometry: first data " in ext4_fill_super()
4498 ext4_msg(sb, KERN_WARNING, "bad geometry: first data " in ext4_fill_super()
4505 EXT4_BLOCKS_PER_GROUP(sb) - 1); in ext4_fill_super()
4506 do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); in ext4_fill_super()
4507 if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) { in ext4_fill_super()
4508 ext4_msg(sb, KERN_WARNING, "groups count too large: %llu " in ext4_fill_super()
4513 EXT4_BLOCKS_PER_GROUP(sb)); in ext4_fill_super()
4518 (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb))); in ext4_fill_super()
4521 ext4_msg(sb, KERN_ERR, "inodes count not valid: %u vs %llu", in ext4_fill_super()
4527 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / in ext4_fill_super()
4528 EXT4_DESC_PER_BLOCK(sb); in ext4_fill_super()
4529 if (ext4_has_feature_meta_bg(sb)) { in ext4_fill_super()
4531 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4543 ext4_msg(sb, KERN_ERR, "not enough memory"); in ext4_fill_super()
4552 block = descriptor_loc(sb, logical_sb_block, i); in ext4_fill_super()
4553 ext4_sb_breadahead_unmovable(sb, block); in ext4_fill_super()
4559 block = descriptor_loc(sb, logical_sb_block, i); in ext4_fill_super()
4560 bh = ext4_sb_bread_unmovable(sb, block); in ext4_fill_super()
4562 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4573 if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { in ext4_fill_super()
4574 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); in ext4_fill_super()
4593 sb->s_op = &ext4_sops; in ext4_fill_super()
4594 sb->s_export_op = &ext4_export_ops; in ext4_fill_super()
4595 sb->s_xattr = ext4_xattr_handlers; in ext4_fill_super()
4597 sb->s_cop = &ext4_cryptops; in ext4_fill_super()
4600 sb->s_vop = &ext4_verityops; in ext4_fill_super()
4603 sb->dq_op = &ext4_quota_operations; in ext4_fill_super()
4604 if (ext4_has_feature_quota(sb)) in ext4_fill_super()
4605 sb->s_qcop = &dquot_quotactl_sysfile_ops; in ext4_fill_super()
4607 sb->s_qcop = &ext4_qctl_operations; in ext4_fill_super()
4608 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; in ext4_fill_super()
4610 memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid)); in ext4_fill_super()
4623 ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); in ext4_fill_super()
4624 ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING); in ext4_fill_super()
4635 sb->s_root = NULL; in ext4_fill_super()
4638 ext4_has_feature_orphan_present(sb) || in ext4_fill_super()
4639 ext4_has_feature_journal_needs_recovery(sb)); in ext4_fill_super()
4641 if (ext4_has_feature_mmp(sb) && !sb_rdonly(sb)) in ext4_fill_super()
4642 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) in ext4_fill_super()
4649 if (!test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) { in ext4_fill_super()
4650 err = ext4_load_journal(sb, es, parsed_opts.journal_devnum); in ext4_fill_super()
4653 } else if (test_opt(sb, NOLOAD) && !sb_rdonly(sb) && in ext4_fill_super()
4654 ext4_has_feature_journal_needs_recovery(sb)) { in ext4_fill_super()
4655 ext4_msg(sb, KERN_ERR, "required journal recovery " in ext4_fill_super()
4660 if (test_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM)) { in ext4_fill_super()
4661 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4665 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_fill_super()
4666 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4671 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4678 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4683 clear_opt(sb, JOURNAL_CHECKSUM); in ext4_fill_super()
4684 clear_opt(sb, DATA_FLAGS); in ext4_fill_super()
4685 clear_opt2(sb, JOURNAL_FAST_COMMIT); in ext4_fill_super()
4691 if (ext4_has_feature_64bit(sb) && in ext4_fill_super()
4692 !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, in ext4_fill_super()
4694 ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature"); in ext4_fill_super()
4698 if (!set_journal_csum_feature_set(sb)) { in ext4_fill_super()
4699 ext4_msg(sb, KERN_ERR, "Failed to set journal checksum " in ext4_fill_super()
4704 if (test_opt2(sb, JOURNAL_FAST_COMMIT) && in ext4_fill_super()
4705 !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, in ext4_fill_super()
4707 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4714 switch (test_opt(sb, DATA_FLAGS)) { in ext4_fill_super()
4722 set_opt(sb, ORDERED_DATA); in ext4_fill_super()
4725 set_opt(sb, JOURNAL_DATA); in ext4_fill_super()
4734 ext4_msg(sb, KERN_ERR, "Journal does not support " in ext4_fill_super()
4743 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA && in ext4_fill_super()
4744 test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_fill_super()
4745 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4758 if (!test_opt(sb, NO_MBCACHE)) { in ext4_fill_super()
4761 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4766 if (ext4_has_feature_ea_inode(sb)) { in ext4_fill_super()
4769 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4776 if (ext4_has_feature_verity(sb) && blocksize != PAGE_SIZE) { in ext4_fill_super()
4777 ext4_msg(sb, KERN_ERR, "Unsupported blocksize for fs-verity"); in ext4_fill_super()
4781 if (DUMMY_ENCRYPTION_ENABLED(sbi) && !sb_rdonly(sb) && in ext4_fill_super()
4782 !ext4_has_feature_encrypt(sb)) { in ext4_fill_super()
4783 ext4_set_feature_encrypt(sb); in ext4_fill_super()
4784 ext4_commit_super(sb); in ext4_fill_super()
4794 err = ext4_calculate_overhead(sb); in ext4_fill_super()
4803 EXT4_SB(sb)->rsv_conversion_wq = in ext4_fill_super()
4805 if (!EXT4_SB(sb)->rsv_conversion_wq) { in ext4_fill_super()
4816 root = ext4_iget(sb, EXT4_ROOT_INO, EXT4_IGET_SPECIAL); in ext4_fill_super()
4818 ext4_msg(sb, KERN_ERR, "get root inode failed"); in ext4_fill_super()
4824 ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); in ext4_fill_super()
4829 sb->s_root = d_make_root(root); in ext4_fill_super()
4830 if (!sb->s_root) { in ext4_fill_super()
4831 ext4_msg(sb, KERN_ERR, "get root dentry failed"); in ext4_fill_super()
4836 ret = ext4_setup_super(sb, es, sb_rdonly(sb)); in ext4_fill_super()
4838 sb->s_flags |= SB_RDONLY; in ext4_fill_super()
4843 ext4_set_resv_clusters(sb); in ext4_fill_super()
4845 if (test_opt(sb, BLOCK_VALIDITY)) { in ext4_fill_super()
4846 err = ext4_setup_system_zone(sb); in ext4_fill_super()
4848 ext4_msg(sb, KERN_ERR, "failed to initialize system " in ext4_fill_super()
4853 ext4_fc_replay_cleanup(sb); in ext4_fill_super()
4855 ext4_ext_init(sb); in ext4_fill_super()
4863 set_opt2(sb, MB_OPTIMIZE_SCAN); in ext4_fill_super()
4865 clear_opt2(sb, MB_OPTIMIZE_SCAN); in ext4_fill_super()
4867 set_opt2(sb, MB_OPTIMIZE_SCAN); in ext4_fill_super()
4869 err = ext4_mb_init(sb); in ext4_fill_super()
4871 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", in ext4_fill_super()
4884 block = ext4_count_free_clusters(sb); in ext4_fill_super()
4890 unsigned long freei = ext4_count_free_inodes(sb); in ext4_fill_super()
4902 ext4_superblock_csum_set(sb); in ext4_fill_super()
4905 ext4_count_dirs(sb), GFP_KERNEL); in ext4_fill_super()
4916 ext4_msg(sb, KERN_ERR, "insufficient memory"); in ext4_fill_super()
4920 if (ext4_has_feature_flex_bg(sb)) in ext4_fill_super()
4921 if (!ext4_fill_flex_info(sb)) { in ext4_fill_super()
4922 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4929 err = ext4_register_li_request(sb, first_not_zeroed); in ext4_fill_super()
4933 err = ext4_register_sysfs(sb); in ext4_fill_super()
4937 err = ext4_init_orphan_info(sb); in ext4_fill_super()
4942 if (ext4_has_feature_quota(sb) && !sb_rdonly(sb)) { in ext4_fill_super()
4943 err = ext4_enable_quotas(sb); in ext4_fill_super()
4954 errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err, in ext4_fill_super()
4956 sb->s_bdev->bd_super = sb; in ext4_fill_super()
4957 EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; in ext4_fill_super()
4958 ext4_orphan_cleanup(sb, es); in ext4_fill_super()
4959 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; in ext4_fill_super()
4961 ext4_msg(sb, KERN_INFO, "recovery complete"); in ext4_fill_super()
4962 err = ext4_mark_recovery_complete(sb, es); in ext4_fill_super()
4966 if (EXT4_SB(sb)->s_journal) { in ext4_fill_super()
4967 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) in ext4_fill_super()
4969 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) in ext4_fill_super()
4976 if (test_opt(sb, DISCARD)) { in ext4_fill_super()
4977 struct request_queue *q = bdev_get_queue(sb->s_bdev); in ext4_fill_super()
4979 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4985 ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " in ext4_fill_super()
4990 ext4_quota_mode(sb)); in ext4_fill_super()
5007 ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem"); in ext4_fill_super()
5011 ext4_release_orphan_info(sb); in ext4_fill_super()
5013 ext4_unregister_sysfs(sb); in ext4_fill_super()
5016 ext4_unregister_li_request(sb); in ext4_fill_super()
5018 ext4_mb_release(sb); in ext4_fill_super()
5034 ext4_ext_release(sb); in ext4_fill_super()
5035 ext4_release_system_zone(sb); in ext4_fill_super()
5037 dput(sb->s_root); in ext4_fill_super()
5038 sb->s_root = NULL; in ext4_fill_super()
5040 ext4_msg(sb, KERN_ERR, "mount failed"); in ext4_fill_super()
5041 if (EXT4_SB(sb)->rsv_conversion_wq) in ext4_fill_super()
5042 destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); in ext4_fill_super()
5075 utf8_unload(sb->s_encoding); in ext4_fill_super()
5080 kfree(get_qf_name(sb, sbi, i)); in ext4_fill_super()
5087 sb->s_fs_info = NULL; in ext4_fill_super()
5101 static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) in ext4_init_journal_params() argument
5103 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_init_journal_params()
5108 ext4_fc_init(sb, journal); in ext4_init_journal_params()
5111 if (test_opt(sb, BARRIER)) in ext4_init_journal_params()
5115 if (test_opt(sb, DATA_ERR_ABORT)) in ext4_init_journal_params()
5122 static struct inode *ext4_get_journal_inode(struct super_block *sb, in ext4_get_journal_inode() argument
5132 journal_inode = ext4_iget(sb, journal_inum, EXT4_IGET_SPECIAL); in ext4_get_journal_inode()
5134 ext4_msg(sb, KERN_ERR, "no journal found"); in ext4_get_journal_inode()
5140 ext4_msg(sb, KERN_ERR, "journal inode is deleted"); in ext4_get_journal_inode()
5147 ext4_msg(sb, KERN_ERR, "invalid journal inode"); in ext4_get_journal_inode()
5154 static journal_t *ext4_get_journal(struct super_block *sb, in ext4_get_journal() argument
5160 if (WARN_ON_ONCE(!ext4_has_feature_journal(sb))) in ext4_get_journal()
5163 journal_inode = ext4_get_journal_inode(sb, journal_inum); in ext4_get_journal()
5169 ext4_msg(sb, KERN_ERR, "Could not load journal inode"); in ext4_get_journal()
5173 journal->j_private = sb; in ext4_get_journal()
5174 ext4_init_journal_params(sb, journal); in ext4_get_journal()
5178 static journal_t *ext4_get_dev_journal(struct super_block *sb, in ext4_get_dev_journal() argument
5191 if (WARN_ON_ONCE(!ext4_has_feature_journal(sb))) in ext4_get_dev_journal()
5194 bdev = ext4_blkdev_get(j_dev, sb); in ext4_get_dev_journal()
5198 blocksize = sb->s_blocksize; in ext4_get_dev_journal()
5201 ext4_msg(sb, KERN_ERR, in ext4_get_dev_journal()
5210 ext4_msg(sb, KERN_ERR, "couldn't read superblock of " in ext4_get_dev_journal()
5219 ext4_msg(sb, KERN_ERR, "external journal has " in ext4_get_dev_journal()
5227 es->s_checksum != ext4_superblock_csum(sb, es)) { in ext4_get_dev_journal()
5228 ext4_msg(sb, KERN_ERR, "external journal has " in ext4_get_dev_journal()
5234 if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { in ext4_get_dev_journal()
5235 ext4_msg(sb, KERN_ERR, "journal UUID does not match"); in ext4_get_dev_journal()
5244 journal = jbd2_journal_init_dev(bdev, sb->s_bdev, in ext4_get_dev_journal()
5247 ext4_msg(sb, KERN_ERR, "failed to create device journal"); in ext4_get_dev_journal()
5250 journal->j_private = sb; in ext4_get_dev_journal()
5252 ext4_msg(sb, KERN_ERR, "I/O error on journal device"); in ext4_get_dev_journal()
5256 ext4_msg(sb, KERN_ERR, "External journal has more than one " in ext4_get_dev_journal()
5261 EXT4_SB(sb)->s_journal_bdev = bdev; in ext4_get_dev_journal()
5262 ext4_init_journal_params(sb, journal); in ext4_get_dev_journal()
5272 static int ext4_load_journal(struct super_block *sb, in ext4_load_journal() argument
5283 if (WARN_ON_ONCE(!ext4_has_feature_journal(sb))) in ext4_load_journal()
5288 ext4_msg(sb, KERN_INFO, "external journal device major/minor " in ext4_load_journal()
5295 ext4_msg(sb, KERN_ERR, in ext4_load_journal()
5301 journal = ext4_get_journal(sb, journal_inum); in ext4_load_journal()
5305 journal = ext4_get_dev_journal(sb, journal_dev); in ext4_load_journal()
5311 really_read_only = bdev_read_only(sb->s_bdev) | journal_dev_ro; in ext4_load_journal()
5313 if (journal_dev_ro && !sb_rdonly(sb)) { in ext4_load_journal()
5314 ext4_msg(sb, KERN_ERR, in ext4_load_journal()
5325 if (ext4_has_feature_journal_needs_recovery(sb)) { in ext4_load_journal()
5326 if (sb_rdonly(sb)) { in ext4_load_journal()
5327 ext4_msg(sb, KERN_INFO, "INFO: recovery " in ext4_load_journal()
5330 ext4_msg(sb, KERN_ERR, "write access " in ext4_load_journal()
5336 ext4_msg(sb, KERN_INFO, "write access will " in ext4_load_journal()
5342 ext4_msg(sb, KERN_INFO, "barriers disabled"); in ext4_load_journal()
5344 if (!ext4_has_feature_journal_needs_recovery(sb)) in ext4_load_journal()
5359 ext4_msg(sb, KERN_ERR, "error loading journal"); in ext4_load_journal()
5363 EXT4_SB(sb)->s_journal = journal; in ext4_load_journal()
5364 err = ext4_clear_journal_err(sb, es); in ext4_load_journal()
5366 EXT4_SB(sb)->s_journal = NULL; in ext4_load_journal()
5376 ext4_commit_super(sb); in ext4_load_journal()
5386 /* Copy state of EXT4_SB(sb) into buffer for on-disk superblock */
5387 static void ext4_update_super(struct super_block *sb) in ext4_update_super() argument
5389 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_update_super()
5404 if (!(sb->s_flags & SB_RDONLY)) in ext4_update_super()
5408 ((part_stat_read(sb->s_bdev, sectors[STAT_WRITE]) - in ext4_update_super()
5458 ext4_superblock_csum_set(sb); in ext4_update_super()
5462 static int ext4_commit_super(struct super_block *sb) in ext4_commit_super() argument
5464 struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; in ext4_commit_super()
5469 if (block_device_ejected(sb)) in ext4_commit_super()
5472 ext4_update_super(sb); in ext4_commit_super()
5483 ext4_msg(sb, KERN_ERR, "previous I/O error to " in ext4_commit_super()
5491 REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0)); in ext4_commit_super()
5493 ext4_msg(sb, KERN_ERR, "I/O error while writing " in ext4_commit_super()
5506 static int ext4_mark_recovery_complete(struct super_block *sb, in ext4_mark_recovery_complete() argument
5510 journal_t *journal = EXT4_SB(sb)->s_journal; in ext4_mark_recovery_complete()
5512 if (!ext4_has_feature_journal(sb)) { in ext4_mark_recovery_complete()
5514 ext4_error(sb, "Journal got removed while the fs was " in ext4_mark_recovery_complete()
5525 if (sb_rdonly(sb) && (ext4_has_feature_journal_needs_recovery(sb) || in ext4_mark_recovery_complete()
5526 ext4_has_feature_orphan_present(sb))) { in ext4_mark_recovery_complete()
5527 if (!ext4_orphan_file_empty(sb)) { in ext4_mark_recovery_complete()
5528 ext4_error(sb, "Orphan file not empty on read-only fs."); in ext4_mark_recovery_complete()
5532 ext4_clear_feature_journal_needs_recovery(sb); in ext4_mark_recovery_complete()
5533 ext4_clear_feature_orphan_present(sb); in ext4_mark_recovery_complete()
5534 ext4_commit_super(sb); in ext4_mark_recovery_complete()
5546 static int ext4_clear_journal_err(struct super_block *sb, in ext4_clear_journal_err() argument
5553 if (!ext4_has_feature_journal(sb)) { in ext4_clear_journal_err()
5554 ext4_error(sb, "Journal got removed while the fs was mounted!"); in ext4_clear_journal_err()
5558 journal = EXT4_SB(sb)->s_journal; in ext4_clear_journal_err()
5569 errstr = ext4_decode_error(sb, j_errno, nbuf); in ext4_clear_journal_err()
5570 ext4_warning(sb, "Filesystem error recorded " in ext4_clear_journal_err()
5572 ext4_warning(sb, "Marking fs in need of filesystem check."); in ext4_clear_journal_err()
5574 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; in ext4_clear_journal_err()
5576 ext4_commit_super(sb); in ext4_clear_journal_err()
5588 int ext4_force_commit(struct super_block *sb) in ext4_force_commit() argument
5592 if (sb_rdonly(sb)) in ext4_force_commit()
5595 journal = EXT4_SB(sb)->s_journal; in ext4_force_commit()
5599 static int ext4_sync_fs(struct super_block *sb, int wait) in ext4_sync_fs() argument
5604 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_sync_fs()
5609 trace_ext4_sync_fs(sb, wait); in ext4_sync_fs()
5615 dquot_writeback_dquots(sb, -1); in ext4_sync_fs()
5632 } else if (wait && test_opt(sb, BARRIER)) in ext4_sync_fs()
5636 err = blkdev_issue_flush(sb->s_bdev); in ext4_sync_fs()
5652 static int ext4_freeze(struct super_block *sb) in ext4_freeze() argument
5657 if (sb_rdonly(sb)) in ext4_freeze()
5660 journal = EXT4_SB(sb)->s_journal; in ext4_freeze()
5675 ext4_clear_feature_journal_needs_recovery(sb); in ext4_freeze()
5676 if (ext4_orphan_file_empty(sb)) in ext4_freeze()
5677 ext4_clear_feature_orphan_present(sb); in ext4_freeze()
5680 error = ext4_commit_super(sb); in ext4_freeze()
5692 static int ext4_unfreeze(struct super_block *sb) in ext4_unfreeze() argument
5694 if (sb_rdonly(sb) || ext4_forced_shutdown(EXT4_SB(sb))) in ext4_unfreeze()
5697 if (EXT4_SB(sb)->s_journal) { in ext4_unfreeze()
5699 ext4_set_feature_journal_needs_recovery(sb); in ext4_unfreeze()
5700 if (ext4_has_feature_orphan_file(sb)) in ext4_unfreeze()
5701 ext4_set_feature_orphan_present(sb); in ext4_unfreeze()
5704 ext4_commit_super(sb); in ext4_unfreeze()
5724 static int ext4_remount(struct super_block *sb, int *flags, char *data) in ext4_remount() argument
5727 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_remount()
5747 old_sb_flags = sb->s_flags; in ext4_remount()
5759 char *qf_name = get_qf_name(sb, sbi, i); in ext4_remount()
5781 sb->s_flags = (sb->s_flags & ~vfs_flags) | (*flags & vfs_flags); in ext4_remount()
5783 if (!parse_options(data, sb, &parsed_opts, 1)) { in ext4_remount()
5789 test_opt(sb, JOURNAL_CHECKSUM)) { in ext4_remount()
5790 ext4_msg(sb, KERN_ERR, "changing journal_checksum " in ext4_remount()
5795 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { in ext4_remount()
5796 if (test_opt2(sb, EXPLICIT_DELALLOC)) { in ext4_remount()
5797 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5802 if (test_opt(sb, DIOREAD_NOLOCK)) { in ext4_remount()
5803 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5808 } else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) { in ext4_remount()
5809 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_remount()
5810 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5818 ext4_msg(sb, KERN_ERR, "can't enable nombcache during remount"); in ext4_remount()
5823 if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) in ext4_remount()
5824 ext4_abort(sb, EXT4_ERR_ESHUTDOWN, "Abort forced by user"); in ext4_remount()
5826 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext4_remount()
5827 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); in ext4_remount()
5832 ext4_init_journal_params(sb, sbi->s_journal); in ext4_remount()
5839 if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) { in ext4_remount()
5840 if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) { in ext4_remount()
5846 err = sync_filesystem(sb); in ext4_remount()
5849 err = dquot_suspend(sb, -1); in ext4_remount()
5857 sb->s_flags |= SB_RDONLY; in ext4_remount()
5873 ext4_mark_recovery_complete(sb, es); in ext4_remount()
5877 if (ext4_has_feature_readonly(sb) || in ext4_remount()
5878 !ext4_feature_set_ok(sb, 0)) { in ext4_remount()
5888 ext4_get_group_desc(sb, g, NULL); in ext4_remount()
5890 if (!ext4_group_desc_csum_verify(sb, g, gdp)) { in ext4_remount()
5891 ext4_msg(sb, KERN_ERR, in ext4_remount()
5893 g, le16_to_cpu(ext4_group_desc_csum(sb, g, gdp)), in ext4_remount()
5905 if (es->s_last_orphan || !ext4_orphan_file_empty(sb)) { in ext4_remount()
5906 ext4_msg(sb, KERN_WARNING, "Couldn't " in ext4_remount()
5921 err = ext4_clear_journal_err(sb, es); in ext4_remount()
5927 err = ext4_setup_super(sb, es, 0); in ext4_remount()
5931 sb->s_flags &= ~SB_RDONLY; in ext4_remount()
5932 if (ext4_has_feature_mmp(sb)) in ext4_remount()
5933 if (ext4_multi_mount_protect(sb, in ext4_remount()
5946 if (sb_rdonly(sb) || !test_opt(sb, INIT_INODE_TABLE)) in ext4_remount()
5947 ext4_unregister_li_request(sb); in ext4_remount()
5950 first_not_zeroed = ext4_has_uninit_itable(sb); in ext4_remount()
5951 ext4_register_li_request(sb, first_not_zeroed); in ext4_remount()
5959 if (test_opt(sb, BLOCK_VALIDITY) && !sbi->s_system_blks) { in ext4_remount()
5960 err = ext4_setup_system_zone(sb); in ext4_remount()
5966 err = ext4_commit_super(sb); in ext4_remount()
5976 if (sb_any_quota_suspended(sb)) in ext4_remount()
5977 dquot_resume(sb, -1); in ext4_remount()
5978 else if (ext4_has_feature_quota(sb)) { in ext4_remount()
5979 err = ext4_enable_quotas(sb); in ext4_remount()
5985 if (!test_opt(sb, BLOCK_VALIDITY) && sbi->s_system_blks) in ext4_remount()
5986 ext4_release_system_zone(sb); in ext4_remount()
5988 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) in ext4_remount()
5996 *flags = (*flags & ~vfs_flags) | (sb->s_flags & vfs_flags); in ext4_remount()
5998 ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s. Quota mode: %s.", in ext4_remount()
5999 orig_data, ext4_quota_mode(sb)); in ext4_remount()
6004 sb->s_flags = old_sb_flags; in ext4_remount()
6012 if (!test_opt(sb, BLOCK_VALIDITY) && sbi->s_system_blks) in ext4_remount()
6013 ext4_release_system_zone(sb); in ext4_remount()
6017 to_free[i] = get_qf_name(sb, sbi, i); in ext4_remount()
6024 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) in ext4_remount()
6031 static int ext4_statfs_project(struct super_block *sb, in ext4_statfs_project() argument
6040 dquot = dqget(sb, qid); in ext4_statfs_project()
6047 limit >>= sb->s_blocksize_bits; in ext4_statfs_project()
6051 dquot->dq_dqb.dqb_rsvspace) >> sb->s_blocksize_bits; in ext4_statfs_project()
6075 struct super_block *sb = dentry->d_sb; in ext4_statfs() local
6076 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_statfs()
6082 if (!test_opt(sb, MINIX_DF)) in ext4_statfs()
6086 buf->f_bsize = sb->s_blocksize; in ext4_statfs()
6103 sb_has_quota_limits_enabled(sb, PRJQUOTA)) in ext4_statfs()
6104 ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf); in ext4_statfs()
6176 struct super_block *sb = dquot->dq_sb; in ext4_mark_dquot_dirty() local
6178 if (ext4_is_quota_journalled(sb)) { in ext4_mark_dquot_dirty()
6186 static int ext4_write_info(struct super_block *sb, int type) in ext4_write_info() argument
6192 handle = ext4_journal_start(d_inode(sb->s_root), EXT4_HT_QUOTA, 2); in ext4_write_info()
6195 ret = dquot_commit_info(sb, type); in ext4_write_info()
6219 static int ext4_quota_on(struct super_block *sb, int type, int format_id, in ext4_quota_on() argument
6224 if (!test_opt(sb, QUOTA)) in ext4_quota_on()
6228 if (path->dentry->d_sb != sb) in ext4_quota_on()
6236 if (EXT4_SB(sb)->s_qf_names[type]) { in ext4_quota_on()
6238 if (path->dentry->d_parent != sb->s_root) in ext4_quota_on()
6239 ext4_msg(sb, KERN_WARNING, in ext4_quota_on()
6242 sb_dqopt(sb)->flags |= DQUOT_NOLIST_DIRTY; in ext4_quota_on()
6248 sb_dqopt(sb)->flags &= ~DQUOT_NOLIST_DIRTY; in ext4_quota_on()
6255 if (EXT4_SB(sb)->s_journal && in ext4_quota_on()
6261 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); in ext4_quota_on()
6262 err = jbd2_journal_flush(EXT4_SB(sb)->s_journal, 0); in ext4_quota_on()
6263 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); in ext4_quota_on()
6269 err = dquot_quota_on(sb, type, format_id, path); in ext4_quota_on()
6297 static int ext4_quota_enable(struct super_block *sb, int type, int format_id, in ext4_quota_enable() argument
6303 le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), in ext4_quota_enable()
6304 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum), in ext4_quota_enable()
6305 le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum) in ext4_quota_enable()
6308 BUG_ON(!ext4_has_feature_quota(sb)); in ext4_quota_enable()
6313 qf_inode = ext4_iget(sb, qf_inums[type], EXT4_IGET_SPECIAL); in ext4_quota_enable()
6315 ext4_error(sb, "Bad quota inode # %lu", qf_inums[type]); in ext4_quota_enable()
6331 int ext4_enable_quotas(struct super_block *sb) in ext4_enable_quotas() argument
6335 le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), in ext4_enable_quotas()
6336 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum), in ext4_enable_quotas()
6337 le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum) in ext4_enable_quotas()
6340 test_opt(sb, USRQUOTA), in ext4_enable_quotas()
6341 test_opt(sb, GRPQUOTA), in ext4_enable_quotas()
6342 test_opt(sb, PRJQUOTA), in ext4_enable_quotas()
6345 sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE | DQUOT_NOLIST_DIRTY; in ext4_enable_quotas()
6348 err = ext4_quota_enable(sb, type, QFMT_VFS_V1, in ext4_enable_quotas()
6352 ext4_warning(sb, in ext4_enable_quotas()
6357 dquot_quota_off(sb, type); in ext4_enable_quotas()
6366 static int ext4_quota_off(struct super_block *sb, int type) in ext4_quota_off() argument
6368 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_off()
6374 if (test_opt(sb, DELALLOC)) in ext4_quota_off()
6375 sync_filesystem(sb); in ext4_quota_off()
6380 err = dquot_quota_off(sb, type); in ext4_quota_off()
6381 if (err || ext4_has_feature_quota(sb)) in ext4_quota_off()
6407 return dquot_quota_off(sb, type); in ext4_quota_off()
6414 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, in ext4_quota_read() argument
6417 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_read()
6418 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); in ext4_quota_read()
6419 int offset = off & (sb->s_blocksize - 1); in ext4_quota_read()
6431 tocopy = sb->s_blocksize - offset < toread ? in ext4_quota_read()
6432 sb->s_blocksize - offset : toread; in ext4_quota_read()
6451 static ssize_t ext4_quota_write(struct super_block *sb, int type, in ext4_quota_write() argument
6454 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_write()
6455 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); in ext4_quota_write()
6456 int err = 0, err2 = 0, offset = off & (sb->s_blocksize - 1); in ext4_quota_write()
6461 if (EXT4_SB(sb)->s_journal && !handle) { in ext4_quota_write()
6462 ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" in ext4_quota_write()
6471 if (sb->s_blocksize - offset < len) { in ext4_quota_write()
6472 ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" in ext4_quota_write()
6489 err = ext4_journal_get_write_access(handle, sb, bh, EXT4_JTR_NONE); in ext4_quota_write()
6532 static inline int ext2_feature_set_ok(struct super_block *sb) in ext2_feature_set_ok() argument
6534 if (ext4_has_unknown_ext2_incompat_features(sb)) in ext2_feature_set_ok()
6536 if (sb_rdonly(sb)) in ext2_feature_set_ok()
6538 if (ext4_has_unknown_ext2_ro_compat_features(sb)) in ext2_feature_set_ok()
6545 static inline int ext2_feature_set_ok(struct super_block *sb) { return 0; } in ext2_feature_set_ok() argument
6561 static inline int ext3_feature_set_ok(struct super_block *sb) in ext3_feature_set_ok() argument
6563 if (ext4_has_unknown_ext3_incompat_features(sb)) in ext3_feature_set_ok()
6565 if (!ext4_has_feature_journal(sb)) in ext3_feature_set_ok()
6567 if (sb_rdonly(sb)) in ext3_feature_set_ok()
6569 if (ext4_has_unknown_ext3_ro_compat_features(sb)) in ext3_feature_set_ok()