Skip to content

Commit

Permalink
v9fs: get rid of v9fs_dentry
Browse files Browse the repository at this point in the history
->d_fsdata can act as hlist_head...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Feb 28, 2013
1 parent c4d3096 commit aaeb7ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 51 deletions.
26 changes: 5 additions & 21 deletions fs/9p/fid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
20 changes: 0 additions & 20 deletions fs/9p/fid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 4 additions & 10 deletions fs/9p/vfs_dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aaeb7ec

Please sign in to comment.