Re: [PATCH 03/13] VFS: remove nameidata args from ->follow_link and ->put_link

From: Al Viro
Date: Mon Mar 16 2015 - 16:47:40 EST


On Mon, Mar 16, 2015 at 03:43:19PM +1100, NeilBrown wrote:
> Now that current->nameidata is available, nd_set_link() and
> nd_get_link() can use that directly, so 'nd' doesn't need to
> be passed through ->follow_link and ->put_link.

FWIW, I would rather pass nd_get_link(nd) to ->put_link() instead of nd.
Note that that's the only thing instances were ever using nd for; what's more,
that's the only thing nd_get_link() is ever used for outside of fs/namei.c,
so with that change it could become static in fs/namei.c. After such change
we would have it used in
* follow_link(). We have nd right there.
* put_link(). Ditto.
* generic_readlink(). Again, nd is right there (and we obviously
only need to call nd_get_link() once).
Hell, it can even become static inline...

> nd->last_type = LAST_BIND;
> - *p = dentry->d_inode->i_op->follow_link(dentry, nd);
> + *p = dentry->d_inode->i_op->follow_link(dentry, nd->flags);

I'm not sure if it's a good idea to expose all flags here - it's really
asking for somebody trying to be "smart" and acting differently depending
on what we are doing pathname resolution for/where in lookup we are/etc.
nd->flags & LOOKUP_RCU might be less tempting.

> @@ -4458,13 +4464,13 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
> int res;
>
> nd.depth = 0;
> - cookie = dentry->d_inode->i_op->follow_link(dentry, &nd);
> + cookie = dentry->d_inode->i_op->follow_link(dentry, nd.flags);

...(dentry, 0); nd.flags is uninitialized, for pity sake...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/