[PATCH] btrfs: don't drop noacl on a remount without acl or noacl

From: Yifan Feng

Date: Tue Dec 01 2026 - 19:24:45 EST


btrfs_init_fs_context() sets SB_POSIXACL in every new context, and
btrfs_reconfigure() applies the flag when it differs from the mounted
one. So a remount that names neither acl nor noacl switches a noacl
mount back to ACLs, and the ACLs stored on the files are enforced
again:

# mount -o noacl /dev/vda /mnt
# findmnt -no OPTIONS /mnt
rw,relatime,discard=async,noacl,space_cache=v2,subvolid=5,subvol=/
# mount -o remount,noatime /dev/vda /mnt
# findmnt -no OPTIONS /mnt
rw,noatime,discard=async,space_cache=v2,subvolid=5,subvol=/

mount(8) hides this when it is given the mount point only, because it
then passes the current options again. Before the conversion to the
mount API the flag changed only when one of the two options was given.

For a remount, set the flag only if the mounted filesystem has it.

Fixes: ad21f15b0f79 ("btrfs: switch to the new mount API")
Signed-off-by: Yifan Feng <evanfengff@xxxxxxxxx>
---
Tested in QEMU with mount(2), mount(8) from util-linux 2.38.1 and fspick()/fsconfig(). fstests -g quick plus 71 acl and remount tests give the same results with and without the patch (BTRFS_DEBUG, btrfs-progs 6.2).
Found and written with the help of an AI coding assistant.

fs/btrfs/super.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index b424cc836bd4..2770ad797a21 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2204,7 +2204,10 @@ static int btrfs_init_fs_context(struct fs_context *fc)
}

#ifdef CONFIG_BTRFS_FS_POSIX_ACL
- fc->sb_flags |= SB_POSIXACL;
+ /* A remount without acl or noacl keeps what is in use. */
+ if (fc->purpose != FS_CONTEXT_FOR_RECONFIGURE ||
+ (fc->root->d_sb->s_flags & SB_POSIXACL))
+ fc->sb_flags |= SB_POSIXACL;
#endif
fc->sb_flags |= SB_I_VERSION;


base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.39.3 (Apple Git-146)