]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ext4: fix remount with 'abort' option
authorLukas Czerner <lczerner@redhat.com>
Tue, 1 Feb 2022 13:13:45 +0000 (14:13 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 26 Feb 2022 02:27:20 +0000 (21:27 -0500)
After commit b02163188675 ("ext4: get rid of super block and sbi from
handle_mount_ops()") the 'abort' options stopped working. This is
because we're using ctx_set_mount_flags() helper that's expecting an
argument with the appropriate bit set, but instead got
EXT4_MF_FS_ABORTED which is a bit position. ext4_set_mount_flag() is
using set_bit() while ctx_set_mount_flags() was using bitwise OR.

Create a separate helper ctx_set_mount_flag() to handle setting the
mount_flags correctly.

While we're at it clean up the EXT4_SET_CTX macros so that we're only
creating helpers that we actually use to avoid warnings.

Fixes: b02163188675 ("ext4: get rid of super block and sbi from handle_mount_ops()")
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Cc: Ye Bin <yebin10@huawei.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Tested-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Link: https://lore.kernel.org/r/20220201131345.77591-1-lczerner@redhat.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/super.c

index c5021ca0a28ad52d99d1f3ee19c490e390c2fe35..1fe91a26b88c7708c7aea047447f37325e9c95d1 100644 (file)
@@ -2045,8 +2045,8 @@ struct ext4_fs_context {
        unsigned int    mask_s_mount_opt;
        unsigned int    vals_s_mount_opt2;
        unsigned int    mask_s_mount_opt2;
-       unsigned int    vals_s_mount_flags;
-       unsigned int    mask_s_mount_flags;
+       unsigned long   vals_s_mount_flags;
+       unsigned long   mask_s_mount_flags;
        unsigned int    opt_flags;      /* MOPT flags */
        unsigned int    spec;
        u32             s_max_batch_time;
@@ -2149,23 +2149,36 @@ static inline void ctx_set_##name(struct ext4_fs_context *ctx,          \
 {                                                                      \
        ctx->mask_s_##name |= flag;                                     \
        ctx->vals_s_##name |= flag;                                     \
-}                                                                      \
+}
+
+#define EXT4_CLEAR_CTX(name)                                           \
 static inline void ctx_clear_##name(struct ext4_fs_context *ctx,       \
                                    unsigned long flag)                 \
 {                                                                      \
        ctx->mask_s_##name |= flag;                                     \
        ctx->vals_s_##name &= ~flag;                                    \
-}                                                                      \
+}
+
+#define EXT4_TEST_CTX(name)                                            \
 static inline unsigned long                                            \
 ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag)       \
 {                                                                      \
        return (ctx->vals_s_##name & flag);                             \
-}                                                                      \
+}
 
-EXT4_SET_CTX(flags);
+EXT4_SET_CTX(flags); /* set only */
 EXT4_SET_CTX(mount_opt);
+EXT4_CLEAR_CTX(mount_opt);
+EXT4_TEST_CTX(mount_opt);
 EXT4_SET_CTX(mount_opt2);
-EXT4_SET_CTX(mount_flags);
+EXT4_CLEAR_CTX(mount_opt2);
+EXT4_TEST_CTX(mount_opt2);
+
+static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit)
+{
+       set_bit(bit, &ctx->mask_s_mount_flags);
+       set_bit(bit, &ctx->vals_s_mount_flags);
+}
 
 static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
 {
@@ -2235,7 +2248,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
                         param->key);
                return 0;
        case Opt_abort:
-               ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
+               ctx_set_mount_flag(ctx, EXT4_MF_FS_ABORTED);
                return 0;
        case Opt_i_version:
                ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20");