Re: [PATCH 10/13] VFS/namei: handle LOOKUP_RCU in page_follow_link_light.

From: NeilBrown
Date: Thu Mar 19 2015 - 18:39:21 EST


On Mon, 16 Mar 2015 22:50:40 +0000 Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:

> On Mon, Mar 16, 2015 at 03:43:20PM +1100, NeilBrown wrote:
> > + char *kaddr;
> > + struct page *page;
> > + struct address_space *mapping = dentry->d_inode->i_mapping;
>
> Who said that dentry->d_inode hasn't gone NULL by that point?
>
> > + nd_terminate_link(kaddr, dentry->d_inode->i_size, PAGE_SIZE - 1);
>
> ... or changed here. Again, dentry->d_inode is stable only if you are
> holding a reference to dentry. That's why we have those dances around
> nd->inode, for example. Doing unlazy_walk() is enough to stabilize the
> damn thing, so currently ->follow_link() doesn't have to worry about it.
> With your changes, though...

Ahhh - that's what nd->inode is for. I wondered.

Am I correct in thinking that dentry->d_inode can only become NULL - it cannot
then become some other inode?

In that case the various follow_link methods that are sufficiently atomic for
rcu-walk just need something like:

struct inode *inode = dentry->d_inode;

if (!inode)
return -ECHILD;

If ->d_inode can become another inode, then I suspect we need to pass the
inode as well as the dentry to ->follow_link.


Thanks,
NeilBrown

Attachment: pgpe0a6KnMsTV.pgp
Description: OpenPGP digital signature