diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-12-18 20:55:04 +0100 |
---|---|---|
committer | Adrian Bunk <bunk@stusta.de> | 2006-12-18 20:55:04 +0100 |
commit | 1488da2060a943584163df47a51d25c708e88b1a (patch) | |
tree | d91b1f18be8c13137cbbd105d7313152bbb7a1e7 /fs | |
parent | e634599b5e6b766634a77b2e05a492c08b32a3a5 (diff) |
NFS: nfs_lookup - don't hash dentry when optimising away the lookup
If the open intents tell us that a given lookup is going to result in a,
exclusive create, we currently optimize away the lookup call itself. The
reason is that the lookup would not be atomic with the create RPC call, so
why do it in the first place?
A problem occurs, however, if the VFS aborts the exclusive create operation
after the lookup, but before the call to create the file/directory: in this
case we will end up with a hashed negative dentry in the dcache that has
never been looked up.
Fix this by only actually hashing the dentry once the create operation has
been successfully completed.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/dir.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index a1554bead692..0087a0da3c65 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -854,9 +854,15 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru lock_kernel(); - /* If we're doing an exclusive create, optimize away the lookup */ - if (nfs_is_exclusive_create(dir, nd)) - goto no_entry; + /* + * If we're doing an exclusive create, optimize away the lookup + * but don't hash the dentry. + */ + if (nfs_is_exclusive_create(dir, nd)) { + d_instantiate(dentry, NULL); + res = NULL; + goto out_unlock; + } error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr); if (error == -ENOENT) @@ -1100,6 +1106,8 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle, if (inode == NULL) goto out_err; d_instantiate(dentry, inode); + if (d_unhashed(dentry)) + d_rehash(dentry); return 0; out_err: d_drop(dentry); |