From: Christian Brauner <brauner@kernel.org>
To: Luca Boccassi <luca.boccassi@gmail.com>
Cc: Aleksa Sarai <cyphar@cyphar.com>,
Alejandro Colomar <alx@kernel.org>,
linux-man@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] man/man2/move_mount.2: document EINVAL on multiple instances
Date: Wed, 22 Oct 2025 09:36:43 +0200 [thread overview]
Message-ID: <20251022-oberdeck-baucontainer-221cf7218f15@brauner> (raw)
In-Reply-To: <CAMw=ZnQki4YR24CfYJMAEWEAQ63yYer-YzSAeH+xFA-fNth-XQ@mail.gmail.com>
On Mon, Oct 06, 2025 at 02:44:58PM +0100, Luca Boccassi wrote:
> On Mon, 6 Oct 2025 at 14:41, Aleksa Sarai <cyphar@cyphar.com> wrote:
> >
> > On 2025-10-06, Luca Boccassi <luca.boccassi@gmail.com> wrote:
> > > On Mon, 6 Oct 2025 at 12:57, Alejandro Colomar <alx@kernel.org> wrote:
> > > >
> > > > Hi Luca,
> > > >
> > > > On Mon, Oct 06, 2025 at 12:46:41PM +0100, Luca Boccassi wrote:
> > > > > > > > > .TP
> > > > > > > > > +.B EINVAL
> > > > > > > > > +The source mount is already mounted somewhere else. Clone it via
> > > > > > [...]
> > > > > > > > > +.BR open_tree (2)
> > > > > > > > > +with
> > > > > > > > > +.B \%OPEN_TREE_CLONE
> > > > > > > > > +and use that as the source instead (since Linux 6.15).
> > > > > > > >
> > > > > > > > The parenthetical in that position makes it unclear if you're saying
> > > > > > > > that one should use open_tree(2) with OPEN_TREE_CLONE since Linux 6.15,
> > > > > > > > or if you're saying that this error can happen since that version.
> > > > > > > > Would you mind clarifying? I think if you mean that the error can
> > > > > > > > happen since Linux 6.15, we could make it part of the paragraph tag, as
> > > > > > > > in unshare(2).
> > > > > > >
> > > > > > > I meant the former, the error is always there, but OPEN_TREE_CLONE can
> > > > > > > be used since 6.15 to avoid it. Sent v2 with this and the other fix,
> > > > > > > thanks for the prompt review.
> > > > > >
> > > > > > Hmmm, I see. Why not use open_tree(2) and OPEN_TREE_CLONE before 6.15?
> > > > > > The syscall and flag existed, AFAICS. I think we should clarify --at
> > > > > > least in the commit message--, why that version is important.
> > > > >
> > > > > It was just not supported at all, so it would still fail with EINVAL
> > > > > before 6.15 even with the clone.
> > > >
> > > > Thanks! What's the exact commit (or set of commits) that changed this?
> > > > That would be useful for the commit message.
> > > >
> > > > > Would you like me to send a v3 or would you prefer to amend the commit
> > > > > message yourself?
> > > >
> > > > I can amend myself.
> > >
> > > Sorry, I am not a kernel dev so I do not know where it was introduced
> > > exactly, and quickly skimming the commits list doesn't immediately
> > > reveal anything. I only know that by testing it, it works on 6.15 and
> > > fails earlier.
> >
> > If I'm understanding the new error entry correctly, this might be commit
> > c5c12f871a30 ("fs: create detached mounts from detached mounts"), but
> > Christian can probably verify that.
> >
> > Just to double check that I understand this new error explanation -- the
> > issue is that you had a file descriptor that you thought was a detached
> > mount object but it was actually attached at some point, and the
> > suggestion is to create a new detached bind-mount to use with
> > move_mount(2)? Do you really get EINVAL in that case or does this move
> > the mount?
>
> Almost - the use case is that I prep an image as a detached mount, and
> then I want to apply it multiple times, without having to reopen it
> again and again. If I just do 'move_mount()' multiple times, the
> second one returns EINVAL. From 6.15, I can do open_tree with
> OPEN_TREE_CLONE before applying with move_mount, and everything works.
Your use-case was to create a new detached filesystem via fsmount().
And then send that fd to multiple different mount namespaces. One of
those mount namespaces would manage to attach that mount. At that point
it's not possible to attach that mount in another different mount
namespace again. IOW, it's fine to move it around in the same mount
namespace but it's not fine to move it _across_ mount namespaces after
it has been attached to one. Only a detached mount can be moved across
mount namespaces freely.
And fyi, your original idea wouldn't have been able to address the
use-case. Even if it would've worked you would've simply moved the same
mount between different mount points defeating the purpose of having it
available at multiple locations.
Being able to create detached mounts from detached mounts mounts enables
that use-case. Now you can distribute the same filesystem across
different mount namespaces.
next prev parent reply other threads:[~2025-10-22 7:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-06 10:38 [PATCH] man/man2/move_mount.2: document EINVAL on multiple instances luca.boccassi
2025-10-06 11:19 ` Alejandro Colomar
2025-10-06 11:32 ` Luca Boccassi
2025-10-06 11:42 ` Alejandro Colomar
2025-10-06 11:46 ` Luca Boccassi
2025-10-06 11:57 ` Alejandro Colomar
2025-10-06 12:28 ` Luca Boccassi
2025-10-06 12:37 ` Alejandro Colomar
2025-10-06 13:11 ` Alejandro Colomar
2025-10-06 13:40 ` Aleksa Sarai
2025-10-06 13:44 ` Luca Boccassi
2025-10-07 18:37 ` Aleksa Sarai
2025-10-07 18:38 ` Luca Boccassi
2025-10-12 6:14 ` Askar Safin
2025-10-12 9:40 ` Luca Boccassi
2025-10-12 11:27 ` Askar Safin
2025-10-12 12:58 ` Askar Safin
2025-10-12 13:16 ` Alejandro Colomar
2025-10-13 5:51 ` Askar Safin
2025-10-12 14:25 ` Luca Boccassi
2025-10-12 14:57 ` Alejandro Colomar
2025-10-12 18:57 ` G. Branden Robinson
2025-10-16 10:29 ` Alejandro Colomar
2025-10-13 4:14 ` Askar Safin
2025-10-22 7:36 ` Christian Brauner [this message]
2025-10-06 11:29 ` [PATCH v2] " luca.boccassi
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=20251022-oberdeck-baucontainer-221cf7218f15@brauner \
--to=brauner@kernel.org \
--cc=alx@kernel.org \
--cc=cyphar@cyphar.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=luca.boccassi@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).