]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
v9fs: get rid of v9fs_dentry
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 28 Feb 2013 06:13:19 +0000 (01:13 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 28 Feb 2013 06:13:19 +0000 (01:13 -0500)
->d_fsdata can act as hlist_head...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/9p/fid.c
fs/9p/fid.h
fs/9p/vfs_dentry.c

index 49de4264db9a82463928f11e3def17e4068de575..ddf618936d8a2ca21cb5b309294bd397dbc7e1c6 100644 (file)
 
 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;
index 86eeb34ce46f4c564799a583b5bd4ffbd1dbe83d..377eb6f2e7f70fb9a65407b238ef6c1dbdff4091 100644 (file)
 #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);
index fcd49833ef80179800dedb718ca8dbefd4f3a97a..f039b104a98e9093cadfb62b040a604628a76b7a 100644 (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)