···43434444int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)4545{4646- struct v9fs_dentry *dent;4747-4848- p9_debug(P9_DEBUG_VFS, "fid %d dentry %s\n",4949- fid->fid, dentry->d_name.name);5050-5151- dent = dentry->d_fsdata;5252- if (!dent) {5353- dent = kmalloc(sizeof(struct v9fs_dentry), GFP_KERNEL);5454- if (!dent)5555- return -ENOMEM;5656-5757- INIT_HLIST_HEAD(&dent->fidlist);5858- dentry->d_fsdata = dent;5959- }6060-6146 spin_lock(&dentry->d_lock);6262- hlist_add_head(&fid->dlist, &dent->fidlist);4747+ hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);6348 spin_unlock(&dentry->d_lock);6464-6549 return 0;6650}6751···59756076static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)6177{6262- struct v9fs_dentry *dent;6378 struct p9_fid *fid, *ret;64796580 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n",6681 dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid),6782 any);6868- dent = (struct v9fs_dentry *) dentry->d_fsdata;6983 ret = NULL;7070- if (dent) {8484+ /* we'll recheck under lock if there's anything to look in */8585+ if (dentry->d_fsdata) {8686+ struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;7187 struct hlist_node *n;7288 spin_lock(&dentry->d_lock);7373- hlist_for_each_entry(fid, n, &dent->fidlist, dlist) {8989+ hlist_for_each_entry(fid, n, h, dlist) {7490 if (any || uid_eq(fid->uid, uid)) {7591 ret = fid;7692 break;
-20
fs/9p/fid.h
···2323#define FS_9P_FID_H2424#include <linux/list.h>25252626-/**2727- * struct v9fs_dentry - 9p private data stored in dentry d_fsdata2828- * @fidlist: list of FIDs currently associated with this dentry2929- *3030- * This structure defines the 9p private data associated with3131- * a particular dentry. In particular, this private data is used3232- * to lookup which 9P FID handle should be used for a particular VFS3333- * operation. FID handles are associated with dentries instead of3434- * inodes in order to more closely map functionality to the Plan 93535- * expected behavior for FID reclaimation and tracking.3636- *3737- * Protected by ->d_lock of dentry it belongs to.3838- *3939- * See Also: Mapping FIDs to Linux VFS model in4040- * Design and Implementation of the Linux 9P File System documentation4141- */4242-struct v9fs_dentry {4343- struct hlist_head fidlist;4444-};4545-4626struct p9_fid *v9fs_fid_lookup(struct dentry *dentry);4727struct p9_fid *v9fs_fid_clone(struct dentry *dentry);4828int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);