summaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 0886fe82e9c4..d9701c869dd3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -405,7 +405,7 @@ static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn)
405 405
406static void ext4_handle_error(struct super_block *sb) 406static void ext4_handle_error(struct super_block *sb)
407{ 407{
408 if (sb->s_flags & MS_RDONLY) 408 if (sb_rdonly(sb))
409 return; 409 return;
410 410
411 if (!test_opt(sb, ERRORS_CONT)) { 411 if (!test_opt(sb, ERRORS_CONT)) {
@@ -587,8 +587,7 @@ void __ext4_std_error(struct super_block *sb, const char *function,
587 /* Special case: if the error is EROFS, and we're not already 587 /* Special case: if the error is EROFS, and we're not already
588 * inside a transaction, then there's really no point in logging 588 * inside a transaction, then there's really no point in logging
589 * an error. */ 589 * an error. */
590 if (errno == -EROFS && journal_current_handle() == NULL && 590 if (errno == -EROFS && journal_current_handle() == NULL && sb_rdonly(sb))
591 (sb->s_flags & MS_RDONLY))
592 return; 591 return;
593 592
594 if (ext4_error_ratelimit(sb)) { 593 if (ext4_error_ratelimit(sb)) {
@@ -628,7 +627,7 @@ void __ext4_abort(struct super_block *sb, const char *function,
628 sb->s_id, function, line, &vaf); 627 sb->s_id, function, line, &vaf);
629 va_end(args); 628 va_end(args);
630 629
631 if ((sb->s_flags & MS_RDONLY) == 0) { 630 if (sb_rdonly(sb) == 0) {
632 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); 631 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
633 EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; 632 EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED;
634 /* 633 /*
@@ -889,11 +888,11 @@ static void ext4_put_super(struct super_block *sb)
889 ext4_mb_release(sb); 888 ext4_mb_release(sb);
890 ext4_ext_release(sb); 889 ext4_ext_release(sb);
891 890
892 if (!(sb->s_flags & MS_RDONLY) && !aborted) { 891 if (!sb_rdonly(sb) && !aborted) {
893 ext4_clear_feature_journal_needs_recovery(sb); 892 ext4_clear_feature_journal_needs_recovery(sb);
894 es->s_state = cpu_to_le16(sbi->s_mount_state); 893 es->s_state = cpu_to_le16(sbi->s_mount_state);
895 } 894 }
896 if (!(sb->s_flags & MS_RDONLY)) 895 if (!sb_rdonly(sb))
897 ext4_commit_super(sb, 1); 896 ext4_commit_super(sb, 1);
898 897
899 for (i = 0; i < sbi->s_gdb_count; i++) 898 for (i = 0; i < sbi->s_gdb_count; i++)
@@ -2101,7 +2100,7 @@ int ext4_seq_options_show(struct seq_file *seq, void *offset)
2101 struct super_block *sb = seq->private; 2100 struct super_block *sb = seq->private;
2102 int rc; 2101 int rc;
2103 2102
2104 seq_puts(seq, (sb->s_flags & MS_RDONLY) ? "ro" : "rw"); 2103 seq_puts(seq, sb_rdonly(sb) ? "ro" : "rw");
2105 rc = _ext4_show_options(seq, sb, 1); 2104 rc = _ext4_show_options(seq, sb, 1);
2106 seq_puts(seq, "\n"); 2105 seq_puts(seq, "\n");
2107 return rc; 2106 return rc;
@@ -2369,7 +2368,7 @@ static int ext4_check_descriptors(struct super_block *sb,
2369 "Checksum for group %u failed (%u!=%u)", 2368 "Checksum for group %u failed (%u!=%u)",
2370 i, le16_to_cpu(ext4_group_desc_csum(sb, i, 2369 i, le16_to_cpu(ext4_group_desc_csum(sb, i,
2371 gdp)), le16_to_cpu(gdp->bg_checksum)); 2370 gdp)), le16_to_cpu(gdp->bg_checksum));
2372 if (!(sb->s_flags & MS_RDONLY)) { 2371 if (!sb_rdonly(sb)) {
2373 ext4_unlock_group(sb, i); 2372 ext4_unlock_group(sb, i);
2374 return 0; 2373 return 0;
2375 } 2374 }
@@ -3116,8 +3115,7 @@ int ext4_register_li_request(struct super_block *sb,
3116 goto out; 3115 goto out;
3117 } 3116 }
3118 3117
3119 if (first_not_zeroed == ngroups || 3118 if (first_not_zeroed == ngroups || sb_rdonly(sb) ||
3120 (sb->s_flags & MS_RDONLY) ||
3121 !test_opt(sb, INIT_INODE_TABLE)) 3119 !test_opt(sb, INIT_INODE_TABLE))
3122 goto out; 3120 goto out;
3123 3121
@@ -3661,7 +3659,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3661 * previously didn't change the revision level when setting the flags, 3659 * previously didn't change the revision level when setting the flags,
3662 * so there is a chance incompat flags are set on a rev 0 filesystem. 3660 * so there is a chance incompat flags are set on a rev 0 filesystem.
3663 */ 3661 */
3664 if (!ext4_feature_set_ok(sb, (sb->s_flags & MS_RDONLY))) 3662 if (!ext4_feature_set_ok(sb, (sb_rdonly(sb))))
3665 goto failed_mount; 3663 goto failed_mount;
3666 3664
3667 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 3665 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
@@ -3790,12 +3788,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3790 sbi->s_hash_unsigned = 3; 3788 sbi->s_hash_unsigned = 3;
3791 else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) { 3789 else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) {
3792#ifdef __CHAR_UNSIGNED__ 3790#ifdef __CHAR_UNSIGNED__
3793 if (!(sb->s_flags & MS_RDONLY)) 3791 if (!sb_rdonly(sb))
3794 es->s_flags |= 3792 es->s_flags |=
3795 cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH); 3793 cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH);
3796 sbi->s_hash_unsigned = 3; 3794 sbi->s_hash_unsigned = 3;
3797#else 3795#else
3798 if (!(sb->s_flags & MS_RDONLY)) 3796 if (!sb_rdonly(sb))
3799 es->s_flags |= 3797 es->s_flags |=
3800 cpu_to_le32(EXT2_FLAGS_SIGNED_HASH); 3798 cpu_to_le32(EXT2_FLAGS_SIGNED_HASH);
3801#endif 3799#endif
@@ -3995,7 +3993,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3995 needs_recovery = (es->s_last_orphan != 0 || 3993 needs_recovery = (es->s_last_orphan != 0 ||
3996 ext4_has_feature_journal_needs_recovery(sb)); 3994 ext4_has_feature_journal_needs_recovery(sb));
3997 3995
3998 if (ext4_has_feature_mmp(sb) && !(sb->s_flags & MS_RDONLY)) 3996 if (ext4_has_feature_mmp(sb) && !sb_rdonly(sb))
3999 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) 3997 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
4000 goto failed_mount3a; 3998 goto failed_mount3a;
4001 3999
@@ -4007,7 +4005,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
4007 err = ext4_load_journal(sb, es, journal_devnum); 4005 err = ext4_load_journal(sb, es, journal_devnum);
4008 if (err) 4006 if (err)
4009 goto failed_mount3a; 4007 goto failed_mount3a;
4010 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && 4008 } else if (test_opt(sb, NOLOAD) && !sb_rdonly(sb) &&
4011 ext4_has_feature_journal_needs_recovery(sb)) { 4009 ext4_has_feature_journal_needs_recovery(sb)) {
4012 ext4_msg(sb, KERN_ERR, "required journal recovery " 4010 ext4_msg(sb, KERN_ERR, "required journal recovery "
4013 "suppressed and not mounted read-only"); 4011 "suppressed and not mounted read-only");
@@ -4121,7 +4119,7 @@ no_journal:
4121 goto failed_mount_wq; 4119 goto failed_mount_wq;
4122 } 4120 }
4123 4121
4124 if (DUMMY_ENCRYPTION_ENABLED(sbi) && !(sb->s_flags & MS_RDONLY) && 4122 if (DUMMY_ENCRYPTION_ENABLED(sbi) && !sb_rdonly(sb) &&
4125 !ext4_has_feature_encrypt(sb)) { 4123 !ext4_has_feature_encrypt(sb)) {
4126 ext4_set_feature_encrypt(sb); 4124 ext4_set_feature_encrypt(sb);
4127 ext4_commit_super(sb, 1); 4125 ext4_commit_super(sb, 1);
@@ -4175,7 +4173,7 @@ no_journal:
4175 goto failed_mount4; 4173 goto failed_mount4;
4176 } 4174 }
4177 4175
4178 if (ext4_setup_super(sb, es, sb->s_flags & MS_RDONLY)) 4176 if (ext4_setup_super(sb, es, sb_rdonly(sb)))
4179 sb->s_flags |= MS_RDONLY; 4177 sb->s_flags |= MS_RDONLY;
4180 4178
4181 /* determine the minimum size of new large inodes, if present */ 4179 /* determine the minimum size of new large inodes, if present */
@@ -4263,7 +4261,7 @@ no_journal:
4263 4261
4264#ifdef CONFIG_QUOTA 4262#ifdef CONFIG_QUOTA
4265 /* Enable quota usage during mount. */ 4263 /* Enable quota usage during mount. */
4266 if (ext4_has_feature_quota(sb) && !(sb->s_flags & MS_RDONLY)) { 4264 if (ext4_has_feature_quota(sb) && !sb_rdonly(sb)) {
4267 err = ext4_enable_quotas(sb); 4265 err = ext4_enable_quotas(sb);
4268 if (err) 4266 if (err)
4269 goto failed_mount8; 4267 goto failed_mount8;
@@ -4586,7 +4584,7 @@ static int ext4_load_journal(struct super_block *sb,
4586 * can get read-write access to the device. 4584 * can get read-write access to the device.
4587 */ 4585 */
4588 if (ext4_has_feature_journal_needs_recovery(sb)) { 4586 if (ext4_has_feature_journal_needs_recovery(sb)) {
4589 if (sb->s_flags & MS_RDONLY) { 4587 if (sb_rdonly(sb)) {
4590 ext4_msg(sb, KERN_INFO, "INFO: recovery " 4588 ext4_msg(sb, KERN_INFO, "INFO: recovery "
4591 "required on readonly filesystem"); 4589 "required on readonly filesystem");
4592 if (really_read_only) { 4590 if (really_read_only) {
@@ -4741,8 +4739,7 @@ static void ext4_mark_recovery_complete(struct super_block *sb,
4741 if (jbd2_journal_flush(journal) < 0) 4739 if (jbd2_journal_flush(journal) < 0)
4742 goto out; 4740 goto out;
4743 4741
4744 if (ext4_has_feature_journal_needs_recovery(sb) && 4742 if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) {
4745 sb->s_flags & MS_RDONLY) {
4746 ext4_clear_feature_journal_needs_recovery(sb); 4743 ext4_clear_feature_journal_needs_recovery(sb);
4747 ext4_commit_super(sb, 1); 4744 ext4_commit_super(sb, 1);
4748 } 4745 }
@@ -4798,7 +4795,7 @@ int ext4_force_commit(struct super_block *sb)
4798{ 4795{
4799 journal_t *journal; 4796 journal_t *journal;
4800 4797
4801 if (sb->s_flags & MS_RDONLY) 4798 if (sb_rdonly(sb))
4802 return 0; 4799 return 0;
4803 4800
4804 journal = EXT4_SB(sb)->s_journal; 4801 journal = EXT4_SB(sb)->s_journal;
@@ -4863,7 +4860,7 @@ static int ext4_freeze(struct super_block *sb)
4863 int error = 0; 4860 int error = 0;
4864 journal_t *journal; 4861 journal_t *journal;
4865 4862
4866 if (sb->s_flags & MS_RDONLY) 4863 if (sb_rdonly(sb))
4867 return 0; 4864 return 0;
4868 4865
4869 journal = EXT4_SB(sb)->s_journal; 4866 journal = EXT4_SB(sb)->s_journal;
@@ -4898,7 +4895,7 @@ out:
4898 */ 4895 */
4899static int ext4_unfreeze(struct super_block *sb) 4896static int ext4_unfreeze(struct super_block *sb)
4900{ 4897{
4901 if ((sb->s_flags & MS_RDONLY) || ext4_forced_shutdown(EXT4_SB(sb))) 4898 if (sb_rdonly(sb) || ext4_forced_shutdown(EXT4_SB(sb)))
4902 return 0; 4899 return 0;
4903 4900
4904 if (EXT4_SB(sb)->s_journal) { 4901 if (EXT4_SB(sb)->s_journal) {
@@ -5036,7 +5033,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
5036 if (*flags & MS_LAZYTIME) 5033 if (*flags & MS_LAZYTIME)
5037 sb->s_flags |= MS_LAZYTIME; 5034 sb->s_flags |= MS_LAZYTIME;
5038 5035
5039 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) { 5036 if ((bool)(*flags & MS_RDONLY) != sb_rdonly(sb)) {
5040 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) { 5037 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) {
5041 err = -EROFS; 5038 err = -EROFS;
5042 goto restore_opts; 5039 goto restore_opts;
@@ -5131,7 +5128,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
5131 * Reinitialize lazy itable initialization thread based on 5128 * Reinitialize lazy itable initialization thread based on
5132 * current settings 5129 * current settings
5133 */ 5130 */
5134 if ((sb->s_flags & MS_RDONLY) || !test_opt(sb, INIT_INODE_TABLE)) 5131 if (sb_rdonly(sb) || !test_opt(sb, INIT_INODE_TABLE))
5135 ext4_unregister_li_request(sb); 5132 ext4_unregister_li_request(sb);
5136 else { 5133 else {
5137 ext4_group_t first_not_zeroed; 5134 ext4_group_t first_not_zeroed;
@@ -5703,7 +5700,7 @@ static inline int ext2_feature_set_ok(struct super_block *sb)
5703{ 5700{
5704 if (ext4_has_unknown_ext2_incompat_features(sb)) 5701 if (ext4_has_unknown_ext2_incompat_features(sb))
5705 return 0; 5702 return 0;
5706 if (sb->s_flags & MS_RDONLY) 5703 if (sb_rdonly(sb))
5707 return 1; 5704 return 1;
5708 if (ext4_has_unknown_ext2_ro_compat_features(sb)) 5705 if (ext4_has_unknown_ext2_ro_compat_features(sb))
5709 return 0; 5706 return 0;
@@ -5734,7 +5731,7 @@ static inline int ext3_feature_set_ok(struct super_block *sb)
5734 return 0; 5731 return 0;
5735 if (!ext4_has_feature_journal(sb)) 5732 if (!ext4_has_feature_journal(sb))
5736 return 0; 5733 return 0;
5737 if (sb->s_flags & MS_RDONLY) 5734 if (sb_rdonly(sb))
5738 return 1; 5735 return 1;
5739 if (ext4_has_unknown_ext3_ro_compat_features(sb)) 5736 if (ext4_has_unknown_ext3_ro_compat_features(sb))
5740 return 0; 5737 return 0;