v9fs: get rid of v9fs_dentry

->d_fsdata can act as hlist_head...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2013-02-28 01:13:19 -05:00
parent c4d30967f3
commit aaeb7ecfb4
3 changed files with 9 additions and 51 deletions

View file

@ -43,25 +43,9 @@
int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
{
struct v9fs_dentry *dent;
p9_debug(P9_DEBUG_VFS, "fid %d dentry %s\n",
fid->fid, dentry->d_name.name);
dent = dentry->d_fsdata;
if (!dent) {
dent = kmalloc(sizeof(struct v9fs_dentry), GFP_KERNEL);
if (!dent)
return -ENOMEM;
INIT_HLIST_HEAD(&dent->fidlist);
dentry->d_fsdata = dent;
}
spin_lock(&dentry->d_lock);
hlist_add_head(&fid->dlist, &dent->fidlist);
hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);
spin_unlock(&dentry->d_lock);
return 0;
}
@ -75,18 +59,18 @@ int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)
{
struct v9fs_dentry *dent;
struct p9_fid *fid, *ret;
p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n",
dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid),
any);
dent = (struct v9fs_dentry *) dentry->d_fsdata;
ret = NULL;
if (dent) {
/* we'll recheck under lock if there's anything to look in */
if (dentry->d_fsdata) {
struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;
struct hlist_node *n;
spin_lock(&dentry->d_lock);
hlist_for_each_entry(fid, n, &dent->fidlist, dlist) {
hlist_for_each_entry(fid, n, h, dlist) {
if (any || uid_eq(fid->uid, uid)) {
ret = fid;
break;

View file

@ -23,26 +23,6 @@
#define FS_9P_FID_H
#include <linux/list.h>
/**
* struct v9fs_dentry - 9p private data stored in dentry d_fsdata
* @fidlist: list of FIDs currently associated with this dentry
*
* This structure defines the 9p private data associated with
* a particular dentry. In particular, this private data is used
* to lookup which 9P FID handle should be used for a particular VFS
* operation. FID handles are associated with dentries instead of
* inodes in order to more closely map functionality to the Plan 9
* expected behavior for FID reclaimation and tracking.
*
* Protected by ->d_lock of dentry it belongs to.
*
* See Also: Mapping FIDs to Linux VFS model in
* Design and Implementation of the Linux 9P File System documentation
*/
struct v9fs_dentry {
struct hlist_head fidlist;
};
struct p9_fid *v9fs_fid_lookup(struct dentry *dentry);
struct p9_fid *v9fs_fid_clone(struct dentry *dentry);
int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);

View file

@ -83,18 +83,12 @@ static int v9fs_cached_dentry_delete(const struct dentry *dentry)
static void v9fs_dentry_release(struct dentry *dentry)
{
struct v9fs_dentry *dent;
struct hlist_node *p, *n;
p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n",
dentry->d_name.name, dentry);
dent = dentry->d_fsdata;
if (dent) {
struct hlist_node *p, *n;
hlist_for_each_safe(p, n, &dent->fidlist)
p9_client_clunk(hlist_entry(p, struct p9_fid, dlist));
kfree(dent);
dentry->d_fsdata = NULL;
}
hlist_for_each_safe(p, n, (struct hlist_head *)&dentry->d_fsdata)
p9_client_clunk(hlist_entry(p, struct p9_fid, dlist));
dentry->d_fsdata = NULL;
}
static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)