From: Hannes Reinecke <hare@kernel.org>
To: Andreas Hindborg <a.hindborg@kernel.org>,
Breno Leitao <leitao@debian.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Chaitanya Kulkarni <kch@nvidia.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-nvme@lists.infradead.org,
Hannes Reinecke <hare@kernel.org>
Subject: [PATCH RFC v2 08/12] fs/configfs: switch to get_tree_keyed()
Date: Fri, 19 Jun 2026 10:36:48 +0200 [thread overview]
Message-ID: <20260619-configfs-ns-v2-8-82fd7094b8dc@kernel.org> (raw)
In-Reply-To: <20260619-configfs-ns-v2-0-82fd7094b8dc@kernel.org>
Switch to get_tree_keyed() to instatiate a new superblock whenever
the mount namespace changed.
Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
fs/configfs/dir.c | 6 ++++--
fs/configfs/mount.c | 31 ++++++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index b87b92e3a248dfb091eb52727f06cc4551143f7b..4caf040a909115ac1997a99a81ba38ffac065449 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1968,8 +1968,10 @@ void configfs_link_subsystems(struct super_block *sb,
if (WARN_ON(IS_ERR(parent)))
return;
- if ((info->net_ns == &init_net) || WARN_ON(parent == info))
+ if ((info->net_ns == &init_net) || WARN_ON(parent == info)) {
+ configfs_put_super_info(parent);
return;
+ }
mutex_lock(&parent->subsys_mutex);
list_splice_init(&parent->subsys_list, &subsys_list);
mutex_unlock(&parent->subsys_mutex);
@@ -2080,7 +2082,7 @@ void configfs_unlink_subsystems(struct super_block *sb,
void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
{
- struct configfs_super_info *info = configfs_get_super_info(0);
+ struct configfs_super_info *info = configfs_get_super_info(&init_net);
struct config_group *group = &subsys->su_group;
if (WARN_ON(IS_ERR(info)))
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index d36fc4a6f6439bea645e62b8423b518a5d7d51c1..36f275aaaf871f748dfcb011b782c22abe19d9d5 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -123,11 +123,10 @@ void configfs_put_super_info(struct configfs_super_info *info)
static int configfs_fill_super(struct super_block *sb, struct fs_context *fc)
{
- struct configfs_super_info *info = configfs_get_super_info(&init_net);
+ struct configfs_super_info *info = sb->s_fs_info;
struct inode *inode;
struct dentry *root;
- sb->s_fs_info = info;
sb->s_blocksize = PAGE_SIZE;
sb->s_blocksize_bits = PAGE_SHIFT;
sb->s_magic = CONFIGFS_MAGIC;
@@ -138,7 +137,6 @@ static int configfs_fill_super(struct super_block *sb, struct fs_context *fc)
&info->root, sb);
if (IS_ERR(inode)) {
pr_debug("could not get root inode\n");
- configfs_put_super_info(info);
return PTR_ERR(inode);
}
inode->i_op = &configfs_root_inode_operations;
@@ -149,7 +147,6 @@ static int configfs_fill_super(struct super_block *sb, struct fs_context *fc)
root = d_make_root(inode);
if (!root) {
pr_debug("%s: could not get root dentry!\n",__func__);
- configfs_put_super_info(info);
return -ENOMEM;
}
info->group.cg_item.ci_dentry = root;
@@ -165,15 +162,38 @@ static int configfs_fill_super(struct super_block *sb, struct fs_context *fc)
static int configfs_get_tree(struct fs_context *fc)
{
- return get_tree_single(fc, configfs_fill_super);
+ struct net *net_ns = fc->fs_private;
+ struct configfs_super_info *info;
+ int err;
+
+ info = configfs_get_super_info(net_ns);
+ if (IS_ERR(info))
+ return PTR_ERR(info);
+
+ err = get_tree_keyed(fc, configfs_fill_super, info);
+ if (err && fc->s_fs_info)
+ configfs_put_super_info(info);
+ return err;
+}
+
+static void configfs_fs_context_free(struct fs_context *fc)
+{
+ struct net *net_ns = fc->fs_private;
+
+ fc->fs_private = NULL;
+ put_net(net_ns);
}
static const struct fs_context_operations configfs_context_ops = {
.get_tree = configfs_get_tree,
+ .free = configfs_fs_context_free,
};
static int configfs_init_fs_context(struct fs_context *fc)
{
+ struct net *net_ns = get_net_ns_by_pid(current->pid);
+
+ fc->fs_private = net_ns;
fc->ops = &configfs_context_ops;
return 0;
}
@@ -193,6 +213,7 @@ static struct file_system_type configfs_fs_type = {
.name = "configfs",
.init_fs_context = configfs_init_fs_context,
.kill_sb = configfs_kill_sb,
+ .fs_flags = FS_USERNS_MOUNT,
};
MODULE_ALIAS_FS("configfs");
--
2.51.0
next prev parent reply other threads:[~2026-06-19 8:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-19 8:36 [PATCH RFC v2 00/12] namespace-aware configfs hare
2026-06-19 8:36 ` [PATCH RFC v2 01/12] fs/configfs: rework configfs_is_root() hare
2026-06-19 8:36 ` [PATCH RFC v2 02/12] fs/configfs: dynamically allocate super_info hare
2026-06-19 8:36 ` [PATCH RFC v2 03/12] fs/configfs: separate out configfs_{link,unlink}_root() hare
2026-06-19 8:36 ` [PATCH RFC v2 04/12] fs/configfs: add superblock as attribute to configfs_pin_fs() Hannes Reinecke
2026-06-19 8:36 ` [PATCH RFC v2 05/12] fs/configfs: add 'fill_subsystem' and 'clear_subsystem' callbacks Hannes Reinecke
2026-06-19 8:36 ` [PATCH RFC v2 06/12] fs/configfs: add superblock as attribute to configfs_pin_fs() Hannes Reinecke
2026-06-19 8:36 ` [PATCH RFC v2 07/12] fs/namespace: implement mnt_clone_direct() Hannes Reinecke
2026-06-19 8:36 ` Hannes Reinecke [this message]
2026-06-19 8:36 ` [PATCH RFC v2 09/12] fs/configfs: open-code simple_pin_fs() Hannes Reinecke
2026-06-19 8:36 ` [PATCH RFC v2 10/12] nvmet: make discovery subsystem dynamic Hannes Reinecke
2026-06-19 8:36 ` [PATCH RFC v2 11/12] nvmet: per net-namespace port list Hannes Reinecke
2026-06-19 8:36 ` [PATCH RFC v2 12/12] nvmet: make configfs setup namespace aware Hannes Reinecke
2026-06-19 13:25 ` [syzbot ci] Re: namespace-aware configfs syzbot ci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260619-configfs-ns-v2-8-82fd7094b8dc@kernel.org \
--to=hare@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=brauner@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=kch@nvidia.com \
--cc=leitao@debian.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome