aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-02-28 01:13:19 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-28 01:13:19 -0500
commitaaeb7ecfb48ad4c8942a26874322d8918524a04f (patch)
treeae2e0dbd1cb3a199e9fd92786a0da2ba810a42ef
parentc4d30967f3020cda9df9ee22af79cd1f2c284244 (diff)
v9fs: get rid of v9fs_dentry
->d_fsdata can act as hlist_head... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/9p/fid.c26
-rw-r--r--fs/9p/fid.h20
-rw-r--r--fs/9p/vfs_dentry.c14
3 files changed, 9 insertions, 51 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index 49de4264db9a..ddf618936d8a 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -43,25 +43,9 @@
43 43
44int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) 44int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
45{ 45{
46 struct v9fs_dentry *dent;
47
48 p9_debug(P9_DEBUG_VFS, "fid %d dentry %s\n",
49 fid->fid, dentry->d_name.name);
50
51 dent = dentry->d_fsdata;
52 if (!dent) {
53 dent = kmalloc(sizeof(struct v9fs_dentry), GFP_KERNEL);
54 if (!dent)
55 return -ENOMEM;
56
57 INIT_HLIST_HEAD(&dent->fidlist);
58 dentry->d_fsdata = dent;
59 }
60
61 spin_lock(&dentry->d_lock); 46 spin_lock(&dentry->d_lock);
62 hlist_add_head(&fid->dlist, &dent->fidlist); 47 hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);
63 spin_unlock(&dentry->d_lock); 48 spin_unlock(&dentry->d_lock);
64
65 return 0; 49 return 0;
66} 50}
67 51
@@ -75,18 +59,18 @@ int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
75 59
76static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) 60static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)
77{ 61{
78 struct v9fs_dentry *dent;
79 struct p9_fid *fid, *ret; 62 struct p9_fid *fid, *ret;
80 63
81 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n", 64 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n",
82 dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid), 65 dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid),
83 any); 66 any);
84 dent = (struct v9fs_dentry *) dentry->d_fsdata;
85 ret = NULL; 67 ret = NULL;
86 if (dent) { 68 /* we'll recheck under lock if there's anything to look in */
69 if (dentry->d_fsdata) {
70 struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;
87 struct hlist_node *n; 71 struct hlist_node *n;
88 spin_lock(&dentry->d_lock); 72 spin_lock(&dentry->d_lock);
89 hlist_for_each_entry(fid, n, &dent->fidlist, dlist) { 73 hlist_for_each_entry(fid, n, h, dlist) {
90 if (any || uid_eq(fid->uid, uid)) { 74 if (any || uid_eq(fid->uid, uid)) {
91 ret = fid; 75 ret = fid;
92 break; 76 break;
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index 86eeb34ce46f..377eb6f2e7f7 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -23,26 +23,6 @@
23#define FS_9P_FID_H 23#define FS_9P_FID_H
24#include <linux/list.h> 24#include <linux/list.h>
25 25
26/**
27 * struct v9fs_dentry - 9p private data stored in dentry d_fsdata
28 * @fidlist: list of FIDs currently associated with this dentry
29 *
30 * This structure defines the 9p private data associated with
31 * a particular dentry. In particular, this private data is used
32 * to lookup which 9P FID handle should be used for a particular VFS
33 * operation. FID handles are associated with dentries instead of
34 * inodes in order to more closely map functionality to the Plan 9
35 * expected behavior for FID reclaimation and tracking.
36 *
37 * Protected by ->d_lock of dentry it belongs to.
38 *
39 * See Also: Mapping FIDs to Linux VFS model in
40 * Design and Implementation of the Linux 9P File System documentation
41 */
42struct v9fs_dentry {
43 struct hlist_head fidlist;
44};
45
46struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); 26struct p9_fid *v9fs_fid_lookup(struct dentry *dentry);
47struct p9_fid *v9fs_fid_clone(struct dentry *dentry); 27struct p9_fid *v9fs_fid_clone(struct dentry *dentry);
48int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); 28int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index fcd49833ef80..f039b104a98e 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -83,18 +83,12 @@ static int v9fs_cached_dentry_delete(const struct dentry *dentry)
83 83
84static void v9fs_dentry_release(struct dentry *dentry) 84static void v9fs_dentry_release(struct dentry *dentry)
85{ 85{
86 struct v9fs_dentry *dent; 86 struct hlist_node *p, *n;
87 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n", 87 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n",
88 dentry->d_name.name, dentry); 88 dentry->d_name.name, dentry);
89 dent = dentry->d_fsdata; 89 hlist_for_each_safe(p, n, (struct hlist_head *)&dentry->d_fsdata)
90 if (dent) { 90 p9_client_clunk(hlist_entry(p, struct p9_fid, dlist));
91 struct hlist_node *p, *n; 91 dentry->d_fsdata = NULL;
92 hlist_for_each_safe(p, n, &dent->fidlist)
93 p9_client_clunk(hlist_entry(p, struct p9_fid, dlist));
94
95 kfree(dent);
96 dentry->d_fsdata = NULL;
97 }
98} 92}
99 93
100static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags) 94static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)