All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs: keep the current mount options on remount
@ 2026-12-05  2:35 Yifan Feng
  2026-12-05 22:57 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Yifan Feng @ 2026-12-05  2:35 UTC (permalink / raw)
  To: Gao Xiang, Chao Yu
  Cc: Yue Hu, Jingbo Xu, Sandeep Dhavale, Hongbo Li, Chunhai Guo,
	linux-erofs, linux-kernel, Yifan Feng

erofs_init_fs_context() fills every new context with the default
options, and erofs_fc_reconfigure() installs them as they are.  So a
remount that does not repeat nouser_xattr, noacl, cache_strategy= and
the other options kept in struct erofs_mount_opts resets them, and the
user xattrs that nouser_xattr hid can be read again:

  # mount -t erofs -o nouser_xattr,cache_strategy=disabled /dev/vda /mnt
  # findmnt -no OPTIONS /mnt
  ro,relatime,nouser_xattr,acl,cache_strategy=disabled
  # mount -o remount,noatime /dev/vda /mnt
  # findmnt -no OPTIONS /mnt
  ro,noatime,user_xattr,acl,cache_strategy=readaround

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 a remount changed only the options that it named.

For a remount, start from the options in use.

Fixes: f57a3fe44995 ("erofs: convert to use the new mount fs_context api")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
---
On the fixes branch of erofs.git. Tested in QEMU with mount(2), mount(8) and fspick()/fsconfig(), on a compressed image and on a file-backed mount.
Found and written with the help of an AI coding assistant.

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

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 01439e748617..80e8e49bbcb5 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -999,7 +999,10 @@ static int erofs_init_fs_context(struct fs_context *fc)
 
 	idr_init(&sbi->devs->tree);
 	init_rwsem(&sbi->devs->rwsem);
-	erofs_default_options(sbi);
+	if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
+		sbi->opt = EROFS_SB(fc->root->d_sb)->opt;
+	else
+		erofs_default_options(sbi);
 	fc->ops = &erofs_context_ops;
 	return 0;
 }

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] erofs: keep the current mount options on remount
  2026-12-05  2:35 [PATCH] erofs: keep the current mount options on remount Yifan Feng
@ 2026-12-05 22:57 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2026-12-05 22:57 UTC (permalink / raw)
  To: Yifan Feng
  Cc: Gao Xiang, Chao Yu, Yue Hu, Jingbo Xu, Sandeep Dhavale, Hongbo Li,
	Chunhai Guo, linux-erofs, linux-kernel, Ping Li

On Fri, Dec 04, 2026 at 06:35:57PM -0800, Yifan Feng wrote:
> erofs_init_fs_context() fills every new context with the default
> options, and erofs_fc_reconfigure() installs them as they are.  So a
> remount that does not repeat nouser_xattr, noacl, cache_strategy= and
> the other options kept in struct erofs_mount_opts resets them, and the
> user xattrs that nouser_xattr hid can be read again:
> 
>   # mount -t erofs -o nouser_xattr,cache_strategy=disabled /dev/vda /mnt
>   # findmnt -no OPTIONS /mnt
>   ro,relatime,nouser_xattr,acl,cache_strategy=disabled
>   # mount -o remount,noatime /dev/vda /mnt
>   # findmnt -no OPTIONS /mnt
>   ro,noatime,user_xattr,acl,cache_strategy=readaround
> 
> 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 a remount changed only the options that it named.
> 
> For a remount, start from the options in use.
> 
> Fixes: f57a3fe44995 ("erofs: convert to use the new mount fs_context api")
> Signed-off-by: Yifan Feng <evanfengff@gmail.com>

Reviewed-by: Gao Xiang <xiang@kernel.org>

There was a similar patch but I think your patch is better:
https://lore.kernel.org/r/20261118112523.3824782-1-leeonion.muyu@gmail.com

I will add a Reported-by credit like:
Reported-by: Ping Li <leeonion.muyu@gmail.com>

Btw, although it's not perfect as Sashiko's pointed out (racy remount,
but I don't think anyone really cares), a follow-up patch maybe just
introduce a new opt_mask field so that it can mask off unchanged bits
in .reconfigure() when updating.

Thanks,
Gao Xiang


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-05 22:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05  2:35 [PATCH] erofs: keep the current mount options on remount Yifan Feng
2026-12-05 22:57 ` Gao Xiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.