Skip to contentSkip to conversation

vfs-scale, d_revalidate from nfsd

DISCUSSION J. R. Okajima 3 participants 11 messages Jan 13, 2011 – Feb 15, 2011 VFS

lore
Share & tools
lore
#0 lore raw

NFSD calls filesystem's ->d_revalidate() with the parameter nd == NULL. So every

	if (nd->flags & LOOKUP_RCU)
		return -ECHILD;

code which was added to ->d_revalidate() of FS which supports NFS exporting will crash.

If we rewrite it as

	if (nd && (nd->flags & LOOKUP_RCU))
		return -ECHILD;

the problem may not occur.
But I am not sure whether lookup_one_len() call in NFSD support rcu-walk.

J. R. Okajima

#1 lore raw
Quoted 8 lines · J. R. Okajima

NFSD calls filesystem's ->d_revalidate() with the parameter nd == NULL. So every
       if (nd->flags & LOOKUP_RCU)
               return -ECHILD;
code which was added to ->d_revalidate() of FS which supports NFS exporting will crash.

Quoted 5 lines

If we rewrite it as
       if (nd && (nd->flags & LOOKUP_RCU))
               return -ECHILD;
the problem may not occur.
But I am not sure whether lookup_one_len() call in NFSD support rcu-walk.

Ah, good catch.

I'm going to change the d_revalidate API so it takes and inode and rcu-walk flag parameter to make it easier for filesystems to implement rcu-walk.

That will take care of this NULL nd case.

Thanks,
Nick

maintainer
#2 lore raw
Quoted 15 lines · Nick Piggin
Quoted 8 lines · J. R. Okajima

NFSD calls filesystem's ->d_revalidate() with the parameter nd == NULL. So every
? ? ? ?if (nd->flags & LOOKUP_RCU)
? ? ? ? ? ? ? ?return -ECHILD;
code which was added to ->d_revalidate() of FS which supports NFS exporting will crash.

Quoted 5 lines

If we rewrite it as
? ? ? ?if (nd && (nd->flags & LOOKUP_RCU))
? ? ? ? ? ? ? ?return -ECHILD;
the problem may not occur.
But I am not sure whether lookup_one_len() call in NFSD support rcu-walk.

Quoted 6 lines

Ah, good catch.

I'm going to change the d_revalidate API so it takes and inode and rcu-walk flag parameter to make it easier for filesystems to implement rcu-walk.

That will take care of this NULL nd case.

Oh, for fuck sake... Would you at least mind posting your API change description to fsdevel before going for it?

->d_revalidate() is one sick puppy and it's intimately involved in atomic open rewrite. Please, *please* don't make that shit even messier...

#3 lore raw
Quoted 18 lines · Al Viro
Quoted 17 lines · Nick Piggin
Quoted 8 lines · J. R. Okajima

NFSD calls filesystem's ->d_revalidate() with the parameter nd == NULL. So every
? ? ? ?if (nd->flags & LOOKUP_RCU)
? ? ? ? ? ? ? ?return -ECHILD;
code which was added to ->d_revalidate() of FS which supports NFS exporting will crash.

Quoted 5 lines

If we rewrite it as
? ? ? ?if (nd && (nd->flags & LOOKUP_RCU))
? ? ? ? ? ? ? ?return -ECHILD;
the problem may not occur.
But I am not sure whether lookup_one_len() call in NFSD support rcu-walk.

Ah, good catch.

Quoted 7 lines
Quoted 4 lines

I'm going to change the d_revalidate API so it takes and inode and rcu-walk flag parameter to make it easier for filesystems to implement rcu-walk.

That will take care of this NULL nd case.

Oh, for fuck sake...  Would you at least mind posting your API change description to fsdevel before going for it?

Of course. I was discussing it with Miklos yesterday too, but haven't finished getting a proposal together.

The main idea here would be to just pass in a flags parameter rather thank poking in nd to get the rcu-walk status. That would solve this problem and also avoid nd for most filesystems that don't care about it.

Quoted 2 lines

->d_revalidate() is one sick puppy and it's intimately involved in atomic open rewrite.  Please, *please* don't make that shit even messier...

Right, I did agree with Miklos that using nd for passing rcu-walk status was going in the wrong direction with that API. Do you agree?
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#4 lore raw
Quoted 4 lines · Nick Piggin

The main idea here would be to just pass in a flags parameter rather thank poking in nd to get the rcu-walk status. That would solve this problem and also avoid nd for most filesystems that don't care about it.

Start with nd->flags getting passed explicitly, and be ready to see
* call on the final stage of open split away and folded with
->lookup() and ->open()/->creat()
* the rest of callers to lose nd completely.
That's what's going to happen in the next cycle.

BTW, why on the earth do you have that:
static int xattr_hide_revalidate(struct dentry *dentry, struct nameidata *nd)

{
        if (nd->flags & LOOKUP_RCU)
                return -ECHILD;
        return -EPERM;
}

when the sole intent of that sucker is to have dentry of /.xattr (pinned in dcache and hashed all along) rejected on lookups from root? IOW, WTF bother with -ECHILD here at all?

maintainer
#5 lore raw
Quoted 10 lines

BTW, why on the earth do you have that:
static int xattr_hide_revalidate(struct dentry *dentry, struct nameidata *nd)

{
        if (nd->flags & LOOKUP_RCU)
                return -ECHILD;
        return -EPERM;
}

when the sole intent of that sucker is to have dentry of /.xattr (pinned in dcache and hashed all along) rejected on lookups from root? IOW, WTF bother with -ECHILD here at all?

PS: that's fs/reiserfs/xattr.c

#6 lore raw
In reply to Al Viro
Quoted 11 lines · Al Viro
Quoted 4 lines · Nick Piggin

The main idea here would be to just pass in a flags parameter rather thank poking in nd to get the rcu-walk status. That would solve this problem and also avoid nd for most filesystems that don't care about it.

Start with nd->flags getting passed explicitly, and be ready to see
       * call on the final stage of open split away and folded with ->lookup() and ->open()/->creat()
       * the rest of callers to lose nd completely. That's what's going to happen in the next cycle.

OK that sounds nice. I'll see what it looks like and definitely run any proposed API change past you and fsdevel.

Quoted 10 lines

BTW, why on the earth do you have that:
static int xattr_hide_revalidate(struct dentry *dentry, struct nameidata *nd) {
       if (nd->flags & LOOKUP_RCU)
               return -ECHILD;
       return -EPERM;
}
when the sole intent of that sucker is to have dentry of /.xattr (pinned in dcache and hashed all along) rejected on lookups from root?  IOW, WTF bother with -ECHILD here at all?

That's true. I guess I always have a weakness for doing "just one little easy optimisation/simplification" folded into patch that is supposed to be more mechanical changes :) I did have exactly that in the patch initially, but I decided it's better just to do everything with -ECHILD first.

That also gives the -ECHILD paths a bit more workout before
fs conversions are done, too.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#7 lore raw
Quoted 8 lines · Nick Piggin
Quoted 7 lines

? ? ? ?if (nd->flags & LOOKUP_RCU)
? ? ? ? ? ? ? ?return -ECHILD;
? ? ? ?return -EPERM;
}
when the sole intent of that sucker is to have dentry of /.xattr (pinned in dcache and hashed all along) rejected on lookups from root? ?IOW, WTF bother with -ECHILD here at all?

Quoted 7 lines

That's true. I guess I always have a weakness for doing "just one little easy optimisation/simplification" folded into patch that is supposed to be more mechanical changes :) I did have exactly that in the patch initially, but I decided it's better just to do everything with -ECHILD first.

That also gives the -ECHILD paths a bit more workout before fs conversions are done, too.

Not unless your test loads include trying to access pathnames like /.xattr/whatever on reiserfs and watching those attempts fail...

#8 lore raw
In reply to Nick Piggin

Nick Piggin:

Quoted 7 lines

Of course. I was discussing it with Miklos yesterday too, but haven't finished getting a proposal together.

The main idea here would be to just pass in a flags parameter rather thank poking in nd to get the rcu-walk status. That would solve this problem and also avoid nd for most filesystems that don't care about it.

Let me make sure.
- add a flag parameter to ->d_revalidate. not remove the panameter nd.
- FS ->d_revalidate() will (probably) return -ECHILD when LOOKUP_RCU is set.
Right?

Then how about the callers?
Current sequence is
- NFSD calls lookup_one_len
- __lookup_hash
- do_revalidate
- d_revalidate

{
	status = dentry->d_op->d_revalidate(dentry, nd);
	if (status == -ECHILD) {
		;;;
		status = dentry->d_op->d_revalidate(dentry, nd);
	}
}

There will be no change in NFSD but VFS d_revalidate(), such like this? VFS d_revalidate()

{
	if (nd) {
		dentry->d_op->d_revalidate(dentry, nd, nd->flags);
		if (-ECHILD) {
			dentry->d_op->d_revalidate(dentry, nd, nd->flags);
		}
	} else
		return dentry->d_op->d_revalidate(dentry, NULL, 0);
}

J. R. Okajima

#9 lore raw
Quoted 31 lines · J. R. Okajima

Nick Piggin:

Quoted 7 lines

Of course. I was discussing it with Miklos yesterday too, but haven't finished getting a proposal together.

The main idea here would be to just pass in a flags parameter rather thank poking in nd to get the rcu-walk status. That would solve this problem and also avoid nd for most filesystems that don't care about it.

Let me make sure.
- add a flag parameter to ->d_revalidate. not remove the panameter nd.
- FS ->d_revalidate() will (probably) return -ECHILD when LOOKUP_RCU is set.
Right?

Then how about the callers?
Current sequence is
- NFSD calls lookup_one_len
- __lookup_hash
- do_revalidate
- d_revalidate
{
       status = dentry->d_op->d_revalidate(dentry, nd); if (status == -ECHILD) {
               ;;;
               status = dentry->d_op->d_revalidate(dentry, nd); }
}

Quoted 11 lines

There will be no change in NFSD but VFS d_revalidate(), such like this? VFS d_revalidate()
{
       if (nd) {
               dentry->d_op->d_revalidate(dentry, nd, nd->flags); if (-ECHILD) { dentry->d_op->d_revalidate(dentry, nd, nd->flags); }
       } else
               return dentry->d_op->d_revalidate(dentry, NULL, 0); }

Yes that's the idea. I also want to pass a struct inode * parameter, to facilitate rcu-walk implementations that want to check the inode (such as fuse).

#10 lore raw
In reply to Nick Piggin

Nick Piggin:

Quoted 4 lines

On Fri, Jan 14, 2011 at 1:03 AM, J. R. Okajima <[email protected]> wrot= e:

Quoted 1 line

NFSD calls filesystem's ->d_revalidate() with the parameter nd =3D=3D NUL=

L.

	:::
Quoted 6 lines

Ah, good catch.

I'm going to change the d_revalidate API so it takes and inode and rcu-walk flag parameter to make it easier for filesystems to implement rcu-walk.

That will take care of this NULL nd case.

While you might already know there are similar parts in fs/namei.c, I'd like to write here just to make sure.

- nfsd calls lookup_one_len()
- lookup_one_len()
+ __lookup_hash() with nd=NULL
+ do_revalidate(dentry, nd)
or/and
+ d_alloc_and_lookup(base, name, nd)

- do_revalidate(dentry, nd)
+ status = d_revalidate(dentry, nd)
+ d_op->d_revalidate(dentry, nd) <-- previous mail pointed out

  + if (status < 0) {
	if (!(nd->flags & LOOKUP_RCU))	<-- this also needs fixing
		dput(dentry);
    } else {
	if (nameidata_dentry_drop_rcu_maybe(nd, dentry)) <-- and here
		return ERR_PTR(-ECHILD);
    }

And if ->d_revalidate() can return ECHILD when 'nd' is NULL, then nameidata_dentry_drop_rcu() call in d_revalidate() needs fixing too.

I don't think ->lookup(inode, dentry, nd) call in d_alloc_and_lookup() is a problem since every FS which supports NFS-exporting never refer 'nd' already.

J. R. Okajima