Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

v9fs: get rid of v9fs_dentry

->d_fsdata can act as hlist_head...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro aaeb7ecf c4d30967

+9 -51
+5 -21
fs/9p/fid.c
··· 43 43 44 44 int 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 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 48 spin_unlock(&dentry->d_lock); 64 - 65 49 return 0; 66 50 } 67 51 ··· 59 75 60 76 static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) 61 77 { 62 - struct v9fs_dentry *dent; 63 78 struct p9_fid *fid, *ret; 64 79 65 80 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n", 66 81 dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid), 67 82 any); 68 - dent = (struct v9fs_dentry *) dentry->d_fsdata; 69 83 ret = NULL; 70 - if (dent) { 84 + /* we'll recheck under lock if there's anything to look in */ 85 + if (dentry->d_fsdata) { 86 + struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata; 71 87 struct hlist_node *n; 72 88 spin_lock(&dentry->d_lock); 73 - hlist_for_each_entry(fid, n, &dent->fidlist, dlist) { 89 + hlist_for_each_entry(fid, n, h, dlist) { 74 90 if (any || uid_eq(fid->uid, uid)) { 75 91 ret = fid; 76 92 break;
-20
fs/9p/fid.h
··· 23 23 #define FS_9P_FID_H 24 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 - */ 42 - struct v9fs_dentry { 43 - struct hlist_head fidlist; 44 - }; 45 - 46 26 struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); 47 27 struct p9_fid *v9fs_fid_clone(struct dentry *dentry); 48 28 int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);
+4 -10
fs/9p/vfs_dentry.c
··· 83 83 84 84 static void v9fs_dentry_release(struct dentry *dentry) 85 85 { 86 - struct v9fs_dentry *dent; 86 + struct hlist_node *p, *n; 87 87 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n", 88 88 dentry->d_name.name, dentry); 89 - dent = dentry->d_fsdata; 90 - if (dent) { 91 - struct hlist_node *p, *n; 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 - } 89 + hlist_for_each_safe(p, n, (struct hlist_head *)&dentry->d_fsdata) 90 + p9_client_clunk(hlist_entry(p, struct p9_fid, dlist)); 91 + dentry->d_fsdata = NULL; 98 92 } 99 93 100 94 static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)