]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ext4: reject the 'data_err=abort' option in nojournal mode
authorBaokun Li <libaokun1@huawei.com>
Wed, 22 Jan 2025 11:05:27 +0000 (19:05 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 13 Mar 2025 14:08:08 +0000 (10:08 -0400)
data_err=abort aborts the journal on I/O errors. However, this option is
meaningless if journal is disabled, so it is rejected in nojournal mode
to reduce unnecessary checks. Also, this option is ignored upon remount.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20250122110533.4116662-4-libaokun@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/super.c

index 7ba5ef80d502e6760311fa5bb34ec165345bdd7a..0611cbfb2c886794bc6b2d6d8cb34e4174cdf9d3 100644 (file)
@@ -2770,6 +2770,13 @@ static int ext4_check_opt_consistency(struct fs_context *fc,
        }
 
        if (is_remount) {
+               if (!sbi->s_journal &&
+                   ctx_test_mount_opt(ctx, EXT4_MOUNT_DATA_ERR_ABORT)) {
+                       ext4_msg(NULL, KERN_WARNING,
+                                "Remounting fs w/o journal so ignoring data_err option");
+                       ctx_clear_mount_opt(ctx, EXT4_MOUNT_DATA_ERR_ABORT);
+               }
+
                if (ctx_test_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS) &&
                    (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)) {
                        ext4_msg(NULL, KERN_ERR, "can't mount with "
@@ -5413,6 +5420,11 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
                                 "data=, fs mounted w/o journal");
                        goto failed_mount3a;
                }
+               if (test_opt(sb, DATA_ERR_ABORT)) {
+                       ext4_msg(sb, KERN_ERR,
+                                "can't mount with data_err=abort, fs mounted w/o journal");
+                       goto failed_mount3a;
+               }
                sbi->s_def_mount_opt &= ~EXT4_MOUNT_JOURNAL_CHECKSUM;
                clear_opt(sb, JOURNAL_CHECKSUM);
                clear_opt(sb, DATA_FLAGS);