[PATCH] devtmpfs: apply mount options to the existing superblock

Shigeru Yoshida <[email protected]>
Newsgroups dev.linux.lists.driver-core,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Commit cb0e0a8bf4e1 ("devtmpfs: replace ->mount with ->get_tree in
public instance") dropped the reconfigure_single() call that
public_dev_mount() used to apply the options of every new mount to the
single, internally created superblock. devtmpfs_get_tree() only takes
a reference on it: the options are still parsed into fc->fs_private,
but ->reconfigure is now only reached via reconfigure_super(), i.e. on
remount, so they are discarded by put_fs_context().

For example, systemd mounts /dev with "-o mode=755,size=4m,nr_inodes=1m",
so size= is silently ignored and /dev falls back to the tmpfs default of
50% of physical RAM.

Call the underlying ->reconfigure from devtmpfs_get_tree(), the same
way tracefs and debugfs do; ramfs has no ->reconfigure, hence the NULL
check.

This restores the behaviour of commit a6097180d884 ("devtmpfs
regression fix: reconfigure on each mount"), which fixed the same
regression when devtmpfs was first converted away from mount_single().

Fixes: cb0e0a8bf4e1 ("devtmpfs: replace ->mount with ->get_tree in public instance")
Cc: [email protected]
Assisted-by: Claude:claude-opus-5
Signed-off-by: Shigeru Yoshida <[email protected]>
---
 drivers/base/devtmpfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index aef0fcc6aba1..f0798fc1bc34 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -80,6 +80,18 @@ static int devtmpfs_get_tree(struct fs_context *fc)
 	atomic_inc(&sb->s_active);
 	down_write(&sb->s_umount);
 	fc->root = dget(sb->s_root);
+
+	if (fc->ops->reconfigure) {
+		int err = fc->ops->reconfigure(fc);
+
+		if (err) {
+			dput(fc->root);
+			fc->root = NULL;
+			deactivate_locked_super(sb);
+			return err;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.