mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-03 00:54:09 +08:00
NFS: remove BUG possibility in nfs4_open_and_get_state
commit4fa2c54b51
NFS: nfs4_do_open should add negative results to the dcache. used "d_drop(); d_add();" to ensure that a dentry was hashed as a negative cached entry. This is not safe if the dentry has an non-NULL ->d_inode. It will trigger a BUG_ON in d_instantiate(). In that case, d_delete() is needed. Also, only d_add if the dentry is currently unhashed, it seems pointless removed and re-adding it unchanged. Reported-by: Christoph Hellwig <hch@infradead.org> Fixes:4fa2c54b51
Cc: Jeff Layton <jeff.layton@primarydata.com> Link: http://lkml.kernel.org/r/20140908144525.GB19811@infradead.org Signed-off-by: NeilBrown <neilb@suse.de> Acked-by: Jeff Layton <jlayton@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:
parent
224ecbf5a6
commit
f39c010479
@ -2226,9 +2226,13 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
|
||||
ret = _nfs4_proc_open(opendata);
|
||||
if (ret != 0) {
|
||||
if (ret == -ENOENT) {
|
||||
d_drop(opendata->dentry);
|
||||
d_add(opendata->dentry, NULL);
|
||||
nfs_set_verifier(opendata->dentry,
|
||||
dentry = opendata->dentry;
|
||||
if (dentry->d_inode)
|
||||
d_delete(dentry);
|
||||
else if (d_unhashed(dentry))
|
||||
d_add(dentry, NULL);
|
||||
|
||||
nfs_set_verifier(dentry,
|
||||
nfs_save_change_attribute(opendata->dir->d_inode));
|
||||
}
|
||||
goto out;
|
||||
|
Loading…
Reference in New Issue
Block a user