From: Ram Pai <linuxram@us.ibm.com>
To: Valerie Aurora <vaurora@redhat.com>
Cc: Ram Pai <ram.n.pai@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Miklos Szeredi <miklos@szeredi.hu>,
Christoph Hellwig <hch@infradead.org>,
Andreas Gruenbacher <agruen@suse.de>,
Nick Piggin <npiggin@kernel.dk>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 03/34] VFS: Add CL_NO_SLAVE flag to clone_mnt()/copy_tree()
Date: Sun, 19 Sep 2010 22:25:53 -0700 [thread overview]
Message-ID: <20100920052553.GM8926@ram-laptop> (raw)
In-Reply-To: <20100917171514.GA32258@shell>
On Fri, Sep 17, 2010 at 01:15:14PM -0400, Valerie Aurora wrote:
> On Thu, Sep 16, 2010 at 09:34:01PM -0700, Ram Pai wrote:
> > On Thu, Sep 16, 2010 at 05:09:58PM -0700, Ram Pai wrote:
> > > On Thu, Sep 16, 2010 at 3:11 PM, Valerie Aurora <vaurora@redhat.com> wrote:
> > >
> > > > Passing the CL_NO_SLAVE flag to clone_mnt() causes the clone
> > > > to fail if the source mnt is a slave.
> > > >
> > > > Signed-off-by: Valerie Aurora <vaurora@redhat.com>
> > > > ---
> > > > fs/namespace.c | 3 +++
> > > > fs/pnode.h | 1 +
> > > > 2 files changed, 4 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/fs/namespace.c b/fs/namespace.c
> > > > index eeb4c22..6956062 100644
> > > > --- a/fs/namespace.c
> > > > +++ b/fs/namespace.c
> > > > @@ -565,6 +565,9 @@ static struct vfsmount *clone_mnt(struct vfsmount *old,
> > > > struct dentry *root,
> > > > if ((flag & CL_NO_SHARED) && (IS_MNT_SHARED(old)))
> > > > return ERR_PTR(-EINVAL);
> > > >
> > > > + if ((flag & CL_NO_SLAVE) && (IS_MNT_SLAVE(old)))
> > > > + return ERR_PTR(-EINVAL);
> > > > +
> > > >
> > >
> > >
> > > its been a while and my memory may have corroded. But I dont think this
> > > check is needed. Because cloning a 'slave mount' makes the mount a 'private
> > > mount' and not a 'slave mount'.
> >
> > There is one case where a 'slave mount' when cloned can generate a 'slave mount', and
> > that is when the 'slave mount' is also a 'shared mount'. So the above check has to
> > be
> >
> > if ((flag & CL_NO_SLAVE) && (IS_MNT_SLAVE(old) && IS_MNT_SHARED(old)))
> > return ERR_PTR(-EINVAL);
>
> Hey Ram,
>
> I added this flag for union mounts. Union mounts can't deal with
> namespace changes in the read-only layers, so we don't allow union of
> read-only mounts that are the target of propagation events (shared or
> slave).
>
> We could automatically convert all slave or shared mounts into private
> mounts when we clone the mounts, but that would surprise an
> administrator who carefully set up their shared or slave read-only
> mounts before unioning them. So instead of silently converting slave
> or shared to private, we error out. Does that make sense?
I understand your intentions, but I think you are making a wrong assumption.
You seem to be thinking that if a slave-mount is cloned, the new cloned
mount will also be a slave-mount and will hence receive propagations. As
per shared subtree semantics, a slave-mount when cloned will create a private
mount. Since your intention is to avoid generating any new mounts that
recieve propagations, you should be checking for shared-mounts and
slave-shared-mounts because these are the two kind of mounts that when
cloned create new mounts that receive propagation.
btw: slave-shared-mount is a mount that is shared and is also a slave of
a shared mount.
>
> All that being said, I debated how to do this cleanly and I'm still
> not satisfied. My goal is to both check and clone the proposed
> read-only layers in one pass. Without these flags, I had to do four
> passes:
>
> 1. Find the "lowest" read-only mount at this mountpoint.
> 2. Check each mount for read-only, not shared, not slave.
> 3. Clone the subtree starting at the "lowest" mount.
> 4. Recheck the cloned tree for rules in #2.
>
> One of the reasons I had to do it this way is that you can't hold
> vfsmount_lock while calling copy_tree(), so the mount flags can change
> between the first check in #2 and the copy_tree() in #3. Also
> sb->s_flag can change.
Isn't this whole operation done under the protection of namespace_sem?
I know that shared/slave flags can't change if the namespace_sem is held.
The same may also be true for sb->s_flag.
> One of the problems with the current code is
> that it can't deal with cloning existing union mounts, which we need
> if we are to make bind mounts work (see do_loopback()).
if I understand your union mount semantics correctly, you dont' allow the
same filesystem to be union mounted rw in two different locations. correct?
If yes, then bind mount of a union-mount has to be disallowed.
RP
>
> Anyway, if you have any ideas, I'm all ears.
>
> Thanks for reviewing,
>
> -VAL
next prev parent reply other threads:[~2010-09-20 5:25 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-16 22:11 [PATCH 00/34] Union mount core for review Valerie Aurora
2010-09-16 22:11 ` [PATCH 01/34] VFS: Make clone_mnt() and copy_tree() return error codes Valerie Aurora
2010-09-20 21:26 ` Andreas Gruenbacher
2010-09-21 18:53 ` Valerie Aurora
2010-09-30 9:51 ` Miklos Szeredi
2010-09-30 21:41 ` Valerie Aurora
2010-09-30 21:44 ` Valerie Aurora
2010-10-01 0:33 ` Ram Pai
2010-10-01 1:58 ` Ram Pai
2010-10-01 9:12 ` Szeredi Miklos
2010-10-01 18:32 ` Ram Pai
2010-10-06 18:24 ` Valerie Aurora
2010-10-12 7:41 ` Ram Pai
2010-10-06 18:31 ` Valerie Aurora
2010-10-07 9:42 ` Miklos Szeredi
2010-09-16 22:11 ` [PATCH 02/34] VFS: Add CL_NO_SHARED flag to clone_mnt()/copy_tree() Valerie Aurora
2010-09-16 22:11 ` [PATCH 03/34] VFS: Add CL_NO_SLAVE " Valerie Aurora
[not found] ` <AANLkTim1bbGrrPcFHThx3XOm8GmudQFSmFUs3NAXT5yC@mail.gmail.com>
2010-09-17 4:34 ` Ram Pai
2010-09-17 17:15 ` Valerie Aurora
2010-09-20 5:25 ` Ram Pai [this message]
2010-09-21 0:03 ` Valerie Aurora
2010-09-27 5:42 ` Ram Pai
2010-09-27 18:50 ` Valerie Aurora
2010-10-01 0:44 ` Ram Pai
2010-09-16 22:11 ` [PATCH 04/34] VFS: Add CL_MAKE_HARD_READONLY " Valerie Aurora
2010-09-16 22:11 ` [PATCH 05/34] union-mount: Union mounts documentation Valerie Aurora
2010-09-16 22:11 ` [PATCH 06/34] union-mount: Introduce MNT_UNION and MS_UNION flags Valerie Aurora
2010-09-16 22:11 ` [PATCH 07/34] union-mount: Add CONFIG_UNION_MOUNT option Valerie Aurora
2010-09-16 22:11 ` [PATCH 08/34] union-mount: Create union_stack structure Valerie Aurora
2010-09-16 22:12 ` [PATCH 09/34] union-mount: Add two superblock fields for union mounts Valerie Aurora
2010-09-16 22:12 ` [PATCH 10/34] union-mount: Add union_alloc() Valerie Aurora
2010-09-16 22:12 ` [PATCH 11/34] union-mount: Add union_find_dir() Valerie Aurora
2010-09-16 22:12 ` [PATCH 12/34] union-mount: Create d_free_unions() Valerie Aurora
2010-09-16 22:12 ` [PATCH 13/34] union-mount: Free union stack on removal of topmost dentry from dcache Valerie Aurora
2010-09-16 22:12 ` [PATCH 14/34] union-mount: Create union_add_dir() Valerie Aurora
2010-09-16 22:12 ` [PATCH 15/34] union-mount: Add union_create_topmost_dir() Valerie Aurora
2010-09-16 22:12 ` [PATCH 16/34] union-mount: Create IS_MNT_UNION() Valerie Aurora
2010-09-16 22:12 ` [PATCH 17/34] union-mount: Create needs_lookup_union() Valerie Aurora
2010-09-16 22:12 ` [PATCH 18/34] union-mount: Create check_topmost_union_mnt() Valerie Aurora
2010-09-16 22:12 ` [PATCH 19/34] union-mount: Add clone_union_tree() and put_union_sb() Valerie Aurora
2010-09-16 22:12 ` [PATCH 20/34] union-mount: Create build_root_union() Valerie Aurora
2010-09-16 22:12 ` [PATCH 21/34] union-mount: Create prepare_mnt_union() and cleanup_mnt_union() Valerie Aurora
2010-09-16 22:12 ` [PATCH 22/34] union-mount: Prevent improper union-related remounts Valerie Aurora
2010-09-16 22:12 ` [PATCH 23/34] union-mount: Prevent topmost file system from being mounted elsewhere Valerie Aurora
2010-09-30 9:37 ` Miklos Szeredi
2010-09-30 21:47 ` Valerie Aurora
2010-09-16 22:12 ` [PATCH 24/34] union-mount: Prevent bind mounts of union mounts Valerie Aurora
2010-09-16 22:12 ` [PATCH 25/34] union-mount: Implement union mount Valerie Aurora
2010-09-16 22:12 ` [PATCH 26/34] union-mount: Temporarily disable some syscalls Valerie Aurora
2010-09-16 22:12 ` [PATCH 27/34] union-mount: Basic infrastructure of __union_lookup() Valerie Aurora
2010-09-16 22:12 ` [PATCH 28/34] union-mount: Process negative dentries in __union_lookup() Valerie Aurora
2010-09-16 22:12 ` [PATCH 29/34] union-mount: Return files found in lower layers " Valerie Aurora
2010-09-16 22:12 ` [PATCH 30/34] union-mount: Build union stack in __lookup_union() Valerie Aurora
2010-09-16 22:12 ` [PATCH 31/34] union-mount: Follow mount " Valerie Aurora
2010-09-16 22:12 ` [PATCH 32/34] union-mount: Add lookup_union() wrapper for __lookup_union() Valerie Aurora
2010-09-16 22:12 ` [PATCH 33/34] union-mount: Add do_lookup_union() " Valerie Aurora
2010-09-16 22:12 ` [PATCH 34/34] union-mount: Call union lookup functions in lookup path Valerie Aurora
2010-09-21 0:02 ` [PATCH -1/34] VFS: Add hard read-only users count to superblock Valerie Aurora
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=20100920052553.GM8926@ram-laptop \
--to=linuxram@us.ibm.com \
--cc=agruen@suse.de \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=npiggin@kernel.dk \
--cc=ram.n.pai@gmail.com \
--cc=vaurora@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).