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 v3 03/12] fs/configfs: separate out configfs_{link,unlink}_root()
Date: Tue, 23 Jun 2026 11:15:48 +0200 [thread overview]
Message-ID: <20260623-configfs-ns-v3-3-841c100fd5dd@kernel.org> (raw)
In-Reply-To: <20260623-configfs-ns-v3-0-841c100fd5dd@kernel.org>
Separate out functions to link and unlink subsystem groups.
Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
fs/configfs/dir.c | 74 ++++++++++++++++++++++++++++++++++---------------------
1 file changed, 46 insertions(+), 28 deletions(-)
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 1e9c82e02741798930b08c96fb59a2767c7e00fc..ffd0e302cff1756f2161bdb58f1d8c1ac0cf893a 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1861,32 +1861,19 @@ void configfs_unregister_default_group(struct config_group *group)
}
EXPORT_SYMBOL(configfs_unregister_default_group);
-int configfs_register_subsystem(struct configfs_subsystem *subsys)
+static int configfs_link_root(struct configfs_super_info *info,
+ struct configfs_subsystem *subsys,
+ struct dentry *root)
{
- struct configfs_super_info *info;
struct config_group *group = &subsys->su_group;
struct dentry *dentry;
- struct dentry *root;
struct configfs_dirent *sd;
struct configfs_fragment *frag;
int err;
- info = configfs_get_super_info(&init_net);
- if (IS_ERR(info))
- return PTR_ERR(info);
-
frag = new_fragment();
- if (!frag) {
- configfs_put_super_info(info);
+ if (!frag)
return -ENOMEM;
- }
-
- root = configfs_pin_fs();
- if (IS_ERR(root)) {
- put_fragment(frag);
- configfs_put_super_info(info);
- return PTR_ERR(root);
- }
if (!group->cg_item.ci_name)
group->cg_item.ci_name = group->cg_item.ci_namebuf;
@@ -1924,33 +1911,48 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
mutex_lock(&info->subsys_mutex);
unlink_group(group);
mutex_unlock(&info->subsys_mutex);
- configfs_release_fs();
}
put_fragment(frag);
- configfs_put_super_info(info);
return err;
}
-void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
+int configfs_register_subsystem(struct configfs_subsystem *subsys)
{
struct configfs_super_info *info;
+ struct dentry *root;
+ int err;
+
+ info = configfs_get_super_info(&init_net);
+ if (WARN_ON(IS_ERR(info)))
+ return PTR_ERR(info);
+
+ root = configfs_pin_fs();
+ if (IS_ERR(root)) {
+ err = PTR_ERR(root);
+ goto out_put;
+ }
+
+ err = configfs_link_root(info, subsys, root);
+ if (err)
+ configfs_release_fs();
+
+out_put:
+ configfs_put_super_info(info);
+ return err;
+}
+
+static bool configfs_unlink_root(struct configfs_subsystem *subsys)
+{
struct config_group *group = &subsys->su_group;
struct dentry *dentry = dget(group->cg_item.ci_dentry);
struct dentry *root = dentry->d_sb->s_root;
struct configfs_dirent *sd = dentry->d_fsdata;
struct configfs_fragment *frag = sd->s_frag;
- info = configfs_get_super_info(&init_net);
- if (WARN_ON(IS_ERR(info))) {
- dput(dentry);
- return;
- }
-
if (dentry->d_parent != root) {
pr_err("Tried to unregister non-subsystem!\n");
dput(dentry);
- configfs_put_super_info(info);
- return;
+ return false;
}
down_write(&frag->frag_sem);
@@ -1978,6 +1980,22 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
inode_unlock(d_inode(root));
dput(dentry);
+ return true;
+}
+
+void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
+{
+ struct configfs_super_info *info;
+ struct config_group *group = &subsys->su_group;
+
+ info = configfs_get_super_info(&init_net);
+ if (WARN_ON(IS_ERR(info)))
+ return;
+
+ if (!configfs_unlink_root(subsys)) {
+ configfs_put_super_info(info);
+ return;
+ }
mutex_lock(&info->subsys_mutex);
unlink_group(group);
--
2.51.0
next prev parent reply other threads:[~2026-06-23 9:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 9:15 [PATCH RFC v3 00/12] namespace-aware configfs Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 01/12] fs/configfs: rework configfs_is_root() Hannes Reinecke
2026-06-23 12:50 ` Breno Leitao
2026-06-23 9:15 ` [PATCH RFC v3 02/12] fs/configfs: dynamically allocate super_info Hannes Reinecke
2026-06-23 9:15 ` Hannes Reinecke [this message]
2026-06-23 9:15 ` [PATCH RFC v3 04/12] fs/configfs: add superblock as attribute to configfs_pin_fs() Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 05/12] fs/configfs: add 'fill_subsystem' and 'clear_subsystem' callbacks Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 06/12] fs/namespace: implement mnt_clone_direct() Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 07/12] fs/configfs: switch to get_tree_keyed() Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 08/12] fs/configfs: open-code simple_pin_fs() Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 09/12] nvmet: make discovery subsystem dynamic Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 10/12] nvmet: per net-namespace port list Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 11/12] nvmet: make configfs setup namespace aware Hannes Reinecke
2026-06-23 9:15 ` [PATCH RFC v3 12/12] nvmet: enable transports for net namespaces Hannes Reinecke
2026-06-23 14:37 ` [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=20260623-configfs-ns-v3-3-841c100fd5dd@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