mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 07/12] fs/namespace: implement mnt_clone_direct()
Date: Fri, 19 Jun 2026 10:36:47 +0200	[thread overview]
Message-ID: <20260619-configfs-ns-v2-7-82fd7094b8dc@kernel.org> (raw)
In-Reply-To: <20260619-configfs-ns-v2-0-82fd7094b8dc@kernel.org>

Implement mnt_clone_direct() to just clone an existing vfsmount.

Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
 fs/namespace.c        | 11 +++++++++++
 include/linux/mount.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index 3d5cd5bf3b05376c867281541100c6a5e599d387..e7abbf632cc70d70547e4a2483f2217c95cc0c48 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1482,6 +1482,17 @@ struct vfsmount *mnt_clone_internal(const struct path *path)
 	return &p->mnt;
 }
 
+struct vfsmount *mnt_clone_direct(struct vfsmount *mnt, struct dentry *dentry)
+{
+	struct mount *p;
+
+	p = clone_mnt(real_mount(mnt), dentry, CL_SLAVE);
+	if (IS_ERR(p))
+		return ERR_CAST(p);
+	p->mnt.mnt_flags |= MNT_INTERNAL;
+	return &p->mnt;
+}
+
 /*
  * Returns the mount which either has the specified mnt_id, or has the next
  * smallest id afer the specified one.
diff --git a/include/linux/mount.h b/include/linux/mount.h
index acfe7ef86a1b3fdd70ab460e6e731d3c532b6487..7e7e7d66c3024b907497954a247c7e35dbcfc946 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -75,6 +75,7 @@ extern void mnt_drop_write_file(struct file *file);
 extern void mntput(struct vfsmount *mnt);
 extern struct vfsmount *mntget(struct vfsmount *mnt);
 extern void mnt_make_shortterm(struct vfsmount *mnt);
+extern struct vfsmount *mnt_clone_direct(struct vfsmount *mnt, struct dentry *dentry);
 extern struct vfsmount *mnt_clone_internal(const struct path *path);
 extern bool __mnt_is_readonly(const struct vfsmount *mnt);
 extern bool mnt_may_suid(struct vfsmount *mnt);

-- 
2.51.0


  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 ` Hannes Reinecke [this message]
2026-06-19  8:36 ` [PATCH RFC v2 08/12] fs/configfs: switch to get_tree_keyed() Hannes Reinecke
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-7-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