]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ext4: avoid remount errors with 'abort' mount option
authorJan Kara <jack@suse.cz>
Fri, 4 Oct 2024 22:15:56 +0000 (00:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:05:38 +0000 (11:05 +0100)
commit 76486b104168ae59703190566e372badf433314b upstream.

When we remount filesystem with 'abort' mount option while changing
other mount options as well (as is LTP test doing), we can return error
from the system call after commit d3476f3dad4a ("ext4: don't set
SB_RDONLY after filesystem errors") because the application of mount
option changes detects shutdown filesystem and refuses to do anything.
The behavior of application of other mount options in presence of
'abort' mount option is currently rather arbitary as some mount option
changes are handled before 'abort' and some after it.

Move aborting of the filesystem to the end of remount handling so all
requested changes are properly applied before the filesystem is shutdown
to have a reasonably consistent behavior.

Fixes: d3476f3dad4a ("ext4: don't set SB_RDONLY after filesystem errors")
Reported-by: Jan Stancek <jstancek@redhat.com>
Link: https://lore.kernel.org/all/Zvp6L+oFnfASaoHl@t14s
Signed-off-by: Jan Kara <jack@suse.cz>
Tested-by: Jan Stancek <jstancek@redhat.com>
Link: https://patch.msgid.link/20241004221556.19222-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/super.c

index 7ce25cdf933424745df802c3e3cf243879985478..4d270874d04e5f8f597a0a7759c8df7c2aec55e1 100644 (file)
@@ -5849,9 +5849,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
                goto restore_opts;
        }
 
-       if (test_opt2(sb, ABORT))
-               ext4_abort(sb, ESHUTDOWN, "Abort forced by user");
-
        sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
                (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
 
@@ -6027,6 +6024,14 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
         */
        *flags = (*flags & ~vfs_flags) | (sb->s_flags & vfs_flags);
 
+       /*
+        * Handle aborting the filesystem as the last thing during remount to
+        * avoid obsure errors during remount when some option changes fail to
+        * apply due to shutdown filesystem.
+        */
+       if (test_opt2(sb, ABORT))
+               ext4_abort(sb, ESHUTDOWN, "Abort forced by user");
+
        ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s. Quota mode: %s.",
                 orig_data, ext4_quota_mode(sb));
        kfree(orig_data);