]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tmpfs: preserve SB_I_VERSION on remount
authorBaokun Li <libaokun1@huawei.com>
Tue, 19 Aug 2025 06:18:03 +0000 (14:18 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 13 Sep 2025 23:55:12 +0000 (16:55 -0700)
Now tmpfs enables i_version by default and tmpfs does not modify it.  But
SB_I_VERSION can also be modified via sb_flags, and reconfigure_super()
always overwrites the existing flags with the latest ones.  This means
that if tmpfs is remounted without specifying iversion, the default
i_version will be unexpectedly disabled.

To ensure iversion remains enabled, SB_I_VERSION is now always set for
fc->sb_flags in shmem_init_fs_context(), instead of for sb->s_flags in
shmem_fill_super().

Link: https://lkml.kernel.org/r/20250819061803.1496443-1-libaokun@huaweicloud.com
Fixes: 36f05cab0a2c ("tmpfs: add support for an i_version counter")
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shmem.c

index d945de3a7f0e7a111b4f11c421a97449e3f50028..13cc51df38939c7c9643629d22ffcddfdb7f708a 100644 (file)
@@ -5081,7 +5081,7 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc)
                sb->s_flags |= SB_NOUSER;
        }
        sb->s_export_op = &shmem_export_ops;
-       sb->s_flags |= SB_NOSEC | SB_I_VERSION;
+       sb->s_flags |= SB_NOSEC;
 
 #if IS_ENABLED(CONFIG_UNICODE)
        if (!ctx->encoding && ctx->strict_encoding) {
@@ -5385,6 +5385,9 @@ int shmem_init_fs_context(struct fs_context *fc)
 
        fc->fs_private = ctx;
        fc->ops = &shmem_fs_context_ops;
+#ifdef CONFIG_TMPFS
+       fc->sb_flags |= SB_I_VERSION;
+#endif
        return 0;
 }