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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag '9p-for-5.20' of https://github.com/martinetd/linux

Pull 9p updates from Dominique Martinet:

- a couple of fixes

- add a tracepoint for fid refcounting

- some cleanup/followup on fid lookup

- some cleanup around req refcounting

* tag '9p-for-5.20' of https://github.com/martinetd/linux:
net/9p: Initialize the iounit field during fid creation
net: 9p: fix refcount leak in p9_read_work() error handling
9p: roll p9_tag_remove into p9_req_put
9p: Add client parameter to p9_req_put()
9p: Drop kref usage
9p: Fix some kernel-doc comments
9p fid refcount: cleanup p9_fid_put calls
9p fid refcount: add a 9p_fid_ref tracepoint
9p fid refcount: add p9_fid_get/put wrappers
9p: Fix minor typo in code comment
9p: Remove unnecessary variable for old fids while walking from d_parent
9p: Make the path walk logic more clear about when cloning is required
9p: Track the root fid with its own variable during lookups

+314 -245
+35 -26
fs/9p/fid.c
··· 28 28 /** 29 29 * v9fs_fid_add - add a fid to a dentry 30 30 * @dentry: dentry that the fid is being added to 31 - * @fid: fid to add 31 + * @pfid: fid to add, NULLed out 32 32 * 33 33 */ 34 - void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) 34 + void v9fs_fid_add(struct dentry *dentry, struct p9_fid **pfid) 35 35 { 36 + struct p9_fid *fid = *pfid; 37 + 36 38 spin_lock(&dentry->d_lock); 37 39 __add_fid(dentry, fid); 38 40 spin_unlock(&dentry->d_lock); 41 + 42 + *pfid = NULL; 39 43 } 40 44 41 45 /** ··· 60 56 h = (struct hlist_head *)&inode->i_private; 61 57 hlist_for_each_entry(fid, h, ilist) { 62 58 if (uid_eq(fid->uid, uid)) { 63 - refcount_inc(&fid->count); 59 + p9_fid_get(fid); 64 60 ret = fid; 65 61 break; 66 62 } ··· 72 68 /** 73 69 * v9fs_open_fid_add - add an open fid to an inode 74 70 * @inode: inode that the fid is being added to 75 - * @fid: fid to add 71 + * @pfid: fid to add, NULLed out 76 72 * 77 73 */ 78 74 79 - void v9fs_open_fid_add(struct inode *inode, struct p9_fid *fid) 75 + void v9fs_open_fid_add(struct inode *inode, struct p9_fid **pfid) 80 76 { 77 + struct p9_fid *fid = *pfid; 78 + 81 79 spin_lock(&inode->i_lock); 82 80 hlist_add_head(&fid->ilist, (struct hlist_head *)&inode->i_private); 83 81 spin_unlock(&inode->i_lock); 82 + 83 + *pfid = NULL; 84 84 } 85 85 86 86 ··· 112 104 hlist_for_each_entry(fid, h, dlist) { 113 105 if (any || uid_eq(fid->uid, uid)) { 114 106 ret = fid; 115 - refcount_inc(&ret->count); 107 + p9_fid_get(ret); 116 108 break; 117 109 } 118 110 } ··· 158 150 { 159 151 struct dentry *ds; 160 152 const unsigned char **wnames, *uname; 161 - int i, n, l, clone, access; 153 + int i, n, l, access; 162 154 struct v9fs_session_info *v9ses; 163 - struct p9_fid *fid, *old_fid; 155 + struct p9_fid *fid, *root_fid, *old_fid; 164 156 165 157 v9ses = v9fs_dentry2v9ses(dentry); 166 158 access = v9ses->flags & V9FS_ACCESS_MASK; ··· 177 169 fid = v9fs_fid_find(ds, uid, any); 178 170 if (fid) { 179 171 /* Found the parent fid do a lookup with that */ 180 - struct p9_fid *ofid = fid; 172 + old_fid = fid; 181 173 182 - fid = p9_client_walk(ofid, 1, &dentry->d_name.name, 1); 183 - p9_client_clunk(ofid); 174 + fid = p9_client_walk(old_fid, 1, &dentry->d_name.name, 1); 175 + p9_fid_put(old_fid); 184 176 goto fid_out; 185 177 } 186 178 up_read(&v9ses->rename_sem); 187 179 188 180 /* start from the root and try to do a lookup */ 189 - fid = v9fs_fid_find(dentry->d_sb->s_root, uid, any); 190 - if (!fid) { 181 + root_fid = v9fs_fid_find(dentry->d_sb->s_root, uid, any); 182 + if (!root_fid) { 191 183 /* the user is not attached to the fs yet */ 192 184 if (access == V9FS_ACCESS_SINGLE) 193 185 return ERR_PTR(-EPERM); ··· 202 194 if (IS_ERR(fid)) 203 195 return fid; 204 196 205 - refcount_inc(&fid->count); 206 - v9fs_fid_add(dentry->d_sb->s_root, fid); 197 + root_fid = p9_fid_get(fid); 198 + v9fs_fid_add(dentry->d_sb->s_root, &fid); 207 199 } 208 200 /* If we are root ourself just return that */ 209 201 if (dentry->d_sb->s_root == dentry) 210 - return fid; 202 + return root_fid; 203 + 211 204 /* 212 205 * Do a multipath walk with attached root. 213 206 * When walking parent we need to make sure we ··· 220 211 fid = ERR_PTR(n); 221 212 goto err_out; 222 213 } 223 - old_fid = fid; 224 - clone = 1; 214 + fid = root_fid; 215 + old_fid = root_fid; 225 216 i = 0; 226 217 while (i < n) { 227 218 l = min(n - i, P9_MAXWELEM); 228 219 /* 229 220 * We need to hold rename lock when doing a multipath 230 - * walk to ensure none of the patch component change 221 + * walk to ensure none of the path components change 231 222 */ 232 - fid = p9_client_walk(fid, l, &wnames[i], clone); 223 + fid = p9_client_walk(old_fid, l, &wnames[i], 224 + old_fid == root_fid /* clone */); 233 225 /* non-cloning walk will return the same fid */ 234 226 if (fid != old_fid) { 235 - p9_client_clunk(old_fid); 227 + p9_fid_put(old_fid); 236 228 old_fid = fid; 237 229 } 238 230 if (IS_ERR(fid)) { ··· 241 231 goto err_out; 242 232 } 243 233 i += l; 244 - clone = 0; 245 234 } 246 235 kfree(wnames); 247 236 fid_out: ··· 248 239 spin_lock(&dentry->d_lock); 249 240 if (d_unhashed(dentry)) { 250 241 spin_unlock(&dentry->d_lock); 251 - p9_client_clunk(fid); 242 + p9_fid_put(fid); 252 243 fid = ERR_PTR(-ENOENT); 253 244 } else { 254 245 __add_fid(dentry, fid); 255 - refcount_inc(&fid->count); 246 + p9_fid_get(fid); 256 247 spin_unlock(&dentry->d_lock); 257 248 } 258 249 } ··· 309 300 fid = clone_fid(ofid); 310 301 if (IS_ERR(fid)) 311 302 goto error_out; 312 - p9_client_clunk(ofid); 303 + p9_fid_put(ofid); 313 304 /* 314 305 * writeback fid will only be used to write back the 315 306 * dirty pages. We always request for the open fid in read-write ··· 318 309 */ 319 310 err = p9_client_open(fid, O_RDWR); 320 311 if (err < 0) { 321 - p9_client_clunk(fid); 312 + p9_fid_put(fid); 322 313 fid = ERR_PTR(err); 323 314 goto error_out; 324 315 }
+3 -3
fs/9p/fid.h
··· 13 13 { 14 14 return v9fs_fid_lookup(dentry->d_parent); 15 15 } 16 - void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); 16 + void v9fs_fid_add(struct dentry *dentry, struct p9_fid **fid); 17 17 struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); 18 - void v9fs_open_fid_add(struct inode *inode, struct p9_fid *fid); 18 + void v9fs_open_fid_add(struct inode *inode, struct p9_fid **fid); 19 19 static inline struct p9_fid *clone_fid(struct p9_fid *fid) 20 20 { 21 21 return IS_ERR(fid) ? fid : p9_client_walk(fid, 0, NULL, 1); ··· 29 29 return fid; 30 30 31 31 nfid = clone_fid(fid); 32 - p9_client_clunk(fid); 32 + p9_fid_put(fid); 33 33 return nfid; 34 34 } 35 35 #endif
+2 -2
fs/9p/vfs_addr.c
··· 73 73 BUG_ON(!fid); 74 74 } 75 75 76 - refcount_inc(&fid->count); 76 + p9_fid_get(fid); 77 77 rreq->netfs_priv = fid; 78 78 return 0; 79 79 } ··· 86 86 { 87 87 struct p9_fid *fid = rreq->netfs_priv; 88 88 89 - p9_client_clunk(fid); 89 + p9_fid_put(fid); 90 90 } 91 91 92 92 /**
+2 -2
fs/9p/vfs_dentry.c
··· 54 54 p9_debug(P9_DEBUG_VFS, " dentry: %pd (%p)\n", 55 55 dentry, dentry); 56 56 hlist_for_each_safe(p, n, (struct hlist_head *)&dentry->d_fsdata) 57 - p9_client_clunk(hlist_entry(p, struct p9_fid, dlist)); 57 + p9_fid_put(hlist_entry(p, struct p9_fid, dlist)); 58 58 dentry->d_fsdata = NULL; 59 59 } 60 60 ··· 85 85 retval = v9fs_refresh_inode_dotl(fid, inode); 86 86 else 87 87 retval = v9fs_refresh_inode(fid, inode); 88 - p9_client_clunk(fid); 88 + p9_fid_put(fid); 89 89 90 90 if (retval == -ENOENT) 91 91 return 0;
+1 -1
fs/9p/vfs_dir.c
··· 218 218 spin_lock(&inode->i_lock); 219 219 hlist_del(&fid->ilist); 220 220 spin_unlock(&inode->i_lock); 221 - p9_client_clunk(fid); 221 + p9_fid_put(fid); 222 222 } 223 223 224 224 if ((filp->f_mode & FMODE_WRITE)) {
+5 -4
fs/9p/vfs_file.c
··· 63 63 64 64 err = p9_client_open(fid, omode); 65 65 if (err < 0) { 66 - p9_client_clunk(fid); 66 + p9_fid_put(fid); 67 67 return err; 68 68 } 69 69 if ((file->f_flags & O_APPEND) && 70 70 (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses))) 71 71 generic_file_llseek(file, 0, SEEK_END); 72 + 73 + file->private_data = fid; 72 74 } 73 75 74 - file->private_data = fid; 75 76 mutex_lock(&v9inode->v_mutex); 76 77 if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) && 77 78 !v9inode->writeback_fid && ··· 96 95 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) 97 96 fscache_use_cookie(v9fs_inode_cookie(v9inode), 98 97 file->f_mode & FMODE_WRITE); 99 - v9fs_open_fid_add(inode, fid); 98 + v9fs_open_fid_add(inode, &fid); 100 99 return 0; 101 100 out_error: 102 - p9_client_clunk(file->private_data); 101 + p9_fid_put(file->private_data); 103 102 file->private_data = NULL; 104 103 return err; 105 104 }
+38 -51
fs/9p/vfs_inode.c
··· 399 399 400 400 fscache_relinquish_cookie(v9fs_inode_cookie(v9inode), false); 401 401 /* clunk the fid stashed in writeback_fid */ 402 - if (v9inode->writeback_fid) { 403 - p9_client_clunk(v9inode->writeback_fid); 404 - v9inode->writeback_fid = NULL; 405 - } 402 + p9_fid_put(v9inode->writeback_fid); 403 + v9inode->writeback_fid = NULL; 406 404 } 407 405 408 406 static int v9fs_test_inode(struct inode *inode, void *data) ··· 567 569 if (v9fs_proto_dotl(v9ses)) 568 570 retval = p9_client_unlinkat(dfid, dentry->d_name.name, 569 571 v9fs_at_to_dotl_flags(flags)); 570 - p9_client_clunk(dfid); 572 + p9_fid_put(dfid); 571 573 if (retval == -EOPNOTSUPP) { 572 574 /* Try the one based on path */ 573 575 v9fid = v9fs_fid_clone(dentry); ··· 631 633 if (IS_ERR(ofid)) { 632 634 err = PTR_ERR(ofid); 633 635 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); 634 - p9_client_clunk(dfid); 635 - return ERR_PTR(err); 636 + goto error; 636 637 } 637 638 638 639 err = p9_client_fcreate(ofid, name, perm, mode, extension); 639 640 if (err < 0) { 640 641 p9_debug(P9_DEBUG_VFS, "p9_client_fcreate failed %d\n", err); 641 - p9_client_clunk(dfid); 642 642 goto error; 643 643 } 644 644 ··· 647 651 err = PTR_ERR(fid); 648 652 p9_debug(P9_DEBUG_VFS, 649 653 "p9_client_walk failed %d\n", err); 650 - fid = NULL; 651 - p9_client_clunk(dfid); 652 654 goto error; 653 655 } 654 656 /* ··· 657 663 err = PTR_ERR(inode); 658 664 p9_debug(P9_DEBUG_VFS, 659 665 "inode creation failed %d\n", err); 660 - p9_client_clunk(dfid); 661 666 goto error; 662 667 } 663 - v9fs_fid_add(dentry, fid); 668 + v9fs_fid_add(dentry, &fid); 664 669 d_instantiate(dentry, inode); 665 670 } 666 - p9_client_clunk(dfid); 671 + p9_fid_put(dfid); 667 672 return ofid; 668 673 error: 669 - if (ofid) 670 - p9_client_clunk(ofid); 671 - 672 - if (fid) 673 - p9_client_clunk(fid); 674 - 674 + p9_fid_put(dfid); 675 + p9_fid_put(ofid); 676 + p9_fid_put(fid); 675 677 return ERR_PTR(err); 676 678 } 677 679 ··· 698 708 return PTR_ERR(fid); 699 709 700 710 v9fs_invalidate_inode_attr(dir); 701 - p9_client_clunk(fid); 711 + p9_fid_put(fid); 702 712 703 713 return 0; 704 714 } ··· 734 744 } 735 745 736 746 if (fid) 737 - p9_client_clunk(fid); 747 + p9_fid_put(fid); 738 748 739 749 return err; 740 750 } ··· 775 785 */ 776 786 name = dentry->d_name.name; 777 787 fid = p9_client_walk(dfid, 1, &name, 1); 778 - p9_client_clunk(dfid); 788 + p9_fid_put(dfid); 779 789 if (fid == ERR_PTR(-ENOENT)) 780 790 inode = NULL; 781 791 else if (IS_ERR(fid)) ··· 794 804 res = d_splice_alias(inode, dentry); 795 805 if (!IS_ERR(fid)) { 796 806 if (!res) 797 - v9fs_fid_add(dentry, fid); 807 + v9fs_fid_add(dentry, &fid); 798 808 else if (!IS_ERR(res)) 799 - v9fs_fid_add(res, fid); 809 + v9fs_fid_add(res, &fid); 800 810 else 801 - p9_client_clunk(fid); 811 + p9_fid_put(fid); 802 812 } 803 813 return res; 804 814 } ··· 837 847 v9fs_proto_dotu(v9ses))); 838 848 if (IS_ERR(fid)) { 839 849 err = PTR_ERR(fid); 840 - fid = NULL; 841 850 goto error; 842 851 } 843 852 ··· 871 882 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) 872 883 fscache_use_cookie(v9fs_inode_cookie(v9inode), 873 884 file->f_mode & FMODE_WRITE); 874 - v9fs_open_fid_add(inode, fid); 885 + v9fs_open_fid_add(inode, &fid); 875 886 876 887 file->f_mode |= FMODE_CREATED; 877 888 out: ··· 879 890 return err; 880 891 881 892 error: 882 - if (fid) 883 - p9_client_clunk(fid); 893 + p9_fid_put(fid); 884 894 goto out; 885 895 } 886 896 ··· 927 939 struct inode *old_inode; 928 940 struct inode *new_inode; 929 941 struct v9fs_session_info *v9ses; 930 - struct p9_fid *oldfid, *dfid; 931 - struct p9_fid *olddirfid; 932 - struct p9_fid *newdirfid; 942 + struct p9_fid *oldfid = NULL, *dfid = NULL; 943 + struct p9_fid *olddirfid = NULL; 944 + struct p9_fid *newdirfid = NULL; 933 945 struct p9_wstat wstat; 934 946 935 947 if (flags) ··· 946 958 947 959 dfid = v9fs_parent_fid(old_dentry); 948 960 olddirfid = clone_fid(dfid); 949 - if (dfid && !IS_ERR(dfid)) 950 - p9_client_clunk(dfid); 961 + p9_fid_put(dfid); 962 + dfid = NULL; 951 963 952 964 if (IS_ERR(olddirfid)) { 953 965 retval = PTR_ERR(olddirfid); 954 - goto done; 966 + goto error; 955 967 } 956 968 957 969 dfid = v9fs_parent_fid(new_dentry); 958 970 newdirfid = clone_fid(dfid); 959 - p9_client_clunk(dfid); 971 + p9_fid_put(dfid); 972 + dfid = NULL; 960 973 961 974 if (IS_ERR(newdirfid)) { 962 975 retval = PTR_ERR(newdirfid); 963 - goto clunk_olddir; 976 + goto error; 964 977 } 965 978 966 979 down_write(&v9ses->rename_sem); ··· 972 983 retval = p9_client_rename(oldfid, newdirfid, 973 984 new_dentry->d_name.name); 974 985 if (retval != -EOPNOTSUPP) 975 - goto clunk_newdir; 986 + goto error_locked; 976 987 } 977 988 if (old_dentry->d_parent != new_dentry->d_parent) { 978 989 /* ··· 981 992 982 993 p9_debug(P9_DEBUG_ERROR, "old dir and new dir are different\n"); 983 994 retval = -EXDEV; 984 - goto clunk_newdir; 995 + goto error_locked; 985 996 } 986 997 v9fs_blank_wstat(&wstat); 987 998 wstat.muid = v9ses->uname; 988 999 wstat.name = new_dentry->d_name.name; 989 1000 retval = p9_client_wstat(oldfid, &wstat); 990 1001 991 - clunk_newdir: 1002 + error_locked: 992 1003 if (!retval) { 993 1004 if (new_inode) { 994 1005 if (S_ISDIR(new_inode->i_mode)) ··· 1009 1020 d_move(old_dentry, new_dentry); 1010 1021 } 1011 1022 up_write(&v9ses->rename_sem); 1012 - p9_client_clunk(newdirfid); 1013 1023 1014 - clunk_olddir: 1015 - p9_client_clunk(olddirfid); 1016 - 1017 - done: 1018 - p9_client_clunk(oldfid); 1024 + error: 1025 + p9_fid_put(newdirfid); 1026 + p9_fid_put(olddirfid); 1027 + p9_fid_put(oldfid); 1019 1028 return retval; 1020 1029 } 1021 1030 ··· 1047 1060 return PTR_ERR(fid); 1048 1061 1049 1062 st = p9_client_stat(fid); 1050 - p9_client_clunk(fid); 1063 + p9_fid_put(fid); 1051 1064 if (IS_ERR(st)) 1052 1065 return PTR_ERR(st); 1053 1066 ··· 1123 1136 retval = p9_client_wstat(fid, &wstat); 1124 1137 1125 1138 if (use_dentry) 1126 - p9_client_clunk(fid); 1139 + p9_fid_put(fid); 1127 1140 1128 1141 if (retval < 0) 1129 1142 return retval; ··· 1248 1261 return ERR_CAST(fid); 1249 1262 1250 1263 st = p9_client_stat(fid); 1251 - p9_client_clunk(fid); 1264 + p9_fid_put(fid); 1252 1265 if (IS_ERR(st)) 1253 1266 return ERR_CAST(st); 1254 1267 ··· 1295 1308 return PTR_ERR(fid); 1296 1309 1297 1310 v9fs_invalidate_inode_attr(dir); 1298 - p9_client_clunk(fid); 1311 + p9_fid_put(fid); 1299 1312 return 0; 1300 1313 } 1301 1314 ··· 1351 1364 v9fs_refresh_inode(oldfid, d_inode(old_dentry)); 1352 1365 v9fs_invalidate_inode_attr(dir); 1353 1366 } 1354 - p9_client_clunk(oldfid); 1367 + p9_fid_put(oldfid); 1355 1368 return retval; 1356 1369 } 1357 1370
+30 -52
fs/9p/vfs_inode_dotl.c
··· 238 238 struct inode *inode; 239 239 struct p9_fid *fid = NULL; 240 240 struct v9fs_inode *v9inode; 241 - struct p9_fid *dfid, *ofid, *inode_fid; 241 + struct p9_fid *dfid = NULL, *ofid = NULL, *inode_fid = NULL; 242 242 struct v9fs_session_info *v9ses; 243 243 struct posix_acl *pacl = NULL, *dacl = NULL; 244 244 struct dentry *res = NULL; ··· 274 274 if (IS_ERR(ofid)) { 275 275 err = PTR_ERR(ofid); 276 276 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); 277 - p9_client_clunk(dfid); 278 277 goto out; 279 278 } 280 279 ··· 285 286 if (err) { 286 287 p9_debug(P9_DEBUG_VFS, "Failed to get acl values in creat %d\n", 287 288 err); 288 - p9_client_clunk(dfid); 289 - goto error; 289 + goto out; 290 290 } 291 291 err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags), 292 292 mode, gid, &qid); 293 293 if (err < 0) { 294 294 p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in creat %d\n", 295 295 err); 296 - p9_client_clunk(dfid); 297 - goto error; 296 + goto out; 298 297 } 299 298 v9fs_invalidate_inode_attr(dir); 300 299 301 300 /* instantiate inode and assign the unopened fid to the dentry */ 302 301 fid = p9_client_walk(dfid, 1, &name, 1); 303 - p9_client_clunk(dfid); 304 302 if (IS_ERR(fid)) { 305 303 err = PTR_ERR(fid); 306 304 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); 307 - fid = NULL; 308 - goto error; 305 + goto out; 309 306 } 310 307 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 311 308 if (IS_ERR(inode)) { 312 309 err = PTR_ERR(inode); 313 310 p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", err); 314 - goto error; 311 + goto out; 315 312 } 316 313 /* Now set the ACL based on the default value */ 317 314 v9fs_set_create_acl(inode, fid, dacl, pacl); 318 315 319 - v9fs_fid_add(dentry, fid); 316 + v9fs_fid_add(dentry, &fid); 320 317 d_instantiate(dentry, inode); 321 318 322 319 v9inode = V9FS_I(inode); ··· 331 336 if (IS_ERR(inode_fid)) { 332 337 err = PTR_ERR(inode_fid); 333 338 mutex_unlock(&v9inode->v_mutex); 334 - goto err_clunk_old_fid; 339 + goto out; 335 340 } 336 341 v9inode->writeback_fid = (void *) inode_fid; 337 342 } ··· 339 344 /* Since we are opening a file, assign the open fid to the file */ 340 345 err = finish_open(file, dentry, generic_file_open); 341 346 if (err) 342 - goto err_clunk_old_fid; 347 + goto out; 343 348 file->private_data = ofid; 344 349 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) 345 350 fscache_use_cookie(v9fs_inode_cookie(v9inode), 346 351 file->f_mode & FMODE_WRITE); 347 - v9fs_open_fid_add(inode, ofid); 352 + v9fs_open_fid_add(inode, &ofid); 348 353 file->f_mode |= FMODE_CREATED; 349 354 out: 355 + p9_fid_put(dfid); 356 + p9_fid_put(ofid); 357 + p9_fid_put(fid); 350 358 v9fs_put_acl(dacl, pacl); 351 359 dput(res); 352 360 return err; 353 - 354 - error: 355 - if (fid) 356 - p9_client_clunk(fid); 357 - err_clunk_old_fid: 358 - if (ofid) 359 - p9_client_clunk(ofid); 360 - goto out; 361 361 } 362 362 363 363 /** ··· 390 400 if (IS_ERR(dfid)) { 391 401 err = PTR_ERR(dfid); 392 402 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 393 - dfid = NULL; 394 403 goto error; 395 404 } 396 405 ··· 411 422 err = PTR_ERR(fid); 412 423 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", 413 424 err); 414 - fid = NULL; 415 425 goto error; 416 426 } 417 427 ··· 423 435 err); 424 436 goto error; 425 437 } 426 - v9fs_fid_add(dentry, fid); 438 + v9fs_fid_add(dentry, &fid); 427 439 v9fs_set_create_acl(inode, fid, dacl, pacl); 428 440 d_instantiate(dentry, inode); 429 - fid = NULL; 430 441 err = 0; 431 442 } else { 432 443 /* ··· 444 457 inc_nlink(dir); 445 458 v9fs_invalidate_inode_attr(dir); 446 459 error: 447 - if (fid) 448 - p9_client_clunk(fid); 460 + p9_fid_put(fid); 449 461 v9fs_put_acl(dacl, pacl); 450 - p9_client_clunk(dfid); 462 + p9_fid_put(dfid); 451 463 return err; 452 464 } 453 465 ··· 475 489 */ 476 490 477 491 st = p9_client_getattr_dotl(fid, P9_STATS_ALL); 478 - p9_client_clunk(fid); 492 + p9_fid_put(fid); 479 493 if (IS_ERR(st)) 480 494 return PTR_ERR(st); 481 495 ··· 589 603 retval = p9_client_setattr(fid, &p9attr); 590 604 if (retval < 0) { 591 605 if (use_dentry) 592 - p9_client_clunk(fid); 606 + p9_fid_put(fid); 593 607 return retval; 594 608 } 595 609 ··· 605 619 retval = v9fs_acl_chmod(inode, fid); 606 620 if (retval < 0) { 607 621 if (use_dentry) 608 - p9_client_clunk(fid); 622 + p9_fid_put(fid); 609 623 return retval; 610 624 } 611 625 } 612 626 if (use_dentry) 613 - p9_client_clunk(fid); 627 + p9_fid_put(fid); 614 628 615 629 return 0; 616 630 } ··· 729 743 err = PTR_ERR(fid); 730 744 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", 731 745 err); 732 - fid = NULL; 733 746 goto error; 734 747 } 735 748 ··· 740 755 err); 741 756 goto error; 742 757 } 743 - v9fs_fid_add(dentry, fid); 758 + v9fs_fid_add(dentry, &fid); 744 759 d_instantiate(dentry, inode); 745 - fid = NULL; 746 760 err = 0; 747 761 } else { 748 762 /* Not in cached mode. No need to populate inode with stat */ ··· 754 770 } 755 771 756 772 error: 757 - if (fid) 758 - p9_client_clunk(fid); 759 - 760 - p9_client_clunk(dfid); 773 + p9_fid_put(fid); 774 + p9_fid_put(dfid); 761 775 return err; 762 776 } 763 777 ··· 785 803 786 804 oldfid = v9fs_fid_lookup(old_dentry); 787 805 if (IS_ERR(oldfid)) { 788 - p9_client_clunk(dfid); 806 + p9_fid_put(dfid); 789 807 return PTR_ERR(oldfid); 790 808 } 791 809 792 810 err = p9_client_link(dfid, oldfid, dentry->d_name.name); 793 811 794 - p9_client_clunk(dfid); 795 - p9_client_clunk(oldfid); 812 + p9_fid_put(dfid); 813 + p9_fid_put(oldfid); 796 814 if (err < 0) { 797 815 p9_debug(P9_DEBUG_VFS, "p9_client_link failed %d\n", err); 798 816 return err; ··· 808 826 return PTR_ERR(fid); 809 827 810 828 v9fs_refresh_inode_dotl(fid, d_inode(old_dentry)); 811 - p9_client_clunk(fid); 829 + p9_fid_put(fid); 812 830 } 813 831 ihold(d_inode(old_dentry)); 814 832 d_instantiate(dentry, d_inode(old_dentry)); ··· 848 866 if (IS_ERR(dfid)) { 849 867 err = PTR_ERR(dfid); 850 868 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 851 - dfid = NULL; 852 869 goto error; 853 870 } 854 871 ··· 872 891 err = PTR_ERR(fid); 873 892 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", 874 893 err); 875 - fid = NULL; 876 894 goto error; 877 895 } 878 896 ··· 885 905 goto error; 886 906 } 887 907 v9fs_set_create_acl(inode, fid, dacl, pacl); 888 - v9fs_fid_add(dentry, fid); 908 + v9fs_fid_add(dentry, &fid); 889 909 d_instantiate(dentry, inode); 890 - fid = NULL; 891 910 err = 0; 892 911 } else { 893 912 /* ··· 902 923 d_instantiate(dentry, inode); 903 924 } 904 925 error: 905 - if (fid) 906 - p9_client_clunk(fid); 926 + p9_fid_put(fid); 907 927 v9fs_put_acl(dacl, pacl); 908 - p9_client_clunk(dfid); 928 + p9_fid_put(dfid); 909 929 910 930 return err; 911 931 } ··· 934 956 if (IS_ERR(fid)) 935 957 return ERR_CAST(fid); 936 958 retval = p9_client_readlink(fid, &target); 937 - p9_client_clunk(fid); 959 + p9_fid_put(fid); 938 960 if (retval) 939 961 return ERR_PTR(retval); 940 962 set_delayed_call(done, kfree_link, target);
+4 -4
fs/9p/vfs_super.c
··· 184 184 retval = v9fs_get_acl(inode, fid); 185 185 if (retval) 186 186 goto release_sb; 187 - v9fs_fid_add(root, fid); 187 + v9fs_fid_add(root, &fid); 188 188 189 189 p9_debug(P9_DEBUG_VFS, " simple set mount, return 0\n"); 190 190 return dget(sb->s_root); 191 191 192 192 clunk_fid: 193 - p9_client_clunk(fid); 193 + p9_fid_put(fid); 194 194 v9fs_session_close(v9ses); 195 195 free_session: 196 196 kfree(v9ses); ··· 203 203 * attached the fid to dentry so it won't get clunked 204 204 * automatically. 205 205 */ 206 - p9_client_clunk(fid); 206 + p9_fid_put(fid); 207 207 deactivate_locked_super(sb); 208 208 return ERR_PTR(retval); 209 209 } ··· 270 270 } 271 271 res = simple_statfs(dentry, buf); 272 272 done: 273 - p9_client_clunk(fid); 273 + p9_fid_put(fid); 274 274 return res; 275 275 } 276 276
+4 -4
fs/9p/xattr.c
··· 44 44 if (err) 45 45 retval = err; 46 46 } 47 - p9_client_clunk(attr_fid); 47 + p9_fid_put(attr_fid); 48 48 return retval; 49 49 } 50 50 ··· 71 71 if (IS_ERR(fid)) 72 72 return PTR_ERR(fid); 73 73 ret = v9fs_fid_xattr_get(fid, name, buffer, buffer_size); 74 - p9_client_clunk(fid); 74 + p9_fid_put(fid); 75 75 76 76 return ret; 77 77 } ··· 98 98 if (IS_ERR(fid)) 99 99 return PTR_ERR(fid); 100 100 ret = v9fs_fid_xattr_set(fid, name, value, value_len, flags); 101 - p9_client_clunk(fid); 101 + p9_fid_put(fid); 102 102 return ret; 103 103 } 104 104 ··· 128 128 retval); 129 129 else 130 130 p9_client_write(fid, 0, &from, &retval); 131 - err = p9_client_clunk(fid); 131 + err = p9_fid_put(fid); 132 132 if (!retval && err) 133 133 retval = err; 134 134 return retval;
+45 -4
include/net/9p/client.h
··· 11 11 12 12 #include <linux/utsname.h> 13 13 #include <linux/idr.h> 14 + #include <linux/tracepoint-defs.h> 14 15 15 16 /* Number of requests per row */ 16 17 #define P9_ROW_MAXTAG 255 ··· 77 76 struct p9_req_t { 78 77 int status; 79 78 int t_err; 80 - struct kref refcount; 79 + refcount_t refcount; 81 80 wait_queue_head_t wq; 82 81 struct p9_fcall tc; 83 82 struct p9_fcall rc; ··· 228 227 229 228 static inline void p9_req_get(struct p9_req_t *r) 230 229 { 231 - kref_get(&r->refcount); 230 + refcount_inc(&r->refcount); 232 231 } 233 232 234 233 static inline int p9_req_try_get(struct p9_req_t *r) 235 234 { 236 - return kref_get_unless_zero(&r->refcount); 235 + return refcount_inc_not_zero(&r->refcount); 237 236 } 238 237 239 - int p9_req_put(struct p9_req_t *r); 238 + int p9_req_put(struct p9_client *c, struct p9_req_t *r); 239 + 240 + /* We cannot have the real tracepoints in header files, 241 + * use a wrapper function */ 242 + DECLARE_TRACEPOINT(9p_fid_ref); 243 + void do_trace_9p_fid_get(struct p9_fid *fid); 244 + void do_trace_9p_fid_put(struct p9_fid *fid); 245 + 246 + /* fid reference counting helpers: 247 + * - fids used for any length of time should always be referenced through 248 + * p9_fid_get(), and released with p9_fid_put() 249 + * - v9fs_fid_lookup() or similar will automatically call get for you 250 + * and also require a put 251 + * - the *_fid_add() helpers will stash the fid in the inode, 252 + * at which point it is the responsibility of evict_inode() 253 + * to call the put 254 + * - the last put will automatically send a clunk to the server 255 + */ 256 + static inline struct p9_fid *p9_fid_get(struct p9_fid *fid) 257 + { 258 + if (tracepoint_enabled(9p_fid_ref)) 259 + do_trace_9p_fid_get(fid); 260 + 261 + refcount_inc(&fid->count); 262 + 263 + return fid; 264 + } 265 + 266 + static inline int p9_fid_put(struct p9_fid *fid) 267 + { 268 + if (!fid || IS_ERR(fid)) 269 + return 0; 270 + 271 + if (tracepoint_enabled(9p_fid_ref)) 272 + do_trace_9p_fid_put(fid); 273 + 274 + if (!refcount_dec_and_test(&fid->count)) 275 + return 0; 276 + 277 + return p9_client_clunk(fid); 278 + } 240 279 241 280 void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status); 242 281
+48
include/trace/events/9p.h
··· 77 77 EM( P9_TWSTAT, "P9_TWSTAT" ) \ 78 78 EMe(P9_RWSTAT, "P9_RWSTAT" ) 79 79 80 + 81 + #define P9_FID_REFTYPE \ 82 + EM( P9_FID_REF_CREATE, "create " ) \ 83 + EM( P9_FID_REF_GET, "get " ) \ 84 + EM( P9_FID_REF_PUT, "put " ) \ 85 + EMe(P9_FID_REF_DESTROY, "destroy" ) 86 + 80 87 /* Define EM() to export the enums to userspace via TRACE_DEFINE_ENUM() */ 81 88 #undef EM 82 89 #undef EMe ··· 91 84 #define EMe(a, b) TRACE_DEFINE_ENUM(a); 92 85 93 86 P9_MSG_T 87 + P9_FID_REFTYPE 88 + 89 + /* And also use EM/EMe to define helper enums -- once */ 90 + #ifndef __9P_DECLARE_TRACE_ENUMS_ONLY_ONCE 91 + #define __9P_DECLARE_TRACE_ENUMS_ONLY_ONCE 92 + #undef EM 93 + #undef EMe 94 + #define EM(a, b) a, 95 + #define EMe(a, b) a 96 + 97 + enum p9_fid_reftype { 98 + P9_FID_REFTYPE 99 + } __mode(byte); 100 + 101 + #endif 94 102 95 103 /* 96 104 * Now redefine the EM() and EMe() macros to map the enums to the strings ··· 118 96 119 97 #define show_9p_op(type) \ 120 98 __print_symbolic(type, P9_MSG_T) 99 + #define show_9p_fid_reftype(type) \ 100 + __print_symbolic(type, P9_FID_REFTYPE) 121 101 122 102 TRACE_EVENT(9p_client_req, 123 103 TP_PROTO(struct p9_client *clnt, int8_t type, int tag), ··· 191 167 (unsigned long)__entry->clnt, show_9p_op(__entry->type), 192 168 __entry->tag, 0, __entry->line, 16, __entry->line + 16) 193 169 ); 170 + 171 + 172 + TRACE_EVENT(9p_fid_ref, 173 + TP_PROTO(struct p9_fid *fid, __u8 type), 174 + 175 + TP_ARGS(fid, type), 176 + 177 + TP_STRUCT__entry( 178 + __field( int, fid ) 179 + __field( int, refcount ) 180 + __field( __u8, type ) 181 + ), 182 + 183 + TP_fast_assign( 184 + __entry->fid = fid->fid; 185 + __entry->refcount = refcount_read(&fid->count); 186 + __entry->type = type; 187 + ), 188 + 189 + TP_printk("%s fid %d, refcount %d", 190 + show_9p_fid_reftype(__entry->type), 191 + __entry->fid, __entry->refcount) 192 + ); 193 + 194 194 195 195 #endif /* _TRACE_9P_H */ 196 196
+86 -82
net/9p/client.c
··· 298 298 /* Init ref to two because in the general case there is one ref 299 299 * that is put asynchronously by a writer thread, one ref 300 300 * temporarily given by p9_tag_lookup and put by p9_client_cb 301 - * in the recv thread, and one ref put by p9_tag_remove in the 301 + * in the recv thread, and one ref put by p9_req_put in the 302 302 * main thread. The only exception is virtio that does not use 303 303 * p9_tag_lookup but does not have a writer thread either 304 304 * (the write happens synchronously in the request/zc_request 305 305 * callback), so p9_client_cb eats the second ref there 306 306 * as the pointer is duplicated directly by virtqueue_add_sgs() 307 307 */ 308 - refcount_set(&req->refcount.refcount, 2); 308 + refcount_set(&req->refcount, 2); 309 309 310 310 return req; 311 311 ··· 341 341 if (!p9_req_try_get(req)) 342 342 goto again; 343 343 if (req->tc.tag != tag) { 344 - p9_req_put(req); 344 + p9_req_put(c, req); 345 345 goto again; 346 346 } 347 347 } ··· 358 358 * 359 359 * Context: Any context. 360 360 */ 361 - static int p9_tag_remove(struct p9_client *c, struct p9_req_t *r) 361 + static void p9_tag_remove(struct p9_client *c, struct p9_req_t *r) 362 362 { 363 363 unsigned long flags; 364 364 u16 tag = r->tc.tag; 365 365 366 - p9_debug(P9_DEBUG_MUX, "clnt %p req %p tag: %d\n", c, r, tag); 366 + p9_debug(P9_DEBUG_MUX, "freeing clnt %p req %p tag: %d\n", c, r, tag); 367 367 spin_lock_irqsave(&c->lock, flags); 368 368 idr_remove(&c->reqs, tag); 369 369 spin_unlock_irqrestore(&c->lock, flags); 370 - return p9_req_put(r); 371 370 } 372 371 373 - static void p9_req_free(struct kref *ref) 372 + int p9_req_put(struct p9_client *c, struct p9_req_t *r) 374 373 { 375 - struct p9_req_t *r = container_of(ref, struct p9_req_t, refcount); 374 + if (refcount_dec_and_test(&r->refcount)) { 375 + p9_tag_remove(c, r); 376 376 377 - p9_fcall_fini(&r->tc); 378 - p9_fcall_fini(&r->rc); 379 - kmem_cache_free(p9_req_cache, r); 380 - } 381 - 382 - int p9_req_put(struct p9_req_t *r) 383 - { 384 - return kref_put(&r->refcount, p9_req_free); 377 + p9_fcall_fini(&r->tc); 378 + p9_fcall_fini(&r->rc); 379 + kmem_cache_free(p9_req_cache, r); 380 + return 1; 381 + } 382 + return 0; 385 383 } 386 384 EXPORT_SYMBOL(p9_req_put); 387 385 ··· 398 400 rcu_read_lock(); 399 401 idr_for_each_entry(&c->reqs, req, id) { 400 402 pr_info("Tag %d still in use\n", id); 401 - if (p9_tag_remove(c, req) == 0) 403 + if (p9_req_put(c, req) == 0) 402 404 pr_warn("Packet with tag %d has still references", 403 405 req->tc.tag); 404 406 } ··· 424 426 425 427 wake_up(&req->wq); 426 428 p9_debug(P9_DEBUG_MUX, "wakeup: %d\n", req->tc.tag); 427 - p9_req_put(req); 429 + p9_req_put(c, req); 428 430 } 429 431 EXPORT_SYMBOL(p9_client_cb); 430 432 ··· 587 589 c->trans_mod->cancelled(c, oldreq); 588 590 } 589 591 590 - p9_tag_remove(c, req); 592 + p9_req_put(c, req); 591 593 return 0; 592 594 } 593 595 ··· 621 623 trace_9p_client_req(c, type, req->tc.tag); 622 624 return req; 623 625 reterr: 624 - p9_tag_remove(c, req); 626 + p9_req_put(c, req); 625 627 /* We have to put also the 2nd reference as it won't be used */ 626 - p9_req_put(req); 628 + p9_req_put(c, req); 627 629 return ERR_PTR(err); 628 630 } 629 631 ··· 633 635 * @type: type of request 634 636 * @fmt: protocol format string (see protocol.c) 635 637 * 636 - * Returns request structure (which client must free using p9_tag_remove) 638 + * Returns request structure (which client must free using p9_req_put) 637 639 */ 638 640 639 641 static struct p9_req_t * ··· 660 662 err = c->trans_mod->request(c, req); 661 663 if (err < 0) { 662 664 /* write won't happen */ 663 - p9_req_put(req); 665 + p9_req_put(c, req); 664 666 if (err != -ERESTARTSYS && err != -EFAULT) 665 667 c->status = Disconnected; 666 668 goto recalc_sigpending; ··· 711 713 if (!err) 712 714 return req; 713 715 reterr: 714 - p9_tag_remove(c, req); 716 + p9_req_put(c, req); 715 717 return ERR_PTR(safe_errno(err)); 716 718 } 717 719 ··· 726 728 * @in_hdrlen: reader header size, This is the size of response protocol data 727 729 * @fmt: protocol format string (see protocol.c) 728 730 * 729 - * Returns request structure (which client must free using p9_tag_remove) 731 + * Returns request structure (which client must free using p9_req_put) 730 732 */ 731 733 static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type, 732 734 struct iov_iter *uidata, ··· 793 795 if (!err) 794 796 return req; 795 797 reterr: 796 - p9_tag_remove(c, req); 798 + p9_req_put(c, req); 797 799 return ERR_PTR(safe_errno(err)); 798 800 } 799 801 ··· 803 805 struct p9_fid *fid; 804 806 805 807 p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt); 806 - fid = kmalloc(sizeof(*fid), GFP_KERNEL); 808 + fid = kzalloc(sizeof(*fid), GFP_KERNEL); 807 809 if (!fid) 808 810 return NULL; 809 811 810 - memset(&fid->qid, 0, sizeof(fid->qid)); 811 812 fid->mode = -1; 812 813 fid->uid = current_fsuid(); 813 814 fid->clnt = clnt; 814 - fid->rdir = NULL; 815 - fid->fid = 0; 816 815 refcount_set(&fid->count, 1); 817 816 818 817 idr_preload(GFP_KERNEL); ··· 818 823 GFP_NOWAIT); 819 824 spin_unlock_irq(&clnt->lock); 820 825 idr_preload_end(); 821 - if (!ret) 826 + if (!ret) { 827 + trace_9p_fid_ref(fid, P9_FID_REF_CREATE); 822 828 return fid; 829 + } 823 830 824 831 kfree(fid); 825 832 return NULL; ··· 833 836 unsigned long flags; 834 837 835 838 p9_debug(P9_DEBUG_FID, "fid %d\n", fid->fid); 839 + trace_9p_fid_ref(fid, P9_FID_REF_DESTROY); 836 840 clnt = fid->clnt; 837 841 spin_lock_irqsave(&clnt->lock, flags); 838 842 idr_remove(&clnt->fids, fid->fid); ··· 841 843 kfree(fid->rdir); 842 844 kfree(fid); 843 845 } 846 + 847 + /* We also need to export tracepoint symbols for tracepoint_enabled() */ 848 + EXPORT_TRACEPOINT_SYMBOL(9p_fid_ref); 849 + 850 + void do_trace_9p_fid_get(struct p9_fid *fid) 851 + { 852 + trace_9p_fid_ref(fid, P9_FID_REF_GET); 853 + } 854 + EXPORT_SYMBOL(do_trace_9p_fid_get); 855 + 856 + void do_trace_9p_fid_put(struct p9_fid *fid) 857 + { 858 + trace_9p_fid_ref(fid, P9_FID_REF_PUT); 859 + } 860 + EXPORT_SYMBOL(do_trace_9p_fid_put); 844 861 845 862 static int p9_client_version(struct p9_client *c) 846 863 { ··· 919 906 920 907 error: 921 908 kfree(version); 922 - p9_tag_remove(c, req); 909 + p9_req_put(c, req); 923 910 924 911 return err; 925 912 } ··· 1073 1060 err = p9pdu_readf(&req->rc, clnt->proto_version, "Q", &qid); 1074 1061 if (err) { 1075 1062 trace_9p_protocol_dump(clnt, &req->rc); 1076 - p9_tag_remove(clnt, req); 1063 + p9_req_put(clnt, req); 1077 1064 goto error; 1078 1065 } 1079 1066 ··· 1082 1069 1083 1070 memmove(&fid->qid, &qid, sizeof(struct p9_qid)); 1084 1071 1085 - p9_tag_remove(clnt, req); 1072 + p9_req_put(clnt, req); 1086 1073 return fid; 1087 1074 1088 1075 error: ··· 1129 1116 err = p9pdu_readf(&req->rc, clnt->proto_version, "R", &nwqids, &wqids); 1130 1117 if (err) { 1131 1118 trace_9p_protocol_dump(clnt, &req->rc); 1132 - p9_tag_remove(clnt, req); 1119 + p9_req_put(clnt, req); 1133 1120 goto clunk_fid; 1134 1121 } 1135 - p9_tag_remove(clnt, req); 1122 + p9_req_put(clnt, req); 1136 1123 1137 1124 p9_debug(P9_DEBUG_9P, "<<< RWALK nwqid %d:\n", nwqids); 1138 1125 ··· 1157 1144 1158 1145 clunk_fid: 1159 1146 kfree(wqids); 1160 - p9_client_clunk(fid); 1147 + p9_fid_put(fid); 1161 1148 fid = NULL; 1162 1149 1163 1150 error: ··· 1208 1195 fid->iounit = iounit; 1209 1196 1210 1197 free_and_error: 1211 - p9_tag_remove(clnt, req); 1198 + p9_req_put(clnt, req); 1212 1199 error: 1213 1200 return err; 1214 1201 } ··· 1252 1239 ofid->iounit = iounit; 1253 1240 1254 1241 free_and_error: 1255 - p9_tag_remove(clnt, req); 1242 + p9_req_put(clnt, req); 1256 1243 error: 1257 1244 return err; 1258 1245 } ··· 1296 1283 fid->iounit = iounit; 1297 1284 1298 1285 free_and_error: 1299 - p9_tag_remove(clnt, req); 1286 + p9_req_put(clnt, req); 1300 1287 error: 1301 1288 return err; 1302 1289 } ··· 1330 1317 qid->type, qid->path, qid->version); 1331 1318 1332 1319 free_and_error: 1333 - p9_tag_remove(clnt, req); 1320 + p9_req_put(clnt, req); 1334 1321 error: 1335 1322 return err; 1336 1323 } ··· 1350 1337 return PTR_ERR(req); 1351 1338 1352 1339 p9_debug(P9_DEBUG_9P, "<<< RLINK\n"); 1353 - p9_tag_remove(clnt, req); 1340 + p9_req_put(clnt, req); 1354 1341 return 0; 1355 1342 } 1356 1343 EXPORT_SYMBOL(p9_client_link); ··· 1374 1361 1375 1362 p9_debug(P9_DEBUG_9P, "<<< RFSYNC fid %d\n", fid->fid); 1376 1363 1377 - p9_tag_remove(clnt, req); 1364 + p9_req_put(clnt, req); 1378 1365 1379 1366 error: 1380 1367 return err; ··· 1387 1374 struct p9_client *clnt; 1388 1375 struct p9_req_t *req; 1389 1376 int retries = 0; 1390 - 1391 - if (!fid || IS_ERR(fid)) { 1392 - pr_warn("%s (%d): Trying to clunk with invalid fid\n", 1393 - __func__, task_pid_nr(current)); 1394 - dump_stack(); 1395 - return 0; 1396 - } 1397 - if (!refcount_dec_and_test(&fid->count)) 1398 - return 0; 1399 1377 1400 1378 again: 1401 1379 p9_debug(P9_DEBUG_9P, ">>> TCLUNK fid %d (try %d)\n", ··· 1402 1398 1403 1399 p9_debug(P9_DEBUG_9P, "<<< RCLUNK fid %d\n", fid->fid); 1404 1400 1405 - p9_tag_remove(clnt, req); 1401 + p9_req_put(clnt, req); 1406 1402 error: 1407 1403 /* Fid is not valid even after a failed clunk 1408 1404 * If interrupted, retry once then give up and ··· 1436 1432 1437 1433 p9_debug(P9_DEBUG_9P, "<<< RREMOVE fid %d\n", fid->fid); 1438 1434 1439 - p9_tag_remove(clnt, req); 1435 + p9_req_put(clnt, req); 1440 1436 error: 1441 1437 if (err == -ERESTARTSYS) 1442 - p9_client_clunk(fid); 1438 + p9_fid_put(fid); 1443 1439 else 1444 1440 p9_fid_destroy(fid); 1445 1441 return err; ··· 1463 1459 } 1464 1460 p9_debug(P9_DEBUG_9P, "<<< RUNLINKAT fid %d %s\n", dfid->fid, name); 1465 1461 1466 - p9_tag_remove(clnt, req); 1462 + p9_req_put(clnt, req); 1467 1463 error: 1468 1464 return err; 1469 1465 } ··· 1531 1527 "D", &count, &dataptr); 1532 1528 if (*err) { 1533 1529 trace_9p_protocol_dump(clnt, &req->rc); 1534 - p9_tag_remove(clnt, req); 1530 + p9_req_put(clnt, req); 1535 1531 return 0; 1536 1532 } 1537 1533 if (rsize < count) { ··· 1546 1542 1547 1543 if (n != count) { 1548 1544 *err = -EFAULT; 1549 - p9_tag_remove(clnt, req); 1545 + p9_req_put(clnt, req); 1550 1546 return n; 1551 1547 } 1552 1548 } else { 1553 1549 iov_iter_advance(to, count); 1554 1550 } 1555 - p9_tag_remove(clnt, req); 1551 + p9_req_put(clnt, req); 1556 1552 return count; 1557 1553 } 1558 1554 EXPORT_SYMBOL(p9_client_read_once); ··· 1595 1591 *err = p9pdu_readf(&req->rc, clnt->proto_version, "d", &count); 1596 1592 if (*err) { 1597 1593 trace_9p_protocol_dump(clnt, &req->rc); 1598 - p9_tag_remove(clnt, req); 1594 + p9_req_put(clnt, req); 1599 1595 break; 1600 1596 } 1601 1597 if (rsize < count) { ··· 1605 1601 1606 1602 p9_debug(P9_DEBUG_9P, "<<< RWRITE count %d\n", count); 1607 1603 1608 - p9_tag_remove(clnt, req); 1604 + p9_req_put(clnt, req); 1609 1605 iov_iter_advance(from, count); 1610 1606 total += count; 1611 1607 offset += count; ··· 1640 1636 err = p9pdu_readf(&req->rc, clnt->proto_version, "wS", &ignored, ret); 1641 1637 if (err) { 1642 1638 trace_9p_protocol_dump(clnt, &req->rc); 1643 - p9_tag_remove(clnt, req); 1639 + p9_req_put(clnt, req); 1644 1640 goto error; 1645 1641 } 1646 1642 ··· 1657 1653 from_kgid(&init_user_ns, ret->n_gid), 1658 1654 from_kuid(&init_user_ns, ret->n_muid)); 1659 1655 1660 - p9_tag_remove(clnt, req); 1656 + p9_req_put(clnt, req); 1661 1657 return ret; 1662 1658 1663 1659 error: ··· 1693 1689 err = p9pdu_readf(&req->rc, clnt->proto_version, "A", ret); 1694 1690 if (err) { 1695 1691 trace_9p_protocol_dump(clnt, &req->rc); 1696 - p9_tag_remove(clnt, req); 1692 + p9_req_put(clnt, req); 1697 1693 goto error; 1698 1694 } 1699 1695 ··· 1719 1715 ret->st_btime_sec, ret->st_btime_nsec, 1720 1716 ret->st_gen, ret->st_data_version); 1721 1717 1722 - p9_tag_remove(clnt, req); 1718 + p9_req_put(clnt, req); 1723 1719 return ret; 1724 1720 1725 1721 error: ··· 1791 1787 1792 1788 p9_debug(P9_DEBUG_9P, "<<< RWSTAT fid %d\n", fid->fid); 1793 1789 1794 - p9_tag_remove(clnt, req); 1790 + p9_req_put(clnt, req); 1795 1791 error: 1796 1792 return err; 1797 1793 } ··· 1823 1819 goto error; 1824 1820 } 1825 1821 p9_debug(P9_DEBUG_9P, "<<< RSETATTR fid %d\n", fid->fid); 1826 - p9_tag_remove(clnt, req); 1822 + p9_req_put(clnt, req); 1827 1823 error: 1828 1824 return err; 1829 1825 } ··· 1851 1847 &sb->files, &sb->ffree, &sb->fsid, &sb->namelen); 1852 1848 if (err) { 1853 1849 trace_9p_protocol_dump(clnt, &req->rc); 1854 - p9_tag_remove(clnt, req); 1850 + p9_req_put(clnt, req); 1855 1851 goto error; 1856 1852 } 1857 1853 ··· 1860 1856 fid->fid, sb->type, sb->bsize, sb->blocks, sb->bfree, 1861 1857 sb->bavail, sb->files, sb->ffree, sb->fsid, sb->namelen); 1862 1858 1863 - p9_tag_remove(clnt, req); 1859 + p9_req_put(clnt, req); 1864 1860 error: 1865 1861 return err; 1866 1862 } ··· 1888 1884 1889 1885 p9_debug(P9_DEBUG_9P, "<<< RRENAME fid %d\n", fid->fid); 1890 1886 1891 - p9_tag_remove(clnt, req); 1887 + p9_req_put(clnt, req); 1892 1888 error: 1893 1889 return err; 1894 1890 } ··· 1918 1914 p9_debug(P9_DEBUG_9P, "<<< RRENAMEAT newdirfid %d new name %s\n", 1919 1915 newdirfid->fid, new_name); 1920 1916 1921 - p9_tag_remove(clnt, req); 1917 + p9_req_put(clnt, req); 1922 1918 error: 1923 1919 return err; 1924 1920 } ··· 1954 1950 err = p9pdu_readf(&req->rc, clnt->proto_version, "q", attr_size); 1955 1951 if (err) { 1956 1952 trace_9p_protocol_dump(clnt, &req->rc); 1957 - p9_tag_remove(clnt, req); 1953 + p9_req_put(clnt, req); 1958 1954 goto clunk_fid; 1959 1955 } 1960 - p9_tag_remove(clnt, req); 1956 + p9_req_put(clnt, req); 1961 1957 p9_debug(P9_DEBUG_9P, "<<< RXATTRWALK fid %d size %llu\n", 1962 1958 attr_fid->fid, *attr_size); 1963 1959 return attr_fid; 1964 1960 clunk_fid: 1965 - p9_client_clunk(attr_fid); 1961 + p9_fid_put(attr_fid); 1966 1962 attr_fid = NULL; 1967 1963 error: 1968 1964 if (attr_fid && attr_fid != file_fid) ··· 1991 1987 goto error; 1992 1988 } 1993 1989 p9_debug(P9_DEBUG_9P, "<<< RXATTRCREATE fid %d\n", fid->fid); 1994 - p9_tag_remove(clnt, req); 1990 + p9_req_put(clnt, req); 1995 1991 error: 1996 1992 return err; 1997 1993 } ··· 2053 2049 if (non_zc) 2054 2050 memmove(data, dataptr, count); 2055 2051 2056 - p9_tag_remove(clnt, req); 2052 + p9_req_put(clnt, req); 2057 2053 return count; 2058 2054 2059 2055 free_and_error: 2060 - p9_tag_remove(clnt, req); 2056 + p9_req_put(clnt, req); 2061 2057 error: 2062 2058 return err; 2063 2059 } ··· 2089 2085 qid->type, qid->path, qid->version); 2090 2086 2091 2087 error: 2092 - p9_tag_remove(clnt, req); 2088 + p9_req_put(clnt, req); 2093 2089 return err; 2094 2090 } 2095 2091 EXPORT_SYMBOL(p9_client_mknod_dotl); ··· 2119 2115 qid->path, qid->version); 2120 2116 2121 2117 error: 2122 - p9_tag_remove(clnt, req); 2118 + p9_req_put(clnt, req); 2123 2119 return err; 2124 2120 } 2125 2121 EXPORT_SYMBOL(p9_client_mkdir_dotl); ··· 2151 2147 } 2152 2148 p9_debug(P9_DEBUG_9P, "<<< RLOCK status %i\n", *status); 2153 2149 error: 2154 - p9_tag_remove(clnt, req); 2150 + p9_req_put(clnt, req); 2155 2151 return err; 2156 2152 } 2157 2153 EXPORT_SYMBOL(p9_client_lock_dotl); ··· 2188 2184 glock->type, glock->start, glock->length, 2189 2185 glock->proc_id, glock->client_id); 2190 2186 error: 2191 - p9_tag_remove(clnt, req); 2187 + p9_req_put(clnt, req); 2192 2188 return err; 2193 2189 } 2194 2190 EXPORT_SYMBOL(p9_client_getlock_dotl); ··· 2214 2210 } 2215 2211 p9_debug(P9_DEBUG_9P, "<<< RREADLINK target %s\n", *target); 2216 2212 error: 2217 - p9_tag_remove(clnt, req); 2213 + p9_req_put(clnt, req); 2218 2214 return err; 2219 2215 } 2220 2216 EXPORT_SYMBOL(p9_client_readlink);
+7 -6
net/9p/trans_fd.c
··· 343 343 p9_debug(P9_DEBUG_ERROR, 344 344 "No recv fcall for tag %d (req %p), disconnecting!\n", 345 345 m->rc.tag, m->rreq); 346 + p9_req_put(m->client, m->rreq); 346 347 m->rreq = NULL; 347 348 err = -EIO; 348 349 goto error; ··· 379 378 m->rc.sdata = NULL; 380 379 m->rc.offset = 0; 381 380 m->rc.capacity = 0; 382 - p9_req_put(m->rreq); 381 + p9_req_put(m->client, m->rreq); 383 382 m->rreq = NULL; 384 383 } 385 384 ··· 493 492 m->wpos += err; 494 493 if (m->wpos == m->wsize) { 495 494 m->wpos = m->wsize = 0; 496 - p9_req_put(m->wreq); 495 + p9_req_put(m->client, m->wreq); 497 496 m->wreq = NULL; 498 497 } 499 498 ··· 696 695 if (req->status == REQ_STATUS_UNSENT) { 697 696 list_del(&req->req_list); 698 697 req->status = REQ_STATUS_FLSHD; 699 - p9_req_put(req); 698 + p9_req_put(client, req); 700 699 ret = 0; 701 700 } 702 701 spin_unlock(&client->lock); ··· 723 722 list_del(&req->req_list); 724 723 req->status = REQ_STATUS_FLSHD; 725 724 spin_unlock(&client->lock); 726 - p9_req_put(req); 725 + p9_req_put(client, req); 727 726 728 727 return 0; 729 728 } ··· 884 883 p9_mux_poll_stop(m); 885 884 cancel_work_sync(&m->rq); 886 885 if (m->rreq) { 887 - p9_req_put(m->rreq); 886 + p9_req_put(m->client, m->rreq); 888 887 m->rreq = NULL; 889 888 } 890 889 cancel_work_sync(&m->wq); 891 890 if (m->wreq) { 892 - p9_req_put(m->wreq); 891 + p9_req_put(m->client, m->wreq); 893 892 m->wreq = NULL; 894 893 } 895 894
+1 -1
net/9p/trans_rdma.c
··· 350 350 c->busa, c->req->tc.size, 351 351 DMA_TO_DEVICE); 352 352 up(&rdma->sq_sem); 353 - p9_req_put(c->req); 353 + p9_req_put(client, c->req); 354 354 kfree(c); 355 355 } 356 356
+2 -2
net/9p/trans_virtio.c
··· 199 199 /* Reply won't come, so drop req ref */ 200 200 static int p9_virtio_cancelled(struct p9_client *client, struct p9_req_t *req) 201 201 { 202 - p9_req_put(req); 202 + p9_req_put(client, req); 203 203 return 0; 204 204 } 205 205 ··· 557 557 kvfree(out_pages); 558 558 if (!kicked) { 559 559 /* reply won't come */ 560 - p9_req_put(req); 560 + p9_req_put(client, req); 561 561 } 562 562 return err; 563 563 }
+1 -1
net/9p/trans_xen.c
··· 163 163 ring->intf->out_prod = prod; 164 164 spin_unlock_irqrestore(&ring->lock, flags); 165 165 notify_remote_via_irq(ring->irq); 166 - p9_req_put(p9_req); 166 + p9_req_put(client, p9_req); 167 167 168 168 return 0; 169 169 }