[PATCH] erofs: preserve unspecified options on remount

From: Ping Li

Date: Wed Nov 18 2026 - 06:25:34 EST


Before the fs_context conversion, erofs_remount() parsed the new
options on top of the live option set, so an option not mentioned
in the remount data kept its current value. After the conversion,
erofs_fc_reconfigure() swaps in a freshly parsed option set, so
every option left unspecified is silently reset to its default.

In practice util-linux and busybox mount paper over this by
re-sending the options shown in /proc/mounts, but any caller doing
a mount(2) remount with NULL or partial data silently loses e.g.
cache_strategy or, on a filesystem mounted with inode_share, the
page cache sharing feature itself -- memory usage then silently
grows once new inodes stop deduplicating. It can be observed on a
mount of "-o domain_id=test,inode_share" followed by:

mount(NULL, mnt, NULL, MS_RDONLY | MS_REMOUNT, NULL);

which returns 0 while "inode_share" disappears from /proc/mounts.

Fix it by seeding the reconfigure option set from the live one,
in the same spirit as ext4 (fc->s_fs_info = EXT4_SB(sb)) and
tmpfs (only "seen" options applied).

Fixes: f57a3fe44995a ("erofs: convert to use the new mount fs_context api")
Signed-off-by: Ping Li <leeonion.muyu@xxxxxxxxx>
---
fs/erofs/super.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index c2c652522fad..305b2daa343f 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -1000,6 +1000,13 @@ static int erofs_init_fs_context(struct fs_context *fc)
idr_init(&sbi->devs->tree);
init_rwsem(&sbi->devs->rwsem);
erofs_default_options(sbi);
+ /*
+ * On remount, start from the current option set so that options
+ * left unspecified this round keep their existing values rather
+ * than being silently reset to defaults.
+ */
+ if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
+ sbi->opt = EROFS_SB(fc->root->d_sb)->opt;
fc->ops = &erofs_context_ops;
return 0;
}

base-commit: 79f9e56d1bbf598503b240b8119624602e7ef3d2
--
2.34.1