From: Hannes Reinecke <hare@kernel.org>
To: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>, Andreas Hindborg <a.hindborg@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-nvme@lists.infradead.org,
Hannes Reinecke <hare@kernel.org>
Subject: [RFC PATCH 0/8] namespace-aware configfs
Date: Sat, 13 Jun 2026 13:14:29 +0200 [thread overview]
Message-ID: <20260613111437.101763-1-hare@kernel.org> (raw)
Hey all,
during discussions at LSF/MM I thought it would be quite helpful
to make configfs namespace aware, such that one could do:
unshare --mnt
mount -t configfs none /sys/kernel/config
and get a new instance of configfs. This will allow to have distinct
configurations for each namespace.
This is particularly helpful if you want to run eg nvmet in a container;
with this patchset each container can have its own configuration, and
one can simulate a multi-node nvmet cluster using containers.
How it works:
The configfs 'root' entries are stored in 'configfs_super_info' which
is stored in an xarray using the namespace ID as the index.
A configfs subsystem can be converted to be namespace aware by implementing
the new subsyste callbacks 'fill_subsystem()' and 'clear_subsystem', which
are responsible for populating the subsystem structure.
Upon registration via 'register_subsystem()' the subsystem is put in a
linked list within 'configfs_super_info'. So when mount() is called from
a different namespace this list is traversed, and new subsystems are created
in the new namespace using the callbacks.
Open Issues:
- I've added a new function 'mnt_clone_direct()' to clone the vfsmount
entry (the original code just did a simple_pin_fs()). Not sure if
that's correct. Christian?
- The current cloning mechanism is not really a hierarchy, but rather
always using the default namespace to find registered subsystems.
Meaning you can only call 'register_subsystem()' for the default
namespace. But then one shouldn't call modprobe in a container, so
that's okay I guess.
- The original content of the configfs remains visible even from
within the container, and the new 'mount' will just overlay that.
Ideally I would have the container start off with an empty
/sys/kernel/config to avoid configuration issues. But again I've
no idea how to do that (or if it's even possible).
Otherwise, as usual, commands and reviews are welcome.
Hannes Reinecke (8):
fs/configfs: rework configfs_is_root()
fs/configfs: dynamically allocate super_info
fs/configfs: separate out configfs_{link,unlink}_root()
fs/namespace: implement mnt_clone_direct()
fs/configfs: add superblock as attribute to configfs_pin_fs()
fs/configfs: add 'fill_subsystem' and 'clear_subsystem' callbacks
fs/configfs: switch to get_tree_keyed()
nvmet: make configfs setup namespace aware
drivers/nvme/target/configfs.c | 183 ++++++++++++++++++++++-----
drivers/nvme/target/core.c | 35 +++---
drivers/nvme/target/discovery.c | 101 +++++++++++----
drivers/nvme/target/nvmet.h | 13 +-
fs/configfs/configfs_internal.h | 21 +++-
fs/configfs/dir.c | 167 +++++++++++++++++++-----
fs/configfs/mount.c | 216 +++++++++++++++++++++++++++-----
fs/namespace.c | 11 ++
include/linux/configfs.h | 7 ++
include/linux/mount.h | 1 +
11 files changed, 615 insertions(+), 144 deletions(-)
--
2.51.0
next reply other threads:[~2026-06-13 11:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 11:14 Hannes Reinecke [this message]
2026-06-13 11:14 ` [PATCH 1/8] fs/configfs: rework configfs_is_root() Hannes Reinecke
2026-06-13 11:14 ` [PATCH 2/8] fs/configfs: dynamically allocate super_info Hannes Reinecke
2026-06-13 11:14 ` [PATCH 3/8] fs/configfs: separate out configfs_{link,unlink}_root() Hannes Reinecke
2026-06-13 11:14 ` [PATCH 4/8] fs/namespace: implement mnt_clone_direct() Hannes Reinecke
2026-06-13 11:14 ` [PATCH 5/8] fs/configfs: add superblock as attribute to configfs_pin_fs() Hannes Reinecke
2026-06-13 11:14 ` [PATCH 6/8] fs/configfs: add 'fill_subsystem' and 'clear_subsystem' callbacks Hannes Reinecke
2026-06-13 11:14 ` [PATCH 7/8] fs/configfs: switch to get_tree_keyed() Hannes Reinecke
2026-06-13 11:14 ` [PATCH 8/8] nvmet: make configfs setup namespace aware Hannes Reinecke
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=20260613111437.101763-1-hare@kernel.org \
--to=hare@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
/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