On Sat, 27 Sep 2014 00:08:01 +0100 Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > On Wed, Sep 10, 2014 at 01:57:39PM +1000, NeilBrown wrote: > > > The d_drop();d_add(); pattern is used a number of times in NFS, but what I > > didn't notice before is that it is only used if ->d_inode is NULL. > > And the point of that "pattern" would be...? If dentry is already negative > and hashed, it does nothing whatsoever. If it is negative and unhashed, > d_drop() is a no-op, obviously. And if it's positive, we get a nice > shiny oops. > > Where are we doing anything of that sort, anyway? I see a bloody odd > instance in nfs_atomic_open() and that's it. Note that nfs_instantiate() > is different (and not necessary nice - that d_drop() in case when this > sucker is called from mkdir() is asking for races with mount()). How > do we get a positive hashed dentry there, anyway? Apart from nfs_atomic_open() and nfs_instantiate(), the main one is in _nfs4_open_and_get_state: /* FIXME: Is this d_drop() ever needed? */ d_drop(dentry); dentry = d_add_unique(dentry, igrab(state->inode)); maybe you can answer the question in the comment nfs_link also has d_drop(dentry); error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); if (error == 0) { ihold(inode); d_add(dentry, inode); } which is similar. Thanks, NeilBrown
Attachment:
pgpHiCiPuNs6N.pgp
Description: OpenPGP digital signature