Lines Matching refs:sb

67 static int ext4_commit_super(struct super_block *sb, int sync);
68 static void ext4_mark_recovery_complete(struct super_block *sb,
70 static void ext4_clear_journal_err(struct super_block *sb,
72 static int ext4_sync_fs(struct super_block *sb, int wait);
73 static int ext4_remount(struct super_block *sb, int *flags, char *data);
75 static int ext4_unfreeze(struct super_block *sb);
76 static int ext4_freeze(struct super_block *sb);
79 static inline int ext2_feature_set_ok(struct super_block *sb);
80 static inline int ext3_feature_set_ok(struct super_block *sb);
81 static int ext4_feature_set_ok(struct super_block *sb, int readonly);
83 static void ext4_unregister_li_request(struct super_block *sb);
85 static struct inode *ext4_get_journal_inode(struct super_block *sb,
126 #define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type) argument
128 #define IS_EXT2_SB(sb) (0) argument
141 #define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) argument
143 static int ext4_verify_csum_type(struct super_block *sb, in ext4_verify_csum_type() argument
146 if (!ext4_has_feature_metadata_csum(sb)) in ext4_verify_csum_type()
152 static __le32 ext4_superblock_csum(struct super_block *sb, in ext4_superblock_csum() argument
155 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_superblock_csum()
164 static int ext4_superblock_csum_verify(struct super_block *sb, in ext4_superblock_csum_verify() argument
167 if (!ext4_has_metadata_csum(sb)) in ext4_superblock_csum_verify()
170 return es->s_checksum == ext4_superblock_csum(sb, es); in ext4_superblock_csum_verify()
173 void ext4_superblock_csum_set(struct super_block *sb) in ext4_superblock_csum_set() argument
175 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in ext4_superblock_csum_set()
177 if (!ext4_has_metadata_csum(sb)) in ext4_superblock_csum_set()
180 es->s_checksum = ext4_superblock_csum(sb, es); in ext4_superblock_csum_set()
203 ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, in ext4_block_bitmap() argument
207 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_block_bitmap()
211 ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, in ext4_inode_bitmap() argument
215 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_inode_bitmap()
219 ext4_fsblk_t ext4_inode_table(struct super_block *sb, in ext4_inode_table() argument
223 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_inode_table()
227 __u32 ext4_free_group_clusters(struct super_block *sb, in ext4_free_group_clusters() argument
231 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_free_group_clusters()
235 __u32 ext4_free_inodes_count(struct super_block *sb, in ext4_free_inodes_count() argument
239 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_free_inodes_count()
243 __u32 ext4_used_dirs_count(struct super_block *sb, in ext4_used_dirs_count() argument
247 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_used_dirs_count()
251 __u32 ext4_itable_unused_count(struct super_block *sb, in ext4_itable_unused_count() argument
255 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? in ext4_itable_unused_count()
259 void ext4_block_bitmap_set(struct super_block *sb, in ext4_block_bitmap_set() argument
263 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_block_bitmap_set()
267 void ext4_inode_bitmap_set(struct super_block *sb, in ext4_inode_bitmap_set() argument
271 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_inode_bitmap_set()
275 void ext4_inode_table_set(struct super_block *sb, in ext4_inode_table_set() argument
279 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_inode_table_set()
283 void ext4_free_group_clusters_set(struct super_block *sb, in ext4_free_group_clusters_set() argument
287 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_free_group_clusters_set()
291 void ext4_free_inodes_set(struct super_block *sb, in ext4_free_inodes_set() argument
295 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_free_inodes_set()
299 void ext4_used_dirs_set(struct super_block *sb, in ext4_used_dirs_set() argument
303 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_used_dirs_set()
307 void ext4_itable_unused_set(struct super_block *sb, in ext4_itable_unused_set() argument
311 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) in ext4_itable_unused_set()
334 static void __save_error_info(struct super_block *sb, const char *func, in __save_error_info() argument
337 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in __save_error_info()
339 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; in __save_error_info()
340 if (bdev_read_only(sb->s_bdev)) in __save_error_info()
360 mod_timer(&EXT4_SB(sb)->s_err_report, jiffies + 24*60*60*HZ); in __save_error_info()
364 static void save_error_info(struct super_block *sb, const char *func, in save_error_info() argument
367 __save_error_info(sb, func, line); in save_error_info()
368 ext4_commit_super(sb, 1); in save_error_info()
379 static int block_device_ejected(struct super_block *sb) in block_device_ejected() argument
381 struct inode *bd_inode = sb->s_bdev->bd_inode; in block_device_ejected()
389 struct super_block *sb = journal->j_private; in ext4_journal_commit_callback() local
390 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_journal_commit_callback()
396 ext4_process_freed_data(sb, txn->t_tid); in ext4_journal_commit_callback()
404 jce->jce_func(sb, jce, error); in ext4_journal_commit_callback()
425 static void ext4_handle_error(struct super_block *sb) in ext4_handle_error() argument
427 if (test_opt(sb, WARN_ON_ERROR)) in ext4_handle_error()
430 if (sb_rdonly(sb)) in ext4_handle_error()
433 if (!test_opt(sb, ERRORS_CONT)) { in ext4_handle_error()
434 journal_t *journal = EXT4_SB(sb)->s_journal; in ext4_handle_error()
436 EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; in ext4_handle_error()
440 if (test_opt(sb, ERRORS_RO)) { in ext4_handle_error()
441 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); in ext4_handle_error()
447 sb->s_flags |= SB_RDONLY; in ext4_handle_error()
449 if (test_opt(sb, ERRORS_PANIC)) { in ext4_handle_error()
450 if (EXT4_SB(sb)->s_journal && in ext4_handle_error()
451 !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) in ext4_handle_error()
454 sb->s_id); in ext4_handle_error()
458 #define ext4_error_ratelimit(sb) \ argument
459 ___ratelimit(&(EXT4_SB(sb)->s_err_ratelimit_state), \
462 void __ext4_error(struct super_block *sb, const char *function, in __ext4_error() argument
468 if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) in __ext4_error()
471 trace_ext4_error(sb, function, line); in __ext4_error()
472 if (ext4_error_ratelimit(sb)) { in __ext4_error()
478 sb->s_id, function, line, current->comm, &vaf); in __ext4_error()
481 save_error_info(sb, function, line); in __ext4_error()
482 ext4_handle_error(sb); in __ext4_error()
560 const char *ext4_decode_error(struct super_block *sb, int errno, in ext4_decode_error() argument
579 if (!sb || (EXT4_SB(sb)->s_journal && in ext4_decode_error()
580 EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT)) in ext4_decode_error()
603 void __ext4_std_error(struct super_block *sb, const char *function, in __ext4_std_error() argument
609 if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) in __ext4_std_error()
615 if (errno == -EROFS && journal_current_handle() == NULL && sb_rdonly(sb)) in __ext4_std_error()
618 if (ext4_error_ratelimit(sb)) { in __ext4_std_error()
619 errstr = ext4_decode_error(sb, errno, nbuf); in __ext4_std_error()
621 sb->s_id, function, line, errstr); in __ext4_std_error()
624 save_error_info(sb, function, line); in __ext4_std_error()
625 ext4_handle_error(sb); in __ext4_std_error()
638 void __ext4_abort(struct super_block *sb, const char *function, in __ext4_abort() argument
644 if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) in __ext4_abort()
647 save_error_info(sb, function, line); in __ext4_abort()
652 sb->s_id, function, line, &vaf); in __ext4_abort()
655 if (sb_rdonly(sb) == 0) { in __ext4_abort()
656 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); in __ext4_abort()
657 EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; in __ext4_abort()
663 sb->s_flags |= SB_RDONLY; in __ext4_abort()
664 if (EXT4_SB(sb)->s_journal) in __ext4_abort()
665 jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); in __ext4_abort()
666 save_error_info(sb, function, line); in __ext4_abort()
668 if (test_opt(sb, ERRORS_PANIC)) { in __ext4_abort()
669 if (EXT4_SB(sb)->s_journal && in __ext4_abort()
670 !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) in __ext4_abort()
676 void __ext4_msg(struct super_block *sb, in __ext4_msg() argument
682 if (!___ratelimit(&(EXT4_SB(sb)->s_msg_ratelimit_state), "EXT4-fs")) in __ext4_msg()
688 printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf); in __ext4_msg()
692 #define ext4_warning_ratelimit(sb) \ argument
693 ___ratelimit(&(EXT4_SB(sb)->s_warning_ratelimit_state), \
696 void __ext4_warning(struct super_block *sb, const char *function, in __ext4_warning() argument
702 if (!ext4_warning_ratelimit(sb)) in __ext4_warning()
709 sb->s_id, function, line, &vaf); in __ext4_warning()
732 struct super_block *sb, ext4_group_t grp, in __ext4_grp_locked_error() argument
740 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in __ext4_grp_locked_error()
742 if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) in __ext4_grp_locked_error()
745 trace_ext4_error(sb, function, line); in __ext4_grp_locked_error()
748 __save_error_info(sb, function, line); in __ext4_grp_locked_error()
750 if (ext4_error_ratelimit(sb)) { in __ext4_grp_locked_error()
755 sb->s_id, function, line, grp); in __ext4_grp_locked_error()
765 if (test_opt(sb, WARN_ON_ERROR)) in __ext4_grp_locked_error()
768 if (test_opt(sb, ERRORS_CONT)) { in __ext4_grp_locked_error()
769 ext4_commit_super(sb, 0); in __ext4_grp_locked_error()
773 ext4_unlock_group(sb, grp); in __ext4_grp_locked_error()
774 ext4_commit_super(sb, 1); in __ext4_grp_locked_error()
775 ext4_handle_error(sb); in __ext4_grp_locked_error()
787 ext4_lock_group(sb, grp); in __ext4_grp_locked_error()
791 void ext4_mark_group_bitmap_corrupted(struct super_block *sb, in ext4_mark_group_bitmap_corrupted() argument
795 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_mark_group_bitmap_corrupted()
796 struct ext4_group_info *grp = ext4_get_group_info(sb, group); in ext4_mark_group_bitmap_corrupted()
797 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL); in ext4_mark_group_bitmap_corrupted()
814 count = ext4_free_inodes_count(sb, gdp); in ext4_mark_group_bitmap_corrupted()
821 void ext4_update_dynamic_rev(struct super_block *sb) in ext4_update_dynamic_rev() argument
823 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in ext4_update_dynamic_rev()
828 ext4_warning(sb, in ext4_update_dynamic_rev()
849 static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb) in ext4_blkdev_get() argument
854 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); in ext4_blkdev_get()
860 ext4_msg(sb, KERN_ERR, "failed to open journal device %s: %ld", in ext4_blkdev_get()
888 static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi) in dump_orphan_list() argument
892 ext4_msg(sb, KERN_ERR, "sb orphan head is %d", in dump_orphan_list()
907 static int ext4_quota_off(struct super_block *sb, int type);
909 static inline void ext4_quota_off_umount(struct super_block *sb) in ext4_quota_off_umount() argument
915 ext4_quota_off(sb, type); in ext4_quota_off_umount()
918 static inline void ext4_quota_off_umount(struct super_block *sb) in ext4_quota_off_umount() argument
923 static void ext4_put_super(struct super_block *sb) in ext4_put_super() argument
925 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_put_super()
930 ext4_unregister_li_request(sb); in ext4_put_super()
931 ext4_quota_off_umount(sb); in ext4_put_super()
940 ext4_abort(sb, "Couldn't clean up the journal"); in ext4_put_super()
943 ext4_unregister_sysfs(sb); in ext4_put_super()
946 ext4_release_system_zone(sb); in ext4_put_super()
947 ext4_mb_release(sb); in ext4_put_super()
948 ext4_ext_release(sb); in ext4_put_super()
950 if (!sb_rdonly(sb) && !aborted) { in ext4_put_super()
951 ext4_clear_feature_journal_needs_recovery(sb); in ext4_put_super()
954 if (!sb_rdonly(sb)) in ext4_put_super()
955 ext4_commit_super(sb, 1); in ext4_put_super()
976 dump_orphan_list(sb, sbi); in ext4_put_super()
979 sync_blockdev(sb->s_bdev); in ext4_put_super()
980 invalidate_bdev(sb->s_bdev); in ext4_put_super()
981 if (sbi->journal_bdev && sbi->journal_bdev != sb->s_bdev) { in ext4_put_super()
1002 sb->s_fs_info = NULL; in ext4_put_super()
1021 static struct inode *ext4_alloc_inode(struct super_block *sb) in ext4_alloc_inode() argument
1136 static struct inode *ext4_nfs_get_inode(struct super_block *sb, in ext4_nfs_get_inode() argument
1141 if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) in ext4_nfs_get_inode()
1143 if (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count)) in ext4_nfs_get_inode()
1154 inode = ext4_iget_normal(sb, ino); in ext4_nfs_get_inode()
1165 static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, in ext4_fh_to_dentry() argument
1168 return generic_fh_to_dentry(sb, fid, fh_len, fh_type, in ext4_fh_to_dentry()
1172 static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, in ext4_fh_to_parent() argument
1175 return generic_fh_to_parent(sb, fid, fh_len, fh_type, in ext4_fh_to_parent()
1185 static int bdev_try_to_free_page(struct super_block *sb, struct page *page, in bdev_try_to_free_page() argument
1188 journal_t *journal = EXT4_SB(sb)->s_journal; in bdev_try_to_free_page()
1313 static int ext4_write_info(struct super_block *sb, int type);
1314 static int ext4_quota_on(struct super_block *sb, int type, int format_id,
1316 static int ext4_quota_on_mount(struct super_block *sb, int type);
1317 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
1319 static ssize_t ext4_quota_write(struct super_block *sb, int type,
1321 static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
1323 static int ext4_enable_quotas(struct super_block *sb);
1324 static int ext4_get_next_id(struct super_block *sb, struct kqid *qid);
1530 static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) in set_qf_name() argument
1532 struct ext4_sb_info *sbi = EXT4_SB(sb); in set_qf_name()
1536 if (sb_any_quota_loaded(sb) && in set_qf_name()
1538 ext4_msg(sb, KERN_ERR, in set_qf_name()
1543 if (ext4_has_feature_quota(sb)) { in set_qf_name()
1544 ext4_msg(sb, KERN_INFO, "Journaled quota options " in set_qf_name()
1550 ext4_msg(sb, KERN_ERR, in set_qf_name()
1558 ext4_msg(sb, KERN_ERR, in set_qf_name()
1564 ext4_msg(sb, KERN_ERR, in set_qf_name()
1569 set_opt(sb, QUOTA); in set_qf_name()
1576 static int clear_qf_name(struct super_block *sb, int qtype) in clear_qf_name() argument
1579 struct ext4_sb_info *sbi = EXT4_SB(sb); in clear_qf_name()
1581 if (sb_any_quota_loaded(sb) && in clear_qf_name()
1583 ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options" in clear_qf_name()
1706 static int handle_mount_opt(struct super_block *sb, char *opt, int token, in handle_mount_opt() argument
1710 struct ext4_sb_info *sbi = EXT4_SB(sb); in handle_mount_opt()
1718 return set_qf_name(sb, USRQUOTA, &args[0]); in handle_mount_opt()
1720 return set_qf_name(sb, GRPQUOTA, &args[0]); in handle_mount_opt()
1722 return clear_qf_name(sb, USRQUOTA); in handle_mount_opt()
1724 return clear_qf_name(sb, GRPQUOTA); in handle_mount_opt()
1729 ext4_msg(sb, KERN_WARNING, deprecated_msg, opt, "3.5"); in handle_mount_opt()
1734 ext4_msg(sb, KERN_WARNING, "Ignoring removed %s option", opt); in handle_mount_opt()
1740 sb->s_flags |= SB_I_VERSION; in handle_mount_opt()
1743 sb->s_flags |= SB_LAZYTIME; in handle_mount_opt()
1746 sb->s_flags &= ~SB_LAZYTIME; in handle_mount_opt()
1755 ext4_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" " in handle_mount_opt()
1760 if ((m->flags & MOPT_NO_EXT2) && IS_EXT2_SB(sb)) { in handle_mount_opt()
1761 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
1765 if ((m->flags & MOPT_NO_EXT3) && IS_EXT3_SB(sb)) { in handle_mount_opt()
1766 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
1777 set_opt2(sb, EXPLICIT_DELALLOC); in handle_mount_opt()
1779 set_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM); in handle_mount_opt()
1784 clear_opt(sb, ERRORS_MASK); in handle_mount_opt()
1785 if (token == Opt_noquota && sb_any_quota_loaded(sb)) { in handle_mount_opt()
1786 ext4_msg(sb, KERN_ERR, "Cannot change quota " in handle_mount_opt()
1792 ext4_msg(sb, KERN_ERR, "%s option not supported", opt); in handle_mount_opt()
1805 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
1812 set_opt(sb, INIT_INODE_TABLE); in handle_mount_opt()
1823 ext4_msg(sb, KERN_ERR, "Invalid uid value %d", arg); in handle_mount_opt()
1830 ext4_msg(sb, KERN_ERR, "Invalid gid value %d", arg); in handle_mount_opt()
1836 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
1848 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
1854 ext4_msg(sb, KERN_ERR, "error: could not dup " in handle_mount_opt()
1861 ext4_msg(sb, KERN_ERR, "error: could not find " in handle_mount_opt()
1869 ext4_msg(sb, KERN_ERR, "error: journal path %s " in handle_mount_opt()
1881 ext4_msg(sb, KERN_ERR, "Invalid journal IO priority" in handle_mount_opt()
1890 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
1893 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
1899 …ext4_msg(sb, KERN_WARNING, "Remounting file system with no journal so ignoring journalled data opt… in handle_mount_opt()
1900 else if (test_opt(sb, DATA_FLAGS) != m->mount_opt) { in handle_mount_opt()
1901 ext4_msg(sb, KERN_ERR, in handle_mount_opt()
1906 clear_opt(sb, DATA_FLAGS); in handle_mount_opt()
1911 if (sb_any_quota_loaded(sb) && in handle_mount_opt()
1913 ext4_msg(sb, KERN_ERR, "Cannot change journaled " in handle_mount_opt()
1917 if (ext4_has_feature_quota(sb)) { in handle_mount_opt()
1918 ext4_msg(sb, KERN_INFO, in handle_mount_opt()
1927 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
1931 ext4_msg(sb, KERN_INFO, "dax option not supported"); in handle_mount_opt()
1944 ext4_msg(sb, KERN_WARNING, in handle_mount_opt()
1957 static int parse_options(char *options, struct super_block *sb, in parse_options() argument
1962 struct ext4_sb_info *sbi = EXT4_SB(sb); in parse_options()
1979 if (handle_mount_opt(sb, p, token, args, journal_devnum, in parse_options()
1989 if (test_opt(sb, PRJQUOTA) && !ext4_has_feature_project(sb)) { in parse_options()
1990 ext4_msg(sb, KERN_ERR, "Project quota feature not enabled. " in parse_options()
1995 if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) in parse_options()
1996 clear_opt(sb, USRQUOTA); in parse_options()
1998 if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) in parse_options()
1999 clear_opt(sb, GRPQUOTA); in parse_options()
2001 if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { in parse_options()
2002 ext4_msg(sb, KERN_ERR, "old and new quota " in parse_options()
2008 ext4_msg(sb, KERN_ERR, "journaled quota format " in parse_options()
2014 if (test_opt(sb, DIOREAD_NOLOCK)) { in parse_options()
2019 ext4_msg(sb, KERN_ERR, "can't mount with " in parse_options()
2028 struct super_block *sb) in ext4_show_quota_options() argument
2031 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_show_quota_options()
2073 static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, in _ext4_show_options() argument
2076 struct ext4_sb_info *sbi = EXT4_SB(sb); in _ext4_show_options()
2111 if (test_opt(sb, ERRORS_RO) && def_errors != EXT4_ERRORS_RO) in _ext4_show_options()
2113 if (test_opt(sb, ERRORS_CONT) && def_errors != EXT4_ERRORS_CONTINUE) in _ext4_show_options()
2115 if (test_opt(sb, ERRORS_PANIC) && def_errors != EXT4_ERRORS_PANIC) in _ext4_show_options()
2123 if (sb->s_flags & SB_I_VERSION) in _ext4_show_options()
2129 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) in _ext4_show_options()
2131 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) in _ext4_show_options()
2133 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA) in _ext4_show_options()
2141 if (test_opt(sb, INIT_INODE_TABLE) && (nodefs || in _ext4_show_options()
2146 if (test_opt(sb, DATA_ERR_ABORT)) in _ext4_show_options()
2151 ext4_show_quota_options(seq, sb); in _ext4_show_options()
2162 struct super_block *sb = seq->private; in ext4_seq_options_show() local
2165 seq_puts(seq, sb_rdonly(sb) ? "ro" : "rw"); in ext4_seq_options_show()
2166 rc = _ext4_show_options(seq, sb, 1); in ext4_seq_options_show()
2171 static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, in ext4_setup_super() argument
2174 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_setup_super()
2178 ext4_msg(sb, KERN_ERR, "revision level too high, " in ext4_setup_super()
2185 ext4_msg(sb, KERN_WARNING, "warning: mounting unchecked fs, " in ext4_setup_super()
2188 ext4_msg(sb, KERN_WARNING, in ext4_setup_super()
2194 ext4_msg(sb, KERN_WARNING, in ext4_setup_super()
2200 ext4_msg(sb, KERN_WARNING, in ext4_setup_super()
2209 ext4_update_dynamic_rev(sb); in ext4_setup_super()
2211 ext4_set_feature_journal_needs_recovery(sb); in ext4_setup_super()
2213 err = ext4_commit_super(sb, 1); in ext4_setup_super()
2215 if (test_opt(sb, DEBUG)) in ext4_setup_super()
2218 sb->s_blocksize, in ext4_setup_super()
2220 EXT4_BLOCKS_PER_GROUP(sb), in ext4_setup_super()
2221 EXT4_INODES_PER_GROUP(sb), in ext4_setup_super()
2224 cleancache_init_fs(sb); in ext4_setup_super()
2228 int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup) in ext4_alloc_flex_bg_array() argument
2230 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_alloc_flex_bg_array()
2244 ext4_msg(sb, KERN_ERR, "not enough memory for %d flex groups", in ext4_alloc_flex_bg_array()
2260 static int ext4_fill_flex_info(struct super_block *sb) in ext4_fill_flex_info() argument
2262 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_fill_flex_info()
2273 err = ext4_alloc_flex_bg_array(sb, sbi->s_groups_count); in ext4_fill_flex_info()
2278 gdp = ext4_get_group_desc(sb, i, NULL); in ext4_fill_flex_info()
2281 atomic_add(ext4_free_inodes_count(sb, gdp), in ext4_fill_flex_info()
2283 atomic64_add(ext4_free_group_clusters(sb, gdp), in ext4_fill_flex_info()
2285 atomic_add(ext4_used_dirs_count(sb, gdp), in ext4_fill_flex_info()
2294 static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum() argument
2300 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_group_desc_csum()
2322 if (!ext4_has_feature_gdt_csum(sb)) in ext4_group_desc_csum()
2330 if (ext4_has_feature_64bit(sb) && in ext4_group_desc_csum()
2340 int ext4_group_desc_csum_verify(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum_verify() argument
2343 if (ext4_has_group_desc_csum(sb) && in ext4_group_desc_csum_verify()
2344 (gdp->bg_checksum != ext4_group_desc_csum(sb, block_group, gdp))) in ext4_group_desc_csum_verify()
2350 void ext4_group_desc_csum_set(struct super_block *sb, __u32 block_group, in ext4_group_desc_csum_set() argument
2353 if (!ext4_has_group_desc_csum(sb)) in ext4_group_desc_csum_set()
2355 gdp->bg_checksum = ext4_group_desc_csum(sb, block_group, gdp); in ext4_group_desc_csum_set()
2359 static int ext4_check_descriptors(struct super_block *sb, in ext4_check_descriptors() argument
2363 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_check_descriptors()
2366 ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0); in ext4_check_descriptors()
2373 if (ext4_has_feature_flex_bg(sb)) in ext4_check_descriptors()
2379 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, NULL); in ext4_check_descriptors()
2385 (EXT4_BLOCKS_PER_GROUP(sb) - 1); in ext4_check_descriptors()
2391 block_bitmap = ext4_block_bitmap(sb, gdp); in ext4_check_descriptors()
2393 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2396 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2401 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2404 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2408 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2413 inode_bitmap = ext4_inode_bitmap(sb, gdp); in ext4_check_descriptors()
2415 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2418 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2423 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2426 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2430 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2435 inode_table = ext4_inode_table(sb, gdp); in ext4_check_descriptors()
2437 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2440 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2445 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2448 if (!sb_rdonly(sb)) in ext4_check_descriptors()
2453 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2458 ext4_lock_group(sb, i); in ext4_check_descriptors()
2459 if (!ext4_group_desc_csum_verify(sb, i, gdp)) { in ext4_check_descriptors()
2460 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " in ext4_check_descriptors()
2462 i, le16_to_cpu(ext4_group_desc_csum(sb, i, in ext4_check_descriptors()
2464 if (!sb_rdonly(sb)) { in ext4_check_descriptors()
2465 ext4_unlock_group(sb, i); in ext4_check_descriptors()
2469 ext4_unlock_group(sb, i); in ext4_check_descriptors()
2471 first_block += EXT4_BLOCKS_PER_GROUP(sb); in ext4_check_descriptors()
2495 static void ext4_orphan_cleanup(struct super_block *sb, in ext4_orphan_cleanup() argument
2498 unsigned int s_flags = sb->s_flags; in ext4_orphan_cleanup()
2509 if (bdev_read_only(sb->s_bdev)) { in ext4_orphan_cleanup()
2510 ext4_msg(sb, KERN_ERR, "write access " in ext4_orphan_cleanup()
2516 if (!ext4_feature_set_ok(sb, 0)) { in ext4_orphan_cleanup()
2517 ext4_msg(sb, KERN_INFO, "Skipping orphan cleanup due to " in ext4_orphan_cleanup()
2522 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) { in ext4_orphan_cleanup()
2525 ext4_msg(sb, KERN_INFO, "Errors on filesystem, " in ext4_orphan_cleanup()
2534 ext4_msg(sb, KERN_INFO, "orphan cleanup on readonly fs"); in ext4_orphan_cleanup()
2535 sb->s_flags &= ~SB_RDONLY; in ext4_orphan_cleanup()
2539 sb->s_flags |= SB_ACTIVE; in ext4_orphan_cleanup()
2545 if (ext4_has_feature_quota(sb) && (s_flags & SB_RDONLY)) { in ext4_orphan_cleanup()
2546 int ret = ext4_enable_quotas(sb); in ext4_orphan_cleanup()
2551 ext4_msg(sb, KERN_ERR, in ext4_orphan_cleanup()
2557 if (EXT4_SB(sb)->s_qf_names[i]) { in ext4_orphan_cleanup()
2558 int ret = ext4_quota_on_mount(sb, i); in ext4_orphan_cleanup()
2563 ext4_msg(sb, KERN_ERR, in ext4_orphan_cleanup()
2577 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) { in ext4_orphan_cleanup()
2583 inode = ext4_orphan_get(sb, le32_to_cpu(es->s_last_orphan)); in ext4_orphan_cleanup()
2589 list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); in ext4_orphan_cleanup()
2592 if (test_opt(sb, DEBUG)) in ext4_orphan_cleanup()
2593 ext4_msg(sb, KERN_DEBUG, in ext4_orphan_cleanup()
2606 if (test_opt(sb, DEBUG)) in ext4_orphan_cleanup()
2607 ext4_msg(sb, KERN_DEBUG, in ext4_orphan_cleanup()
2620 ext4_msg(sb, KERN_INFO, "%d orphan inode%s deleted", in ext4_orphan_cleanup()
2623 ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up", in ext4_orphan_cleanup()
2629 if (sb_dqopt(sb)->files[i]) in ext4_orphan_cleanup()
2630 dquot_quota_off(sb, i); in ext4_orphan_cleanup()
2634 sb->s_flags = s_flags; /* Restore SB_RDONLY status */ in ext4_orphan_cleanup()
2749 static ext4_fsblk_t descriptor_loc(struct super_block *sb, in descriptor_loc() argument
2752 struct ext4_sb_info *sbi = EXT4_SB(sb); in descriptor_loc()
2758 if (!ext4_has_feature_meta_bg(sb) || nr < first_meta_bg) in descriptor_loc()
2761 if (ext4_bg_has_super(sb, bg)) in descriptor_loc()
2770 if (sb->s_blocksize == 1024 && nr == 0 && in descriptor_loc()
2774 return (has_super + ext4_group_first_block_no(sb, bg)); in descriptor_loc()
2820 static int ext4_feature_set_ok(struct super_block *sb, int readonly) in ext4_feature_set_ok() argument
2822 if (ext4_has_unknown_ext4_incompat_features(sb)) { in ext4_feature_set_ok()
2823 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
2826 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & in ext4_feature_set_ok()
2834 if (ext4_has_feature_readonly(sb)) { in ext4_feature_set_ok()
2835 ext4_msg(sb, KERN_INFO, "filesystem is read-only"); in ext4_feature_set_ok()
2836 sb->s_flags |= SB_RDONLY; in ext4_feature_set_ok()
2841 if (ext4_has_unknown_ext4_ro_compat_features(sb)) { in ext4_feature_set_ok()
2842 ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of " in ext4_feature_set_ok()
2844 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & in ext4_feature_set_ok()
2852 if (ext4_has_feature_huge_file(sb)) { in ext4_feature_set_ok()
2854 ext4_msg(sb, KERN_ERR, "Filesystem with huge files " in ext4_feature_set_ok()
2860 if (ext4_has_feature_bigalloc(sb) && !ext4_has_feature_extents(sb)) { in ext4_feature_set_ok()
2861 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
2868 if (ext4_has_feature_quota(sb) && !readonly) { in ext4_feature_set_ok()
2869 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
2874 if (ext4_has_feature_project(sb) && !readonly) { in ext4_feature_set_ok()
2875 ext4_msg(sb, KERN_ERR, in ext4_feature_set_ok()
2891 struct super_block *sb = sbi->s_sb; in print_daily_error_info() local
2896 ext4_msg(sb, KERN_NOTICE, "error count since last fsck: %u", in print_daily_error_info()
2900 sb->s_id, in print_daily_error_info()
2915 sb->s_id, in print_daily_error_info()
2936 struct super_block *sb; in ext4_run_li_request() local
2940 sb = elr->lr_super; in ext4_run_li_request()
2941 ngroups = EXT4_SB(sb)->s_groups_count; in ext4_run_li_request()
2944 gdp = ext4_get_group_desc(sb, group, NULL); in ext4_run_li_request()
2959 ret = ext4_init_inode_table(sb, group, in ext4_run_li_request()
2990 static void ext4_unregister_li_request(struct super_block *sb) in ext4_unregister_li_request() argument
2999 ext4_remove_li_request(EXT4_SB(sb)->s_li_request); in ext4_unregister_li_request()
3154 static ext4_group_t ext4_has_uninit_itable(struct super_block *sb) in ext4_has_uninit_itable() argument
3156 ext4_group_t group, ngroups = EXT4_SB(sb)->s_groups_count; in ext4_has_uninit_itable()
3159 if (!ext4_has_group_desc_csum(sb)) in ext4_has_uninit_itable()
3163 gdp = ext4_get_group_desc(sb, group, NULL); in ext4_has_uninit_itable()
3192 static struct ext4_li_request *ext4_li_request_new(struct super_block *sb, in ext4_li_request_new() argument
3195 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_li_request_new()
3202 elr->lr_super = sb; in ext4_li_request_new()
3216 int ext4_register_li_request(struct super_block *sb, in ext4_register_li_request() argument
3219 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_register_li_request()
3234 if (first_not_zeroed == ngroups || sb_rdonly(sb) || in ext4_register_li_request()
3235 !test_opt(sb, INIT_INODE_TABLE)) in ext4_register_li_request()
3238 elr = ext4_li_request_new(sb, first_not_zeroed); in ext4_register_li_request()
3290 static int set_journal_csum_feature_set(struct super_block *sb) in set_journal_csum_feature_set() argument
3294 struct ext4_sb_info *sbi = EXT4_SB(sb); in set_journal_csum_feature_set()
3296 if (ext4_has_metadata_csum(sb)) { in set_journal_csum_feature_set()
3310 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in set_journal_csum_feature_set()
3315 } else if (test_opt(sb, JOURNAL_CHECKSUM)) { in set_journal_csum_feature_set()
3344 static int count_overhead(struct super_block *sb, ext4_group_t grp, in count_overhead() argument
3347 struct ext4_sb_info *sbi = EXT4_SB(sb); in count_overhead()
3350 ext4_group_t i, ngroups = ext4_get_groups_count(sb); in count_overhead()
3353 if (!ext4_has_feature_bigalloc(sb)) in count_overhead()
3354 return (ext4_bg_has_super(sb, grp) + ext4_bg_num_gdb(sb, grp) + in count_overhead()
3358 (grp * EXT4_BLOCKS_PER_GROUP(sb)); in count_overhead()
3359 last_block = first_block + EXT4_BLOCKS_PER_GROUP(sb) - 1; in count_overhead()
3361 gdp = ext4_get_group_desc(sb, i, NULL); in count_overhead()
3362 b = ext4_block_bitmap(sb, gdp); in count_overhead()
3367 b = ext4_inode_bitmap(sb, gdp); in count_overhead()
3372 b = ext4_inode_table(sb, gdp); in count_overhead()
3382 if (ext4_bg_has_super(sb, grp)) { in count_overhead()
3386 j = ext4_bg_num_gdb(sb, grp); in count_overhead()
3387 if (s + j > EXT4_BLOCKS_PER_GROUP(sb)) { in count_overhead()
3388 ext4_error(sb, "Invalid number of block group " in count_overhead()
3390 j = EXT4_BLOCKS_PER_GROUP(sb) - s; in count_overhead()
3398 return EXT4_CLUSTERS_PER_GROUP(sb) - in count_overhead()
3399 ext4_count_free(buf, EXT4_CLUSTERS_PER_GROUP(sb) / 8); in count_overhead()
3405 int ext4_calculate_overhead(struct super_block *sb) in ext4_calculate_overhead() argument
3407 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_calculate_overhead()
3411 ext4_group_t i, ngroups = ext4_get_groups_count(sb); in ext4_calculate_overhead()
3435 blks = count_overhead(sb, i, buf); in ext4_calculate_overhead()
3448 else if (ext4_has_feature_journal(sb) && !sbi->s_journal) { in ext4_calculate_overhead()
3449 j_inode = ext4_get_journal_inode(sb, j_inum); in ext4_calculate_overhead()
3451 j_blocks = j_inode->i_size >> sb->s_blocksize_bits; in ext4_calculate_overhead()
3455 ext4_msg(sb, KERN_ERR, "can't get journal size"); in ext4_calculate_overhead()
3464 static void ext4_set_resv_clusters(struct super_block *sb) in ext4_set_resv_clusters() argument
3467 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_set_resv_clusters()
3475 if (!ext4_has_feature_extents(sb)) in ext4_set_resv_clusters()
3494 static int ext4_fill_super(struct super_block *sb, void *data, int silent) in ext4_fill_super() argument
3496 struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev); in ext4_fill_super()
3528 sb->s_fs_info = sbi; in ext4_fill_super()
3529 sbi->s_sb = sb; in ext4_fill_super()
3532 if (sb->s_bdev->bd_part) in ext4_fill_super()
3534 part_stat_read(sb->s_bdev->bd_part, sectors[STAT_WRITE]); in ext4_fill_super()
3537 strreplace(sb->s_id, '/', '!'); in ext4_fill_super()
3541 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); in ext4_fill_super()
3543 ext4_msg(sb, KERN_ERR, "unable to set blocksize"); in ext4_fill_super()
3558 if (!(bh = sb_bread_unmovable(sb, logical_sb_block))) { in ext4_fill_super()
3559 ext4_msg(sb, KERN_ERR, "unable to read superblock"); in ext4_fill_super()
3568 sb->s_magic = le16_to_cpu(es->s_magic); in ext4_fill_super()
3569 if (sb->s_magic != EXT4_SUPER_MAGIC) in ext4_fill_super()
3574 if (ext4_has_feature_metadata_csum(sb) && in ext4_fill_super()
3575 ext4_has_feature_gdt_csum(sb)) in ext4_fill_super()
3576 ext4_warning(sb, "metadata_csum and uninit_bg are " in ext4_fill_super()
3580 if (!ext4_verify_csum_type(sb, es)) { in ext4_fill_super()
3581 ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " in ext4_fill_super()
3590 ext4_msg(sb, KERN_ERR, "Cannot load crc32c driver."); in ext4_fill_super()
3597 if (!ext4_superblock_csum_verify(sb, es)) { in ext4_fill_super()
3598 ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " in ext4_fill_super()
3606 if (ext4_has_feature_csum_seed(sb)) in ext4_fill_super()
3608 else if (ext4_has_metadata_csum(sb) || ext4_has_feature_ea_inode(sb)) in ext4_fill_super()
3614 set_opt(sb, INIT_INODE_TABLE); in ext4_fill_super()
3616 set_opt(sb, DEBUG); in ext4_fill_super()
3618 set_opt(sb, GRPID); in ext4_fill_super()
3620 set_opt(sb, NO_UID32); in ext4_fill_super()
3622 set_opt(sb, XATTR_USER); in ext4_fill_super()
3624 set_opt(sb, POSIX_ACL); in ext4_fill_super()
3627 if (ext4_has_metadata_csum(sb)) in ext4_fill_super()
3628 set_opt(sb, JOURNAL_CHECKSUM); in ext4_fill_super()
3631 set_opt(sb, JOURNAL_DATA); in ext4_fill_super()
3633 set_opt(sb, ORDERED_DATA); in ext4_fill_super()
3635 set_opt(sb, WRITEBACK_DATA); in ext4_fill_super()
3638 set_opt(sb, ERRORS_PANIC); in ext4_fill_super()
3640 set_opt(sb, ERRORS_CONT); in ext4_fill_super()
3642 set_opt(sb, ERRORS_RO); in ext4_fill_super()
3644 set_opt(sb, BLOCK_VALIDITY); in ext4_fill_super()
3646 set_opt(sb, DISCARD); in ext4_fill_super()
3655 set_opt(sb, BARRIER); in ext4_fill_super()
3661 if (!IS_EXT3_SB(sb) && !IS_EXT2_SB(sb) && in ext4_fill_super()
3663 set_opt(sb, DELALLOC); in ext4_fill_super()
3677 if (!parse_options(s_mount_opts, sb, &journal_devnum, in ext4_fill_super()
3679 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
3686 if (!parse_options((char *) data, sb, &journal_devnum, in ext4_fill_super()
3690 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { in ext4_fill_super()
3694 if (test_opt2(sb, EXPLICIT_DELALLOC)) { in ext4_fill_super()
3695 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
3699 if (test_opt(sb, DIOREAD_NOLOCK)) { in ext4_fill_super()
3700 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
3704 if (test_opt(sb, DAX)) { in ext4_fill_super()
3705 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
3709 if (ext4_has_feature_encrypt(sb)) { in ext4_fill_super()
3710 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
3714 if (test_opt(sb, DELALLOC)) in ext4_fill_super()
3715 clear_opt(sb, DELALLOC); in ext4_fill_super()
3717 sb->s_iflags |= SB_I_CGROUPWB; in ext4_fill_super()
3720 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext4_fill_super()
3721 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); in ext4_fill_super()
3724 (ext4_has_compat_features(sb) || in ext4_fill_super()
3725 ext4_has_ro_compat_features(sb) || in ext4_fill_super()
3726 ext4_has_incompat_features(sb))) in ext4_fill_super()
3727 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
3732 set_opt2(sb, HURD_COMPAT); in ext4_fill_super()
3733 if (ext4_has_feature_64bit(sb)) { in ext4_fill_super()
3734 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3743 if (ext4_has_feature_ea_inode(sb)) { in ext4_fill_super()
3744 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3750 if (IS_EXT2_SB(sb)) { in ext4_fill_super()
3751 if (ext2_feature_set_ok(sb)) in ext4_fill_super()
3752 ext4_msg(sb, KERN_INFO, "mounting ext2 file system " in ext4_fill_super()
3759 if (silent && ext4_feature_set_ok(sb, sb_rdonly(sb))) in ext4_fill_super()
3761 ext4_msg(sb, KERN_ERR, "couldn't mount as ext2 due " in ext4_fill_super()
3767 if (IS_EXT3_SB(sb)) { in ext4_fill_super()
3768 if (ext3_feature_set_ok(sb)) in ext4_fill_super()
3769 ext4_msg(sb, KERN_INFO, "mounting ext3 file system " in ext4_fill_super()
3776 if (silent && ext4_feature_set_ok(sb, sb_rdonly(sb))) in ext4_fill_super()
3778 ext4_msg(sb, KERN_ERR, "couldn't mount as ext3 due " in ext4_fill_super()
3789 if (!ext4_feature_set_ok(sb, (sb_rdonly(sb)))) in ext4_fill_super()
3795 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3802 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3809 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3816 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3823 if (ext4_has_feature_inline_data(sb)) { in ext4_fill_super()
3824 ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" in ext4_fill_super()
3828 if (!bdev_dax_supported(sb->s_bdev, blocksize)) { in ext4_fill_super()
3829 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3835 if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) { in ext4_fill_super()
3836 ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d", in ext4_fill_super()
3841 if (sb->s_blocksize != blocksize) { in ext4_fill_super()
3843 if (!sb_set_blocksize(sb, blocksize)) { in ext4_fill_super()
3844 ext4_msg(sb, KERN_ERR, "bad block size %d", in ext4_fill_super()
3852 bh = sb_bread_unmovable(sb, logical_sb_block); in ext4_fill_super()
3854 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3861 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3867 has_huge_files = ext4_has_feature_huge_file(sb); in ext4_fill_super()
3868 sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits, in ext4_fill_super()
3870 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files); in ext4_fill_super()
3879 ext4_msg(sb, KERN_ERR, "invalid first ino: %u", in ext4_fill_super()
3886 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3892 sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2); in ext4_fill_super()
3896 if (ext4_has_feature_64bit(sb)) { in ext4_fill_super()
3900 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3911 sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); in ext4_fill_super()
3916 ext4_msg(sb, KERN_ERR, "invalid inodes per group: %lu\n", in ext4_fill_super()
3922 sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb); in ext4_fill_super()
3925 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); in ext4_fill_super()
3926 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); in ext4_fill_super()
3931 if (ext4_has_feature_dir_index(sb)) { in ext4_fill_super()
3937 if (!sb_rdonly(sb)) in ext4_fill_super()
3942 if (!sb_rdonly(sb)) in ext4_fill_super()
3951 has_bigalloc = ext4_has_feature_bigalloc(sb); in ext4_fill_super()
3954 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3964 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3971 ext4_msg(sb, KERN_ERR, "blocks per group (%lu) and " in ext4_fill_super()
3979 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3985 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
3997 set_opt2(sb, STD_GROUP_SIZE); in ext4_fill_super()
4003 err = generic_check_addressable(sb->s_blocksize_bits, in ext4_fill_super()
4006 ext4_msg(sb, KERN_ERR, "filesystem" in ext4_fill_super()
4009 ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); in ext4_fill_super()
4013 if (EXT4_BLOCKS_PER_GROUP(sb) == 0) in ext4_fill_super()
4017 blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; in ext4_fill_super()
4019 ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu " in ext4_fill_super()
4030 ext4_msg(sb, KERN_WARNING, "bad geometry: first data " in ext4_fill_super()
4038 ext4_msg(sb, KERN_WARNING, "bad geometry: first data " in ext4_fill_super()
4045 EXT4_BLOCKS_PER_GROUP(sb) - 1); in ext4_fill_super()
4046 do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); in ext4_fill_super()
4047 if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) { in ext4_fill_super()
4048 ext4_msg(sb, KERN_WARNING, "groups count too large: %u " in ext4_fill_super()
4053 EXT4_BLOCKS_PER_GROUP(sb)); in ext4_fill_super()
4058 (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb))); in ext4_fill_super()
4059 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / in ext4_fill_super()
4060 EXT4_DESC_PER_BLOCK(sb); in ext4_fill_super()
4061 if (ext4_has_feature_meta_bg(sb)) { in ext4_fill_super()
4063 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4074 ext4_msg(sb, KERN_ERR, "not enough memory"); in ext4_fill_super()
4080 ext4_msg(sb, KERN_ERR, "inodes count not valid: %u vs %llu", in ext4_fill_super()
4091 block = descriptor_loc(sb, logical_sb_block, i); in ext4_fill_super()
4092 sb_breadahead(sb, block); in ext4_fill_super()
4096 block = descriptor_loc(sb, logical_sb_block, i); in ext4_fill_super()
4097 sbi->s_group_desc[i] = sb_bread_unmovable(sb, block); in ext4_fill_super()
4099 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4106 if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { in ext4_fill_super()
4107 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); in ext4_fill_super()
4124 sb->s_op = &ext4_sops; in ext4_fill_super()
4125 sb->s_export_op = &ext4_export_ops; in ext4_fill_super()
4126 sb->s_xattr = ext4_xattr_handlers; in ext4_fill_super()
4128 sb->s_cop = &ext4_cryptops; in ext4_fill_super()
4131 sb->dq_op = &ext4_quota_operations; in ext4_fill_super()
4132 if (ext4_has_feature_quota(sb)) in ext4_fill_super()
4133 sb->s_qcop = &dquot_quotactl_sysfile_ops; in ext4_fill_super()
4135 sb->s_qcop = &ext4_qctl_operations; in ext4_fill_super()
4136 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; in ext4_fill_super()
4138 memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid)); in ext4_fill_super()
4143 sb->s_root = NULL; in ext4_fill_super()
4146 ext4_has_feature_journal_needs_recovery(sb)); in ext4_fill_super()
4148 if (ext4_has_feature_mmp(sb) && !sb_rdonly(sb)) in ext4_fill_super()
4149 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) in ext4_fill_super()
4156 if (!test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) { in ext4_fill_super()
4157 err = ext4_load_journal(sb, es, journal_devnum); in ext4_fill_super()
4160 } else if (test_opt(sb, NOLOAD) && !sb_rdonly(sb) && in ext4_fill_super()
4161 ext4_has_feature_journal_needs_recovery(sb)) { in ext4_fill_super()
4162 ext4_msg(sb, KERN_ERR, "required journal recovery " in ext4_fill_super()
4167 if (test_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM)) { in ext4_fill_super()
4168 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4172 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_fill_super()
4173 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4178 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4185 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4190 clear_opt(sb, JOURNAL_CHECKSUM); in ext4_fill_super()
4191 clear_opt(sb, DATA_FLAGS); in ext4_fill_super()
4197 if (ext4_has_feature_64bit(sb) && in ext4_fill_super()
4198 !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, in ext4_fill_super()
4200 ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature"); in ext4_fill_super()
4204 if (!set_journal_csum_feature_set(sb)) { in ext4_fill_super()
4205 ext4_msg(sb, KERN_ERR, "Failed to set journal checksum " in ext4_fill_super()
4212 switch (test_opt(sb, DATA_FLAGS)) { in ext4_fill_super()
4220 set_opt(sb, ORDERED_DATA); in ext4_fill_super()
4223 set_opt(sb, JOURNAL_DATA); in ext4_fill_super()
4232 ext4_msg(sb, KERN_ERR, "Journal does not support " in ext4_fill_super()
4240 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA && in ext4_fill_super()
4241 test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_fill_super()
4242 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_fill_super()
4252 if (!test_opt(sb, NO_MBCACHE)) { in ext4_fill_super()
4255 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4260 if (ext4_has_feature_ea_inode(sb)) { in ext4_fill_super()
4263 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4270 if ((DUMMY_ENCRYPTION_ENABLED(sbi) || ext4_has_feature_encrypt(sb)) && in ext4_fill_super()
4272 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4277 if (DUMMY_ENCRYPTION_ENABLED(sbi) && !sb_rdonly(sb) && in ext4_fill_super()
4278 !ext4_has_feature_encrypt(sb)) { in ext4_fill_super()
4279 ext4_set_feature_encrypt(sb); in ext4_fill_super()
4280 ext4_commit_super(sb, 1); in ext4_fill_super()
4290 err = ext4_calculate_overhead(sb); in ext4_fill_super()
4299 EXT4_SB(sb)->rsv_conversion_wq = in ext4_fill_super()
4301 if (!EXT4_SB(sb)->rsv_conversion_wq) { in ext4_fill_super()
4312 root = ext4_iget(sb, EXT4_ROOT_INO); in ext4_fill_super()
4314 ext4_msg(sb, KERN_ERR, "get root inode failed"); in ext4_fill_super()
4320 ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); in ext4_fill_super()
4324 sb->s_root = d_make_root(root); in ext4_fill_super()
4325 if (!sb->s_root) { in ext4_fill_super()
4326 ext4_msg(sb, KERN_ERR, "get root dentry failed"); in ext4_fill_super()
4331 ret = ext4_setup_super(sb, es, sb_rdonly(sb)); in ext4_fill_super()
4333 sb->s_flags |= SB_RDONLY; in ext4_fill_super()
4343 if (ext4_has_feature_extra_isize(sb)) { in ext4_fill_super()
4359 ext4_msg(sb, KERN_INFO, "required extra inode space not" in ext4_fill_super()
4363 ext4_set_resv_clusters(sb); in ext4_fill_super()
4365 err = ext4_setup_system_zone(sb); in ext4_fill_super()
4367 ext4_msg(sb, KERN_ERR, "failed to initialize system " in ext4_fill_super()
4372 ext4_ext_init(sb); in ext4_fill_super()
4373 err = ext4_mb_init(sb); in ext4_fill_super()
4375 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", in ext4_fill_super()
4380 block = ext4_count_free_clusters(sb); in ext4_fill_super()
4383 ext4_superblock_csum_set(sb); in ext4_fill_super()
4387 unsigned long freei = ext4_count_free_inodes(sb); in ext4_fill_super()
4389 ext4_superblock_csum_set(sb); in ext4_fill_super()
4395 ext4_count_dirs(sb), GFP_KERNEL); in ext4_fill_super()
4403 ext4_msg(sb, KERN_ERR, "insufficient memory"); in ext4_fill_super()
4407 if (ext4_has_feature_flex_bg(sb)) in ext4_fill_super()
4408 if (!ext4_fill_flex_info(sb)) { in ext4_fill_super()
4409 ext4_msg(sb, KERN_ERR, in ext4_fill_super()
4415 err = ext4_register_li_request(sb, first_not_zeroed); in ext4_fill_super()
4419 err = ext4_register_sysfs(sb); in ext4_fill_super()
4425 if (ext4_has_feature_quota(sb) && !sb_rdonly(sb)) { in ext4_fill_super()
4426 err = ext4_enable_quotas(sb); in ext4_fill_super()
4432 EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; in ext4_fill_super()
4433 ext4_orphan_cleanup(sb, es); in ext4_fill_super()
4434 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; in ext4_fill_super()
4436 ext4_msg(sb, KERN_INFO, "recovery complete"); in ext4_fill_super()
4437 ext4_mark_recovery_complete(sb, es); in ext4_fill_super()
4439 if (EXT4_SB(sb)->s_journal) { in ext4_fill_super()
4440 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) in ext4_fill_super()
4442 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) in ext4_fill_super()
4449 if (test_opt(sb, DISCARD)) { in ext4_fill_super()
4450 struct request_queue *q = bdev_get_queue(sb->s_bdev); in ext4_fill_super()
4452 ext4_msg(sb, KERN_WARNING, in ext4_fill_super()
4458 ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " in ext4_fill_super()
4477 ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem"); in ext4_fill_super()
4482 ext4_unregister_sysfs(sb); in ext4_fill_super()
4485 ext4_unregister_li_request(sb); in ext4_fill_super()
4487 ext4_mb_release(sb); in ext4_fill_super()
4495 ext4_ext_release(sb); in ext4_fill_super()
4496 ext4_release_system_zone(sb); in ext4_fill_super()
4498 dput(sb->s_root); in ext4_fill_super()
4499 sb->s_root = NULL; in ext4_fill_super()
4501 ext4_msg(sb, KERN_ERR, "mount failed"); in ext4_fill_super()
4502 if (EXT4_SB(sb)->rsv_conversion_wq) in ext4_fill_super()
4503 destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); in ext4_fill_super()
4537 sb->s_fs_info = NULL; in ext4_fill_super()
4551 static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) in ext4_init_journal_params() argument
4553 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_init_journal_params()
4560 if (test_opt(sb, BARRIER)) in ext4_init_journal_params()
4564 if (test_opt(sb, DATA_ERR_ABORT)) in ext4_init_journal_params()
4571 static struct inode *ext4_get_journal_inode(struct super_block *sb, in ext4_get_journal_inode() argument
4581 journal_inode = ext4_iget(sb, journal_inum); in ext4_get_journal_inode()
4583 ext4_msg(sb, KERN_ERR, "no journal found"); in ext4_get_journal_inode()
4589 ext4_msg(sb, KERN_ERR, "journal inode is deleted"); in ext4_get_journal_inode()
4596 ext4_msg(sb, KERN_ERR, "invalid journal inode"); in ext4_get_journal_inode()
4603 static journal_t *ext4_get_journal(struct super_block *sb, in ext4_get_journal() argument
4609 BUG_ON(!ext4_has_feature_journal(sb)); in ext4_get_journal()
4611 journal_inode = ext4_get_journal_inode(sb, journal_inum); in ext4_get_journal()
4617 ext4_msg(sb, KERN_ERR, "Could not load journal inode"); in ext4_get_journal()
4621 journal->j_private = sb; in ext4_get_journal()
4622 ext4_init_journal_params(sb, journal); in ext4_get_journal()
4626 static journal_t *ext4_get_dev_journal(struct super_block *sb, in ext4_get_dev_journal() argument
4639 BUG_ON(!ext4_has_feature_journal(sb)); in ext4_get_dev_journal()
4641 bdev = ext4_blkdev_get(j_dev, sb); in ext4_get_dev_journal()
4645 blocksize = sb->s_blocksize; in ext4_get_dev_journal()
4648 ext4_msg(sb, KERN_ERR, in ext4_get_dev_journal()
4657 ext4_msg(sb, KERN_ERR, "couldn't read superblock of " in ext4_get_dev_journal()
4666 ext4_msg(sb, KERN_ERR, "external journal has " in ext4_get_dev_journal()
4674 es->s_checksum != ext4_superblock_csum(sb, es)) { in ext4_get_dev_journal()
4675 ext4_msg(sb, KERN_ERR, "external journal has " in ext4_get_dev_journal()
4681 if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { in ext4_get_dev_journal()
4682 ext4_msg(sb, KERN_ERR, "journal UUID does not match"); in ext4_get_dev_journal()
4691 journal = jbd2_journal_init_dev(bdev, sb->s_bdev, in ext4_get_dev_journal()
4694 ext4_msg(sb, KERN_ERR, "failed to create device journal"); in ext4_get_dev_journal()
4697 journal->j_private = sb; in ext4_get_dev_journal()
4701 ext4_msg(sb, KERN_ERR, "I/O error on journal device"); in ext4_get_dev_journal()
4705 ext4_msg(sb, KERN_ERR, "External journal has more than one " in ext4_get_dev_journal()
4710 EXT4_SB(sb)->journal_bdev = bdev; in ext4_get_dev_journal()
4711 ext4_init_journal_params(sb, journal); in ext4_get_dev_journal()
4721 static int ext4_load_journal(struct super_block *sb, in ext4_load_journal() argument
4731 BUG_ON(!ext4_has_feature_journal(sb)); in ext4_load_journal()
4735 ext4_msg(sb, KERN_INFO, "external journal device major/minor " in ext4_load_journal()
4741 really_read_only = bdev_read_only(sb->s_bdev); in ext4_load_journal()
4748 if (ext4_has_feature_journal_needs_recovery(sb)) { in ext4_load_journal()
4749 if (sb_rdonly(sb)) { in ext4_load_journal()
4750 ext4_msg(sb, KERN_INFO, "INFO: recovery " in ext4_load_journal()
4753 ext4_msg(sb, KERN_ERR, "write access " in ext4_load_journal()
4758 ext4_msg(sb, KERN_INFO, "write access will " in ext4_load_journal()
4764 ext4_msg(sb, KERN_ERR, "filesystem has both journal " in ext4_load_journal()
4770 if (!(journal = ext4_get_journal(sb, journal_inum))) in ext4_load_journal()
4773 if (!(journal = ext4_get_dev_journal(sb, journal_dev))) in ext4_load_journal()
4778 ext4_msg(sb, KERN_INFO, "barriers disabled"); in ext4_load_journal()
4780 if (!ext4_has_feature_journal_needs_recovery(sb)) in ext4_load_journal()
4795 ext4_msg(sb, KERN_ERR, "error loading journal"); in ext4_load_journal()
4800 EXT4_SB(sb)->s_journal = journal; in ext4_load_journal()
4801 ext4_clear_journal_err(sb, es); in ext4_load_journal()
4808 ext4_commit_super(sb, 1); in ext4_load_journal()
4814 static int ext4_commit_super(struct super_block *sb, int sync) in ext4_commit_super() argument
4816 struct ext4_super_block *es = EXT4_SB(sb)->s_es; in ext4_commit_super()
4817 struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; in ext4_commit_super()
4820 if (!sbh || block_device_ejected(sb)) in ext4_commit_super()
4840 if (!(sb->s_flags & SB_RDONLY)) in ext4_commit_super()
4842 if (sb->s_bdev->bd_part) in ext4_commit_super()
4844 cpu_to_le64(EXT4_SB(sb)->s_kbytes_written + in ext4_commit_super()
4845 ((part_stat_read(sb->s_bdev->bd_part, in ext4_commit_super()
4847 EXT4_SB(sb)->s_sectors_written_start) >> 1)); in ext4_commit_super()
4850 cpu_to_le64(EXT4_SB(sb)->s_kbytes_written); in ext4_commit_super()
4851 if (percpu_counter_initialized(&EXT4_SB(sb)->s_freeclusters_counter)) in ext4_commit_super()
4853 EXT4_C2B(EXT4_SB(sb), percpu_counter_sum_positive( in ext4_commit_super()
4854 &EXT4_SB(sb)->s_freeclusters_counter))); in ext4_commit_super()
4855 if (percpu_counter_initialized(&EXT4_SB(sb)->s_freeinodes_counter)) in ext4_commit_super()
4858 &EXT4_SB(sb)->s_freeinodes_counter)); in ext4_commit_super()
4860 ext4_superblock_csum_set(sb); in ext4_commit_super()
4872 ext4_msg(sb, KERN_ERR, "previous I/O error to " in ext4_commit_super()
4881 REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0)); in ext4_commit_super()
4883 ext4_msg(sb, KERN_ERR, "I/O error while writing " in ext4_commit_super()
4897 static void ext4_mark_recovery_complete(struct super_block *sb, in ext4_mark_recovery_complete() argument
4900 journal_t *journal = EXT4_SB(sb)->s_journal; in ext4_mark_recovery_complete()
4902 if (!ext4_has_feature_journal(sb)) { in ext4_mark_recovery_complete()
4910 if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) { in ext4_mark_recovery_complete()
4911 ext4_clear_feature_journal_needs_recovery(sb); in ext4_mark_recovery_complete()
4912 ext4_commit_super(sb, 1); in ext4_mark_recovery_complete()
4924 static void ext4_clear_journal_err(struct super_block *sb, in ext4_clear_journal_err() argument
4931 BUG_ON(!ext4_has_feature_journal(sb)); in ext4_clear_journal_err()
4933 journal = EXT4_SB(sb)->s_journal; in ext4_clear_journal_err()
4944 errstr = ext4_decode_error(sb, j_errno, nbuf); in ext4_clear_journal_err()
4945 ext4_warning(sb, "Filesystem error recorded " in ext4_clear_journal_err()
4947 ext4_warning(sb, "Marking fs in need of filesystem check."); in ext4_clear_journal_err()
4949 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; in ext4_clear_journal_err()
4951 ext4_commit_super(sb, 1); in ext4_clear_journal_err()
4962 int ext4_force_commit(struct super_block *sb) in ext4_force_commit() argument
4966 if (sb_rdonly(sb)) in ext4_force_commit()
4969 journal = EXT4_SB(sb)->s_journal; in ext4_force_commit()
4973 static int ext4_sync_fs(struct super_block *sb, int wait) in ext4_sync_fs() argument
4978 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_sync_fs()
4983 trace_ext4_sync_fs(sb, wait); in ext4_sync_fs()
4989 dquot_writeback_dquots(sb, -1); in ext4_sync_fs()
5006 } else if (wait && test_opt(sb, BARRIER)) in ext4_sync_fs()
5010 err = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL); in ext4_sync_fs()
5026 static int ext4_freeze(struct super_block *sb) in ext4_freeze() argument
5031 if (sb_rdonly(sb)) in ext4_freeze()
5034 journal = EXT4_SB(sb)->s_journal; in ext4_freeze()
5049 ext4_clear_feature_journal_needs_recovery(sb); in ext4_freeze()
5052 error = ext4_commit_super(sb, 1); in ext4_freeze()
5064 static int ext4_unfreeze(struct super_block *sb) in ext4_unfreeze() argument
5066 if (sb_rdonly(sb) || ext4_forced_shutdown(EXT4_SB(sb))) in ext4_unfreeze()
5069 if (EXT4_SB(sb)->s_journal) { in ext4_unfreeze()
5071 ext4_set_feature_journal_needs_recovery(sb); in ext4_unfreeze()
5074 ext4_commit_super(sb, 1); in ext4_unfreeze()
5094 static int ext4_remount(struct super_block *sb, int *flags, char *data) in ext4_remount() argument
5097 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_remount()
5113 old_sb_flags = sb->s_flags; in ext4_remount()
5139 if (!parse_options(data, sb, NULL, &journal_ioprio, 1)) { in ext4_remount()
5145 test_opt(sb, JOURNAL_CHECKSUM)) { in ext4_remount()
5146 ext4_msg(sb, KERN_ERR, "changing journal_checksum " in ext4_remount()
5151 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { in ext4_remount()
5152 if (test_opt2(sb, EXPLICIT_DELALLOC)) { in ext4_remount()
5153 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5158 if (test_opt(sb, DIOREAD_NOLOCK)) { in ext4_remount()
5159 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5164 if (test_opt(sb, DAX)) { in ext4_remount()
5165 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5170 } else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) { in ext4_remount()
5171 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { in ext4_remount()
5172 ext4_msg(sb, KERN_ERR, "can't mount with " in ext4_remount()
5180 ext4_msg(sb, KERN_ERR, "can't enable nombcache during remount"); in ext4_remount()
5186 ext4_msg(sb, KERN_WARNING, "warning: refusing change of " in ext4_remount()
5192 ext4_abort(sb, "Abort forced by user"); in ext4_remount()
5194 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext4_remount()
5195 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); in ext4_remount()
5200 ext4_init_journal_params(sb, sbi->s_journal); in ext4_remount()
5205 sb->s_flags |= SB_LAZYTIME; in ext4_remount()
5207 if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) { in ext4_remount()
5214 err = sync_filesystem(sb); in ext4_remount()
5217 err = dquot_suspend(sb, -1); in ext4_remount()
5225 sb->s_flags |= SB_RDONLY; in ext4_remount()
5237 ext4_mark_recovery_complete(sb, es); in ext4_remount()
5242 if (ext4_has_feature_readonly(sb) || in ext4_remount()
5243 !ext4_feature_set_ok(sb, 0)) { in ext4_remount()
5253 ext4_get_group_desc(sb, g, NULL); in ext4_remount()
5255 if (!ext4_group_desc_csum_verify(sb, g, gdp)) { in ext4_remount()
5256 ext4_msg(sb, KERN_ERR, in ext4_remount()
5258 g, le16_to_cpu(ext4_group_desc_csum(sb, g, gdp)), in ext4_remount()
5271 ext4_msg(sb, KERN_WARNING, "Couldn't " in ext4_remount()
5286 ext4_clear_journal_err(sb, es); in ext4_remount()
5289 err = ext4_setup_super(sb, es, 0); in ext4_remount()
5293 sb->s_flags &= ~SB_RDONLY; in ext4_remount()
5294 if (ext4_has_feature_mmp(sb)) in ext4_remount()
5295 if (ext4_multi_mount_protect(sb, in ext4_remount()
5308 if (sb_rdonly(sb) || !test_opt(sb, INIT_INODE_TABLE)) in ext4_remount()
5309 ext4_unregister_li_request(sb); in ext4_remount()
5312 first_not_zeroed = ext4_has_uninit_itable(sb); in ext4_remount()
5313 ext4_register_li_request(sb, first_not_zeroed); in ext4_remount()
5316 ext4_setup_system_zone(sb); in ext4_remount()
5318 err = ext4_commit_super(sb, 1); in ext4_remount()
5328 if (sb_any_quota_suspended(sb)) in ext4_remount()
5329 dquot_resume(sb, -1); in ext4_remount()
5330 else if (ext4_has_feature_quota(sb)) { in ext4_remount()
5331 err = ext4_enable_quotas(sb); in ext4_remount()
5338 *flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME); in ext4_remount()
5339 ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data); in ext4_remount()
5344 sb->s_flags = old_sb_flags; in ext4_remount()
5364 static int ext4_statfs_project(struct super_block *sb, in ext4_statfs_project() argument
5373 dquot = dqget(sb, qid); in ext4_statfs_project()
5380 dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits; in ext4_statfs_project()
5383 dquot->dq_dqb.dqb_rsvspace) >> sb->s_blocksize_bits; in ext4_statfs_project()
5408 struct super_block *sb = dentry->d_sb; in ext4_statfs() local
5409 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_statfs()
5416 if (!test_opt(sb, MINIX_DF)) in ext4_statfs()
5420 buf->f_bsize = sb->s_blocksize; in ext4_statfs()
5440 sb_has_quota_limits_enabled(sb, PRJQUOTA)) in ext4_statfs()
5441 ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf); in ext4_statfs()
5513 struct super_block *sb = dquot->dq_sb; in ext4_mark_dquot_dirty() local
5514 struct ext4_sb_info *sbi = EXT4_SB(sb); in ext4_mark_dquot_dirty()
5517 if (ext4_has_feature_quota(sb) || in ext4_mark_dquot_dirty()
5526 static int ext4_write_info(struct super_block *sb, int type) in ext4_write_info() argument
5532 handle = ext4_journal_start(d_inode(sb->s_root), EXT4_HT_QUOTA, 2); in ext4_write_info()
5535 ret = dquot_commit_info(sb, type); in ext4_write_info()
5546 static int ext4_quota_on_mount(struct super_block *sb, int type) in ext4_quota_on_mount() argument
5548 return dquot_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type], in ext4_quota_on_mount()
5549 EXT4_SB(sb)->s_jquota_fmt, type); in ext4_quota_on_mount()
5569 static int ext4_quota_on(struct super_block *sb, int type, int format_id, in ext4_quota_on() argument
5574 if (!test_opt(sb, QUOTA)) in ext4_quota_on()
5578 if (path->dentry->d_sb != sb) in ext4_quota_on()
5581 if (EXT4_SB(sb)->s_qf_names[type]) { in ext4_quota_on()
5583 if (path->dentry->d_parent != sb->s_root) in ext4_quota_on()
5584 ext4_msg(sb, KERN_WARNING, in ext4_quota_on()
5587 sb_dqopt(sb)->flags |= DQUOT_NOLIST_DIRTY; in ext4_quota_on()
5593 sb_dqopt(sb)->flags &= ~DQUOT_NOLIST_DIRTY; in ext4_quota_on()
5600 if (EXT4_SB(sb)->s_journal && in ext4_quota_on()
5606 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); in ext4_quota_on()
5607 err = jbd2_journal_flush(EXT4_SB(sb)->s_journal); in ext4_quota_on()
5608 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); in ext4_quota_on()
5614 err = dquot_quota_on(sb, type, format_id, path); in ext4_quota_on()
5642 static int ext4_quota_enable(struct super_block *sb, int type, int format_id, in ext4_quota_enable() argument
5648 le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), in ext4_quota_enable()
5649 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum), in ext4_quota_enable()
5650 le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum) in ext4_quota_enable()
5653 BUG_ON(!ext4_has_feature_quota(sb)); in ext4_quota_enable()
5658 qf_inode = ext4_iget(sb, qf_inums[type]); in ext4_quota_enable()
5660 ext4_error(sb, "Bad quota inode # %lu", qf_inums[type]); in ext4_quota_enable()
5676 static int ext4_enable_quotas(struct super_block *sb) in ext4_enable_quotas() argument
5680 le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), in ext4_enable_quotas()
5681 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum), in ext4_enable_quotas()
5682 le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum) in ext4_enable_quotas()
5685 test_opt(sb, USRQUOTA), in ext4_enable_quotas()
5686 test_opt(sb, GRPQUOTA), in ext4_enable_quotas()
5687 test_opt(sb, PRJQUOTA), in ext4_enable_quotas()
5690 sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE | DQUOT_NOLIST_DIRTY; in ext4_enable_quotas()
5693 err = ext4_quota_enable(sb, type, QFMT_VFS_V1, in ext4_enable_quotas()
5697 ext4_warning(sb, in ext4_enable_quotas()
5702 dquot_quota_off(sb, type); in ext4_enable_quotas()
5711 static int ext4_quota_off(struct super_block *sb, int type) in ext4_quota_off() argument
5713 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_off()
5719 if (test_opt(sb, DELALLOC)) in ext4_quota_off()
5720 sync_filesystem(sb); in ext4_quota_off()
5725 err = dquot_quota_off(sb, type); in ext4_quota_off()
5726 if (err || ext4_has_feature_quota(sb)) in ext4_quota_off()
5750 return dquot_quota_off(sb, type); in ext4_quota_off()
5757 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, in ext4_quota_read() argument
5760 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_read()
5761 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); in ext4_quota_read()
5762 int offset = off & (sb->s_blocksize - 1); in ext4_quota_read()
5774 tocopy = sb->s_blocksize - offset < toread ? in ext4_quota_read()
5775 sb->s_blocksize - offset : toread; in ext4_quota_read()
5794 static ssize_t ext4_quota_write(struct super_block *sb, int type, in ext4_quota_write() argument
5797 struct inode *inode = sb_dqopt(sb)->files[type]; in ext4_quota_write()
5798 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); in ext4_quota_write()
5799 int err, offset = off & (sb->s_blocksize - 1); in ext4_quota_write()
5804 if (EXT4_SB(sb)->s_journal && !handle) { in ext4_quota_write()
5805 ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" in ext4_quota_write()
5814 if (sb->s_blocksize - offset < len) { in ext4_quota_write()
5815 ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" in ext4_quota_write()
5852 static int ext4_get_next_id(struct super_block *sb, struct kqid *qid) in ext4_get_next_id() argument
5856 if (!sb_has_quota_loaded(sb, qid->type)) in ext4_get_next_id()
5858 ops = sb_dqopt(sb)->ops[qid->type]; in ext4_get_next_id()
5861 return dquot_get_next_id(sb, qid); in ext4_get_next_id()
5885 static inline int ext2_feature_set_ok(struct super_block *sb) in ext2_feature_set_ok() argument
5887 if (ext4_has_unknown_ext2_incompat_features(sb)) in ext2_feature_set_ok()
5889 if (sb_rdonly(sb)) in ext2_feature_set_ok()
5891 if (ext4_has_unknown_ext2_ro_compat_features(sb)) in ext2_feature_set_ok()
5898 static inline int ext2_feature_set_ok(struct super_block *sb) { return 0; } in ext2_feature_set_ok() argument
5914 static inline int ext3_feature_set_ok(struct super_block *sb) in ext3_feature_set_ok() argument
5916 if (ext4_has_unknown_ext3_incompat_features(sb)) in ext3_feature_set_ok()
5918 if (!ext4_has_feature_journal(sb)) in ext3_feature_set_ok()
5920 if (sb_rdonly(sb)) in ext3_feature_set_ok()
5922 if (ext4_has_unknown_ext3_ro_compat_features(sb)) in ext3_feature_set_ok()