linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ram <linuxram@us.ibm.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	viro@parcelfarce.linux.theplanet.co.uk,
	Andrew Morton <akpm@osdl.org>,
	mike@waychison.com, bfields@fieldses.org
Subject: Re: [RFC PATCH 1/8] share/private/slave a subtree
Date: Fri, 08 Jul 2005 09:19:29 -0700	[thread overview]
Message-ID: <1120839568.30164.88.camel@localhost> (raw)
In-Reply-To: <E1Dqttu-0004kx-00@dorka.pomaz.szeredi.hu>

On Fri, 2005-07-08 at 07:32, Miklos Szeredi wrote:
> > This patch adds the shared/private/slave support for VFS trees.
> 
> [...]
> 
> > -struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
> > +struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, struct dentry *root)
> >  {
> 
> How about changing it to inline and calling it __lookup_mnt_root(),
> and calling it from lookup_mnt() (which could keep the old signature)
> and lookup_mnt_root().  That way the compiler can optimize away the
> root check for the plain lookup_mnt() case, and there's no need to
> modify callers of lookup_mnt().
> 
> [...]


ok. 

> 
> >  
> > +struct vfsmount *do_make_mounted(struct vfsmount *mnt, struct dentry *dentry)
> > +{
> 
> What does this function do?  Can we have a header comment?

This function does the equivalent of 'mount --bind dir dir'
It  creates a new child vfsmount at that dentry, and moves
the children vfsmounts below that dentry, under the newly created child
vfsmount.  There is a header comment for that function. But it got
into the 2nd patch.

> 
> > +int
> > +_do_make_mounted(struct nameidata *nd, struct vfsmount **mnt)
> > +{
> 
> Ditto.

This function returns immeditely if a vfsmount already exists at the
dentry. Otherwise it creates a vfsmount at the specified dentry, and if
the dentry belongs to shared vfsmount it ensures the same
operation is done on all peer vfsmounts to which propogation
is set.


> 
> > +/*
> > + * recursively change the type of the mountpoint.
> > + */
> > +static int do_change_type(struct nameidata *nd, int flag)
> > +{
> > +	struct vfsmount *m, *mnt;
> > +	struct vfspnode *old_pnode = NULL;
> > +	int err;
> > +
> > +	if (!(flag & MS_SHARED) && !(flag & MS_PRIVATE)
> > +			&& !(flag & MS_SLAVE))
> > +		return -EINVAL;
> > +
> > +	if ((err = _do_make_mounted(nd, &mnt)))
> > +		return err;
> 
> 
> Why does this opertation do any mounting?  If it's a type change, it
> should just change the type of something already mounted, no?

apart from changing types, it has to create a new vfsmount if one
does not exist at that point. 

> 
> > +		case MS_SHARED:
> > +			/*
> > +			 * if the mount is already a slave mount,
> > +			 * allocated a new pnode and make it
> > +			 * a slave pnode of the original pnode.
> > +			 */
> > +			if (IS_MNT_SLAVE(m)) {
> > +				old_pnode = m->mnt_pnode;
> > +				pnode_del_slave_mnt(m);
> > +			}
> > +			if(!IS_MNT_SHARED(m)) {
> > +				m->mnt_pnode = pnode_alloc();
> > +				if(!m->mnt_pnode) {
> > +					pnode_add_slave_mnt(old_pnode, m);
> > +					err = -ENOMEM;
> > +					break;
> > +				}
> > +				pnode_add_member_mnt(m->mnt_pnode, m);
> > +			}
> > +			if(old_pnode) {
> > +				pnode_add_slave_pnode(old_pnode,
> > +						m->mnt_pnode);
> > +			}
> > +			SET_MNT_SHARED(m);
> > +			break;
> > +
> > +		case MS_SLAVE:
> > +			if (IS_MNT_SLAVE(m)) {
> > +				break;
> > +			}
> > +			/*
> > +			 * only shared mounts can
> > +			 * be made slave
> > +			 */
> > +			if (!IS_MNT_SHARED(m)) {
> > +				err = -EINVAL;
> > +				break;
> > +			}
> > +			old_pnode = m->mnt_pnode;
> > +			pnode_del_member_mnt(m);
> > +			pnode_add_slave_mnt(old_pnode, m);
> > +			SET_MNT_SLAVE(m);
> > +			break;
> > +
> > +		case MS_PRIVATE:
> > +			if(m->mnt_pnode)
> > +				pnode_disassociate_mnt(m);
> > +			SET_MNT_PRIVATE(m);
> > +			break;
> > +
> 
> Can this be split into three functions?

yes. will do.

> 
> [...]
> 
> > +/*
> > + * Walk the pnode tree for each pnode encountered.  A given pnode in the tree
> > + * can be returned a minimum of 2 times.  First time the pnode is encountered,
> > + * it is returned with the flag PNODE_DOWN. Everytime the pnode is encountered
> > + * after having traversed through each of its children, it is returned with the
> > + * flag PNODE_MID.  And finally when the pnode is encountered after having
> > + * walked all of its children, it is returned with the flag PNODE_UP.
> > + *
> > + * @context: provides context on the state of the last walk in the pnode
> > + * 		tree.
> > + */
> > +static int inline
> > +pnode_next(struct pcontext *context)
> > +{
> 
> Is such a generic traversal function really needed?  Why?

Yes. I found it useful to write generic code without having to worry
about the details of the traversal being duplicated everywhere.  Do you
have better suggestion? This function is the equivalent of next_mnt()
for traversing pnode trees.



> 
> [...]
> 
> > +struct vfsmount *
> > +pnode_make_mounted(struct vfspnode *pnode, struct vfsmount *mnt, struct dentry *dentry)
> > +{
> 
> Again a header comment would be nice, on what exactly this function
> does.  Also the implementation is really cryptic, but I can't even
> start to decipher without knowing what it's supposed to do.

yes. this function takes care of traversing the propogation tree and
creating a child vfsmount for dentries in each vfsmount encountered.
In other words it calls do_make_mounted() for each vfsmount that belongs
to the propogation tree.


> 
> [...]
> 
> > +static inline struct vfspnode *
> > +get_pnode_n(struct vfspnode *pnode, size_t n)
> > +{
> 
> Seems to be unused throughout the patch series

Yes. will delete it. Initially thought I would need it.


> > +	struct list_head mnt_pnode_mntlist;/* and going through their
> > +					   pnode's vfsmount */
> > +	struct vfspnode *mnt_pnode;	/* and going through their
> > +					   pnode's vfsmount */
> >  	atomic_t mnt_count;
> >  	int mnt_flags;
> >  	int mnt_expiry_mark;		/* true if marked for expiry */
> > @@ -38,6 +66,7 @@ struct vfsmount
> >  	struct namespace *mnt_namespace; /* containing namespace */
> >  };
> >  
> > +
> >  static inline struct vfsmount *mntget(struct vfsmount *mnt)
> 
> Please don't add empty lines.

ok.

RP
> 
> Miklos

  reply	other threads:[~2005-07-08 16:19 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1120816072.30164.10.camel@localhost>
2005-07-08 10:25 ` [RFC PATCH 0/8] shared subtree Ram
     [not found] ` <1120816229.30164.13.camel@localhost>
2005-07-08 10:25   ` [RFC PATCH 1/8] share/private/slave a subtree Ram
2005-07-08 11:17     ` Pekka Enberg
2005-07-08 12:19       ` Roman Zippel
2005-07-08 12:26         ` Pekka J Enberg
2005-07-08 12:46           ` Roman Zippel
2005-07-08 12:58             ` Pekka J Enberg
2005-07-08 13:34               ` Roman Zippel
2005-07-08 16:17                 ` Pekka Enberg
2005-07-08 16:33                 ` share/private/slave a subtree - define vs enum Bryan Henderson
2005-07-08 16:57                   ` Roman Zippel
2005-07-08 17:16                     ` Bryan Henderson
2005-07-08 18:21                       ` Pekka J Enberg
2005-07-08 19:11                         ` Roman Zippel
2005-07-08 19:33                           ` Pekka Enberg
2005-07-08 19:59                             ` Roman Zippel
2005-07-10 18:21                               ` Pekka Enberg
2005-07-10 18:40                                 ` randy_dunlap
2005-07-10 19:14                                 ` Roman Zippel
2005-07-11  6:37                                   ` Pekka J Enberg
2005-07-11 17:13                                   ` Horst von Brand
2005-07-11 17:57                                     ` Roman Zippel
2005-07-10 19:16                                 ` Vojtech Pavlik
2005-07-11 17:18                                   ` Horst von Brand
2005-07-08 19:38                           ` Ram
2005-07-08 22:12                         ` Bryan Henderson
2005-07-10 10:55                     ` Denis Vlasenko
2005-07-08 18:03                   ` Wichert Akkerman
2005-07-08 18:10                     ` Mike Waychison
2005-07-08 18:15                       ` Wichert Akkerman
2005-07-08 20:23                         ` Mike Waychison
2005-07-10 21:57                           ` Pavel Machek
2005-07-08 16:29       ` [RFC PATCH 1/8] share/private/slave a subtree Ram
2005-07-08 14:32     ` Miklos Szeredi
2005-07-08 16:19       ` Ram [this message]
2005-07-08 16:51         ` Miklos Szeredi
2005-07-08 17:52           ` Ram
2005-07-08 19:49             ` Miklos Szeredi
2005-07-14  1:27               ` Ram
2005-07-18 11:06                 ` shared subtrees implementation writeup Miklos Szeredi
2005-07-18 17:18                   ` Ram Pai
     [not found]   ` <1120816355.30164.16.camel@localhost>
2005-07-08 10:25     ` [RFC PATCH 2/8] unclone a subtree Ram
     [not found]     ` <1120816436.30164.19.camel@localhost>
2005-07-08 10:25       ` [RFC PATCH 3/8] bind/rbind a shared/private/slave/unclone tree Ram
     [not found]       ` <1120816521.30164.22.camel@localhost>
2005-07-08 10:25         ` [RFC PATCH 4/8] move " Ram
     [not found]         ` <1120816600.30164.25.camel@localhost>
2005-07-08 10:25           ` [RFC PATCH 5/8] umount " Ram
     [not found]           ` <1120816720.30164.28.camel@localhost>
2005-07-08 10:26             ` [RFC PATCH 6/8] clone a namespace containing " Ram
     [not found]             ` <1120816835.30164.31.camel@localhost>
2005-07-08 10:26               ` [RFC PATCH 7/8] automounter support for shared/slave/private/unclone Ram
2005-07-08 10:26                 ` [RFC PATCH 8/8] pnode.c optimization Ram

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=1120839568.30164.88.camel@localhost \
    --to=linuxram@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=bfields@fieldses.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike@waychison.com \
    --cc=miklos@szeredi.hu \
    --cc=viro@parcelfarce.linux.theplanet.co.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).