Commit 5e608671 authored by Al Viro's avatar Al Viro

9p: if v9fs_fid_lookup() gets to asking server, it'd better have hashed dentry

... otherwise the path we'd built isn't worth much.  Don't accept such fids
obtained from paths unless dentry is still alived by the end of the work.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent a3b2157e
...@@ -41,10 +41,15 @@ ...@@ -41,10 +41,15 @@
* *
*/ */
static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid)
{
hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);
}
void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
{ {
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata); __add_fid(dentry, fid);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
} }
...@@ -198,8 +203,17 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, ...@@ -198,8 +203,17 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
} }
kfree(wnames); kfree(wnames);
fid_out: fid_out:
if (!IS_ERR(fid)) if (!IS_ERR(fid)) {
v9fs_fid_add(dentry, fid); spin_lock(&dentry->d_lock);
if (d_unhashed(dentry)) {
spin_unlock(&dentry->d_lock);
p9_client_clunk(fid);
fid = ERR_PTR(-ENOENT);
} else {
__add_fid(dentry, fid);
spin_unlock(&dentry->d_lock);
}
}
err_out: err_out:
up_read(&v9ses->rename_sem); up_read(&v9ses->rename_sem);
return fid; return fid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment