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

Merge tag 'nfs-for-4.21-1' of git://git.linux-nfs.org/projects/anna/linux-nfs

Pull NFS client updates from Anna Schumaker:
"Stable bugfixes:
- xprtrdma: Yet another double DMA-unmap # v4.20

Features:
- Allow some /proc/sys/sunrpc entries without CONFIG_SUNRPC_DEBUG
- Per-xprt rdma receive workqueues
- Drop support for FMR memory registration
- Make port= mount option optional for RDMA mounts

Other bugfixes and cleanups:
- Remove unused nfs4_xdev_fs_type declaration
- Fix comments for behavior that has changed
- Remove generic RPC credentials by switching to 'struct cred'
- Fix crossing mountpoints with different auth flavors
- Various xprtrdma fixes from testing and auditing the close code
- Fixes for disconnect issues when using xprtrdma with krb5
- Clean up and improve xprtrdma trace points
- Fix NFS v4.2 async copy reboot recovery"

* tag 'nfs-for-4.21-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (63 commits)
sunrpc: convert to DEFINE_SHOW_ATTRIBUTE
sunrpc: Add xprt after nfs4_test_session_trunk()
sunrpc: convert unnecessary GFP_ATOMIC to GFP_NOFS
sunrpc: handle ENOMEM in rpcb_getport_async
NFS: remove unnecessary test for IS_ERR(cred)
xprtrdma: Prevent leak of rpcrdma_rep objects
NFSv4.2 fix async copy reboot recovery
xprtrdma: Don't leak freed MRs
xprtrdma: Add documenting comment for rpcrdma_buffer_destroy
xprtrdma: Replace outdated comment for rpcrdma_ep_post
xprtrdma: Update comments in frwr_op_send
SUNRPC: Fix some kernel doc complaints
SUNRPC: Simplify defining common RPC trace events
NFS: Fix NFSv4 symbolic trace point output
xprtrdma: Trace mapping, alloc, and dereg failures
xprtrdma: Add trace points for calls to transport switch methods
xprtrdma: Relocate the xprtrdma_mr_map trace points
xprtrdma: Clean up of xprtrdma chunk trace points
xprtrdma: Remove unused fields from rpcrdma_ia
xprtrdma: Cull dprintk() call sites
...

+1519 -1996
+3 -3
fs/lockd/clntproc.c
··· 256 256 * Generic NLM call 257 257 */ 258 258 static int 259 - nlmclnt_call(struct rpc_cred *cred, struct nlm_rqst *req, u32 proc) 259 + nlmclnt_call(const struct cred *cred, struct nlm_rqst *req, u32 proc) 260 260 { 261 261 struct nlm_host *host = req->a_host; 262 262 struct rpc_clnt *clnt; ··· 401 401 * completion in order to be able to correctly track the lock 402 402 * state. 403 403 */ 404 - static int nlmclnt_async_call(struct rpc_cred *cred, struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops) 404 + static int nlmclnt_async_call(const struct cred *cred, struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops) 405 405 { 406 406 struct rpc_message msg = { 407 407 .rpc_argp = &req->a_args, ··· 510 510 static int 511 511 nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) 512 512 { 513 - struct rpc_cred *cred = nfs_file_cred(fl->fl_file); 513 + const struct cred *cred = nfs_file_cred(fl->fl_file); 514 514 struct nlm_host *host = req->a_host; 515 515 struct nlm_res *resp = &req->a_res; 516 516 struct nlm_wait *block = NULL;
+1 -1
fs/nfs/blocklayout/blocklayout.c
··· 584 584 585 585 static struct nfs4_deviceid_node * 586 586 bl_find_get_deviceid(struct nfs_server *server, 587 - const struct nfs4_deviceid *id, struct rpc_cred *cred, 587 + const struct nfs4_deviceid *id, const struct cred *cred, 588 588 gfp_t gfp_mask) 589 589 { 590 590 struct nfs4_deviceid_node *node;
+2 -7
fs/nfs/client.c
··· 151 151 struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init) 152 152 { 153 153 struct nfs_client *clp; 154 - struct rpc_cred *cred; 155 154 int err = -ENOMEM; 156 155 157 156 if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL) ··· 181 182 clp->cl_proto = cl_init->proto; 182 183 clp->cl_net = get_net(cl_init->net); 183 184 184 - cred = rpc_lookup_machine_cred("*"); 185 - if (!IS_ERR(cred)) 186 - clp->cl_machine_cred = cred; 185 + clp->cl_principal = "*"; 187 186 nfs_fscache_get_client_cookie(clp); 188 187 189 188 return clp; ··· 242 245 /* -EIO all pending I/O */ 243 246 if (!IS_ERR(clp->cl_rpcclient)) 244 247 rpc_shutdown_client(clp->cl_rpcclient); 245 - 246 - if (clp->cl_machine_cred != NULL) 247 - put_rpccred(clp->cl_machine_cred); 248 248 249 249 put_net(clp->cl_net); 250 250 put_nfs_version(clp->cl_nfs_mod); ··· 521 527 return PTR_ERR(clnt); 522 528 } 523 529 530 + clnt->cl_principal = clp->cl_principal; 524 531 clp->cl_rpcclient = clnt; 525 532 return 0; 526 533 }
+13 -15
fs/nfs/delegation.c
··· 26 26 27 27 static void nfs_free_delegation(struct nfs_delegation *delegation) 28 28 { 29 - if (delegation->cred) { 30 - put_rpccred(delegation->cred); 31 - delegation->cred = NULL; 32 - } 29 + put_cred(delegation->cred); 30 + delegation->cred = NULL; 33 31 kfree_rcu(delegation, rcu); 34 32 } 35 33 ··· 176 178 * @pagemod_limit: write delegation "space_limit" 177 179 * 178 180 */ 179 - void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, 181 + void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, 180 182 fmode_t type, 181 183 const nfs4_stateid *stateid, 182 184 unsigned long pagemod_limit) 183 185 { 184 186 struct nfs_delegation *delegation; 185 - struct rpc_cred *oldcred = NULL; 187 + const struct cred *oldcred = NULL; 186 188 187 189 rcu_read_lock(); 188 190 delegation = rcu_dereference(NFS_I(inode)->delegation); ··· 193 195 delegation->type = type; 194 196 delegation->pagemod_limit = pagemod_limit; 195 197 oldcred = delegation->cred; 196 - delegation->cred = get_rpccred(cred); 198 + delegation->cred = get_cred(cred); 197 199 clear_bit(NFS_DELEGATION_NEED_RECLAIM, 198 200 &delegation->flags); 199 201 spin_unlock(&delegation->lock); 200 202 rcu_read_unlock(); 201 - put_rpccred(oldcred); 203 + put_cred(oldcred); 202 204 trace_nfs4_reclaim_delegation(inode, type); 203 205 return; 204 206 } ··· 339 341 * 340 342 * Returns zero on success, or a negative errno value. 341 343 */ 342 - int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, 344 + int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, 343 345 fmode_t type, 344 346 const nfs4_stateid *stateid, 345 347 unsigned long pagemod_limit) ··· 358 360 delegation->type = type; 359 361 delegation->pagemod_limit = pagemod_limit; 360 362 delegation->change_attr = inode_peek_iversion_raw(inode); 361 - delegation->cred = get_rpccred(cred); 363 + delegation->cred = get_cred(cred); 362 364 delegation->inode = inode; 363 365 delegation->flags = 1<<NFS_DELEGATION_REFERENCED; 364 366 spin_lock_init(&delegation->lock); ··· 1045 1047 struct nfs_delegation *delegation; 1046 1048 struct nfs_server *server; 1047 1049 struct inode *inode; 1048 - struct rpc_cred *cred; 1050 + const struct cred *cred; 1049 1051 nfs4_stateid stateid; 1050 1052 1051 1053 restart: ··· 1067 1069 nfs_sb_deactive(server->super); 1068 1070 goto restart; 1069 1071 } 1070 - cred = get_rpccred_rcu(delegation->cred); 1072 + cred = get_cred_rcu(delegation->cred); 1071 1073 nfs4_stateid_copy(&stateid, &delegation->stateid); 1072 1074 clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); 1073 1075 rcu_read_unlock(); ··· 1076 1078 nfs_revoke_delegation(inode, &stateid); 1077 1079 nfs_inode_find_state_and_recover(inode, &stateid); 1078 1080 } 1079 - put_rpccred(cred); 1081 + put_cred(cred); 1080 1082 if (nfs4_server_rebooted(clp)) { 1081 1083 nfs_inode_mark_test_expired_delegation(server,inode); 1082 1084 iput(inode); ··· 1171 1173 * otherwise "false" is returned. 1172 1174 */ 1173 1175 bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, 1174 - nfs4_stateid *dst, struct rpc_cred **cred) 1176 + nfs4_stateid *dst, const struct cred **cred) 1175 1177 { 1176 1178 struct nfs_inode *nfsi = NFS_I(inode); 1177 1179 struct nfs_delegation *delegation; ··· 1185 1187 nfs4_stateid_copy(dst, &delegation->stateid); 1186 1188 nfs_mark_delegation_referenced(delegation); 1187 1189 if (cred) 1188 - *cred = get_rpccred(delegation->cred); 1190 + *cred = get_cred(delegation->cred); 1189 1191 } 1190 1192 rcu_read_unlock(); 1191 1193 return ret;
+5 -5
fs/nfs/delegation.h
··· 15 15 */ 16 16 struct nfs_delegation { 17 17 struct list_head super_list; 18 - struct rpc_cred *cred; 18 + const struct cred *cred; 19 19 struct inode *inode; 20 20 nfs4_stateid stateid; 21 21 fmode_t type; ··· 36 36 NFS_DELEGATION_TEST_EXPIRED, 37 37 }; 38 38 39 - int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, 39 + int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, 40 40 fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit); 41 - void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, 41 + void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, 42 42 fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit); 43 43 int nfs4_inode_return_delegation(struct inode *inode); 44 44 int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); ··· 60 60 void nfs_reap_expired_delegations(struct nfs_client *clp); 61 61 62 62 /* NFSv4 delegation-related procedures */ 63 - int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync); 63 + int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync); 64 64 int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid, fmode_t type); 65 65 int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid *stateid); 66 - bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, struct rpc_cred **cred); 66 + bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, const struct cred **cred); 67 67 bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode); 68 68 69 69 void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
+24 -35
fs/nfs/dir.c
··· 67 67 .freepage = nfs_readdir_clear_array, 68 68 }; 69 69 70 - static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir, struct rpc_cred *cred) 70 + static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir, const struct cred *cred) 71 71 { 72 72 struct nfs_inode *nfsi = NFS_I(dir); 73 73 struct nfs_open_dir_context *ctx; ··· 77 77 ctx->attr_gencount = nfsi->attr_gencount; 78 78 ctx->dir_cookie = 0; 79 79 ctx->dup_cookie = 0; 80 - ctx->cred = get_rpccred(cred); 80 + ctx->cred = get_cred(cred); 81 81 spin_lock(&dir->i_lock); 82 82 list_add(&ctx->list, &nfsi->open_files); 83 83 spin_unlock(&dir->i_lock); ··· 91 91 spin_lock(&dir->i_lock); 92 92 list_del(&ctx->list); 93 93 spin_unlock(&dir->i_lock); 94 - put_rpccred(ctx->cred); 94 + put_cred(ctx->cred); 95 95 kfree(ctx); 96 96 } 97 97 ··· 103 103 { 104 104 int res = 0; 105 105 struct nfs_open_dir_context *ctx; 106 - struct rpc_cred *cred; 107 106 108 107 dfprintk(FILE, "NFS: open dir(%pD2)\n", filp); 109 108 110 109 nfs_inc_stats(inode, NFSIOS_VFSOPEN); 111 110 112 - cred = rpc_lookup_cred(); 113 - if (IS_ERR(cred)) 114 - return PTR_ERR(cred); 115 - ctx = alloc_nfs_open_dir_context(inode, cred); 111 + ctx = alloc_nfs_open_dir_context(inode, current_cred()); 116 112 if (IS_ERR(ctx)) { 117 113 res = PTR_ERR(ctx); 118 114 goto out; 119 115 } 120 116 filp->private_data = ctx; 121 117 out: 122 - put_rpccred(cred); 123 118 return res; 124 119 } 125 120 ··· 329 334 struct nfs_entry *entry, struct file *file, struct inode *inode) 330 335 { 331 336 struct nfs_open_dir_context *ctx = file->private_data; 332 - struct rpc_cred *cred = ctx->cred; 337 + const struct cred *cred = ctx->cred; 333 338 unsigned long timestamp, gencount; 334 339 int error; 335 340 ··· 2134 2139 2135 2140 static void nfs_access_free_entry(struct nfs_access_entry *entry) 2136 2141 { 2137 - put_rpccred(entry->cred); 2142 + put_cred(entry->cred); 2138 2143 kfree_rcu(entry, rcu_head); 2139 2144 smp_mb__before_atomic(); 2140 2145 atomic_long_dec(&nfs_access_nr_entries); ··· 2260 2265 } 2261 2266 EXPORT_SYMBOL_GPL(nfs_access_zap_cache); 2262 2267 2263 - static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, struct rpc_cred *cred) 2268 + static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, const struct cred *cred) 2264 2269 { 2265 2270 struct rb_node *n = NFS_I(inode)->access_cache.rb_node; 2266 - struct nfs_access_entry *entry; 2267 2271 2268 2272 while (n != NULL) { 2269 - entry = rb_entry(n, struct nfs_access_entry, rb_node); 2273 + struct nfs_access_entry *entry = 2274 + rb_entry(n, struct nfs_access_entry, rb_node); 2275 + int cmp = cred_fscmp(cred, entry->cred); 2270 2276 2271 - if (cred < entry->cred) 2277 + if (cmp < 0) 2272 2278 n = n->rb_left; 2273 - else if (cred > entry->cred) 2279 + else if (cmp > 0) 2274 2280 n = n->rb_right; 2275 2281 else 2276 2282 return entry; ··· 2279 2283 return NULL; 2280 2284 } 2281 2285 2282 - static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res, bool may_block) 2286 + static int nfs_access_get_cached(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res, bool may_block) 2283 2287 { 2284 2288 struct nfs_inode *nfsi = NFS_I(inode); 2285 2289 struct nfs_access_entry *cache; ··· 2322 2326 return -ENOENT; 2323 2327 } 2324 2328 2325 - static int nfs_access_get_cached_rcu(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res) 2329 + static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res) 2326 2330 { 2327 2331 /* Only check the most recently returned cache entry, 2328 2332 * but do it without locking. ··· 2359 2363 struct rb_node **p = &root_node->rb_node; 2360 2364 struct rb_node *parent = NULL; 2361 2365 struct nfs_access_entry *entry; 2366 + int cmp; 2362 2367 2363 2368 spin_lock(&inode->i_lock); 2364 2369 while (*p != NULL) { 2365 2370 parent = *p; 2366 2371 entry = rb_entry(parent, struct nfs_access_entry, rb_node); 2372 + cmp = cred_fscmp(set->cred, entry->cred); 2367 2373 2368 - if (set->cred < entry->cred) 2374 + if (cmp < 0) 2369 2375 p = &parent->rb_left; 2370 - else if (set->cred > entry->cred) 2376 + else if (cmp > 0) 2371 2377 p = &parent->rb_right; 2372 2378 else 2373 2379 goto found; ··· 2393 2395 if (cache == NULL) 2394 2396 return; 2395 2397 RB_CLEAR_NODE(&cache->rb_node); 2396 - cache->cred = get_rpccred(set->cred); 2398 + cache->cred = get_cred(set->cred); 2397 2399 cache->mask = set->mask; 2398 2400 2399 2401 /* The above field assignments must be visible ··· 2457 2459 } 2458 2460 EXPORT_SYMBOL_GPL(nfs_access_set_mask); 2459 2461 2460 - static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask) 2462 + static int nfs_do_access(struct inode *inode, const struct cred *cred, int mask) 2461 2463 { 2462 2464 struct nfs_access_entry cache; 2463 2465 bool may_block = (mask & MAY_NOT_BLOCK) == 0; ··· 2521 2523 return mask; 2522 2524 } 2523 2525 2524 - int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags) 2526 + int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags) 2525 2527 { 2526 2528 return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags)); 2527 2529 } ··· 2546 2548 2547 2549 int nfs_permission(struct inode *inode, int mask) 2548 2550 { 2549 - struct rpc_cred *cred; 2551 + const struct cred *cred = current_cred(); 2550 2552 int res = 0; 2551 2553 2552 2554 nfs_inc_stats(inode, NFSIOS_VFSACCESS); ··· 2580 2582 2581 2583 /* Always try fast lookups first */ 2582 2584 rcu_read_lock(); 2583 - cred = rpc_lookup_cred_nonblock(); 2584 - if (!IS_ERR(cred)) 2585 - res = nfs_do_access(inode, cred, mask|MAY_NOT_BLOCK); 2586 - else 2587 - res = PTR_ERR(cred); 2585 + res = nfs_do_access(inode, cred, mask|MAY_NOT_BLOCK); 2588 2586 rcu_read_unlock(); 2589 2587 if (res == -ECHILD && !(mask & MAY_NOT_BLOCK)) { 2590 2588 /* Fast lookup failed, try the slow way */ 2591 - cred = rpc_lookup_cred(); 2592 - if (!IS_ERR(cred)) { 2593 - res = nfs_do_access(inode, cred, mask); 2594 - put_rpccred(cred); 2595 - } else 2596 - res = PTR_ERR(cred); 2589 + res = nfs_do_access(inode, cred, mask); 2597 2590 } 2598 2591 out: 2599 2592 if (!res && (mask & MAY_EXEC))
+30 -34
fs/nfs/flexfilelayout/flexfilelayout.c
··· 9 9 #include <linux/nfs_fs.h> 10 10 #include <linux/nfs_page.h> 11 11 #include <linux/module.h> 12 + #include <linux/sched/mm.h> 12 13 13 14 #include <linux/sunrpc/metrics.h> 14 15 ··· 27 26 28 27 #define FF_LAYOUT_POLL_RETRY_MAX (15*HZ) 29 28 #define FF_LAYOUTRETURN_MAXERR 20 30 - 31 - 32 - static struct group_info *ff_zero_group; 33 29 34 30 static void ff_layout_read_record_layoutstats_done(struct rpc_task *task, 35 31 struct nfs_pgio_header *hdr); ··· 224 226 225 227 static void ff_layout_free_mirror(struct nfs4_ff_layout_mirror *mirror) 226 228 { 227 - struct rpc_cred *cred; 229 + const struct cred *cred; 228 230 229 231 ff_layout_remove_mirror(mirror); 230 232 kfree(mirror->fh_versions); 231 233 cred = rcu_access_pointer(mirror->ro_cred); 232 - if (cred) 233 - put_rpccred(cred); 234 + put_cred(cred); 234 235 cred = rcu_access_pointer(mirror->rw_cred); 235 - if (cred) 236 - put_rpccred(cred); 236 + put_cred(cred); 237 237 nfs4_ff_layout_put_deviceid(mirror->mirror_ds); 238 238 kfree(mirror); 239 239 } ··· 409 413 410 414 for (i = 0; i < fls->mirror_array_cnt; i++) { 411 415 struct nfs4_ff_layout_mirror *mirror; 412 - struct auth_cred acred = { .group_info = ff_zero_group }; 413 - struct rpc_cred __rcu *cred; 416 + struct cred *kcred; 417 + const struct cred *cred; 418 + kuid_t uid; 419 + kgid_t gid; 414 420 u32 ds_count, fh_count, id; 415 421 int j; 416 422 ··· 480 482 if (rc) 481 483 goto out_err_free; 482 484 483 - acred.uid = make_kuid(&init_user_ns, id); 485 + uid = make_kuid(&init_user_ns, id); 484 486 485 487 /* group */ 486 488 rc = decode_name(&stream, &id); 487 489 if (rc) 488 490 goto out_err_free; 489 491 490 - acred.gid = make_kgid(&init_user_ns, id); 492 + gid = make_kgid(&init_user_ns, id); 491 493 492 - /* find the cred for it */ 493 - rcu_assign_pointer(cred, rpc_lookup_generic_cred(&acred, 0, gfp_flags)); 494 - if (IS_ERR(cred)) { 495 - rc = PTR_ERR(cred); 496 - goto out_err_free; 494 + if (gfp_flags & __GFP_FS) 495 + kcred = prepare_kernel_cred(NULL); 496 + else { 497 + unsigned int nofs_flags = memalloc_nofs_save(); 498 + kcred = prepare_kernel_cred(NULL); 499 + memalloc_nofs_restore(nofs_flags); 497 500 } 501 + rc = -ENOMEM; 502 + if (!kcred) 503 + goto out_err_free; 504 + kcred->fsuid = uid; 505 + kcred->fsgid = gid; 506 + cred = kcred; 498 507 499 508 if (lgr->range.iomode == IOMODE_READ) 500 509 rcu_assign_pointer(fls->mirror_array[i]->ro_cred, cred); ··· 524 519 525 520 dprintk("%s: iomode %s uid %u gid %u\n", __func__, 526 521 lgr->range.iomode == IOMODE_READ ? "READ" : "RW", 527 - from_kuid(&init_user_ns, acred.uid), 528 - from_kgid(&init_user_ns, acred.gid)); 522 + from_kuid(&init_user_ns, uid), 523 + from_kgid(&init_user_ns, gid)); 529 524 } 530 525 531 526 p = xdr_inline_decode(&stream, 4); ··· 1703 1698 struct pnfs_layout_segment *lseg = hdr->lseg; 1704 1699 struct nfs4_pnfs_ds *ds; 1705 1700 struct rpc_clnt *ds_clnt; 1706 - struct rpc_cred *ds_cred; 1701 + const struct cred *ds_cred; 1707 1702 loff_t offset = hdr->args.offset; 1708 1703 u32 idx = hdr->pgio_mirror_idx; 1709 1704 int vers; ··· 1754 1749 vers == 3 ? &ff_layout_read_call_ops_v3 : 1755 1750 &ff_layout_read_call_ops_v4, 1756 1751 0, RPC_TASK_SOFTCONN); 1757 - put_rpccred(ds_cred); 1752 + put_cred(ds_cred); 1758 1753 return PNFS_ATTEMPTED; 1759 1754 1760 1755 out_failed: ··· 1770 1765 struct pnfs_layout_segment *lseg = hdr->lseg; 1771 1766 struct nfs4_pnfs_ds *ds; 1772 1767 struct rpc_clnt *ds_clnt; 1773 - struct rpc_cred *ds_cred; 1768 + const struct cred *ds_cred; 1774 1769 loff_t offset = hdr->args.offset; 1775 1770 int vers; 1776 1771 struct nfs_fh *fh; ··· 1819 1814 vers == 3 ? &ff_layout_write_call_ops_v3 : 1820 1815 &ff_layout_write_call_ops_v4, 1821 1816 sync, RPC_TASK_SOFTCONN); 1822 - put_rpccred(ds_cred); 1817 + put_cred(ds_cred); 1823 1818 return PNFS_ATTEMPTED; 1824 1819 1825 1820 out_failed: ··· 1849 1844 struct pnfs_layout_segment *lseg = data->lseg; 1850 1845 struct nfs4_pnfs_ds *ds; 1851 1846 struct rpc_clnt *ds_clnt; 1852 - struct rpc_cred *ds_cred; 1847 + const struct cred *ds_cred; 1853 1848 u32 idx; 1854 1849 int vers, ret; 1855 1850 struct nfs_fh *fh; ··· 1889 1884 vers == 3 ? &ff_layout_commit_call_ops_v3 : 1890 1885 &ff_layout_commit_call_ops_v4, 1891 1886 how, RPC_TASK_SOFTCONN); 1892 - put_rpccred(ds_cred); 1887 + put_cred(ds_cred); 1893 1888 return ret; 1894 1889 out_err: 1895 1890 pnfs_generic_prepare_to_resend_writes(data); ··· 2388 2383 { 2389 2384 printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Registering...\n", 2390 2385 __func__); 2391 - if (!ff_zero_group) { 2392 - ff_zero_group = groups_alloc(0); 2393 - if (!ff_zero_group) 2394 - return -ENOMEM; 2395 - } 2396 2386 return pnfs_register_layoutdriver(&flexfilelayout_type); 2397 2387 } 2398 2388 ··· 2396 2396 printk(KERN_INFO "%s: NFSv4 Flexfile Layout Driver Unregistering...\n", 2397 2397 __func__); 2398 2398 pnfs_unregister_layoutdriver(&flexfilelayout_type); 2399 - if (ff_zero_group) { 2400 - put_group_info(ff_zero_group); 2401 - ff_zero_group = NULL; 2402 - } 2403 2399 } 2404 2400 2405 2401 MODULE_ALIAS("nfs-layouttype4-4");
+4 -4
fs/nfs/flexfilelayout/flexfilelayout.h
··· 81 81 u32 fh_versions_cnt; 82 82 struct nfs_fh *fh_versions; 83 83 nfs4_stateid stateid; 84 - struct rpc_cred __rcu *ro_cred; 85 - struct rpc_cred __rcu *rw_cred; 84 + const struct cred __rcu *ro_cred; 85 + const struct cred __rcu *rw_cred; 86 86 refcount_t ref; 87 87 spinlock_t lock; 88 88 unsigned long flags; ··· 229 229 u32 ds_idx, 230 230 struct nfs_client *ds_clp, 231 231 struct inode *inode); 232 - struct rpc_cred *ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg, 233 - u32 ds_idx, struct rpc_cred *mdscred); 232 + const struct cred *ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg, 233 + u32 ds_idx, const struct cred *mdscred); 234 234 bool ff_layout_avoid_mds_available_ds(struct pnfs_layout_segment *lseg); 235 235 bool ff_layout_avoid_read_on_rw(struct pnfs_layout_segment *lseg); 236 236
+8 -8
fs/nfs/flexfilelayout/flexfilelayoutdev.c
··· 330 330 return 0; 331 331 } 332 332 333 - static struct rpc_cred * 333 + static const struct cred * 334 334 ff_layout_get_mirror_cred(struct nfs4_ff_layout_mirror *mirror, u32 iomode) 335 335 { 336 - struct rpc_cred *cred, __rcu **pcred; 336 + const struct cred *cred, __rcu **pcred; 337 337 338 338 if (iomode == IOMODE_READ) 339 339 pcred = &mirror->ro_cred; ··· 346 346 if (!cred) 347 347 break; 348 348 349 - cred = get_rpccred_rcu(cred); 349 + cred = get_cred_rcu(cred); 350 350 } while(!cred); 351 351 rcu_read_unlock(); 352 352 return cred; ··· 465 465 return ds; 466 466 } 467 467 468 - struct rpc_cred * 468 + const struct cred * 469 469 ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg, u32 ds_idx, 470 - struct rpc_cred *mdscred) 470 + const struct cred *mdscred) 471 471 { 472 472 struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx); 473 - struct rpc_cred *cred; 473 + const struct cred *cred; 474 474 475 475 if (mirror && !mirror->mirror_ds->ds_versions[0].tightly_coupled) { 476 476 cred = ff_layout_get_mirror_cred(mirror, lseg->pls_range.iomode); 477 477 if (!cred) 478 - cred = get_rpccred(mdscred); 478 + cred = get_cred(mdscred); 479 479 } else { 480 - cred = get_rpccred(mdscred); 480 + cred = get_cred(mdscred); 481 481 } 482 482 return cred; 483 483 }
+6 -7
fs/nfs/inode.c
··· 950 950 struct file *filp) 951 951 { 952 952 struct nfs_open_context *ctx; 953 - struct rpc_cred *cred = rpc_lookup_cred(); 954 - if (IS_ERR(cred)) 955 - return ERR_CAST(cred); 953 + const struct cred *cred = get_current_cred(); 956 954 957 955 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 958 956 if (!ctx) { 959 - put_rpccred(cred); 957 + put_cred(cred); 960 958 return ERR_PTR(-ENOMEM); 961 959 } 962 960 nfs_sb_active(dentry->d_sb); 963 961 ctx->dentry = dget(dentry); 964 962 ctx->cred = cred; 963 + ctx->ll_cred = NULL; 965 964 ctx->state = NULL; 966 965 ctx->mode = f_mode; 967 966 ctx->flags = 0; ··· 996 997 } 997 998 if (inode != NULL) 998 999 NFS_PROTO(inode)->close_context(ctx, is_sync); 999 - if (ctx->cred != NULL) 1000 - put_rpccred(ctx->cred); 1000 + put_cred(ctx->cred); 1001 1001 dput(ctx->dentry); 1002 1002 nfs_sb_deactive(sb); 1003 + put_rpccred(ctx->ll_cred); 1003 1004 kfree(ctx->mdsthreshold); 1004 1005 kfree_rcu(ctx, rcu_head); 1005 1006 } ··· 1041 1042 /* 1042 1043 * Given an inode, search for an open context with the desired characteristics 1043 1044 */ 1044 - struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode) 1045 + struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct cred *cred, fmode_t mode) 1045 1046 { 1046 1047 struct nfs_inode *nfsi = NFS_I(inode); 1047 1048 struct nfs_open_context *pos, *ctx = NULL;
+7 -8
fs/nfs/internal.h
··· 254 254 void nfs_pgio_header_free(struct nfs_pgio_header *); 255 255 int nfs_generic_pgio(struct nfs_pageio_descriptor *, struct nfs_pgio_header *); 256 256 int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr, 257 - struct rpc_cred *cred, const struct nfs_rpc_ops *rpc_ops, 257 + const struct cred *cred, const struct nfs_rpc_ops *rpc_ops, 258 258 const struct rpc_call_ops *call_ops, int how, int flags); 259 259 void nfs_free_request(struct nfs_page *req); 260 260 struct nfs_pgio_mirror * ··· 269 269 static inline bool nfs_match_open_context(const struct nfs_open_context *ctx1, 270 270 const struct nfs_open_context *ctx2) 271 271 { 272 - return ctx1->cred == ctx2->cred && ctx1->state == ctx2->state; 272 + return cred_fscmp(ctx1->cred, ctx2->cred) == 0 && ctx1->state == ctx2->state; 273 273 } 274 274 275 275 /* nfs2xdr.c */ ··· 395 395 extern struct file_system_type nfs_fs_type; 396 396 extern struct file_system_type nfs_xdev_fs_type; 397 397 #if IS_ENABLED(CONFIG_NFS_V4) 398 - extern struct file_system_type nfs4_xdev_fs_type; 399 398 extern struct file_system_type nfs4_referral_fs_type; 400 399 #endif 401 400 bool nfs_auth_info_match(const struct nfs_auth_info *, rpc_authflavor_t); ··· 564 565 const struct nfs_client_initdata *); 565 566 extern int nfs40_walk_client_list(struct nfs_client *clp, 566 567 struct nfs_client **result, 567 - struct rpc_cred *cred); 568 + const struct cred *cred); 568 569 extern int nfs41_walk_client_list(struct nfs_client *clp, 569 570 struct nfs_client **result, 570 - struct rpc_cred *cred); 571 - extern int nfs4_test_session_trunk(struct rpc_clnt *, 572 - struct rpc_xprt *, 573 - void *); 571 + const struct cred *cred); 572 + extern void nfs4_test_session_trunk(struct rpc_clnt *clnt, 573 + struct rpc_xprt *xprt, 574 + void *data); 574 575 575 576 static inline struct inode *nfs_igrab_and_active(struct inode *inode) 576 577 {
+2 -2
fs/nfs/nfs3proc.c
··· 607 607 * readdirplus. 608 608 */ 609 609 static int 610 - nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, 610 + nfs3_proc_readdir(struct dentry *dentry, const struct cred *cred, 611 611 u64 cookie, struct page **pages, unsigned int count, bool plus) 612 612 { 613 613 struct inode *dir = d_inode(dentry); ··· 628 628 .rpc_proc = &nfs3_procedures[NFS3PROC_READDIR], 629 629 .rpc_argp = &arg, 630 630 .rpc_resp = &res, 631 - .rpc_cred = cred 631 + .rpc_cred = cred, 632 632 }; 633 633 int status = -ENOMEM; 634 634
+31 -37
fs/nfs/nfs4_fs.h
··· 62 62 void (*free_lock_state)(struct nfs_server *, 63 63 struct nfs4_lock_state *); 64 64 int (*test_and_free_expired)(struct nfs_server *, 65 - nfs4_stateid *, struct rpc_cred *); 65 + nfs4_stateid *, const struct cred *); 66 66 struct nfs_seqid * 67 67 (*alloc_seqid)(struct nfs_seqid_counter *, gfp_t); 68 - int (*session_trunk)(struct rpc_clnt *, struct rpc_xprt *, void *); 68 + void (*session_trunk)(struct rpc_clnt *clnt, 69 + struct rpc_xprt *xprt, void *data); 69 70 const struct rpc_call_ops *call_sync_ops; 70 71 const struct nfs4_state_recovery_ops *reboot_recovery_ops; 71 72 const struct nfs4_state_recovery_ops *nograce_recovery_ops; ··· 108 107 unsigned long so_expires; 109 108 struct rb_node so_server_node; 110 109 111 - struct rpc_cred *so_cred; /* Associated cred */ 110 + const struct cred *so_cred; /* Associated cred */ 112 111 113 112 spinlock_t so_lock; 114 113 atomic_t so_count; ··· 213 212 int state_flag_bit; 214 213 int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *); 215 214 int (*recover_lock)(struct nfs4_state *, struct file_lock *); 216 - int (*establish_clid)(struct nfs_client *, struct rpc_cred *); 217 - int (*reclaim_complete)(struct nfs_client *, struct rpc_cred *); 215 + int (*establish_clid)(struct nfs_client *, const struct cred *); 216 + int (*reclaim_complete)(struct nfs_client *, const struct cred *); 218 217 int (*detect_trunking)(struct nfs_client *, struct nfs_client **, 219 - struct rpc_cred *); 218 + const struct cred *); 220 219 }; 221 220 222 221 struct nfs4_opendata { ··· 246 245 247 246 struct nfs4_add_xprt_data { 248 247 struct nfs_client *clp; 249 - struct rpc_cred *cred; 248 + const struct cred *cred; 250 249 }; 251 250 252 251 struct nfs4_state_maintenance_ops { 253 - int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *, unsigned); 254 - struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *); 255 - int (*renew_lease)(struct nfs_client *, struct rpc_cred *); 252 + int (*sched_state_renewal)(struct nfs_client *, const struct cred *, unsigned); 253 + const struct cred * (*get_state_renewal_cred)(struct nfs_client *); 254 + int (*renew_lease)(struct nfs_client *, const struct cred *); 256 255 }; 257 256 258 257 struct nfs4_mig_recovery_ops { 259 258 int (*get_locations)(struct inode *, struct nfs4_fs_locations *, 260 - struct page *, struct rpc_cred *); 261 - int (*fsid_present)(struct inode *, struct rpc_cred *); 259 + struct page *, const struct cred *); 260 + int (*fsid_present)(struct inode *, const struct cred *); 262 261 }; 263 262 264 263 extern const struct dentry_operations nfs4_dentry_operations; ··· 287 286 struct rpc_message *, struct nfs4_sequence_args *, 288 287 struct nfs4_sequence_res *, int); 289 288 extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int); 290 - extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *); 291 - extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *); 289 + extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, const struct cred *, struct nfs4_setclientid_res *); 290 + extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, const struct cred *); 292 291 extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *, bool); 293 - extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, struct rpc_cred *cred); 294 - extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); 292 + extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, const struct cred *cred); 293 + extern int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred); 295 294 extern int nfs4_destroy_clientid(struct nfs_client *clp); 296 - extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); 297 - extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); 295 + extern int nfs4_init_clientid(struct nfs_client *, const struct cred *); 296 + extern int nfs41_init_clientid(struct nfs_client *, const struct cred *); 298 297 extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait); 299 298 extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); 300 299 extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *, 301 300 struct nfs4_fs_locations *, struct page *); 302 301 extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *, 303 - struct page *page, struct rpc_cred *); 304 - extern int nfs4_proc_fsid_present(struct inode *, struct rpc_cred *); 302 + struct page *page, const struct cred *); 303 + extern int nfs4_proc_fsid_present(struct inode *, const struct cred *); 305 304 extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, const struct qstr *, 306 305 struct nfs_fh *, struct nfs_fattr *); 307 306 extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *); ··· 313 312 314 313 #if defined(CONFIG_NFS_V4_1) 315 314 extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *); 316 - extern int nfs4_proc_create_session(struct nfs_client *, struct rpc_cred *); 317 - extern int nfs4_proc_destroy_session(struct nfs4_session *, struct rpc_cred *); 315 + extern int nfs4_proc_create_session(struct nfs_client *, const struct cred *); 316 + extern int nfs4_proc_destroy_session(struct nfs4_session *, const struct cred *); 318 317 extern int nfs4_proc_get_lease_time(struct nfs_client *clp, 319 318 struct nfs_fsinfo *fsinfo); 320 319 extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, ··· 339 338 _nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, 340 339 struct rpc_clnt **clntp, struct rpc_message *msg) 341 340 { 342 - struct rpc_cred *newcred = NULL; 343 341 rpc_authflavor_t flavor; 344 342 345 343 if (sp4_mode == NFS_SP4_MACH_CRED_CLEANUP || ··· 353 353 return false; 354 354 } 355 355 if (test_bit(sp4_mode, &clp->cl_sp4_flags)) { 356 - spin_lock(&clp->cl_lock); 357 - if (clp->cl_machine_cred != NULL) 358 - /* don't call get_rpccred on the machine cred - 359 - * a reference will be held for life of clp */ 360 - newcred = clp->cl_machine_cred; 361 - spin_unlock(&clp->cl_lock); 362 - msg->rpc_cred = newcred; 356 + msg->rpc_cred = rpc_machine_cred(); 363 357 364 358 flavor = clp->cl_rpcclient->cl_auth->au_flavor; 365 359 WARN_ON_ONCE(flavor != RPC_AUTH_GSS_KRB5I && ··· 444 450 445 451 446 452 /* nfs4state.c */ 447 - struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp); 448 - struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp); 449 - struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp); 453 + const struct cred *nfs4_get_clid_cred(struct nfs_client *clp); 454 + const struct cred *nfs4_get_machine_cred(struct nfs_client *clp); 455 + const struct cred *nfs4_get_renew_cred(struct nfs_client *clp); 450 456 int nfs4_discover_server_trunking(struct nfs_client *clp, 451 457 struct nfs_client **); 452 458 int nfs40_discover_server_trunking(struct nfs_client *clp, 453 - struct nfs_client **, struct rpc_cred *); 459 + struct nfs_client **, const struct cred *); 454 460 #if defined(CONFIG_NFS_V4_1) 455 461 int nfs41_discover_server_trunking(struct nfs_client *clp, 456 - struct nfs_client **, struct rpc_cred *); 462 + struct nfs_client **, const struct cred *); 457 463 extern void nfs4_schedule_session_recovery(struct nfs4_session *, int); 458 464 extern void nfs41_notify_server(struct nfs_client *); 459 465 #else ··· 462 468 } 463 469 #endif /* CONFIG_NFS_V4_1 */ 464 470 465 - extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *, gfp_t); 471 + extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, const struct cred *, gfp_t); 466 472 extern void nfs4_put_state_owner(struct nfs4_state_owner *); 467 473 extern void nfs4_purge_state_owners(struct nfs_server *); 468 474 extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); ··· 488 494 extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); 489 495 extern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t, 490 496 const struct nfs_lock_context *, nfs4_stateid *, 491 - struct rpc_cred **); 497 + const struct cred **); 492 498 extern bool nfs4_refresh_open_stateid(nfs4_stateid *dst, 493 499 struct nfs4_state *state); 494 500 extern bool nfs4_copy_open_stateid(nfs4_stateid *dst,
+2 -2
fs/nfs/nfs4client.c
··· 545 545 */ 546 546 int nfs40_walk_client_list(struct nfs_client *new, 547 547 struct nfs_client **result, 548 - struct rpc_cred *cred) 548 + const struct cred *cred) 549 549 { 550 550 struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id); 551 551 struct nfs_client *pos, *prev = NULL; ··· 711 711 */ 712 712 int nfs41_walk_client_list(struct nfs_client *new, 713 713 struct nfs_client **result, 714 - struct rpc_cred *cred) 714 + const struct cred *cred) 715 715 { 716 716 struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id); 717 717 struct nfs_client *pos, *prev = NULL;
+76 -82
fs/nfs/nfs4proc.c
··· 93 93 static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr); 94 94 static int nfs4_proc_getattr(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *label, struct inode *inode); 95 95 static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label, struct inode *inode); 96 - static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, 96 + static int nfs4_do_setattr(struct inode *inode, const struct cred *cred, 97 97 struct nfs_fattr *fattr, struct iattr *sattr, 98 98 struct nfs_open_context *ctx, struct nfs4_label *ilabel, 99 99 struct nfs4_label *olabel); 100 100 #ifdef CONFIG_NFS_V4_1 101 101 static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, 102 - struct rpc_cred *cred, 102 + const struct cred *cred, 103 103 struct nfs4_slot *slot, 104 104 bool is_privileged); 105 105 static int nfs41_test_stateid(struct nfs_server *, nfs4_stateid *, 106 - struct rpc_cred *); 106 + const struct cred *); 107 107 static int nfs41_free_stateid(struct nfs_server *, const nfs4_stateid *, 108 - struct rpc_cred *, bool); 108 + const struct cred *, bool); 109 109 #endif 110 110 111 111 #ifdef CONFIG_NFS_V4_SECURITY_LABEL ··· 361 361 362 362 static void nfs4_test_and_free_stateid(struct nfs_server *server, 363 363 nfs4_stateid *stateid, 364 - struct rpc_cred *cred) 364 + const struct cred *cred) 365 365 { 366 366 const struct nfs4_minor_version_ops *ops = server->nfs_client->cl_mvops; 367 367 ··· 370 370 371 371 static void __nfs4_free_revoked_stateid(struct nfs_server *server, 372 372 nfs4_stateid *stateid, 373 - struct rpc_cred *cred) 373 + const struct cred *cred) 374 374 { 375 375 stateid->type = NFS4_REVOKED_STATEID_TYPE; 376 376 nfs4_test_and_free_stateid(server, stateid, cred); ··· 378 378 379 379 static void nfs4_free_revoked_stateid(struct nfs_server *server, 380 380 const nfs4_stateid *stateid, 381 - struct rpc_cred *cred) 381 + const struct cred *cred) 382 382 { 383 383 nfs4_stateid tmp; 384 384 ··· 908 908 909 909 static void 910 910 nfs4_sequence_process_interrupted(struct nfs_client *client, 911 - struct nfs4_slot *slot, struct rpc_cred *cred) 911 + struct nfs4_slot *slot, const struct cred *cred) 912 912 { 913 913 struct rpc_task *task; 914 914 ··· 939 939 940 940 static void 941 941 nfs4_sequence_process_interrupted(struct nfs_client *client, 942 - struct nfs4_slot *slot, struct rpc_cred *cred) 942 + struct nfs4_slot *slot, const struct cred *cred) 943 943 { 944 944 WARN_ON_ONCE(1); 945 945 slot->interrupted = 0; ··· 2484 2484 * Note that in the non-execute case, we want to turn off permission 2485 2485 * checking if we just created a new file (POSIX open() semantics). 2486 2486 */ 2487 - static int nfs4_opendata_access(struct rpc_cred *cred, 2487 + static int nfs4_opendata_access(const struct cred *cred, 2488 2488 struct nfs4_opendata *opendata, 2489 2489 struct nfs4_state *state, fmode_t fmode, 2490 2490 int openflags) ··· 2651 2651 2652 2652 static int nfs40_test_and_free_expired_stateid(struct nfs_server *server, 2653 2653 nfs4_stateid *stateid, 2654 - struct rpc_cred *cred) 2654 + const struct cred *cred) 2655 2655 { 2656 2656 return -NFS4ERR_BAD_STATEID; 2657 2657 } ··· 2659 2659 #if defined(CONFIG_NFS_V4_1) 2660 2660 static int nfs41_test_and_free_expired_stateid(struct nfs_server *server, 2661 2661 nfs4_stateid *stateid, 2662 - struct rpc_cred *cred) 2662 + const struct cred *cred) 2663 2663 { 2664 2664 int status; 2665 2665 ··· 2693 2693 struct nfs_server *server = NFS_SERVER(state->inode); 2694 2694 nfs4_stateid stateid; 2695 2695 struct nfs_delegation *delegation; 2696 - struct rpc_cred *cred; 2696 + const struct cred *cred = NULL; 2697 2697 int status; 2698 2698 2699 2699 /* Get the delegation credential for use by test/free_stateid */ ··· 2718 2718 return; 2719 2719 } 2720 2720 2721 - cred = get_rpccred(delegation->cred); 2721 + if (delegation->cred) 2722 + cred = get_cred(delegation->cred); 2722 2723 rcu_read_unlock(); 2723 2724 status = nfs41_test_and_free_expired_stateid(server, &stateid, cred); 2724 2725 trace_nfs4_test_delegation_stateid(state, NULL, status); 2725 2726 if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID) 2726 2727 nfs_finish_clear_delegation_stateid(state, &stateid); 2727 2728 2728 - put_rpccred(cred); 2729 + if (delegation->cred) 2730 + put_cred(cred); 2729 2731 } 2730 2732 2731 2733 /** ··· 2750 2748 spin_lock(&state->state_lock); 2751 2749 list_for_each_entry(lsp, &state->lock_states, ls_locks) { 2752 2750 if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags)) { 2753 - struct rpc_cred *cred = lsp->ls_state->owner->so_cred; 2751 + const struct cred *cred = lsp->ls_state->owner->so_cred; 2754 2752 2755 2753 refcount_inc(&lsp->ls_count); 2756 2754 spin_unlock(&state->state_lock); ··· 2794 2792 { 2795 2793 struct nfs_server *server = NFS_SERVER(state->inode); 2796 2794 nfs4_stateid *stateid = &state->open_stateid; 2797 - struct rpc_cred *cred = state->owner->so_cred; 2795 + const struct cred *cred = state->owner->so_cred; 2798 2796 int status; 2799 2797 2800 2798 if (test_bit(NFS_OPEN_STATE, &state->flags) == 0) { ··· 2952 2950 struct nfs_server *server = NFS_SERVER(dir); 2953 2951 struct nfs4_opendata *opendata; 2954 2952 struct dentry *dentry = ctx->dentry; 2955 - struct rpc_cred *cred = ctx->cred; 2953 + const struct cred *cred = ctx->cred; 2956 2954 struct nfs4_threshold **ctx_th = &ctx->mdsthreshold; 2957 2955 fmode_t fmode = ctx->mode & (FMODE_READ|FMODE_WRITE|FMODE_EXEC); 2958 2956 enum open_claim_type4 claim = NFS4_OPEN_CLAIM_NULL; ··· 3122 3120 static int _nfs4_do_setattr(struct inode *inode, 3123 3121 struct nfs_setattrargs *arg, 3124 3122 struct nfs_setattrres *res, 3125 - struct rpc_cred *cred, 3123 + const struct cred *cred, 3126 3124 struct nfs_open_context *ctx) 3127 3125 { 3128 3126 struct nfs_server *server = NFS_SERVER(inode); ··· 3132 3130 .rpc_resp = res, 3133 3131 .rpc_cred = cred, 3134 3132 }; 3135 - struct rpc_cred *delegation_cred = NULL; 3133 + const struct cred *delegation_cred = NULL; 3136 3134 unsigned long timestamp = jiffies; 3137 3135 bool truncate; 3138 3136 int status; ··· 3167 3165 3168 3166 status = nfs4_call_sync(server->client, server, &msg, &arg->seq_args, &res->seq_res, 1); 3169 3167 3170 - put_rpccred(delegation_cred); 3168 + put_cred(delegation_cred); 3171 3169 if (status == 0 && ctx != NULL) 3172 3170 renew_lease(server, timestamp); 3173 3171 trace_nfs4_setattr(inode, &arg->stateid, status); 3174 3172 return status; 3175 3173 } 3176 3174 3177 - static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, 3175 + static int nfs4_do_setattr(struct inode *inode, const struct cred *cred, 3178 3176 struct nfs_fattr *fattr, struct iattr *sattr, 3179 3177 struct nfs_open_context *ctx, struct nfs4_label *ilabel, 3180 3178 struct nfs4_label *olabel) ··· 3975 3973 struct iattr *sattr) 3976 3974 { 3977 3975 struct inode *inode = d_inode(dentry); 3978 - struct rpc_cred *cred = NULL; 3976 + const struct cred *cred = NULL; 3979 3977 struct nfs_open_context *ctx = NULL; 3980 3978 struct nfs4_label *label = NULL; 3981 3979 int status; ··· 4204 4202 return -ENOMEM; 4205 4203 args.bitmask = server->cache_consistency_bitmask; 4206 4204 } 4207 - 4208 4205 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); 4209 4206 if (!status) { 4210 4207 nfs_access_set_mask(entry, res.access); ··· 4692 4691 return err; 4693 4692 } 4694 4693 4695 - static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, 4694 + static int _nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred, 4696 4695 u64 cookie, struct page **pages, unsigned int count, bool plus) 4697 4696 { 4698 4697 struct inode *dir = d_inode(dentry); ··· 4730 4729 return status; 4731 4730 } 4732 4731 4733 - static int nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, 4732 + static int nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred, 4734 4733 u64 cookie, struct page **pages, unsigned int count, bool plus) 4735 4734 { 4736 4735 struct nfs4_exception exception = { }; ··· 5258 5257 .rpc_release = nfs4_renew_release, 5259 5258 }; 5260 5259 5261 - static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags) 5260 + static int nfs4_proc_async_renew(struct nfs_client *clp, const struct cred *cred, unsigned renew_flags) 5262 5261 { 5263 5262 struct rpc_message msg = { 5264 5263 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], ··· 5282 5281 &nfs4_renew_ops, data); 5283 5282 } 5284 5283 5285 - static int nfs4_proc_renew(struct nfs_client *clp, struct rpc_cred *cred) 5284 + static int nfs4_proc_renew(struct nfs_client *clp, const struct cred *cred) 5286 5285 { 5287 5286 struct rpc_message msg = { 5288 5287 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], ··· 5697 5696 { 5698 5697 struct nfs4_label ilabel, *olabel = NULL; 5699 5698 struct nfs_fattr fattr; 5700 - struct rpc_cred *cred; 5701 5699 int status; 5702 5700 5703 5701 if (!nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) ··· 5708 5708 ilabel.lfs = 0; 5709 5709 ilabel.label = (char *)buf; 5710 5710 ilabel.len = buflen; 5711 - 5712 - cred = rpc_lookup_cred(); 5713 - if (IS_ERR(cred)) 5714 - return PTR_ERR(cred); 5715 5711 5716 5712 olabel = nfs4_label_alloc(NFS_SERVER(inode), GFP_KERNEL); 5717 5713 if (IS_ERR(olabel)) { ··· 5721 5725 5722 5726 nfs4_label_free(olabel); 5723 5727 out: 5724 - put_rpccred(cred); 5725 5728 return status; 5726 5729 } 5727 5730 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */ ··· 5889 5894 * @clp: state data structure 5890 5895 * @program: RPC program for NFSv4 callback service 5891 5896 * @port: IP port number for NFS4 callback service 5892 - * @cred: RPC credential to use for this call 5897 + * @cred: credential to use for this call 5893 5898 * @res: where to place the result 5894 5899 * 5895 5900 * Returns zero, a negative errno, or a negative NFS4ERR status code. 5896 5901 */ 5897 5902 int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, 5898 - unsigned short port, struct rpc_cred *cred, 5903 + unsigned short port, const struct cred *cred, 5899 5904 struct nfs4_setclientid_res *res) 5900 5905 { 5901 5906 nfs4_verifier sc_verifier; ··· 5964 5969 * nfs4_proc_setclientid_confirm - Confirm client ID 5965 5970 * @clp: state data structure 5966 5971 * @res: result of a previous SETCLIENTID 5967 - * @cred: RPC credential to use for this call 5972 + * @cred: credential to use for this call 5968 5973 * 5969 5974 * Returns zero, a negative errno, or a negative NFS4ERR status code. 5970 5975 */ 5971 5976 int nfs4_proc_setclientid_confirm(struct nfs_client *clp, 5972 5977 struct nfs4_setclientid_res *arg, 5973 - struct rpc_cred *cred) 5978 + const struct cred *cred) 5974 5979 { 5975 5980 struct rpc_message msg = { 5976 5981 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], ··· 6133 6138 .rpc_release = nfs4_delegreturn_release, 6134 6139 }; 6135 6140 6136 - static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync) 6141 + static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync) 6137 6142 { 6138 6143 struct nfs4_delegreturndata *data; 6139 6144 struct nfs_server *server = NFS_SERVER(inode); ··· 6200 6205 return status; 6201 6206 } 6202 6207 6203 - int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync) 6208 + int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync) 6204 6209 { 6205 6210 struct nfs_server *server = NFS_SERVER(inode); 6206 6211 struct nfs4_exception exception = { }; ··· 7263 7268 */ 7264 7269 static int _nfs40_proc_get_locations(struct inode *inode, 7265 7270 struct nfs4_fs_locations *locations, 7266 - struct page *page, struct rpc_cred *cred) 7271 + struct page *page, const struct cred *cred) 7267 7272 { 7268 7273 struct nfs_server *server = NFS_SERVER(inode); 7269 7274 struct rpc_clnt *clnt = server->client; ··· 7320 7325 */ 7321 7326 static int _nfs41_proc_get_locations(struct inode *inode, 7322 7327 struct nfs4_fs_locations *locations, 7323 - struct page *page, struct rpc_cred *cred) 7328 + struct page *page, const struct cred *cred) 7324 7329 { 7325 7330 struct nfs_server *server = NFS_SERVER(inode); 7326 7331 struct rpc_clnt *clnt = server->client; ··· 7379 7384 */ 7380 7385 int nfs4_proc_get_locations(struct inode *inode, 7381 7386 struct nfs4_fs_locations *locations, 7382 - struct page *page, struct rpc_cred *cred) 7387 + struct page *page, const struct cred *cred) 7383 7388 { 7384 7389 struct nfs_server *server = NFS_SERVER(inode); 7385 7390 struct nfs_client *clp = server->nfs_client; ··· 7410 7415 * is appended to this compound to identify the client ID which is 7411 7416 * performing recovery. 7412 7417 */ 7413 - static int _nfs40_proc_fsid_present(struct inode *inode, struct rpc_cred *cred) 7418 + static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred) 7414 7419 { 7415 7420 struct nfs_server *server = NFS_SERVER(inode); 7416 7421 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; ··· 7456 7461 * this operation is identified in the SEQUENCE operation in this 7457 7462 * compound. 7458 7463 */ 7459 - static int _nfs41_proc_fsid_present(struct inode *inode, struct rpc_cred *cred) 7464 + static int _nfs41_proc_fsid_present(struct inode *inode, const struct cred *cred) 7460 7465 { 7461 7466 struct nfs_server *server = NFS_SERVER(inode); 7462 7467 struct rpc_clnt *clnt = server->client; ··· 7503 7508 * NFS4ERR code if some error occurred on the server, or a 7504 7509 * negative errno if a local failure occurred. 7505 7510 */ 7506 - int nfs4_proc_fsid_present(struct inode *inode, struct rpc_cred *cred) 7511 + int nfs4_proc_fsid_present(struct inode *inode, const struct cred *cred) 7507 7512 { 7508 7513 struct nfs_server *server = NFS_SERVER(inode); 7509 7514 struct nfs_client *clp = server->nfs_client; ··· 7550 7555 .rpc_resp = &res, 7551 7556 }; 7552 7557 struct rpc_clnt *clnt = NFS_SERVER(dir)->client; 7553 - struct rpc_cred *cred = NULL; 7558 + const struct cred *cred = NULL; 7554 7559 7555 7560 if (use_integrity) { 7556 7561 clnt = NFS_SERVER(dir)->nfs_client->cl_rpcclient; ··· 7567 7572 &res.seq_res, 0); 7568 7573 dprintk("NFS reply secinfo: %d\n", status); 7569 7574 7570 - if (cred) 7571 - put_rpccred(cred); 7575 + put_cred(cred); 7572 7576 7573 7577 return status; 7574 7578 } ··· 7648 7654 int nfs4_proc_bind_one_conn_to_session(struct rpc_clnt *clnt, 7649 7655 struct rpc_xprt *xprt, 7650 7656 struct nfs_client *clp, 7651 - struct rpc_cred *cred) 7657 + const struct cred *cred) 7652 7658 { 7653 7659 int status; 7654 7660 struct nfs41_bind_conn_to_session_args args = { ··· 7710 7716 7711 7717 struct rpc_bind_conn_calldata { 7712 7718 struct nfs_client *clp; 7713 - struct rpc_cred *cred; 7719 + const struct cred *cred; 7714 7720 }; 7715 7721 7716 7722 static int ··· 7723 7729 return nfs4_proc_bind_one_conn_to_session(clnt, xprt, p->clp, p->cred); 7724 7730 } 7725 7731 7726 - int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred) 7732 + int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, const struct cred *cred) 7727 7733 { 7728 7734 struct rpc_bind_conn_calldata data = { 7729 7735 .clp = clp, ··· 7889 7895 * Wrapper for EXCHANGE_ID operation. 7890 7896 */ 7891 7897 static struct rpc_task * 7892 - nfs4_run_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, 7898 + nfs4_run_exchange_id(struct nfs_client *clp, const struct cred *cred, 7893 7899 u32 sp4_how, struct rpc_xprt *xprt) 7894 7900 { 7895 7901 struct rpc_message msg = { ··· 7985 7991 * 7986 7992 * Wrapper for EXCHANGE_ID operation. 7987 7993 */ 7988 - static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, 7994 + static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred, 7989 7995 u32 sp4_how) 7990 7996 { 7991 7997 struct rpc_task *task; ··· 8052 8058 * 8053 8059 * Will attempt to negotiate SP4_MACH_CRED if krb5i / krb5p auth is used. 8054 8060 */ 8055 - int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) 8061 + int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred) 8056 8062 { 8057 8063 rpc_authflavor_t authflavor = clp->cl_rpcclient->cl_auth->au_flavor; 8058 8064 int status; ··· 8084 8090 * @xprt: the rpc_xprt to test 8085 8091 * @data: call data for _nfs4_proc_exchange_id. 8086 8092 */ 8087 - int nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt, 8093 + void nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt, 8088 8094 void *data) 8089 8095 { 8090 8096 struct nfs4_add_xprt_data *adata = (struct nfs4_add_xprt_data *)data; ··· 8101 8107 /* Test connection for session trunking. Async exchange_id call */ 8102 8108 task = nfs4_run_exchange_id(adata->clp, adata->cred, sp4_how, xprt); 8103 8109 if (IS_ERR(task)) 8104 - return PTR_ERR(task); 8110 + return; 8105 8111 8106 8112 status = task->tk_status; 8107 8113 if (status == 0) 8108 8114 status = nfs4_detect_session_trunking(adata->clp, 8109 8115 task->tk_msg.rpc_resp, xprt); 8110 8116 8117 + if (status == 0) 8118 + rpc_clnt_xprt_switch_add_xprt(clnt, xprt); 8119 + 8111 8120 rpc_put_task(task); 8112 - return status; 8113 8121 } 8114 8122 EXPORT_SYMBOL_GPL(nfs4_test_session_trunk); 8115 8123 8116 8124 static int _nfs4_proc_destroy_clientid(struct nfs_client *clp, 8117 - struct rpc_cred *cred) 8125 + const struct cred *cred) 8118 8126 { 8119 8127 struct rpc_message msg = { 8120 8128 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_CLIENTID], ··· 8134 8138 } 8135 8139 8136 8140 static int nfs4_proc_destroy_clientid(struct nfs_client *clp, 8137 - struct rpc_cred *cred) 8141 + const struct cred *cred) 8138 8142 { 8139 8143 unsigned int loop; 8140 8144 int ret; ··· 8155 8159 8156 8160 int nfs4_destroy_clientid(struct nfs_client *clp) 8157 8161 { 8158 - struct rpc_cred *cred; 8162 + const struct cred *cred; 8159 8163 int ret = 0; 8160 8164 8161 8165 if (clp->cl_mvops->minor_version < 1) ··· 8166 8170 goto out; 8167 8171 cred = nfs4_get_clid_cred(clp); 8168 8172 ret = nfs4_proc_destroy_clientid(clp, cred); 8169 - if (cred) 8170 - put_rpccred(cred); 8173 + put_cred(cred); 8171 8174 switch (ret) { 8172 8175 case 0: 8173 8176 case -NFS4ERR_STALE_CLIENTID: ··· 8382 8387 } 8383 8388 8384 8389 static int _nfs4_proc_create_session(struct nfs_client *clp, 8385 - struct rpc_cred *cred) 8390 + const struct cred *cred) 8386 8391 { 8387 8392 struct nfs4_session *session = clp->cl_session; 8388 8393 struct nfs41_create_session_args args = { ··· 8434 8439 * It is the responsibility of the caller to verify the session is 8435 8440 * expired before calling this routine. 8436 8441 */ 8437 - int nfs4_proc_create_session(struct nfs_client *clp, struct rpc_cred *cred) 8442 + int nfs4_proc_create_session(struct nfs_client *clp, const struct cred *cred) 8438 8443 { 8439 8444 int status; 8440 8445 unsigned *ptr; ··· 8465 8470 * The caller must serialize access to this routine. 8466 8471 */ 8467 8472 int nfs4_proc_destroy_session(struct nfs4_session *session, 8468 - struct rpc_cred *cred) 8473 + const struct cred *cred) 8469 8474 { 8470 8475 struct rpc_message msg = { 8471 8476 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION], ··· 8567 8572 }; 8568 8573 8569 8574 static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, 8570 - struct rpc_cred *cred, 8575 + const struct cred *cred, 8571 8576 struct nfs4_slot *slot, 8572 8577 bool is_privileged) 8573 8578 { ··· 8610 8615 return ret; 8611 8616 } 8612 8617 8613 - static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cred, unsigned renew_flags) 8618 + static int nfs41_proc_async_sequence(struct nfs_client *clp, const struct cred *cred, unsigned renew_flags) 8614 8619 { 8615 8620 struct rpc_task *task; 8616 8621 int ret = 0; ··· 8626 8631 return ret; 8627 8632 } 8628 8633 8629 - static int nfs4_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred) 8634 + static int nfs4_proc_sequence(struct nfs_client *clp, const struct cred *cred) 8630 8635 { 8631 8636 struct rpc_task *task; 8632 8637 int ret; ··· 8722 8727 * Issue a global reclaim complete. 8723 8728 */ 8724 8729 static int nfs41_proc_reclaim_complete(struct nfs_client *clp, 8725 - struct rpc_cred *cred) 8730 + const struct cred *cred) 8726 8731 { 8727 8732 struct nfs4_reclaim_complete_data *calldata; 8728 8733 struct rpc_task *task; ··· 9075 9080 static int 9076 9081 _nfs4_proc_getdeviceinfo(struct nfs_server *server, 9077 9082 struct pnfs_device *pdev, 9078 - struct rpc_cred *cred) 9083 + const struct cred *cred) 9079 9084 { 9080 9085 struct nfs4_getdeviceinfo_args args = { 9081 9086 .pdev = pdev, ··· 9107 9112 9108 9113 int nfs4_proc_getdeviceinfo(struct nfs_server *server, 9109 9114 struct pnfs_device *pdev, 9110 - struct rpc_cred *cred) 9115 + const struct cred *cred) 9111 9116 { 9112 9117 struct nfs4_exception exception = { }; 9113 9118 int err; ··· 9164 9169 pnfs_cleanup_layoutcommit(data); 9165 9170 nfs_post_op_update_inode_force_wcc(data->args.inode, 9166 9171 data->res.fattr); 9167 - put_rpccred(data->cred); 9172 + put_cred(data->cred); 9168 9173 nfs_iput_and_deactive(data->inode); 9169 9174 kfree(data); 9170 9175 } ··· 9240 9245 .rpc_resp = &res, 9241 9246 }; 9242 9247 struct rpc_clnt *clnt = server->client; 9243 - struct rpc_cred *cred = NULL; 9248 + const struct cred *cred = NULL; 9244 9249 int status; 9245 9250 9246 9251 if (use_integrity) { ··· 9254 9259 &res.seq_res, 0); 9255 9260 dprintk("<-- %s status=%d\n", __func__, status); 9256 9261 9257 - if (cred) 9258 - put_rpccred(cred); 9262 + put_cred(cred); 9259 9263 9260 9264 return status; 9261 9265 } ··· 9367 9373 9368 9374 static int _nfs41_test_stateid(struct nfs_server *server, 9369 9375 nfs4_stateid *stateid, 9370 - struct rpc_cred *cred) 9376 + const struct cred *cred) 9371 9377 { 9372 9378 int status; 9373 9379 struct nfs41_test_stateid_args args = { ··· 9428 9434 */ 9429 9435 static int nfs41_test_stateid(struct nfs_server *server, 9430 9436 nfs4_stateid *stateid, 9431 - struct rpc_cred *cred) 9437 + const struct cred *cred) 9432 9438 { 9433 9439 struct nfs4_exception exception = { }; 9434 9440 int err; ··· 9490 9496 */ 9491 9497 static int nfs41_free_stateid(struct nfs_server *server, 9492 9498 const nfs4_stateid *stateid, 9493 - struct rpc_cred *cred, 9499 + const struct cred *cred, 9494 9500 bool privileged) 9495 9501 { 9496 9502 struct rpc_message msg = { ··· 9531 9537 static void 9532 9538 nfs41_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp) 9533 9539 { 9534 - struct rpc_cred *cred = lsp->ls_state->owner->so_cred; 9540 + const struct cred *cred = lsp->ls_state->owner->so_cred; 9535 9541 9536 9542 nfs41_free_stateid(server, &lsp->ls_stateid, cred, false); 9537 9543 nfs4_free_lock_state(server, lsp); ··· 9602 9608 9603 9609 static const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = { 9604 9610 .sched_state_renewal = nfs4_proc_async_renew, 9605 - .get_state_renewal_cred_locked = nfs4_get_renew_cred_locked, 9611 + .get_state_renewal_cred = nfs4_get_renew_cred, 9606 9612 .renew_lease = nfs4_proc_renew, 9607 9613 }; 9608 9614 9609 9615 #if defined(CONFIG_NFS_V4_1) 9610 9616 static const struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = { 9611 9617 .sched_state_renewal = nfs41_proc_async_sequence, 9612 - .get_state_renewal_cred_locked = nfs4_get_machine_cred_locked, 9618 + .get_state_renewal_cred = nfs4_get_machine_cred, 9613 9619 .renew_lease = nfs4_proc_sequence, 9614 9620 }; 9615 9621 #endif
+3 -6
fs/nfs/nfs4renewd.c
··· 57 57 const struct nfs4_state_maintenance_ops *ops; 58 58 struct nfs_client *clp = 59 59 container_of(work, struct nfs_client, cl_renewd.work); 60 - struct rpc_cred *cred; 60 + const struct cred *cred; 61 61 long lease; 62 62 unsigned long last, now; 63 63 unsigned renew_flags = 0; ··· 68 68 if (test_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state)) 69 69 goto out; 70 70 71 - spin_lock(&clp->cl_lock); 72 71 lease = clp->cl_lease_time; 73 72 last = clp->cl_last_renewal; 74 73 now = jiffies; ··· 78 79 renew_flags |= NFS4_RENEW_DELEGATION_CB; 79 80 80 81 if (renew_flags != 0) { 81 - cred = ops->get_state_renewal_cred_locked(clp); 82 - spin_unlock(&clp->cl_lock); 82 + cred = ops->get_state_renewal_cred(clp); 83 83 if (cred == NULL) { 84 84 if (!(renew_flags & NFS4_RENEW_DELEGATION_CB)) { 85 85 set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); ··· 90 92 91 93 /* Queue an asynchronous RENEW. */ 92 94 ret = ops->sched_state_renewal(clp, cred, renew_flags); 93 - put_rpccred(cred); 95 + put_cred(cred); 94 96 switch (ret) { 95 97 default: 96 98 goto out_exp; ··· 102 104 } else { 103 105 dprintk("%s: failed to call renewd. Reason: lease not expired \n", 104 106 __func__); 105 - spin_unlock(&clp->cl_lock); 106 107 } 107 108 nfs4_schedule_state_renewal(clp); 108 109 out_exp:
+2 -3
fs/nfs/nfs4session.c
··· 573 573 void nfs4_destroy_session(struct nfs4_session *session) 574 574 { 575 575 struct rpc_xprt *xprt; 576 - struct rpc_cred *cred; 576 + const struct cred *cred; 577 577 578 578 cred = nfs4_get_clid_cred(session->clp); 579 579 nfs4_proc_destroy_session(session, cred); 580 - if (cred) 581 - put_rpccred(cred); 580 + put_cred(cred); 582 581 583 582 rcu_read_lock(); 584 583 xprt = rcu_dereference(session->clp->cl_rpcclient->cl_xprt);
+59 -72
fs/nfs/nfs4state.c
··· 87 87 88 88 static DEFINE_MUTEX(nfs_clid_init_mutex); 89 89 90 - int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) 90 + int nfs4_init_clientid(struct nfs_client *clp, const struct cred *cred) 91 91 { 92 92 struct nfs4_setclientid_res clid = { 93 93 .clientid = clp->cl_clientid, ··· 134 134 */ 135 135 int nfs40_discover_server_trunking(struct nfs_client *clp, 136 136 struct nfs_client **result, 137 - struct rpc_cred *cred) 137 + const struct cred *cred) 138 138 { 139 139 struct nfs4_setclientid_res clid = { 140 140 .clientid = clp->cl_clientid, ··· 164 164 return status; 165 165 } 166 166 167 - struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp) 167 + const struct cred *nfs4_get_machine_cred(struct nfs_client *clp) 168 168 { 169 - struct rpc_cred *cred = NULL; 170 - 171 - if (clp->cl_machine_cred != NULL) 172 - cred = get_rpccred(clp->cl_machine_cred); 173 - return cred; 169 + return get_cred(rpc_machine_cred()); 174 170 } 175 171 176 172 static void nfs4_root_machine_cred(struct nfs_client *clp) 177 173 { 178 - struct rpc_cred *cred, *new; 179 174 180 - new = rpc_lookup_machine_cred(NULL); 181 - spin_lock(&clp->cl_lock); 182 - cred = clp->cl_machine_cred; 183 - clp->cl_machine_cred = new; 184 - spin_unlock(&clp->cl_lock); 185 - if (cred != NULL) 186 - put_rpccred(cred); 175 + /* Force root creds instead of machine */ 176 + clp->cl_principal = NULL; 177 + clp->cl_rpcclient->cl_principal = NULL; 187 178 } 188 179 189 - static struct rpc_cred * 180 + static const struct cred * 190 181 nfs4_get_renew_cred_server_locked(struct nfs_server *server) 191 182 { 192 - struct rpc_cred *cred = NULL; 183 + const struct cred *cred = NULL; 193 184 struct nfs4_state_owner *sp; 194 185 struct rb_node *pos; 195 186 ··· 190 199 sp = rb_entry(pos, struct nfs4_state_owner, so_server_node); 191 200 if (list_empty(&sp->so_states)) 192 201 continue; 193 - cred = get_rpccred(sp->so_cred); 202 + cred = get_cred(sp->so_cred); 194 203 break; 195 204 } 196 205 return cred; 197 206 } 198 207 199 208 /** 200 - * nfs4_get_renew_cred_locked - Acquire credential for a renew operation 209 + * nfs4_get_renew_cred - Acquire credential for a renew operation 201 210 * @clp: client state handle 202 211 * 203 212 * Returns an rpc_cred with reference count bumped, or NULL. 204 213 * Caller must hold clp->cl_lock. 205 214 */ 206 - struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp) 215 + const struct cred *nfs4_get_renew_cred(struct nfs_client *clp) 207 216 { 208 - struct rpc_cred *cred = NULL; 217 + const struct cred *cred = NULL; 209 218 struct nfs_server *server; 210 219 211 220 /* Use machine credentials if available */ 212 - cred = nfs4_get_machine_cred_locked(clp); 221 + cred = nfs4_get_machine_cred(clp); 213 222 if (cred != NULL) 214 223 goto out; 215 224 225 + spin_lock(&clp->cl_lock); 216 226 rcu_read_lock(); 217 227 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { 218 228 cred = nfs4_get_renew_cred_server_locked(server); ··· 221 229 break; 222 230 } 223 231 rcu_read_unlock(); 232 + spin_unlock(&clp->cl_lock); 224 233 225 234 out: 226 235 return cred; ··· 312 319 nfs41_setup_state_renewal(clp); 313 320 } 314 321 315 - int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) 322 + int nfs41_init_clientid(struct nfs_client *clp, const struct cred *cred) 316 323 { 317 324 int status; 318 325 ··· 347 354 */ 348 355 int nfs41_discover_server_trunking(struct nfs_client *clp, 349 356 struct nfs_client **result, 350 - struct rpc_cred *cred) 357 + const struct cred *cred) 351 358 { 352 359 int status; 353 360 ··· 385 392 * nfs4_get_clid_cred - Acquire credential for a setclientid operation 386 393 * @clp: client state handle 387 394 * 388 - * Returns an rpc_cred with reference count bumped, or NULL. 395 + * Returns a cred with reference count bumped, or NULL. 389 396 */ 390 - struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp) 397 + const struct cred *nfs4_get_clid_cred(struct nfs_client *clp) 391 398 { 392 - struct rpc_cred *cred; 399 + const struct cred *cred; 393 400 394 - spin_lock(&clp->cl_lock); 395 - cred = nfs4_get_machine_cred_locked(clp); 396 - spin_unlock(&clp->cl_lock); 401 + cred = nfs4_get_machine_cred(clp); 397 402 return cred; 398 403 } 399 404 400 405 static struct nfs4_state_owner * 401 - nfs4_find_state_owner_locked(struct nfs_server *server, struct rpc_cred *cred) 406 + nfs4_find_state_owner_locked(struct nfs_server *server, const struct cred *cred) 402 407 { 403 408 struct rb_node **p = &server->state_owners.rb_node, 404 409 *parent = NULL; 405 410 struct nfs4_state_owner *sp; 411 + int cmp; 406 412 407 413 while (*p != NULL) { 408 414 parent = *p; 409 415 sp = rb_entry(parent, struct nfs4_state_owner, so_server_node); 416 + cmp = cred_fscmp(cred, sp->so_cred); 410 417 411 - if (cred < sp->so_cred) 418 + if (cmp < 0) 412 419 p = &parent->rb_left; 413 - else if (cred > sp->so_cred) 420 + else if (cmp > 0) 414 421 p = &parent->rb_right; 415 422 else { 416 423 if (!list_empty(&sp->so_lru)) ··· 429 436 struct rb_node **p = &server->state_owners.rb_node, 430 437 *parent = NULL; 431 438 struct nfs4_state_owner *sp; 439 + int cmp; 432 440 433 441 while (*p != NULL) { 434 442 parent = *p; 435 443 sp = rb_entry(parent, struct nfs4_state_owner, so_server_node); 444 + cmp = cred_fscmp(new->so_cred, sp->so_cred); 436 445 437 - if (new->so_cred < sp->so_cred) 446 + if (cmp < 0) 438 447 p = &parent->rb_left; 439 - else if (new->so_cred > sp->so_cred) 448 + else if (cmp > 0) 440 449 p = &parent->rb_right; 441 450 else { 442 451 if (!list_empty(&sp->so_lru)) ··· 485 490 */ 486 491 static struct nfs4_state_owner * 487 492 nfs4_alloc_state_owner(struct nfs_server *server, 488 - struct rpc_cred *cred, 493 + const struct cred *cred, 489 494 gfp_t gfp_flags) 490 495 { 491 496 struct nfs4_state_owner *sp; ··· 500 505 return NULL; 501 506 } 502 507 sp->so_server = server; 503 - sp->so_cred = get_rpccred(cred); 508 + sp->so_cred = get_cred(cred); 504 509 spin_lock_init(&sp->so_lock); 505 510 INIT_LIST_HEAD(&sp->so_states); 506 511 nfs4_init_seqid_counter(&sp->so_seqid); ··· 529 534 static void nfs4_free_state_owner(struct nfs4_state_owner *sp) 530 535 { 531 536 nfs4_destroy_seqid_counter(&sp->so_seqid); 532 - put_rpccred(sp->so_cred); 537 + put_cred(sp->so_cred); 533 538 ida_simple_remove(&sp->so_server->openowner_id, sp->so_seqid.owner_id); 534 539 kfree(sp); 535 540 } ··· 567 572 * Returns a pointer to an instantiated nfs4_state_owner struct, or NULL. 568 573 */ 569 574 struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, 570 - struct rpc_cred *cred, 575 + const struct cred *cred, 571 576 gfp_t gfp_flags) 572 577 { 573 578 struct nfs_client *clp = server->nfs_client; ··· 1036 1041 */ 1037 1042 int nfs4_select_rw_stateid(struct nfs4_state *state, 1038 1043 fmode_t fmode, const struct nfs_lock_context *l_ctx, 1039 - nfs4_stateid *dst, struct rpc_cred **cred) 1044 + nfs4_stateid *dst, const struct cred **cred) 1040 1045 { 1041 1046 int ret; 1042 1047 ··· 1555 1560 1556 1561 spin_lock(&sp->so_server->nfs_client->cl_lock); 1557 1562 list_for_each_entry(copy, &sp->so_server->ss_copies, copies) { 1558 - if (nfs4_stateid_match_other(&state->stateid, &copy->parent_state->stateid)) 1563 + if (!nfs4_stateid_match_other(&state->stateid, &copy->parent_state->stateid)) 1559 1564 continue; 1560 1565 copy->flags = 1; 1561 1566 complete(&copy->completion); ··· 1736 1741 1737 1742 static int nfs4_reclaim_complete(struct nfs_client *clp, 1738 1743 const struct nfs4_state_recovery_ops *ops, 1739 - struct rpc_cred *cred) 1744 + const struct cred *cred) 1740 1745 { 1741 1746 /* Notify the server we're done reclaiming our state */ 1742 1747 if (ops->reclaim_complete) ··· 1787 1792 static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) 1788 1793 { 1789 1794 const struct nfs4_state_recovery_ops *ops; 1790 - struct rpc_cred *cred; 1795 + const struct cred *cred; 1791 1796 int err; 1792 1797 1793 1798 if (!nfs4_state_clear_reclaim_reboot(clp)) ··· 1795 1800 ops = clp->cl_mvops->reboot_recovery_ops; 1796 1801 cred = nfs4_get_clid_cred(clp); 1797 1802 err = nfs4_reclaim_complete(clp, ops, cred); 1798 - put_rpccred(cred); 1803 + put_cred(cred); 1799 1804 if (err == -NFS4ERR_CONN_NOT_BOUND_TO_SESSION) 1800 1805 set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state); 1801 1806 } ··· 1891 1896 1892 1897 static int nfs4_check_lease(struct nfs_client *clp) 1893 1898 { 1894 - struct rpc_cred *cred; 1899 + const struct cred *cred; 1895 1900 const struct nfs4_state_maintenance_ops *ops = 1896 1901 clp->cl_mvops->state_renewal_ops; 1897 1902 int status; ··· 1899 1904 /* Is the client already known to have an expired lease? */ 1900 1905 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) 1901 1906 return 0; 1902 - spin_lock(&clp->cl_lock); 1903 - cred = ops->get_state_renewal_cred_locked(clp); 1904 - spin_unlock(&clp->cl_lock); 1907 + cred = ops->get_state_renewal_cred(clp); 1905 1908 if (cred == NULL) { 1906 1909 cred = nfs4_get_clid_cred(clp); 1907 1910 status = -ENOKEY; ··· 1907 1914 goto out; 1908 1915 } 1909 1916 status = ops->renew_lease(clp, cred); 1910 - put_rpccred(cred); 1917 + put_cred(cred); 1911 1918 if (status == -ETIMEDOUT) { 1912 1919 set_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); 1913 1920 return 0; ··· 1967 1974 1968 1975 static int nfs4_establish_lease(struct nfs_client *clp) 1969 1976 { 1970 - struct rpc_cred *cred; 1977 + const struct cred *cred; 1971 1978 const struct nfs4_state_recovery_ops *ops = 1972 1979 clp->cl_mvops->reboot_recovery_ops; 1973 1980 int status; ··· 1979 1986 if (cred == NULL) 1980 1987 return -ENOENT; 1981 1988 status = ops->establish_clid(clp, cred); 1982 - put_rpccred(cred); 1989 + put_cred(cred); 1983 1990 if (status != 0) 1984 1991 return status; 1985 1992 pnfs_destroy_all_layouts(clp); ··· 2026 2033 * 2027 2034 * Returns zero or a negative NFS4ERR status code. 2028 2035 */ 2029 - static int nfs4_try_migration(struct nfs_server *server, struct rpc_cred *cred) 2036 + static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred) 2030 2037 { 2031 2038 struct nfs_client *clp = server->nfs_client; 2032 2039 struct nfs4_fs_locations *locations = NULL; ··· 2096 2103 const struct nfs4_state_maintenance_ops *ops = 2097 2104 clp->cl_mvops->state_renewal_ops; 2098 2105 struct nfs_server *server; 2099 - struct rpc_cred *cred; 2106 + const struct cred *cred; 2100 2107 2101 2108 dprintk("%s: migration reported on \"%s\"\n", __func__, 2102 2109 clp->cl_hostname); 2103 2110 2104 - spin_lock(&clp->cl_lock); 2105 - cred = ops->get_state_renewal_cred_locked(clp); 2106 - spin_unlock(&clp->cl_lock); 2111 + cred = ops->get_state_renewal_cred(clp); 2107 2112 if (cred == NULL) 2108 2113 return -NFS4ERR_NOENT; 2109 2114 ··· 2122 2131 rcu_read_unlock(); 2123 2132 status = nfs4_try_migration(server, cred); 2124 2133 if (status < 0) { 2125 - put_rpccred(cred); 2134 + put_cred(cred); 2126 2135 return status; 2127 2136 } 2128 2137 goto restart; 2129 2138 } 2130 2139 rcu_read_unlock(); 2131 - put_rpccred(cred); 2140 + put_cred(cred); 2132 2141 return 0; 2133 2142 } 2134 2143 ··· 2142 2151 const struct nfs4_state_maintenance_ops *ops = 2143 2152 clp->cl_mvops->state_renewal_ops; 2144 2153 struct nfs_server *server; 2145 - struct rpc_cred *cred; 2154 + const struct cred *cred; 2146 2155 2147 2156 dprintk("%s: lease moved reported on \"%s\"\n", __func__, 2148 2157 clp->cl_hostname); 2149 2158 2150 - spin_lock(&clp->cl_lock); 2151 - cred = ops->get_state_renewal_cred_locked(clp); 2152 - spin_unlock(&clp->cl_lock); 2159 + cred = ops->get_state_renewal_cred(clp); 2153 2160 if (cred == NULL) 2154 2161 return -NFS4ERR_NOENT; 2155 2162 ··· 2175 2186 rcu_read_unlock(); 2176 2187 2177 2188 out: 2178 - put_rpccred(cred); 2189 + put_cred(cred); 2179 2190 return 0; 2180 2191 } 2181 2192 ··· 2198 2209 const struct nfs4_state_recovery_ops *ops = 2199 2210 clp->cl_mvops->reboot_recovery_ops; 2200 2211 struct rpc_clnt *clnt; 2201 - struct rpc_cred *cred; 2212 + const struct cred *cred; 2202 2213 int i, status; 2203 2214 2204 2215 dprintk("NFS: %s: testing '%s'\n", __func__, clp->cl_hostname); ··· 2214 2225 goto out_unlock; 2215 2226 2216 2227 status = ops->detect_trunking(clp, result, cred); 2217 - put_rpccred(cred); 2228 + put_cred(cred); 2218 2229 switch (status) { 2219 2230 case 0: 2220 2231 case -EINTR: ··· 2405 2416 2406 2417 static int nfs4_reset_session(struct nfs_client *clp) 2407 2418 { 2408 - struct rpc_cred *cred; 2419 + const struct cred *cred; 2409 2420 int status; 2410 2421 2411 2422 if (!nfs4_has_session(clp)) ··· 2443 2454 dprintk("%s: session reset was successful for server %s!\n", 2444 2455 __func__, clp->cl_hostname); 2445 2456 out: 2446 - if (cred) 2447 - put_rpccred(cred); 2457 + put_cred(cred); 2448 2458 return status; 2449 2459 } 2450 2460 2451 2461 static int nfs4_bind_conn_to_session(struct nfs_client *clp) 2452 2462 { 2453 - struct rpc_cred *cred; 2463 + const struct cred *cred; 2454 2464 int ret; 2455 2465 2456 2466 if (!nfs4_has_session(clp)) ··· 2459 2471 return ret; 2460 2472 cred = nfs4_get_clid_cred(clp); 2461 2473 ret = nfs4_proc_bind_conn_to_session(clp, cred); 2462 - if (cred) 2463 - put_rpccred(cred); 2474 + put_cred(cred); 2464 2475 clear_bit(NFS4CLNT_BIND_CONN_TO_SESSION, &clp->cl_state); 2465 2476 switch (ret) { 2466 2477 case 0:
+313 -143
fs/nfs/nfs4trace.h
··· 10 10 11 11 #include <linux/tracepoint.h> 12 12 13 + TRACE_DEFINE_ENUM(EPERM); 14 + TRACE_DEFINE_ENUM(ENOENT); 15 + TRACE_DEFINE_ENUM(EIO); 16 + TRACE_DEFINE_ENUM(ENXIO); 17 + TRACE_DEFINE_ENUM(EACCES); 18 + TRACE_DEFINE_ENUM(EEXIST); 19 + TRACE_DEFINE_ENUM(EXDEV); 20 + TRACE_DEFINE_ENUM(ENOTDIR); 21 + TRACE_DEFINE_ENUM(EISDIR); 22 + TRACE_DEFINE_ENUM(EFBIG); 23 + TRACE_DEFINE_ENUM(ENOSPC); 24 + TRACE_DEFINE_ENUM(EROFS); 25 + TRACE_DEFINE_ENUM(EMLINK); 26 + TRACE_DEFINE_ENUM(ENAMETOOLONG); 27 + TRACE_DEFINE_ENUM(ENOTEMPTY); 28 + TRACE_DEFINE_ENUM(EDQUOT); 29 + TRACE_DEFINE_ENUM(ESTALE); 30 + TRACE_DEFINE_ENUM(EBADHANDLE); 31 + TRACE_DEFINE_ENUM(EBADCOOKIE); 32 + TRACE_DEFINE_ENUM(ENOTSUPP); 33 + TRACE_DEFINE_ENUM(ETOOSMALL); 34 + TRACE_DEFINE_ENUM(EREMOTEIO); 35 + TRACE_DEFINE_ENUM(EBADTYPE); 36 + TRACE_DEFINE_ENUM(EAGAIN); 37 + TRACE_DEFINE_ENUM(ELOOP); 38 + TRACE_DEFINE_ENUM(EOPNOTSUPP); 39 + TRACE_DEFINE_ENUM(EDEADLK); 40 + TRACE_DEFINE_ENUM(ENOMEM); 41 + TRACE_DEFINE_ENUM(EKEYEXPIRED); 42 + TRACE_DEFINE_ENUM(ETIMEDOUT); 43 + TRACE_DEFINE_ENUM(ERESTARTSYS); 44 + TRACE_DEFINE_ENUM(ECONNREFUSED); 45 + TRACE_DEFINE_ENUM(ECONNRESET); 46 + TRACE_DEFINE_ENUM(ENETUNREACH); 47 + TRACE_DEFINE_ENUM(EHOSTUNREACH); 48 + TRACE_DEFINE_ENUM(EHOSTDOWN); 49 + TRACE_DEFINE_ENUM(EPIPE); 50 + TRACE_DEFINE_ENUM(EPFNOSUPPORT); 51 + TRACE_DEFINE_ENUM(EPROTONOSUPPORT); 52 + 53 + TRACE_DEFINE_ENUM(NFS4_OK); 54 + TRACE_DEFINE_ENUM(NFS4ERR_ACCESS); 55 + TRACE_DEFINE_ENUM(NFS4ERR_ATTRNOTSUPP); 56 + TRACE_DEFINE_ENUM(NFS4ERR_ADMIN_REVOKED); 57 + TRACE_DEFINE_ENUM(NFS4ERR_BACK_CHAN_BUSY); 58 + TRACE_DEFINE_ENUM(NFS4ERR_BADCHAR); 59 + TRACE_DEFINE_ENUM(NFS4ERR_BADHANDLE); 60 + TRACE_DEFINE_ENUM(NFS4ERR_BADIOMODE); 61 + TRACE_DEFINE_ENUM(NFS4ERR_BADLAYOUT); 62 + TRACE_DEFINE_ENUM(NFS4ERR_BADLABEL); 63 + TRACE_DEFINE_ENUM(NFS4ERR_BADNAME); 64 + TRACE_DEFINE_ENUM(NFS4ERR_BADOWNER); 65 + TRACE_DEFINE_ENUM(NFS4ERR_BADSESSION); 66 + TRACE_DEFINE_ENUM(NFS4ERR_BADSLOT); 67 + TRACE_DEFINE_ENUM(NFS4ERR_BADTYPE); 68 + TRACE_DEFINE_ENUM(NFS4ERR_BADXDR); 69 + TRACE_DEFINE_ENUM(NFS4ERR_BAD_COOKIE); 70 + TRACE_DEFINE_ENUM(NFS4ERR_BAD_HIGH_SLOT); 71 + TRACE_DEFINE_ENUM(NFS4ERR_BAD_RANGE); 72 + TRACE_DEFINE_ENUM(NFS4ERR_BAD_SEQID); 73 + TRACE_DEFINE_ENUM(NFS4ERR_BAD_SESSION_DIGEST); 74 + TRACE_DEFINE_ENUM(NFS4ERR_BAD_STATEID); 75 + TRACE_DEFINE_ENUM(NFS4ERR_CB_PATH_DOWN); 76 + TRACE_DEFINE_ENUM(NFS4ERR_CLID_INUSE); 77 + TRACE_DEFINE_ENUM(NFS4ERR_CLIENTID_BUSY); 78 + TRACE_DEFINE_ENUM(NFS4ERR_COMPLETE_ALREADY); 79 + TRACE_DEFINE_ENUM(NFS4ERR_CONN_NOT_BOUND_TO_SESSION); 80 + TRACE_DEFINE_ENUM(NFS4ERR_DEADLOCK); 81 + TRACE_DEFINE_ENUM(NFS4ERR_DEADSESSION); 82 + TRACE_DEFINE_ENUM(NFS4ERR_DELAY); 83 + TRACE_DEFINE_ENUM(NFS4ERR_DELEG_ALREADY_WANTED); 84 + TRACE_DEFINE_ENUM(NFS4ERR_DELEG_REVOKED); 85 + TRACE_DEFINE_ENUM(NFS4ERR_DENIED); 86 + TRACE_DEFINE_ENUM(NFS4ERR_DIRDELEG_UNAVAIL); 87 + TRACE_DEFINE_ENUM(NFS4ERR_DQUOT); 88 + TRACE_DEFINE_ENUM(NFS4ERR_ENCR_ALG_UNSUPP); 89 + TRACE_DEFINE_ENUM(NFS4ERR_EXIST); 90 + TRACE_DEFINE_ENUM(NFS4ERR_EXPIRED); 91 + TRACE_DEFINE_ENUM(NFS4ERR_FBIG); 92 + TRACE_DEFINE_ENUM(NFS4ERR_FHEXPIRED); 93 + TRACE_DEFINE_ENUM(NFS4ERR_FILE_OPEN); 94 + TRACE_DEFINE_ENUM(NFS4ERR_GRACE); 95 + TRACE_DEFINE_ENUM(NFS4ERR_HASH_ALG_UNSUPP); 96 + TRACE_DEFINE_ENUM(NFS4ERR_INVAL); 97 + TRACE_DEFINE_ENUM(NFS4ERR_IO); 98 + TRACE_DEFINE_ENUM(NFS4ERR_ISDIR); 99 + TRACE_DEFINE_ENUM(NFS4ERR_LAYOUTTRYLATER); 100 + TRACE_DEFINE_ENUM(NFS4ERR_LAYOUTUNAVAILABLE); 101 + TRACE_DEFINE_ENUM(NFS4ERR_LEASE_MOVED); 102 + TRACE_DEFINE_ENUM(NFS4ERR_LOCKED); 103 + TRACE_DEFINE_ENUM(NFS4ERR_LOCKS_HELD); 104 + TRACE_DEFINE_ENUM(NFS4ERR_LOCK_RANGE); 105 + TRACE_DEFINE_ENUM(NFS4ERR_MINOR_VERS_MISMATCH); 106 + TRACE_DEFINE_ENUM(NFS4ERR_MLINK); 107 + TRACE_DEFINE_ENUM(NFS4ERR_MOVED); 108 + TRACE_DEFINE_ENUM(NFS4ERR_NAMETOOLONG); 109 + TRACE_DEFINE_ENUM(NFS4ERR_NOENT); 110 + TRACE_DEFINE_ENUM(NFS4ERR_NOFILEHANDLE); 111 + TRACE_DEFINE_ENUM(NFS4ERR_NOMATCHING_LAYOUT); 112 + TRACE_DEFINE_ENUM(NFS4ERR_NOSPC); 113 + TRACE_DEFINE_ENUM(NFS4ERR_NOTDIR); 114 + TRACE_DEFINE_ENUM(NFS4ERR_NOTEMPTY); 115 + TRACE_DEFINE_ENUM(NFS4ERR_NOTSUPP); 116 + TRACE_DEFINE_ENUM(NFS4ERR_NOT_ONLY_OP); 117 + TRACE_DEFINE_ENUM(NFS4ERR_NOT_SAME); 118 + TRACE_DEFINE_ENUM(NFS4ERR_NO_GRACE); 119 + TRACE_DEFINE_ENUM(NFS4ERR_NXIO); 120 + TRACE_DEFINE_ENUM(NFS4ERR_OLD_STATEID); 121 + TRACE_DEFINE_ENUM(NFS4ERR_OPENMODE); 122 + TRACE_DEFINE_ENUM(NFS4ERR_OP_ILLEGAL); 123 + TRACE_DEFINE_ENUM(NFS4ERR_OP_NOT_IN_SESSION); 124 + TRACE_DEFINE_ENUM(NFS4ERR_PERM); 125 + TRACE_DEFINE_ENUM(NFS4ERR_PNFS_IO_HOLE); 126 + TRACE_DEFINE_ENUM(NFS4ERR_PNFS_NO_LAYOUT); 127 + TRACE_DEFINE_ENUM(NFS4ERR_RECALLCONFLICT); 128 + TRACE_DEFINE_ENUM(NFS4ERR_RECLAIM_BAD); 129 + TRACE_DEFINE_ENUM(NFS4ERR_RECLAIM_CONFLICT); 130 + TRACE_DEFINE_ENUM(NFS4ERR_REJECT_DELEG); 131 + TRACE_DEFINE_ENUM(NFS4ERR_REP_TOO_BIG); 132 + TRACE_DEFINE_ENUM(NFS4ERR_REP_TOO_BIG_TO_CACHE); 133 + TRACE_DEFINE_ENUM(NFS4ERR_REQ_TOO_BIG); 134 + TRACE_DEFINE_ENUM(NFS4ERR_RESOURCE); 135 + TRACE_DEFINE_ENUM(NFS4ERR_RESTOREFH); 136 + TRACE_DEFINE_ENUM(NFS4ERR_RETRY_UNCACHED_REP); 137 + TRACE_DEFINE_ENUM(NFS4ERR_RETURNCONFLICT); 138 + TRACE_DEFINE_ENUM(NFS4ERR_ROFS); 139 + TRACE_DEFINE_ENUM(NFS4ERR_SAME); 140 + TRACE_DEFINE_ENUM(NFS4ERR_SHARE_DENIED); 141 + TRACE_DEFINE_ENUM(NFS4ERR_SEQUENCE_POS); 142 + TRACE_DEFINE_ENUM(NFS4ERR_SEQ_FALSE_RETRY); 143 + TRACE_DEFINE_ENUM(NFS4ERR_SEQ_MISORDERED); 144 + TRACE_DEFINE_ENUM(NFS4ERR_SERVERFAULT); 145 + TRACE_DEFINE_ENUM(NFS4ERR_STALE); 146 + TRACE_DEFINE_ENUM(NFS4ERR_STALE_CLIENTID); 147 + TRACE_DEFINE_ENUM(NFS4ERR_STALE_STATEID); 148 + TRACE_DEFINE_ENUM(NFS4ERR_SYMLINK); 149 + TRACE_DEFINE_ENUM(NFS4ERR_TOOSMALL); 150 + TRACE_DEFINE_ENUM(NFS4ERR_TOO_MANY_OPS); 151 + TRACE_DEFINE_ENUM(NFS4ERR_UNKNOWN_LAYOUTTYPE); 152 + TRACE_DEFINE_ENUM(NFS4ERR_UNSAFE_COMPOUND); 153 + TRACE_DEFINE_ENUM(NFS4ERR_WRONGSEC); 154 + TRACE_DEFINE_ENUM(NFS4ERR_WRONG_CRED); 155 + TRACE_DEFINE_ENUM(NFS4ERR_WRONG_TYPE); 156 + TRACE_DEFINE_ENUM(NFS4ERR_XDEV); 157 + 13 158 #define show_nfsv4_errors(error) \ 14 - __print_symbolic(error, \ 159 + __print_symbolic(-(error), \ 15 160 { NFS4_OK, "OK" }, \ 16 161 /* Mapped by nfs4_stat_to_errno() */ \ 17 - { -EPERM, "EPERM" }, \ 18 - { -ENOENT, "ENOENT" }, \ 19 - { -EIO, "EIO" }, \ 20 - { -ENXIO, "ENXIO" }, \ 21 - { -EACCES, "EACCES" }, \ 22 - { -EEXIST, "EEXIST" }, \ 23 - { -EXDEV, "EXDEV" }, \ 24 - { -ENOTDIR, "ENOTDIR" }, \ 25 - { -EISDIR, "EISDIR" }, \ 26 - { -EFBIG, "EFBIG" }, \ 27 - { -ENOSPC, "ENOSPC" }, \ 28 - { -EROFS, "EROFS" }, \ 29 - { -EMLINK, "EMLINK" }, \ 30 - { -ENAMETOOLONG, "ENAMETOOLONG" }, \ 31 - { -ENOTEMPTY, "ENOTEMPTY" }, \ 32 - { -EDQUOT, "EDQUOT" }, \ 33 - { -ESTALE, "ESTALE" }, \ 34 - { -EBADHANDLE, "EBADHANDLE" }, \ 35 - { -EBADCOOKIE, "EBADCOOKIE" }, \ 36 - { -ENOTSUPP, "ENOTSUPP" }, \ 37 - { -ETOOSMALL, "ETOOSMALL" }, \ 38 - { -EREMOTEIO, "EREMOTEIO" }, \ 39 - { -EBADTYPE, "EBADTYPE" }, \ 40 - { -EAGAIN, "EAGAIN" }, \ 41 - { -ELOOP, "ELOOP" }, \ 42 - { -EOPNOTSUPP, "EOPNOTSUPP" }, \ 43 - { -EDEADLK, "EDEADLK" }, \ 162 + { EPERM, "EPERM" }, \ 163 + { ENOENT, "ENOENT" }, \ 164 + { EIO, "EIO" }, \ 165 + { ENXIO, "ENXIO" }, \ 166 + { EACCES, "EACCES" }, \ 167 + { EEXIST, "EEXIST" }, \ 168 + { EXDEV, "EXDEV" }, \ 169 + { ENOTDIR, "ENOTDIR" }, \ 170 + { EISDIR, "EISDIR" }, \ 171 + { EFBIG, "EFBIG" }, \ 172 + { ENOSPC, "ENOSPC" }, \ 173 + { EROFS, "EROFS" }, \ 174 + { EMLINK, "EMLINK" }, \ 175 + { ENAMETOOLONG, "ENAMETOOLONG" }, \ 176 + { ENOTEMPTY, "ENOTEMPTY" }, \ 177 + { EDQUOT, "EDQUOT" }, \ 178 + { ESTALE, "ESTALE" }, \ 179 + { EBADHANDLE, "EBADHANDLE" }, \ 180 + { EBADCOOKIE, "EBADCOOKIE" }, \ 181 + { ENOTSUPP, "ENOTSUPP" }, \ 182 + { ETOOSMALL, "ETOOSMALL" }, \ 183 + { EREMOTEIO, "EREMOTEIO" }, \ 184 + { EBADTYPE, "EBADTYPE" }, \ 185 + { EAGAIN, "EAGAIN" }, \ 186 + { ELOOP, "ELOOP" }, \ 187 + { EOPNOTSUPP, "EOPNOTSUPP" }, \ 188 + { EDEADLK, "EDEADLK" }, \ 44 189 /* RPC errors */ \ 45 - { -ENOMEM, "ENOMEM" }, \ 46 - { -EKEYEXPIRED, "EKEYEXPIRED" }, \ 47 - { -ETIMEDOUT, "ETIMEDOUT" }, \ 48 - { -ERESTARTSYS, "ERESTARTSYS" }, \ 49 - { -ECONNREFUSED, "ECONNREFUSED" }, \ 50 - { -ECONNRESET, "ECONNRESET" }, \ 51 - { -ENETUNREACH, "ENETUNREACH" }, \ 52 - { -EHOSTUNREACH, "EHOSTUNREACH" }, \ 53 - { -EHOSTDOWN, "EHOSTDOWN" }, \ 54 - { -EPIPE, "EPIPE" }, \ 55 - { -EPFNOSUPPORT, "EPFNOSUPPORT" }, \ 56 - { -EPROTONOSUPPORT, "EPROTONOSUPPORT" }, \ 190 + { ENOMEM, "ENOMEM" }, \ 191 + { EKEYEXPIRED, "EKEYEXPIRED" }, \ 192 + { ETIMEDOUT, "ETIMEDOUT" }, \ 193 + { ERESTARTSYS, "ERESTARTSYS" }, \ 194 + { ECONNREFUSED, "ECONNREFUSED" }, \ 195 + { ECONNRESET, "ECONNRESET" }, \ 196 + { ENETUNREACH, "ENETUNREACH" }, \ 197 + { EHOSTUNREACH, "EHOSTUNREACH" }, \ 198 + { EHOSTDOWN, "EHOSTDOWN" }, \ 199 + { EPIPE, "EPIPE" }, \ 200 + { EPFNOSUPPORT, "EPFNOSUPPORT" }, \ 201 + { EPROTONOSUPPORT, "EPROTONOSUPPORT" }, \ 57 202 /* NFSv4 native errors */ \ 58 - { -NFS4ERR_ACCESS, "ACCESS" }, \ 59 - { -NFS4ERR_ATTRNOTSUPP, "ATTRNOTSUPP" }, \ 60 - { -NFS4ERR_ADMIN_REVOKED, "ADMIN_REVOKED" }, \ 61 - { -NFS4ERR_BACK_CHAN_BUSY, "BACK_CHAN_BUSY" }, \ 62 - { -NFS4ERR_BADCHAR, "BADCHAR" }, \ 63 - { -NFS4ERR_BADHANDLE, "BADHANDLE" }, \ 64 - { -NFS4ERR_BADIOMODE, "BADIOMODE" }, \ 65 - { -NFS4ERR_BADLAYOUT, "BADLAYOUT" }, \ 66 - { -NFS4ERR_BADLABEL, "BADLABEL" }, \ 67 - { -NFS4ERR_BADNAME, "BADNAME" }, \ 68 - { -NFS4ERR_BADOWNER, "BADOWNER" }, \ 69 - { -NFS4ERR_BADSESSION, "BADSESSION" }, \ 70 - { -NFS4ERR_BADSLOT, "BADSLOT" }, \ 71 - { -NFS4ERR_BADTYPE, "BADTYPE" }, \ 72 - { -NFS4ERR_BADXDR, "BADXDR" }, \ 73 - { -NFS4ERR_BAD_COOKIE, "BAD_COOKIE" }, \ 74 - { -NFS4ERR_BAD_HIGH_SLOT, "BAD_HIGH_SLOT" }, \ 75 - { -NFS4ERR_BAD_RANGE, "BAD_RANGE" }, \ 76 - { -NFS4ERR_BAD_SEQID, "BAD_SEQID" }, \ 77 - { -NFS4ERR_BAD_SESSION_DIGEST, "BAD_SESSION_DIGEST" }, \ 78 - { -NFS4ERR_BAD_STATEID, "BAD_STATEID" }, \ 79 - { -NFS4ERR_CB_PATH_DOWN, "CB_PATH_DOWN" }, \ 80 - { -NFS4ERR_CLID_INUSE, "CLID_INUSE" }, \ 81 - { -NFS4ERR_CLIENTID_BUSY, "CLIENTID_BUSY" }, \ 82 - { -NFS4ERR_COMPLETE_ALREADY, "COMPLETE_ALREADY" }, \ 83 - { -NFS4ERR_CONN_NOT_BOUND_TO_SESSION, \ 203 + { NFS4ERR_ACCESS, "ACCESS" }, \ 204 + { NFS4ERR_ATTRNOTSUPP, "ATTRNOTSUPP" }, \ 205 + { NFS4ERR_ADMIN_REVOKED, "ADMIN_REVOKED" }, \ 206 + { NFS4ERR_BACK_CHAN_BUSY, "BACK_CHAN_BUSY" }, \ 207 + { NFS4ERR_BADCHAR, "BADCHAR" }, \ 208 + { NFS4ERR_BADHANDLE, "BADHANDLE" }, \ 209 + { NFS4ERR_BADIOMODE, "BADIOMODE" }, \ 210 + { NFS4ERR_BADLAYOUT, "BADLAYOUT" }, \ 211 + { NFS4ERR_BADLABEL, "BADLABEL" }, \ 212 + { NFS4ERR_BADNAME, "BADNAME" }, \ 213 + { NFS4ERR_BADOWNER, "BADOWNER" }, \ 214 + { NFS4ERR_BADSESSION, "BADSESSION" }, \ 215 + { NFS4ERR_BADSLOT, "BADSLOT" }, \ 216 + { NFS4ERR_BADTYPE, "BADTYPE" }, \ 217 + { NFS4ERR_BADXDR, "BADXDR" }, \ 218 + { NFS4ERR_BAD_COOKIE, "BAD_COOKIE" }, \ 219 + { NFS4ERR_BAD_HIGH_SLOT, "BAD_HIGH_SLOT" }, \ 220 + { NFS4ERR_BAD_RANGE, "BAD_RANGE" }, \ 221 + { NFS4ERR_BAD_SEQID, "BAD_SEQID" }, \ 222 + { NFS4ERR_BAD_SESSION_DIGEST, "BAD_SESSION_DIGEST" }, \ 223 + { NFS4ERR_BAD_STATEID, "BAD_STATEID" }, \ 224 + { NFS4ERR_CB_PATH_DOWN, "CB_PATH_DOWN" }, \ 225 + { NFS4ERR_CLID_INUSE, "CLID_INUSE" }, \ 226 + { NFS4ERR_CLIENTID_BUSY, "CLIENTID_BUSY" }, \ 227 + { NFS4ERR_COMPLETE_ALREADY, "COMPLETE_ALREADY" }, \ 228 + { NFS4ERR_CONN_NOT_BOUND_TO_SESSION, \ 84 229 "CONN_NOT_BOUND_TO_SESSION" }, \ 85 - { -NFS4ERR_DEADLOCK, "DEADLOCK" }, \ 86 - { -NFS4ERR_DEADSESSION, "DEAD_SESSION" }, \ 87 - { -NFS4ERR_DELAY, "DELAY" }, \ 88 - { -NFS4ERR_DELEG_ALREADY_WANTED, \ 230 + { NFS4ERR_DEADLOCK, "DEADLOCK" }, \ 231 + { NFS4ERR_DEADSESSION, "DEAD_SESSION" }, \ 232 + { NFS4ERR_DELAY, "DELAY" }, \ 233 + { NFS4ERR_DELEG_ALREADY_WANTED, \ 89 234 "DELEG_ALREADY_WANTED" }, \ 90 - { -NFS4ERR_DELEG_REVOKED, "DELEG_REVOKED" }, \ 91 - { -NFS4ERR_DENIED, "DENIED" }, \ 92 - { -NFS4ERR_DIRDELEG_UNAVAIL, "DIRDELEG_UNAVAIL" }, \ 93 - { -NFS4ERR_DQUOT, "DQUOT" }, \ 94 - { -NFS4ERR_ENCR_ALG_UNSUPP, "ENCR_ALG_UNSUPP" }, \ 95 - { -NFS4ERR_EXIST, "EXIST" }, \ 96 - { -NFS4ERR_EXPIRED, "EXPIRED" }, \ 97 - { -NFS4ERR_FBIG, "FBIG" }, \ 98 - { -NFS4ERR_FHEXPIRED, "FHEXPIRED" }, \ 99 - { -NFS4ERR_FILE_OPEN, "FILE_OPEN" }, \ 100 - { -NFS4ERR_GRACE, "GRACE" }, \ 101 - { -NFS4ERR_HASH_ALG_UNSUPP, "HASH_ALG_UNSUPP" }, \ 102 - { -NFS4ERR_INVAL, "INVAL" }, \ 103 - { -NFS4ERR_IO, "IO" }, \ 104 - { -NFS4ERR_ISDIR, "ISDIR" }, \ 105 - { -NFS4ERR_LAYOUTTRYLATER, "LAYOUTTRYLATER" }, \ 106 - { -NFS4ERR_LAYOUTUNAVAILABLE, "LAYOUTUNAVAILABLE" }, \ 107 - { -NFS4ERR_LEASE_MOVED, "LEASE_MOVED" }, \ 108 - { -NFS4ERR_LOCKED, "LOCKED" }, \ 109 - { -NFS4ERR_LOCKS_HELD, "LOCKS_HELD" }, \ 110 - { -NFS4ERR_LOCK_RANGE, "LOCK_RANGE" }, \ 111 - { -NFS4ERR_MINOR_VERS_MISMATCH, "MINOR_VERS_MISMATCH" }, \ 112 - { -NFS4ERR_MLINK, "MLINK" }, \ 113 - { -NFS4ERR_MOVED, "MOVED" }, \ 114 - { -NFS4ERR_NAMETOOLONG, "NAMETOOLONG" }, \ 115 - { -NFS4ERR_NOENT, "NOENT" }, \ 116 - { -NFS4ERR_NOFILEHANDLE, "NOFILEHANDLE" }, \ 117 - { -NFS4ERR_NOMATCHING_LAYOUT, "NOMATCHING_LAYOUT" }, \ 118 - { -NFS4ERR_NOSPC, "NOSPC" }, \ 119 - { -NFS4ERR_NOTDIR, "NOTDIR" }, \ 120 - { -NFS4ERR_NOTEMPTY, "NOTEMPTY" }, \ 121 - { -NFS4ERR_NOTSUPP, "NOTSUPP" }, \ 122 - { -NFS4ERR_NOT_ONLY_OP, "NOT_ONLY_OP" }, \ 123 - { -NFS4ERR_NOT_SAME, "NOT_SAME" }, \ 124 - { -NFS4ERR_NO_GRACE, "NO_GRACE" }, \ 125 - { -NFS4ERR_NXIO, "NXIO" }, \ 126 - { -NFS4ERR_OLD_STATEID, "OLD_STATEID" }, \ 127 - { -NFS4ERR_OPENMODE, "OPENMODE" }, \ 128 - { -NFS4ERR_OP_ILLEGAL, "OP_ILLEGAL" }, \ 129 - { -NFS4ERR_OP_NOT_IN_SESSION, "OP_NOT_IN_SESSION" }, \ 130 - { -NFS4ERR_PERM, "PERM" }, \ 131 - { -NFS4ERR_PNFS_IO_HOLE, "PNFS_IO_HOLE" }, \ 132 - { -NFS4ERR_PNFS_NO_LAYOUT, "PNFS_NO_LAYOUT" }, \ 133 - { -NFS4ERR_RECALLCONFLICT, "RECALLCONFLICT" }, \ 134 - { -NFS4ERR_RECLAIM_BAD, "RECLAIM_BAD" }, \ 135 - { -NFS4ERR_RECLAIM_CONFLICT, "RECLAIM_CONFLICT" }, \ 136 - { -NFS4ERR_REJECT_DELEG, "REJECT_DELEG" }, \ 137 - { -NFS4ERR_REP_TOO_BIG, "REP_TOO_BIG" }, \ 138 - { -NFS4ERR_REP_TOO_BIG_TO_CACHE, \ 235 + { NFS4ERR_DELEG_REVOKED, "DELEG_REVOKED" }, \ 236 + { NFS4ERR_DENIED, "DENIED" }, \ 237 + { NFS4ERR_DIRDELEG_UNAVAIL, "DIRDELEG_UNAVAIL" }, \ 238 + { NFS4ERR_DQUOT, "DQUOT" }, \ 239 + { NFS4ERR_ENCR_ALG_UNSUPP, "ENCR_ALG_UNSUPP" }, \ 240 + { NFS4ERR_EXIST, "EXIST" }, \ 241 + { NFS4ERR_EXPIRED, "EXPIRED" }, \ 242 + { NFS4ERR_FBIG, "FBIG" }, \ 243 + { NFS4ERR_FHEXPIRED, "FHEXPIRED" }, \ 244 + { NFS4ERR_FILE_OPEN, "FILE_OPEN" }, \ 245 + { NFS4ERR_GRACE, "GRACE" }, \ 246 + { NFS4ERR_HASH_ALG_UNSUPP, "HASH_ALG_UNSUPP" }, \ 247 + { NFS4ERR_INVAL, "INVAL" }, \ 248 + { NFS4ERR_IO, "IO" }, \ 249 + { NFS4ERR_ISDIR, "ISDIR" }, \ 250 + { NFS4ERR_LAYOUTTRYLATER, "LAYOUTTRYLATER" }, \ 251 + { NFS4ERR_LAYOUTUNAVAILABLE, "LAYOUTUNAVAILABLE" }, \ 252 + { NFS4ERR_LEASE_MOVED, "LEASE_MOVED" }, \ 253 + { NFS4ERR_LOCKED, "LOCKED" }, \ 254 + { NFS4ERR_LOCKS_HELD, "LOCKS_HELD" }, \ 255 + { NFS4ERR_LOCK_RANGE, "LOCK_RANGE" }, \ 256 + { NFS4ERR_MINOR_VERS_MISMATCH, "MINOR_VERS_MISMATCH" }, \ 257 + { NFS4ERR_MLINK, "MLINK" }, \ 258 + { NFS4ERR_MOVED, "MOVED" }, \ 259 + { NFS4ERR_NAMETOOLONG, "NAMETOOLONG" }, \ 260 + { NFS4ERR_NOENT, "NOENT" }, \ 261 + { NFS4ERR_NOFILEHANDLE, "NOFILEHANDLE" }, \ 262 + { NFS4ERR_NOMATCHING_LAYOUT, "NOMATCHING_LAYOUT" }, \ 263 + { NFS4ERR_NOSPC, "NOSPC" }, \ 264 + { NFS4ERR_NOTDIR, "NOTDIR" }, \ 265 + { NFS4ERR_NOTEMPTY, "NOTEMPTY" }, \ 266 + { NFS4ERR_NOTSUPP, "NOTSUPP" }, \ 267 + { NFS4ERR_NOT_ONLY_OP, "NOT_ONLY_OP" }, \ 268 + { NFS4ERR_NOT_SAME, "NOT_SAME" }, \ 269 + { NFS4ERR_NO_GRACE, "NO_GRACE" }, \ 270 + { NFS4ERR_NXIO, "NXIO" }, \ 271 + { NFS4ERR_OLD_STATEID, "OLD_STATEID" }, \ 272 + { NFS4ERR_OPENMODE, "OPENMODE" }, \ 273 + { NFS4ERR_OP_ILLEGAL, "OP_ILLEGAL" }, \ 274 + { NFS4ERR_OP_NOT_IN_SESSION, "OP_NOT_IN_SESSION" }, \ 275 + { NFS4ERR_PERM, "PERM" }, \ 276 + { NFS4ERR_PNFS_IO_HOLE, "PNFS_IO_HOLE" }, \ 277 + { NFS4ERR_PNFS_NO_LAYOUT, "PNFS_NO_LAYOUT" }, \ 278 + { NFS4ERR_RECALLCONFLICT, "RECALLCONFLICT" }, \ 279 + { NFS4ERR_RECLAIM_BAD, "RECLAIM_BAD" }, \ 280 + { NFS4ERR_RECLAIM_CONFLICT, "RECLAIM_CONFLICT" }, \ 281 + { NFS4ERR_REJECT_DELEG, "REJECT_DELEG" }, \ 282 + { NFS4ERR_REP_TOO_BIG, "REP_TOO_BIG" }, \ 283 + { NFS4ERR_REP_TOO_BIG_TO_CACHE, \ 139 284 "REP_TOO_BIG_TO_CACHE" }, \ 140 - { -NFS4ERR_REQ_TOO_BIG, "REQ_TOO_BIG" }, \ 141 - { -NFS4ERR_RESOURCE, "RESOURCE" }, \ 142 - { -NFS4ERR_RESTOREFH, "RESTOREFH" }, \ 143 - { -NFS4ERR_RETRY_UNCACHED_REP, "RETRY_UNCACHED_REP" }, \ 144 - { -NFS4ERR_RETURNCONFLICT, "RETURNCONFLICT" }, \ 145 - { -NFS4ERR_ROFS, "ROFS" }, \ 146 - { -NFS4ERR_SAME, "SAME" }, \ 147 - { -NFS4ERR_SHARE_DENIED, "SHARE_DENIED" }, \ 148 - { -NFS4ERR_SEQUENCE_POS, "SEQUENCE_POS" }, \ 149 - { -NFS4ERR_SEQ_FALSE_RETRY, "SEQ_FALSE_RETRY" }, \ 150 - { -NFS4ERR_SEQ_MISORDERED, "SEQ_MISORDERED" }, \ 151 - { -NFS4ERR_SERVERFAULT, "SERVERFAULT" }, \ 152 - { -NFS4ERR_STALE, "STALE" }, \ 153 - { -NFS4ERR_STALE_CLIENTID, "STALE_CLIENTID" }, \ 154 - { -NFS4ERR_STALE_STATEID, "STALE_STATEID" }, \ 155 - { -NFS4ERR_SYMLINK, "SYMLINK" }, \ 156 - { -NFS4ERR_TOOSMALL, "TOOSMALL" }, \ 157 - { -NFS4ERR_TOO_MANY_OPS, "TOO_MANY_OPS" }, \ 158 - { -NFS4ERR_UNKNOWN_LAYOUTTYPE, "UNKNOWN_LAYOUTTYPE" }, \ 159 - { -NFS4ERR_UNSAFE_COMPOUND, "UNSAFE_COMPOUND" }, \ 160 - { -NFS4ERR_WRONGSEC, "WRONGSEC" }, \ 161 - { -NFS4ERR_WRONG_CRED, "WRONG_CRED" }, \ 162 - { -NFS4ERR_WRONG_TYPE, "WRONG_TYPE" }, \ 163 - { -NFS4ERR_XDEV, "XDEV" }) 285 + { NFS4ERR_REQ_TOO_BIG, "REQ_TOO_BIG" }, \ 286 + { NFS4ERR_RESOURCE, "RESOURCE" }, \ 287 + { NFS4ERR_RESTOREFH, "RESTOREFH" }, \ 288 + { NFS4ERR_RETRY_UNCACHED_REP, "RETRY_UNCACHED_REP" }, \ 289 + { NFS4ERR_RETURNCONFLICT, "RETURNCONFLICT" }, \ 290 + { NFS4ERR_ROFS, "ROFS" }, \ 291 + { NFS4ERR_SAME, "SAME" }, \ 292 + { NFS4ERR_SHARE_DENIED, "SHARE_DENIED" }, \ 293 + { NFS4ERR_SEQUENCE_POS, "SEQUENCE_POS" }, \ 294 + { NFS4ERR_SEQ_FALSE_RETRY, "SEQ_FALSE_RETRY" }, \ 295 + { NFS4ERR_SEQ_MISORDERED, "SEQ_MISORDERED" }, \ 296 + { NFS4ERR_SERVERFAULT, "SERVERFAULT" }, \ 297 + { NFS4ERR_STALE, "STALE" }, \ 298 + { NFS4ERR_STALE_CLIENTID, "STALE_CLIENTID" }, \ 299 + { NFS4ERR_STALE_STATEID, "STALE_STATEID" }, \ 300 + { NFS4ERR_SYMLINK, "SYMLINK" }, \ 301 + { NFS4ERR_TOOSMALL, "TOOSMALL" }, \ 302 + { NFS4ERR_TOO_MANY_OPS, "TOO_MANY_OPS" }, \ 303 + { NFS4ERR_UNKNOWN_LAYOUTTYPE, "UNKNOWN_LAYOUTTYPE" }, \ 304 + { NFS4ERR_UNSAFE_COMPOUND, "UNSAFE_COMPOUND" }, \ 305 + { NFS4ERR_WRONGSEC, "WRONGSEC" }, \ 306 + { NFS4ERR_WRONG_CRED, "WRONG_CRED" }, \ 307 + { NFS4ERR_WRONG_TYPE, "WRONG_TYPE" }, \ 308 + { NFS4ERR_XDEV, "XDEV" }) 164 309 165 310 #define show_open_flags(flags) \ 166 311 __print_flags(flags, "|", \ ··· 702 557 __entry->stateid_seq, __entry->stateid_hash 703 558 ) 704 559 ); 560 + 561 + TRACE_DEFINE_ENUM(F_GETLK); 562 + TRACE_DEFINE_ENUM(F_SETLK); 563 + TRACE_DEFINE_ENUM(F_SETLKW); 564 + TRACE_DEFINE_ENUM(F_RDLCK); 565 + TRACE_DEFINE_ENUM(F_WRLCK); 566 + TRACE_DEFINE_ENUM(F_UNLCK); 705 567 706 568 #define show_lock_cmd(type) \ 707 569 __print_symbolic((int)type, \ ··· 1603 1451 #ifdef CONFIG_NFS_V4_1 1604 1452 DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds); 1605 1453 1454 + TRACE_DEFINE_ENUM(IOMODE_READ); 1455 + TRACE_DEFINE_ENUM(IOMODE_RW); 1456 + TRACE_DEFINE_ENUM(IOMODE_ANY); 1457 + 1606 1458 #define show_pnfs_iomode(iomode) \ 1607 1459 __print_symbolic(iomode, \ 1608 1460 { IOMODE_READ, "READ" }, \ ··· 1683 1527 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutcommit); 1684 1528 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn); 1685 1529 DEFINE_NFS4_INODE_EVENT(nfs4_layoutreturn_on_close); 1530 + 1531 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_UNKNOWN); 1532 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NO_PNFS); 1533 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RD_ZEROLEN); 1534 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_MDSTHRESH); 1535 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NOMEM); 1536 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BULK_RECALL); 1537 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_IO_TEST_FAIL); 1538 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_FOUND_CACHED); 1539 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETURN); 1540 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BLOCKED); 1541 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_INVALID_OPEN); 1542 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETRY); 1543 + TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET); 1686 1544 1687 1545 #define show_pnfs_update_layout_reason(reason) \ 1688 1546 __print_symbolic(reason, \
+2 -2
fs/nfs/pagelist.c
··· 461 461 * @prev: previous request in desc, or NULL 462 462 * @req: this request 463 463 * 464 - * Returns zero if @req can be coalesced into @desc, otherwise it returns 464 + * Returns zero if @req cannot be coalesced into @desc, otherwise it returns 465 465 * the size of the request. 466 466 */ 467 467 size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, ··· 587 587 } 588 588 589 589 int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr, 590 - struct rpc_cred *cred, const struct nfs_rpc_ops *rpc_ops, 590 + const struct cred *cred, const struct nfs_rpc_ops *rpc_ops, 591 591 const struct rpc_call_ops *call_ops, int how, int flags) 592 592 { 593 593 struct rpc_task *task;
+7 -7
fs/nfs/pnfs.c
··· 275 275 list_del_init(&lo->plh_layouts); 276 276 spin_unlock(&clp->cl_lock); 277 277 } 278 - put_rpccred(lo->plh_lc_cred); 278 + put_cred(lo->plh_lc_cred); 279 279 return ld->free_layout_hdr(lo); 280 280 } 281 281 ··· 1038 1038 lgp->args.ctx = get_nfs_open_context(ctx); 1039 1039 nfs4_stateid_copy(&lgp->args.stateid, stateid); 1040 1040 lgp->gfp_flags = gfp_flags; 1041 - lgp->cred = get_rpccred(ctx->cred); 1041 + lgp->cred = get_cred(ctx->cred); 1042 1042 return lgp; 1043 1043 } 1044 1044 ··· 1049 1049 nfs4_free_pages(lgp->args.layout.pages, max_pages); 1050 1050 if (lgp->args.inode) 1051 1051 pnfs_put_layout_hdr(NFS_I(lgp->args.inode)->layout); 1052 - put_rpccred(lgp->cred); 1052 + put_cred(lgp->cred); 1053 1053 put_nfs_open_context(lgp->args.ctx); 1054 1054 kfree(lgp); 1055 1055 } ··· 1324 1324 bool pnfs_roc(struct inode *ino, 1325 1325 struct nfs4_layoutreturn_args *args, 1326 1326 struct nfs4_layoutreturn_res *res, 1327 - const struct rpc_cred *cred) 1327 + const struct cred *cred) 1328 1328 { 1329 1329 struct nfs_inode *nfsi = NFS_I(ino); 1330 1330 struct nfs_open_context *ctx; ··· 1583 1583 INIT_LIST_HEAD(&lo->plh_return_segs); 1584 1584 INIT_LIST_HEAD(&lo->plh_bulk_destroy); 1585 1585 lo->plh_inode = ino; 1586 - lo->plh_lc_cred = get_rpccred(ctx->cred); 1586 + lo->plh_lc_cred = get_cred(ctx->cred); 1587 1587 lo->plh_flags |= 1 << NFS_LAYOUT_INVALID_STID; 1588 1588 return lo; 1589 1589 } ··· 2928 2928 spin_unlock(&inode->i_lock); 2929 2929 2930 2930 data->args.inode = inode; 2931 - data->cred = get_rpccred(nfsi->layout->plh_lc_cred); 2931 + data->cred = get_cred(nfsi->layout->plh_lc_cred); 2932 2932 nfs_fattr_init(&data->fattr); 2933 2933 data->args.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask; 2934 2934 data->res.fattr = &data->fattr; ··· 2941 2941 if (ld->prepare_layoutcommit) { 2942 2942 status = ld->prepare_layoutcommit(&data->args); 2943 2943 if (status) { 2944 - put_rpccred(data->cred); 2944 + put_cred(data->cred); 2945 2945 spin_lock(&inode->i_lock); 2946 2946 set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags); 2947 2947 if (end_pos > nfsi->layout->plh_lwb)
+5 -5
fs/nfs/pnfs.h
··· 200 200 u32 plh_return_seq; 201 201 enum pnfs_iomode plh_return_iomode; 202 202 loff_t plh_lwb; /* last write byte for layoutcommit */ 203 - struct rpc_cred *plh_lc_cred; /* layoutcommit cred */ 203 + const struct cred *plh_lc_cred; /* layoutcommit cred */ 204 204 struct inode *plh_inode; 205 205 }; 206 206 ··· 230 230 extern size_t max_response_pages(struct nfs_server *server); 231 231 extern int nfs4_proc_getdeviceinfo(struct nfs_server *server, 232 232 struct pnfs_device *dev, 233 - struct rpc_cred *cred); 233 + const struct cred *cred); 234 234 extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout); 235 235 extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync); 236 236 ··· 280 280 bool pnfs_roc(struct inode *ino, 281 281 struct nfs4_layoutreturn_args *args, 282 282 struct nfs4_layoutreturn_res *res, 283 - const struct rpc_cred *cred); 283 + const struct cred *cred); 284 284 void pnfs_roc_release(struct nfs4_layoutreturn_args *args, 285 285 struct nfs4_layoutreturn_res *res, 286 286 int ret); ··· 343 343 344 344 struct nfs4_deviceid_node * 345 345 nfs4_find_get_deviceid(struct nfs_server *server, 346 - const struct nfs4_deviceid *id, struct rpc_cred *cred, 346 + const struct nfs4_deviceid *id, const struct cred *cred, 347 347 gfp_t gfp_mask); 348 348 void nfs4_delete_deviceid(const struct pnfs_layoutdriver_type *, const struct nfs_client *, const struct nfs4_deviceid *); 349 349 void nfs4_init_deviceid_node(struct nfs4_deviceid_node *, struct nfs_server *, ··· 694 694 pnfs_roc(struct inode *ino, 695 695 struct nfs4_layoutreturn_args *args, 696 696 struct nfs4_layoutreturn_res *res, 697 - const struct rpc_cred *cred) 697 + const struct cred *cred) 698 698 { 699 699 return false; 700 700 }
+2 -2
fs/nfs/pnfs_dev.c
··· 94 94 static struct nfs4_deviceid_node * 95 95 nfs4_get_device_info(struct nfs_server *server, 96 96 const struct nfs4_deviceid *dev_id, 97 - struct rpc_cred *cred, gfp_t gfp_flags) 97 + const struct cred *cred, gfp_t gfp_flags) 98 98 { 99 99 struct nfs4_deviceid_node *d = NULL; 100 100 struct pnfs_device *pdev = NULL; ··· 184 184 185 185 struct nfs4_deviceid_node * 186 186 nfs4_find_get_deviceid(struct nfs_server *server, 187 - const struct nfs4_deviceid *id, struct rpc_cred *cred, 187 + const struct nfs4_deviceid *id, const struct cred *cred, 188 188 gfp_t gfp_mask) 189 189 { 190 190 long hash = nfs4_deviceid_hash(id);
+1 -1
fs/nfs/pnfs_nfs.c
··· 686 686 rpc_clnt_setup_test_and_add_xprt, 687 687 &rpcdata); 688 688 if (xprtdata.cred) 689 - put_rpccred(xprtdata.cred); 689 + put_cred(xprtdata.cred); 690 690 } else { 691 691 clp = nfs4_set_ds_client(mds_srv, 692 692 (struct sockaddr *)&da->da_addr,
+1 -1
fs/nfs/proc.c
··· 490 490 * from nfs_readdir by calling the decode_entry function directly. 491 491 */ 492 492 static int 493 - nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, 493 + nfs_proc_readdir(struct dentry *dentry, const struct cred *cred, 494 494 u64 cookie, struct page **pages, unsigned int count, bool plus) 495 495 { 496 496 struct inode *dir = d_inode(dentry);
+9 -4
fs/nfs/super.c
··· 2168 2168 2169 2169 if (args->version == 4) { 2170 2170 #if IS_ENABLED(CONFIG_NFS_V4) 2171 - port = NFS_PORT; 2171 + if (args->nfs_server.protocol == XPRT_TRANSPORT_RDMA) 2172 + port = NFS_RDMA_PORT; 2173 + else 2174 + port = NFS_PORT; 2172 2175 max_namelen = NFS4_MAXNAMLEN; 2173 2176 max_pathlen = NFS4_MAXPATHLEN; 2174 2177 nfs_validate_transport_protocol(args); ··· 2181 2178 #else 2182 2179 goto out_v4_not_compiled; 2183 2180 #endif /* CONFIG_NFS_V4 */ 2184 - } else 2181 + } else { 2185 2182 nfs_set_mount_transport_protocol(args); 2183 + if (args->nfs_server.protocol == XPRT_TRANSPORT_RDMA) 2184 + port = NFS_RDMA_PORT; 2185 + } 2186 2186 2187 2187 nfs_set_port(sap, &args->nfs_server.port, port); 2188 2188 ··· 2415 2409 goto Ebusy; 2416 2410 if (a->acdirmax != b->acdirmax) 2417 2411 goto Ebusy; 2418 - if (b->auth_info.flavor_len > 0 && 2419 - clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor) 2412 + if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor) 2420 2413 goto Ebusy; 2421 2414 return 1; 2422 2415 Ebusy:
+5 -15
fs/nfs/unlink.c
··· 31 31 static void 32 32 nfs_free_unlinkdata(struct nfs_unlinkdata *data) 33 33 { 34 - put_rpccred(data->cred); 34 + put_cred(data->cred); 35 35 kfree(data->args.name.name); 36 36 kfree(data); 37 37 } ··· 177 177 goto out_free; 178 178 data->args.name.len = name->len; 179 179 180 - data->cred = rpc_lookup_cred(); 181 - if (IS_ERR(data->cred)) { 182 - status = PTR_ERR(data->cred); 183 - goto out_free_name; 184 - } 180 + data->cred = get_current_cred(); 185 181 data->res.dir_attr = &data->dir_attr; 186 182 init_waitqueue_head(&data->wq); 187 183 ··· 198 202 return 0; 199 203 out_unlock: 200 204 spin_unlock(&dentry->d_lock); 201 - put_rpccred(data->cred); 202 - out_free_name: 205 + put_cred(data->cred); 203 206 kfree(data->args.name.name); 204 207 out_free: 205 208 kfree(data); ··· 302 307 iput(data->old_dir); 303 308 iput(data->new_dir); 304 309 nfs_sb_deactive(sb); 305 - put_rpccred(data->cred); 310 + put_cred(data->cred); 306 311 kfree(data); 307 312 } 308 313 ··· 347 352 return ERR_PTR(-ENOMEM); 348 353 task_setup_data.callback_data = data; 349 354 350 - data->cred = rpc_lookup_cred(); 351 - if (IS_ERR(data->cred)) { 352 - struct rpc_task *task = ERR_CAST(data->cred); 353 - kfree(data); 354 - return task; 355 - } 355 + data->cred = get_current_cred(); 356 356 357 357 msg.rpc_argp = &data->args; 358 358 msg.rpc_resp = &data->res;
+21 -3
fs/nfs/write.c
··· 1233 1233 nfs_key_timeout_notify(struct file *filp, struct inode *inode) 1234 1234 { 1235 1235 struct nfs_open_context *ctx = nfs_file_open_context(filp); 1236 - struct rpc_auth *auth = NFS_SERVER(inode)->client->cl_auth; 1237 1236 1238 - return rpcauth_key_timeout_notify(auth, ctx->cred); 1237 + if (nfs_ctx_key_to_expire(ctx, inode) && 1238 + !ctx->ll_cred) 1239 + /* Already expired! */ 1240 + return -EACCES; 1241 + return 0; 1239 1242 } 1240 1243 1241 1244 /* ··· 1247 1244 bool nfs_ctx_key_to_expire(struct nfs_open_context *ctx, struct inode *inode) 1248 1245 { 1249 1246 struct rpc_auth *auth = NFS_SERVER(inode)->client->cl_auth; 1247 + struct rpc_cred *cred = ctx->ll_cred; 1248 + struct auth_cred acred = { 1249 + .cred = ctx->cred, 1250 + }; 1250 1251 1251 - return rpcauth_cred_key_to_expire(auth, ctx->cred); 1252 + if (cred && !cred->cr_ops->crmatch(&acred, cred, 0)) { 1253 + put_rpccred(cred); 1254 + ctx->ll_cred = NULL; 1255 + cred = NULL; 1256 + } 1257 + if (!cred) 1258 + cred = auth->au_ops->lookup_cred(auth, &acred, 0); 1259 + if (!cred || IS_ERR(cred)) 1260 + return true; 1261 + ctx->ll_cred = cred; 1262 + return !!(cred->cr_ops->crkey_timeout && 1263 + cred->cr_ops->crkey_timeout(cred)); 1252 1264 } 1253 1265 1254 1266 /*
+14 -15
fs/nfsd/nfs4callback.c
··· 844 844 return max(nn->nfsd4_lease/10, (time_t)1) * HZ; 845 845 } 846 846 847 - static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses) 847 + static const struct cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses) 848 848 { 849 849 if (clp->cl_minorversion == 0) { 850 - char *principal = clp->cl_cred.cr_targ_princ ? 851 - clp->cl_cred.cr_targ_princ : "nfs"; 852 - struct rpc_cred *cred; 850 + client->cl_principal = clp->cl_cred.cr_targ_princ ? 851 + clp->cl_cred.cr_targ_princ : "nfs"; 853 852 854 - cred = rpc_lookup_machine_cred(principal); 855 - if (!IS_ERR(cred)) 856 - get_rpccred(cred); 857 - return cred; 853 + return get_cred(rpc_machine_cred()); 858 854 } else { 859 - struct rpc_auth *auth = client->cl_auth; 860 - struct auth_cred acred = {}; 855 + struct cred *kcred; 861 856 862 - acred.uid = ses->se_cb_sec.uid; 863 - acred.gid = ses->se_cb_sec.gid; 864 - return auth->au_ops->lookup_cred(client->cl_auth, &acred, 0); 857 + kcred = prepare_kernel_cred(NULL); 858 + if (!kcred) 859 + return NULL; 860 + 861 + kcred->uid = ses->se_cb_sec.uid; 862 + kcred->gid = ses->se_cb_sec.gid; 863 + return kcred; 865 864 } 866 865 } 867 866 ··· 883 884 .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), 884 885 }; 885 886 struct rpc_clnt *client; 886 - struct rpc_cred *cred; 887 + const struct cred *cred; 887 888 888 889 if (clp->cl_minorversion == 0) { 889 890 if (!clp->cl_cred.cr_principal && ··· 1213 1214 if (clp->cl_cb_client) { 1214 1215 rpc_shutdown_client(clp->cl_cb_client); 1215 1216 clp->cl_cb_client = NULL; 1216 - put_rpccred(clp->cl_cb_cred); 1217 + put_cred(clp->cl_cb_cred); 1217 1218 clp->cl_cb_cred = NULL; 1218 1219 } 1219 1220 if (clp->cl_cb_conn.cb_xprt) {
+1 -1
fs/nfsd/state.h
··· 327 327 #define NFSD4_CLIENT_CB_FLAG_MASK (1 << NFSD4_CLIENT_CB_UPDATE | \ 328 328 1 << NFSD4_CLIENT_CB_KILL) 329 329 unsigned long cl_flags; 330 - struct rpc_cred *cl_cb_cred; 330 + const struct cred *cl_cb_cred; 331 331 struct rpc_clnt *cl_cb_client; 332 332 u32 cl_cb_ident; 333 333 #define NFSD4_CB_UP 0
+21 -5
include/linux/cred.h
··· 169 169 extern int set_security_override(struct cred *, u32); 170 170 extern int set_security_override_from_ctx(struct cred *, const char *); 171 171 extern int set_create_files_as(struct cred *, struct inode *); 172 + extern int cred_fscmp(const struct cred *, const struct cred *); 172 173 extern void __init cred_init(void); 173 174 174 175 /* ··· 237 236 * @cred: The credentials to reference 238 237 * 239 238 * Get a reference on the specified set of credentials. The caller must 240 - * release the reference. 239 + * release the reference. If %NULL is passed, it is returned with no action. 241 240 * 242 241 * This is used to deal with a committed set of credentials. Although the 243 242 * pointer is const, this will temporarily discard the const and increment the ··· 248 247 static inline const struct cred *get_cred(const struct cred *cred) 249 248 { 250 249 struct cred *nonconst_cred = (struct cred *) cred; 250 + if (!cred) 251 + return cred; 251 252 validate_creds(cred); 252 253 return get_new_cred(nonconst_cred); 254 + } 255 + 256 + static inline const struct cred *get_cred_rcu(const struct cred *cred) 257 + { 258 + struct cred *nonconst_cred = (struct cred *) cred; 259 + if (!cred) 260 + return NULL; 261 + if (!atomic_inc_not_zero(&nonconst_cred->usage)) 262 + return NULL; 263 + validate_creds(cred); 264 + return cred; 253 265 } 254 266 255 267 /** ··· 270 256 * @cred: The credentials to release 271 257 * 272 258 * Release a reference to a set of credentials, deleting them when the last ref 273 - * is released. 259 + * is released. If %NULL is passed, nothing is done. 274 260 * 275 261 * This takes a const pointer to a set of credentials because the credentials 276 262 * on task_struct are attached by const pointers to prevent accidental ··· 280 266 { 281 267 struct cred *cred = (struct cred *) _cred; 282 268 283 - validate_creds(cred); 284 - if (atomic_dec_and_test(&(cred)->usage)) 285 - __put_cred(cred); 269 + if (cred) { 270 + validate_creds(cred); 271 + if (atomic_dec_and_test(&(cred)->usage)) 272 + __put_cred(cred); 273 + } 286 274 } 287 275 288 276 /**
+7 -6
include/linux/nfs_fs.h
··· 51 51 struct nfs_access_entry { 52 52 struct rb_node rb_node; 53 53 struct list_head lru; 54 - struct rpc_cred * cred; 54 + const struct cred * cred; 55 55 __u32 mask; 56 56 struct rcu_head rcu_head; 57 57 }; ··· 70 70 struct nfs_lock_context lock_context; 71 71 fl_owner_t flock_owner; 72 72 struct dentry *dentry; 73 - struct rpc_cred *cred; 73 + const struct cred *cred; 74 + struct rpc_cred *ll_cred; /* low-level cred - use to check for expiry */ 74 75 struct nfs4_state *state; 75 76 fmode_t mode; 76 77 ··· 89 88 90 89 struct nfs_open_dir_context { 91 90 struct list_head list; 92 - struct rpc_cred *cred; 91 + const struct cred *cred; 93 92 unsigned long attr_gencount; 94 93 __u64 dir_cookie; 95 94 __u64 dup_cookie; ··· 391 390 struct nfs4_label *label); 392 391 extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx); 393 392 extern void put_nfs_open_context(struct nfs_open_context *ctx); 394 - extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode); 393 + extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct cred *cred, fmode_t mode); 395 394 extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode, struct file *filp); 396 395 extern void nfs_inode_attach_open_context(struct nfs_open_context *ctx); 397 396 extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx); ··· 462 461 return filp->private_data; 463 462 } 464 463 465 - static inline struct rpc_cred *nfs_file_cred(struct file *file) 464 + static inline const struct cred *nfs_file_cred(struct file *file) 466 465 { 467 466 if (file != NULL) { 468 467 struct nfs_open_context *ctx = ··· 491 490 extern void nfs_force_lookup_revalidate(struct inode *dir); 492 491 extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh, 493 492 struct nfs_fattr *fattr, struct nfs4_label *label); 494 - extern int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags); 493 + extern int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags); 495 494 extern void nfs_access_zap_cache(struct inode *inode); 496 495 497 496 /*
+1 -1
include/linux/nfs_fs_sb.h
··· 58 58 struct nfs_subversion * cl_nfs_mod; /* pointer to nfs version module */ 59 59 60 60 u32 cl_minorversion;/* NFSv4 minorversion */ 61 - struct rpc_cred *cl_machine_cred; 61 + const char * cl_principal; /* used for machine cred */ 62 62 63 63 #if IS_ENABLED(CONFIG_NFS_V4) 64 64 struct list_head cl_ds_clients; /* auth flavor data servers */
+8 -8
include/linux/nfs_xdr.h
··· 270 270 struct nfs4_layoutget { 271 271 struct nfs4_layoutget_args args; 272 272 struct nfs4_layoutget_res res; 273 - struct rpc_cred *cred; 273 + const struct cred *cred; 274 274 gfp_t gfp_flags; 275 275 }; 276 276 ··· 309 309 struct rpc_task task; 310 310 struct nfs_fattr fattr; 311 311 struct list_head lseg_list; 312 - struct rpc_cred *cred; 312 + const struct cred *cred; 313 313 struct inode *inode; 314 314 struct nfs4_layoutcommit_args args; 315 315 struct nfs4_layoutcommit_res res; ··· 334 334 struct nfs4_layoutreturn { 335 335 struct nfs4_layoutreturn_args args; 336 336 struct nfs4_layoutreturn_res res; 337 - struct rpc_cred *cred; 337 + const struct cred *cred; 338 338 struct nfs_client *clp; 339 339 struct inode *inode; 340 340 int rpc_status; ··· 1469 1469 struct nfs_io_completion; 1470 1470 struct nfs_pgio_header { 1471 1471 struct inode *inode; 1472 - struct rpc_cred *cred; 1472 + const struct cred *cred; 1473 1473 struct list_head pages; 1474 1474 struct nfs_page *req; 1475 1475 struct nfs_writeverf verf; /* Used for writes */ ··· 1529 1529 struct nfs_commit_data { 1530 1530 struct rpc_task task; 1531 1531 struct inode *inode; 1532 - struct rpc_cred *cred; 1532 + const struct cred *cred; 1533 1533 struct nfs_fattr fattr; 1534 1534 struct nfs_writeverf verf; 1535 1535 struct list_head pages; /* Coalesced requests we wish to flush */ ··· 1560 1560 struct nfs_removeres res; 1561 1561 struct dentry *dentry; 1562 1562 wait_queue_head_t wq; 1563 - struct rpc_cred *cred; 1563 + const struct cred *cred; 1564 1564 struct nfs_fattr dir_attr; 1565 1565 long timeout; 1566 1566 }; ··· 1568 1568 struct nfs_renamedata { 1569 1569 struct nfs_renameargs args; 1570 1570 struct nfs_renameres res; 1571 - struct rpc_cred *cred; 1571 + const struct cred *cred; 1572 1572 struct inode *old_dir; 1573 1573 struct dentry *old_dentry; 1574 1574 struct nfs_fattr old_fattr; ··· 1634 1634 unsigned int, struct iattr *); 1635 1635 int (*mkdir) (struct inode *, struct dentry *, struct iattr *); 1636 1636 int (*rmdir) (struct inode *, const struct qstr *); 1637 - int (*readdir) (struct dentry *, struct rpc_cred *, 1637 + int (*readdir) (struct dentry *, const struct cred *, 1638 1638 u64, struct page **, unsigned int, bool); 1639 1639 int (*mknod) (struct inode *, struct dentry *, struct iattr *, 1640 1640 dev_t);
+4 -47
include/linux/sunrpc/auth.h
··· 37 37 38 38 struct rpcsec_gss_info; 39 39 40 - /* auth_cred ac_flags bits */ 41 - enum { 42 - RPC_CRED_KEY_EXPIRE_SOON = 1, /* underlying cred key will expire soon */ 43 - RPC_CRED_NOTIFY_TIMEOUT = 2, /* nofity generic cred when underlying 44 - key will expire soon */ 45 - }; 46 - 47 - /* Work around the lack of a VFS credential */ 48 40 struct auth_cred { 49 - kuid_t uid; 50 - kgid_t gid; 51 - struct group_info *group_info; 52 - const char *principal; 53 - unsigned long ac_flags; 54 - unsigned char machine_cred : 1; 41 + const struct cred *cred; 42 + const char *principal; /* If present, this is a machine credential */ 55 43 }; 56 44 57 45 /* ··· 56 68 unsigned long cr_expire; /* when to gc */ 57 69 unsigned long cr_flags; /* various flags */ 58 70 refcount_t cr_count; /* ref count */ 59 - 60 - kuid_t cr_uid; 71 + const struct cred *cr_cred; 61 72 62 73 /* per-flavor data */ 63 74 }; ··· 65 78 #define RPCAUTH_CRED_HASHED 2 66 79 #define RPCAUTH_CRED_NEGATIVE 3 67 80 68 - /* rpc_auth au_flags */ 69 - #define RPCAUTH_AUTH_NO_CRKEY_TIMEOUT 0x0001 /* underlying cred has no key timeout */ 81 + const struct cred *rpc_machine_cred(void); 70 82 71 83 /* 72 84 * Client authentication handle ··· 102 116 103 117 /* Flags for rpcauth_lookupcred() */ 104 118 #define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */ 105 - #define RPCAUTH_LOOKUP_RCU 0x02 /* lock-less lookup */ 106 119 107 120 /* 108 121 * Client authentication ops ··· 131 146 void (*crdestroy)(struct rpc_cred *); 132 147 133 148 int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); 134 - struct rpc_cred * (*crbind)(struct rpc_task *, struct rpc_cred *, int); 135 149 __be32 * (*crmarshal)(struct rpc_task *, __be32 *); 136 150 int (*crrefresh)(struct rpc_task *); 137 151 __be32 * (*crvalidate)(struct rpc_task *, __be32 *); ··· 139 155 int (*crunwrap_resp)(struct rpc_task *, kxdrdproc_t, 140 156 void *, __be32 *, void *); 141 157 int (*crkey_timeout)(struct rpc_cred *); 142 - bool (*crkey_to_expire)(struct rpc_cred *); 143 158 char * (*crstringify_acceptor)(struct rpc_cred *); 144 159 bool (*crneed_reencode)(struct rpc_task *); 145 160 }; ··· 147 164 extern const struct rpc_authops authnull_ops; 148 165 149 166 int __init rpc_init_authunix(void); 150 - int __init rpc_init_generic_auth(void); 151 167 int __init rpcauth_init_module(void); 152 168 void rpcauth_remove_module(void); 153 - void rpc_destroy_generic_auth(void); 154 169 void rpc_destroy_authunix(void); 155 170 156 - struct rpc_cred * rpc_lookup_cred(void); 157 - struct rpc_cred * rpc_lookup_cred_nonblock(void); 158 - struct rpc_cred * rpc_lookup_generic_cred(struct auth_cred *, int, gfp_t); 159 - struct rpc_cred * rpc_lookup_machine_cred(const char *service_name); 160 171 int rpcauth_register(const struct rpc_authops *); 161 172 int rpcauth_unregister(const struct rpc_authops *); 162 173 struct rpc_auth * rpcauth_create(const struct rpc_auth_create_args *, ··· 164 187 struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int, gfp_t); 165 188 void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); 166 189 struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); 167 - struct rpc_cred * rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *, int); 168 190 void put_rpccred(struct rpc_cred *); 169 191 __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); 170 192 __be32 * rpcauth_checkverf(struct rpc_task *, __be32 *); ··· 176 200 int rpcauth_init_credcache(struct rpc_auth *); 177 201 void rpcauth_destroy_credcache(struct rpc_auth *); 178 202 void rpcauth_clear_credcache(struct rpc_cred_cache *); 179 - int rpcauth_key_timeout_notify(struct rpc_auth *, 180 - struct rpc_cred *); 181 - bool rpcauth_cred_key_to_expire(struct rpc_auth *, struct rpc_cred *); 182 203 char * rpcauth_stringify_acceptor(struct rpc_cred *); 183 204 184 205 static inline ··· 184 211 if (cred != NULL && refcount_inc_not_zero(&cred->cr_count)) 185 212 return cred; 186 213 return NULL; 187 - } 188 - 189 - /** 190 - * get_rpccred_rcu - get a reference to a cred using rcu-protected pointer 191 - * @cred: cred of which to take a reference 192 - * 193 - * In some cases, we may have a pointer to a credential to which we 194 - * want to take a reference, but don't already have one. Because these 195 - * objects are freed using RCU, we can access the cr_count while its 196 - * on its way to destruction and only take a reference if it's not already 197 - * zero. 198 - */ 199 - static inline struct rpc_cred * 200 - get_rpccred_rcu(struct rpc_cred *cred) 201 - { 202 - return get_rpccred(cred); 203 214 } 204 215 205 216 #endif /* __KERNEL__ */
+3 -2
include/linux/sunrpc/clnt.h
··· 66 66 struct rpc_rtt cl_rtt_default; 67 67 struct rpc_timeout cl_timeout_default; 68 68 const struct rpc_program *cl_program; 69 + const char * cl_principal; /* use for machine cred */ 69 70 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 70 71 struct dentry *cl_debugfs; /* debugfs directory */ 71 72 #endif ··· 128 127 }; 129 128 130 129 struct rpc_add_xprt_test { 131 - int (*add_xprt_test)(struct rpc_clnt *, 132 - struct rpc_xprt *, 130 + void (*add_xprt_test)(struct rpc_clnt *clnt, 131 + struct rpc_xprt *xprt, 133 132 void *calldata); 134 133 void *data; 135 134 };
+4 -2
include/linux/sunrpc/sched.h
··· 26 26 const struct rpc_procinfo *rpc_proc; /* Procedure information */ 27 27 void * rpc_argp; /* Arguments */ 28 28 void * rpc_resp; /* Result */ 29 - struct rpc_cred * rpc_cred; /* Credentials */ 29 + const struct cred * rpc_cred; /* Credentials */ 30 30 }; 31 31 32 32 struct rpc_call_ops; ··· 71 71 72 72 struct rpc_clnt * tk_client; /* RPC client */ 73 73 struct rpc_xprt * tk_xprt; /* Transport */ 74 + struct rpc_cred * tk_op_cred; /* cred being operated on */ 74 75 75 76 struct rpc_rqst * tk_rqstp; /* RPC request */ 76 77 ··· 106 105 struct rpc_task *task; 107 106 struct rpc_clnt *rpc_client; 108 107 struct rpc_xprt *rpc_xprt; 108 + struct rpc_cred *rpc_op_cred; /* credential being operated on */ 109 109 const struct rpc_message *rpc_message; 110 110 const struct rpc_call_ops *callback_ops; 111 111 void *callback_data; ··· 120 118 */ 121 119 #define RPC_TASK_ASYNC 0x0001 /* is an async task */ 122 120 #define RPC_TASK_SWAPPER 0x0002 /* is swapping in/out */ 121 + #define RPC_TASK_NULLCREDS 0x0010 /* Use AUTH_NULL credential */ 123 122 #define RPC_CALL_MAJORSEEN 0x0020 /* major timeout seen */ 124 123 #define RPC_TASK_ROOTCREDS 0x0040 /* force root creds */ 125 124 #define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */ ··· 134 131 135 132 #define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) 136 133 #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) 137 - #define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) 138 134 #define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) 139 135 #define RPC_IS_SOFT(t) ((t)->tk_flags & (RPC_TASK_SOFT|RPC_TASK_TIMEOUT)) 140 136 #define RPC_IS_SOFTCONN(t) ((t)->tk_flags & RPC_TASK_SOFTCONN)
+197 -21
include/trace/events/rpcrdma.h
··· 10 10 #if !defined(_TRACE_RPCRDMA_H) || defined(TRACE_HEADER_MULTI_READ) 11 11 #define _TRACE_RPCRDMA_H 12 12 13 + #include <linux/scatterlist.h> 13 14 #include <linux/tracepoint.h> 14 15 #include <trace/events/rdma.h> 15 16 ··· 98 97 TP_STRUCT__entry( 99 98 __field(unsigned int, task_id) 100 99 __field(unsigned int, client_id) 101 - __field(const void *, mr) 102 100 __field(unsigned int, pos) 103 101 __field(int, nents) 104 102 __field(u32, handle) ··· 109 109 TP_fast_assign( 110 110 __entry->task_id = task->tk_pid; 111 111 __entry->client_id = task->tk_client->cl_clid; 112 - __entry->mr = mr; 113 112 __entry->pos = pos; 114 113 __entry->nents = mr->mr_nents; 115 114 __entry->handle = mr->mr_handle; ··· 117 118 __entry->nsegs = nsegs; 118 119 ), 119 120 120 - TP_printk("task:%u@%u mr=%p pos=%u %u@0x%016llx:0x%08x (%s)", 121 - __entry->task_id, __entry->client_id, __entry->mr, 121 + TP_printk("task:%u@%u pos=%u %u@0x%016llx:0x%08x (%s)", 122 + __entry->task_id, __entry->client_id, 122 123 __entry->pos, __entry->length, 123 124 (unsigned long long)__entry->offset, __entry->handle, 124 125 __entry->nents < __entry->nsegs ? "more" : "last" ··· 126 127 ); 127 128 128 129 #define DEFINE_RDCH_EVENT(name) \ 129 - DEFINE_EVENT(xprtrdma_rdch_event, name, \ 130 + DEFINE_EVENT(xprtrdma_rdch_event, xprtrdma_chunk_##name,\ 130 131 TP_PROTO( \ 131 132 const struct rpc_task *task, \ 132 133 unsigned int pos, \ ··· 147 148 TP_STRUCT__entry( 148 149 __field(unsigned int, task_id) 149 150 __field(unsigned int, client_id) 150 - __field(const void *, mr) 151 151 __field(int, nents) 152 152 __field(u32, handle) 153 153 __field(u32, length) ··· 157 159 TP_fast_assign( 158 160 __entry->task_id = task->tk_pid; 159 161 __entry->client_id = task->tk_client->cl_clid; 160 - __entry->mr = mr; 161 162 __entry->nents = mr->mr_nents; 162 163 __entry->handle = mr->mr_handle; 163 164 __entry->length = mr->mr_length; ··· 164 167 __entry->nsegs = nsegs; 165 168 ), 166 169 167 - TP_printk("task:%u@%u mr=%p %u@0x%016llx:0x%08x (%s)", 168 - __entry->task_id, __entry->client_id, __entry->mr, 170 + TP_printk("task:%u@%u %u@0x%016llx:0x%08x (%s)", 171 + __entry->task_id, __entry->client_id, 169 172 __entry->length, (unsigned long long)__entry->offset, 170 173 __entry->handle, 171 174 __entry->nents < __entry->nsegs ? "more" : "last" ··· 173 176 ); 174 177 175 178 #define DEFINE_WRCH_EVENT(name) \ 176 - DEFINE_EVENT(xprtrdma_wrch_event, name, \ 179 + DEFINE_EVENT(xprtrdma_wrch_event, xprtrdma_chunk_##name,\ 177 180 TP_PROTO( \ 178 181 const struct rpc_task *task, \ 179 182 struct rpcrdma_mr *mr, \ ··· 231 234 ), \ 232 235 TP_ARGS(wc, frwr)) 233 236 237 + TRACE_DEFINE_ENUM(DMA_BIDIRECTIONAL); 238 + TRACE_DEFINE_ENUM(DMA_TO_DEVICE); 239 + TRACE_DEFINE_ENUM(DMA_FROM_DEVICE); 240 + TRACE_DEFINE_ENUM(DMA_NONE); 241 + 242 + #define xprtrdma_show_direction(x) \ 243 + __print_symbolic(x, \ 244 + { DMA_BIDIRECTIONAL, "BIDIR" }, \ 245 + { DMA_TO_DEVICE, "TO_DEVICE" }, \ 246 + { DMA_FROM_DEVICE, "FROM_DEVICE" }, \ 247 + { DMA_NONE, "NONE" }) 248 + 234 249 DECLARE_EVENT_CLASS(xprtrdma_mr, 235 250 TP_PROTO( 236 251 const struct rpcrdma_mr *mr ··· 255 246 __field(u32, handle) 256 247 __field(u32, length) 257 248 __field(u64, offset) 249 + __field(u32, dir) 258 250 ), 259 251 260 252 TP_fast_assign( ··· 263 253 __entry->handle = mr->mr_handle; 264 254 __entry->length = mr->mr_length; 265 255 __entry->offset = mr->mr_offset; 256 + __entry->dir = mr->mr_dir; 266 257 ), 267 258 268 - TP_printk("mr=%p %u@0x%016llx:0x%08x", 259 + TP_printk("mr=%p %u@0x%016llx:0x%08x (%s)", 269 260 __entry->mr, __entry->length, 270 - (unsigned long long)__entry->offset, 271 - __entry->handle 261 + (unsigned long long)__entry->offset, __entry->handle, 262 + xprtrdma_show_direction(__entry->dir) 272 263 ) 273 264 ); 274 265 ··· 382 371 DEFINE_RXPRT_EVENT(xprtrdma_conn_start); 383 372 DEFINE_RXPRT_EVENT(xprtrdma_conn_tout); 384 373 DEFINE_RXPRT_EVENT(xprtrdma_create); 385 - DEFINE_RXPRT_EVENT(xprtrdma_destroy); 374 + DEFINE_RXPRT_EVENT(xprtrdma_op_destroy); 386 375 DEFINE_RXPRT_EVENT(xprtrdma_remove); 387 376 DEFINE_RXPRT_EVENT(xprtrdma_reinsert); 388 377 DEFINE_RXPRT_EVENT(xprtrdma_reconnect); 389 - DEFINE_RXPRT_EVENT(xprtrdma_inject_dsc); 378 + DEFINE_RXPRT_EVENT(xprtrdma_op_inject_dsc); 379 + DEFINE_RXPRT_EVENT(xprtrdma_op_close); 380 + DEFINE_RXPRT_EVENT(xprtrdma_op_connect); 390 381 391 382 TRACE_EVENT(xprtrdma_qp_event, 392 383 TP_PROTO( ··· 450 437 451 438 DEFINE_RXPRT_EVENT(xprtrdma_nomrs); 452 439 453 - DEFINE_RDCH_EVENT(xprtrdma_read_chunk); 454 - DEFINE_WRCH_EVENT(xprtrdma_write_chunk); 455 - DEFINE_WRCH_EVENT(xprtrdma_reply_chunk); 440 + DEFINE_RDCH_EVENT(read); 441 + DEFINE_WRCH_EVENT(write); 442 + DEFINE_WRCH_EVENT(reply); 456 443 457 444 TRACE_DEFINE_ENUM(rpcrdma_noch); 458 445 TRACE_DEFINE_ENUM(rpcrdma_readch); ··· 583 570 __entry->r_xprt = r_xprt; 584 571 __entry->count = count; 585 572 __entry->status = status; 586 - __entry->posted = r_xprt->rx_buf.rb_posted_receives; 573 + __entry->posted = r_xprt->rx_ep.rep_receive_count; 587 574 __assign_str(addr, rpcrdma_addrstr(r_xprt)); 588 575 __assign_str(port, rpcrdma_portstr(r_xprt)); 589 576 ), ··· 664 651 DEFINE_FRWR_DONE_EVENT(xprtrdma_wc_li); 665 652 DEFINE_FRWR_DONE_EVENT(xprtrdma_wc_li_wake); 666 653 654 + TRACE_EVENT(xprtrdma_frwr_alloc, 655 + TP_PROTO( 656 + const struct rpcrdma_mr *mr, 657 + int rc 658 + ), 659 + 660 + TP_ARGS(mr, rc), 661 + 662 + TP_STRUCT__entry( 663 + __field(const void *, mr) 664 + __field(int, rc) 665 + ), 666 + 667 + TP_fast_assign( 668 + __entry->mr = mr; 669 + __entry->rc = rc; 670 + ), 671 + 672 + TP_printk("mr=%p: rc=%d", 673 + __entry->mr, __entry->rc 674 + ) 675 + ); 676 + 677 + TRACE_EVENT(xprtrdma_frwr_dereg, 678 + TP_PROTO( 679 + const struct rpcrdma_mr *mr, 680 + int rc 681 + ), 682 + 683 + TP_ARGS(mr, rc), 684 + 685 + TP_STRUCT__entry( 686 + __field(const void *, mr) 687 + __field(u32, handle) 688 + __field(u32, length) 689 + __field(u64, offset) 690 + __field(u32, dir) 691 + __field(int, rc) 692 + ), 693 + 694 + TP_fast_assign( 695 + __entry->mr = mr; 696 + __entry->handle = mr->mr_handle; 697 + __entry->length = mr->mr_length; 698 + __entry->offset = mr->mr_offset; 699 + __entry->dir = mr->mr_dir; 700 + __entry->rc = rc; 701 + ), 702 + 703 + TP_printk("mr=%p %u@0x%016llx:0x%08x (%s): rc=%d", 704 + __entry->mr, __entry->length, 705 + (unsigned long long)__entry->offset, __entry->handle, 706 + xprtrdma_show_direction(__entry->dir), 707 + __entry->rc 708 + ) 709 + ); 710 + 711 + TRACE_EVENT(xprtrdma_frwr_sgerr, 712 + TP_PROTO( 713 + const struct rpcrdma_mr *mr, 714 + int sg_nents 715 + ), 716 + 717 + TP_ARGS(mr, sg_nents), 718 + 719 + TP_STRUCT__entry( 720 + __field(const void *, mr) 721 + __field(u64, addr) 722 + __field(u32, dir) 723 + __field(int, nents) 724 + ), 725 + 726 + TP_fast_assign( 727 + __entry->mr = mr; 728 + __entry->addr = mr->mr_sg->dma_address; 729 + __entry->dir = mr->mr_dir; 730 + __entry->nents = sg_nents; 731 + ), 732 + 733 + TP_printk("mr=%p dma addr=0x%llx (%s) sg_nents=%d", 734 + __entry->mr, __entry->addr, 735 + xprtrdma_show_direction(__entry->dir), 736 + __entry->nents 737 + ) 738 + ); 739 + 740 + TRACE_EVENT(xprtrdma_frwr_maperr, 741 + TP_PROTO( 742 + const struct rpcrdma_mr *mr, 743 + int num_mapped 744 + ), 745 + 746 + TP_ARGS(mr, num_mapped), 747 + 748 + TP_STRUCT__entry( 749 + __field(const void *, mr) 750 + __field(u64, addr) 751 + __field(u32, dir) 752 + __field(int, num_mapped) 753 + __field(int, nents) 754 + ), 755 + 756 + TP_fast_assign( 757 + __entry->mr = mr; 758 + __entry->addr = mr->mr_sg->dma_address; 759 + __entry->dir = mr->mr_dir; 760 + __entry->num_mapped = num_mapped; 761 + __entry->nents = mr->mr_nents; 762 + ), 763 + 764 + TP_printk("mr=%p dma addr=0x%llx (%s) nents=%d of %d", 765 + __entry->mr, __entry->addr, 766 + xprtrdma_show_direction(__entry->dir), 767 + __entry->num_mapped, __entry->nents 768 + ) 769 + ); 770 + 667 771 DEFINE_MR_EVENT(localinv); 668 772 DEFINE_MR_EVENT(map); 669 773 DEFINE_MR_EVENT(unmap); 670 774 DEFINE_MR_EVENT(remoteinv); 671 775 DEFINE_MR_EVENT(recycle); 776 + 777 + TRACE_EVENT(xprtrdma_dma_maperr, 778 + TP_PROTO( 779 + u64 addr 780 + ), 781 + 782 + TP_ARGS(addr), 783 + 784 + TP_STRUCT__entry( 785 + __field(u64, addr) 786 + ), 787 + 788 + TP_fast_assign( 789 + __entry->addr = addr; 790 + ), 791 + 792 + TP_printk("dma addr=0x%llx\n", __entry->addr) 793 + ); 672 794 673 795 /** 674 796 ** Reply events ··· 972 824 ** Allocation/release of rpcrdma_reqs and rpcrdma_reps 973 825 **/ 974 826 975 - TRACE_EVENT(xprtrdma_allocate, 827 + TRACE_EVENT(xprtrdma_op_allocate, 976 828 TP_PROTO( 977 829 const struct rpc_task *task, 978 830 const struct rpcrdma_req *req ··· 1002 854 ) 1003 855 ); 1004 856 1005 - TRACE_EVENT(xprtrdma_rpc_done, 857 + TRACE_EVENT(xprtrdma_op_free, 1006 858 TP_PROTO( 1007 859 const struct rpc_task *task, 1008 860 const struct rpcrdma_req *req ··· 1064 916 1065 917 DEFINE_CB_EVENT(xprtrdma_cb_call); 1066 918 DEFINE_CB_EVENT(xprtrdma_cb_reply); 919 + 920 + TRACE_EVENT(xprtrdma_leaked_rep, 921 + TP_PROTO( 922 + const struct rpc_rqst *rqst, 923 + const struct rpcrdma_rep *rep 924 + ), 925 + 926 + TP_ARGS(rqst, rep), 927 + 928 + TP_STRUCT__entry( 929 + __field(unsigned int, task_id) 930 + __field(unsigned int, client_id) 931 + __field(u32, xid) 932 + __field(const void *, rep) 933 + ), 934 + 935 + TP_fast_assign( 936 + __entry->task_id = rqst->rq_task->tk_pid; 937 + __entry->client_id = rqst->rq_task->tk_client->cl_clid; 938 + __entry->xid = be32_to_cpu(rqst->rq_xid); 939 + __entry->rep = rep; 940 + ), 941 + 942 + TP_printk("task:%u@%u xid=0x%08x rep=%p", 943 + __entry->task_id, __entry->client_id, __entry->xid, 944 + __entry->rep 945 + ) 946 + ); 1067 947 1068 948 /** 1069 949 ** Server-side RPC/RDMA events
+69 -103
include/trace/events/sunrpc.h
··· 16 16 17 17 DECLARE_EVENT_CLASS(rpc_task_status, 18 18 19 - TP_PROTO(struct rpc_task *task), 20 - 21 - TP_ARGS(task), 22 - 23 - TP_STRUCT__entry( 24 - __field(unsigned int, task_id) 25 - __field(unsigned int, client_id) 26 - __field(int, status) 27 - ), 28 - 29 - TP_fast_assign( 30 - __entry->task_id = task->tk_pid; 31 - __entry->client_id = task->tk_client->cl_clid; 32 - __entry->status = task->tk_status; 33 - ), 34 - 35 - TP_printk("task:%u@%u status=%d", 36 - __entry->task_id, __entry->client_id, 37 - __entry->status) 38 - ); 39 - 40 - DEFINE_EVENT(rpc_task_status, rpc_call_status, 41 - TP_PROTO(struct rpc_task *task), 42 - 43 - TP_ARGS(task) 44 - ); 45 - 46 - DEFINE_EVENT(rpc_task_status, rpc_bind_status, 47 - TP_PROTO(struct rpc_task *task), 48 - 49 - TP_ARGS(task) 50 - ); 51 - 52 - TRACE_EVENT(rpc_connect_status, 53 19 TP_PROTO(const struct rpc_task *task), 54 20 55 21 TP_ARGS(task), ··· 36 70 __entry->task_id, __entry->client_id, 37 71 __entry->status) 38 72 ); 73 + #define DEFINE_RPC_STATUS_EVENT(name) \ 74 + DEFINE_EVENT(rpc_task_status, rpc_##name##_status, \ 75 + TP_PROTO( \ 76 + const struct rpc_task *task \ 77 + ), \ 78 + TP_ARGS(task)) 79 + 80 + DEFINE_RPC_STATUS_EVENT(call); 81 + DEFINE_RPC_STATUS_EVENT(bind); 82 + DEFINE_RPC_STATUS_EVENT(connect); 39 83 40 84 TRACE_EVENT(rpc_request, 41 85 TP_PROTO(const struct rpc_task *task), ··· 110 134 __entry->action 111 135 ) 112 136 ); 137 + #define DEFINE_RPC_RUNNING_EVENT(name) \ 138 + DEFINE_EVENT(rpc_task_running, rpc_task_##name, \ 139 + TP_PROTO( \ 140 + const struct rpc_task *task, \ 141 + const void *action \ 142 + ), \ 143 + TP_ARGS(task, action)) 113 144 114 - DEFINE_EVENT(rpc_task_running, rpc_task_begin, 115 - 116 - TP_PROTO(const struct rpc_task *task, const void *action), 117 - 118 - TP_ARGS(task, action) 119 - 120 - ); 121 - 122 - DEFINE_EVENT(rpc_task_running, rpc_task_run_action, 123 - 124 - TP_PROTO(const struct rpc_task *task, const void *action), 125 - 126 - TP_ARGS(task, action) 127 - 128 - ); 129 - 130 - DEFINE_EVENT(rpc_task_running, rpc_task_complete, 131 - 132 - TP_PROTO(const struct rpc_task *task, const void *action), 133 - 134 - TP_ARGS(task, action) 135 - 136 - ); 145 + DEFINE_RPC_RUNNING_EVENT(begin); 146 + DEFINE_RPC_RUNNING_EVENT(run_action); 147 + DEFINE_RPC_RUNNING_EVENT(complete); 137 148 138 149 DECLARE_EVENT_CLASS(rpc_task_queued, 139 150 ··· 158 195 __get_str(q_name) 159 196 ) 160 197 ); 198 + #define DEFINE_RPC_QUEUED_EVENT(name) \ 199 + DEFINE_EVENT(rpc_task_queued, rpc_task_##name, \ 200 + TP_PROTO( \ 201 + const struct rpc_task *task, \ 202 + const struct rpc_wait_queue *q \ 203 + ), \ 204 + TP_ARGS(task, q)) 161 205 162 - DEFINE_EVENT(rpc_task_queued, rpc_task_sleep, 163 - 164 - TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q), 165 - 166 - TP_ARGS(task, q) 167 - 168 - ); 169 - 170 - DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup, 171 - 172 - TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q), 173 - 174 - TP_ARGS(task, q) 175 - 176 - ); 206 + DEFINE_RPC_QUEUED_EVENT(sleep); 207 + DEFINE_RPC_QUEUED_EVENT(wakeup); 177 208 178 209 TRACE_EVENT(rpc_stats_latency, 179 210 ··· 367 410 DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown); 368 411 369 412 DECLARE_EVENT_CLASS(rpc_xprt_event, 370 - TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status), 413 + TP_PROTO( 414 + const struct rpc_xprt *xprt, 415 + __be32 xid, 416 + int status 417 + ), 371 418 372 419 TP_ARGS(xprt, xid, status), 373 420 ··· 393 432 __get_str(port), __entry->xid, 394 433 __entry->status) 395 434 ); 435 + #define DEFINE_RPC_XPRT_EVENT(name) \ 436 + DEFINE_EVENT(rpc_xprt_event, xprt_##name, \ 437 + TP_PROTO( \ 438 + const struct rpc_xprt *xprt, \ 439 + __be32 xid, \ 440 + int status \ 441 + ), \ 442 + TP_ARGS(xprt, xid, status)) 396 443 397 - DEFINE_EVENT(rpc_xprt_event, xprt_timer, 398 - TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status), 399 - TP_ARGS(xprt, xid, status)); 400 - 401 - DEFINE_EVENT(rpc_xprt_event, xprt_lookup_rqst, 402 - TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status), 403 - TP_ARGS(xprt, xid, status)); 404 - 405 - DEFINE_EVENT(rpc_xprt_event, xprt_transmit, 406 - TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status), 407 - TP_ARGS(xprt, xid, status)); 408 - 409 - DEFINE_EVENT(rpc_xprt_event, xprt_complete_rqst, 410 - TP_PROTO(struct rpc_xprt *xprt, __be32 xid, int status), 411 - TP_ARGS(xprt, xid, status)); 444 + DEFINE_RPC_XPRT_EVENT(timer); 445 + DEFINE_RPC_XPRT_EVENT(lookup_rqst); 446 + DEFINE_RPC_XPRT_EVENT(transmit); 447 + DEFINE_RPC_XPRT_EVENT(complete_rqst); 412 448 413 449 TRACE_EVENT(xprt_ping, 414 450 TP_PROTO(const struct rpc_xprt *xprt, int status), ··· 547 589 548 590 DECLARE_EVENT_CLASS(svc_rqst_event, 549 591 550 - TP_PROTO(struct svc_rqst *rqst), 592 + TP_PROTO( 593 + const struct svc_rqst *rqst 594 + ), 551 595 552 596 TP_ARGS(rqst), 553 597 ··· 569 609 __get_str(addr), __entry->xid, 570 610 show_rqstp_flags(__entry->flags)) 571 611 ); 612 + #define DEFINE_SVC_RQST_EVENT(name) \ 613 + DEFINE_EVENT(svc_rqst_event, svc_##name, \ 614 + TP_PROTO( \ 615 + const struct svc_rqst *rqst \ 616 + ), \ 617 + TP_ARGS(rqst)) 572 618 573 - DEFINE_EVENT(svc_rqst_event, svc_defer, 574 - TP_PROTO(struct svc_rqst *rqst), 575 - TP_ARGS(rqst)); 576 - 577 - DEFINE_EVENT(svc_rqst_event, svc_drop, 578 - TP_PROTO(struct svc_rqst *rqst), 579 - TP_ARGS(rqst)); 619 + DEFINE_SVC_RQST_EVENT(defer); 620 + DEFINE_SVC_RQST_EVENT(drop); 580 621 581 622 DECLARE_EVENT_CLASS(svc_rqst_status, 582 623 ··· 764 803 ); 765 804 766 805 DECLARE_EVENT_CLASS(svc_deferred_event, 767 - TP_PROTO(struct svc_deferred_req *dr), 806 + TP_PROTO( 807 + const struct svc_deferred_req *dr 808 + ), 768 809 769 810 TP_ARGS(dr), 770 811 ··· 783 820 784 821 TP_printk("addr=%s xid=0x%08x", __get_str(addr), __entry->xid) 785 822 ); 823 + #define DEFINE_SVC_DEFERRED_EVENT(name) \ 824 + DEFINE_EVENT(svc_deferred_event, svc_##name##_deferred, \ 825 + TP_PROTO( \ 826 + const struct svc_deferred_req *dr \ 827 + ), \ 828 + TP_ARGS(dr)) 786 829 787 - DEFINE_EVENT(svc_deferred_event, svc_drop_deferred, 788 - TP_PROTO(struct svc_deferred_req *dr), 789 - TP_ARGS(dr)); 790 - DEFINE_EVENT(svc_deferred_event, svc_revisit_deferred, 791 - TP_PROTO(struct svc_deferred_req *dr), 792 - TP_ARGS(dr)); 830 + DEFINE_SVC_DEFERRED_EVENT(drop); 831 + DEFINE_SVC_DEFERRED_EVENT(revisit); 832 + 793 833 #endif /* _TRACE_SUNRPC_H */ 794 834 795 835 #include <trace/define_trace.h>
+57 -1
kernel/cred.c
··· 19 19 #include <linux/security.h> 20 20 #include <linux/binfmts.h> 21 21 #include <linux/cn_proc.h> 22 + #include <linux/uidgid.h> 22 23 23 24 #if 0 24 25 #define kdebug(FMT, ...) \ ··· 195 194 do { 196 195 cred = __task_cred((task)); 197 196 BUG_ON(!cred); 198 - } while (!atomic_inc_not_zero(&((struct cred *)cred)->usage)); 197 + } while (!get_cred_rcu(cred)); 199 198 200 199 rcu_read_unlock(); 201 200 return cred; 202 201 } 202 + EXPORT_SYMBOL(get_task_cred); 203 203 204 204 /* 205 205 * Allocate blank credentials, such that the credentials can be filled in at a ··· 565 563 put_cred(override); 566 564 } 567 565 EXPORT_SYMBOL(revert_creds); 566 + 567 + /** 568 + * cred_fscmp - Compare two credentials with respect to filesystem access. 569 + * @a: The first credential 570 + * @b: The second credential 571 + * 572 + * cred_cmp() will return zero if both credentials have the same 573 + * fsuid, fsgid, and supplementary groups. That is, if they will both 574 + * provide the same access to files based on mode/uid/gid. 575 + * If the credentials are different, then either -1 or 1 will 576 + * be returned depending on whether @a comes before or after @b 577 + * respectively in an arbitrary, but stable, ordering of credentials. 578 + * 579 + * Return: -1, 0, or 1 depending on comparison 580 + */ 581 + int cred_fscmp(const struct cred *a, const struct cred *b) 582 + { 583 + struct group_info *ga, *gb; 584 + int g; 585 + 586 + if (a == b) 587 + return 0; 588 + if (uid_lt(a->fsuid, b->fsuid)) 589 + return -1; 590 + if (uid_gt(a->fsuid, b->fsuid)) 591 + return 1; 592 + 593 + if (gid_lt(a->fsgid, b->fsgid)) 594 + return -1; 595 + if (gid_gt(a->fsgid, b->fsgid)) 596 + return 1; 597 + 598 + ga = a->group_info; 599 + gb = b->group_info; 600 + if (ga == gb) 601 + return 0; 602 + if (ga == NULL) 603 + return -1; 604 + if (gb == NULL) 605 + return 1; 606 + if (ga->ngroups < gb->ngroups) 607 + return -1; 608 + if (ga->ngroups > gb->ngroups) 609 + return 1; 610 + 611 + for (g = 0; g < ga->ngroups; g++) { 612 + if (gid_lt(ga->gid[g], gb->gid[g])) 613 + return -1; 614 + if (gid_gt(ga->gid[g], gb->gid[g])) 615 + return 1; 616 + } 617 + return 0; 618 + } 619 + EXPORT_SYMBOL(cred_fscmp); 568 620 569 621 /* 570 622 * initialise the credentials stuff
+1 -1
net/sunrpc/Makefile
··· 9 9 obj-$(CONFIG_SUNRPC_XPRT_RDMA) += xprtrdma/ 10 10 11 11 sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ 12 - auth.o auth_null.o auth_unix.o auth_generic.o \ 12 + auth.o auth_null.o auth_unix.o \ 13 13 svc.o svcsock.o svcauth.o svcauth_unix.o \ 14 14 addr.o rpcb_clnt.o timer.o xdr.o \ 15 15 sunrpc_syms.o cache.o rpc_pipe.o \
+58 -60
net/sunrpc/auth.c
··· 39 39 static LIST_HEAD(cred_unused); 40 40 static unsigned long number_cred_unused; 41 41 42 + static struct cred machine_cred = { 43 + .usage = ATOMIC_INIT(1), 44 + }; 45 + 46 + /* 47 + * Return the machine_cred pointer to be used whenever 48 + * the a generic machine credential is needed. 49 + */ 50 + const struct cred *rpc_machine_cred(void) 51 + { 52 + return &machine_cred; 53 + } 54 + EXPORT_SYMBOL_GPL(rpc_machine_cred); 55 + 42 56 #define MAX_HASHTABLE_BITS (14) 43 57 static int param_set_hashtbl_sz(const char *val, const struct kernel_param *kp) 44 58 { ··· 360 346 } 361 347 EXPORT_SYMBOL_GPL(rpcauth_init_credcache); 362 348 363 - /* 364 - * Setup a credential key lifetime timeout notification 365 - */ 366 - int 367 - rpcauth_key_timeout_notify(struct rpc_auth *auth, struct rpc_cred *cred) 368 - { 369 - if (!cred->cr_auth->au_ops->key_timeout) 370 - return 0; 371 - return cred->cr_auth->au_ops->key_timeout(auth, cred); 372 - } 373 - EXPORT_SYMBOL_GPL(rpcauth_key_timeout_notify); 374 - 375 - bool 376 - rpcauth_cred_key_to_expire(struct rpc_auth *auth, struct rpc_cred *cred) 377 - { 378 - if (auth->au_flags & RPCAUTH_AUTH_NO_CRKEY_TIMEOUT) 379 - return false; 380 - if (!cred->cr_ops->crkey_to_expire) 381 - return false; 382 - return cred->cr_ops->crkey_to_expire(cred); 383 - } 384 - EXPORT_SYMBOL_GPL(rpcauth_cred_key_to_expire); 385 - 386 349 char * 387 350 rpcauth_stringify_acceptor(struct rpc_cred *cred) 388 351 { ··· 578 587 hlist_for_each_entry_rcu(entry, &cache->hashtable[nr], cr_hash) { 579 588 if (!entry->cr_ops->crmatch(acred, entry, flags)) 580 589 continue; 581 - if (flags & RPCAUTH_LOOKUP_RCU) { 582 - if (test_bit(RPCAUTH_CRED_NEW, &entry->cr_flags) || 583 - refcount_read(&entry->cr_count) == 0) 584 - continue; 585 - cred = entry; 586 - break; 587 - } 588 590 cred = get_rpccred(entry); 589 591 if (cred) 590 592 break; ··· 586 602 587 603 if (cred != NULL) 588 604 goto found; 589 - 590 - if (flags & RPCAUTH_LOOKUP_RCU) 591 - return ERR_PTR(-ECHILD); 592 605 593 606 new = auth->au_ops->crcreate(auth, acred, flags, gfp); 594 607 if (IS_ERR(new)) { ··· 637 656 auth->au_ops->au_name); 638 657 639 658 memset(&acred, 0, sizeof(acred)); 640 - acred.uid = cred->fsuid; 641 - acred.gid = cred->fsgid; 642 - acred.group_info = cred->group_info; 659 + acred.cred = cred; 643 660 ret = auth->au_ops->lookup_cred(auth, &acred, flags); 644 661 return ret; 645 662 } ··· 651 672 INIT_LIST_HEAD(&cred->cr_lru); 652 673 refcount_set(&cred->cr_count, 1); 653 674 cred->cr_auth = auth; 675 + cred->cr_flags = 0; 654 676 cred->cr_ops = ops; 655 677 cred->cr_expire = jiffies; 656 - cred->cr_uid = acred->uid; 678 + cred->cr_cred = get_cred(acred->cred); 657 679 } 658 680 EXPORT_SYMBOL_GPL(rpcauth_init_cred); 659 - 660 - struct rpc_cred * 661 - rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred, int lookupflags) 662 - { 663 - dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid, 664 - cred->cr_auth->au_ops->au_name, cred); 665 - return get_rpccred(cred); 666 - } 667 - EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred); 668 681 669 682 static struct rpc_cred * 670 683 rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags) 671 684 { 672 685 struct rpc_auth *auth = task->tk_client->cl_auth; 673 686 struct auth_cred acred = { 674 - .uid = GLOBAL_ROOT_UID, 675 - .gid = GLOBAL_ROOT_GID, 687 + .cred = get_task_cred(&init_task), 676 688 }; 689 + struct rpc_cred *ret; 677 690 678 691 dprintk("RPC: %5u looking up %s cred\n", 692 + task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); 693 + ret = auth->au_ops->lookup_cred(auth, &acred, lookupflags); 694 + put_cred(acred.cred); 695 + return ret; 696 + } 697 + 698 + static struct rpc_cred * 699 + rpcauth_bind_machine_cred(struct rpc_task *task, int lookupflags) 700 + { 701 + struct rpc_auth *auth = task->tk_client->cl_auth; 702 + struct auth_cred acred = { 703 + .principal = task->tk_client->cl_principal, 704 + .cred = init_task.cred, 705 + }; 706 + 707 + if (!acred.principal) 708 + return NULL; 709 + dprintk("RPC: %5u looking up %s machine cred\n", 679 710 task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); 680 711 return auth->au_ops->lookup_cred(auth, &acred, lookupflags); 681 712 } ··· 701 712 } 702 713 703 714 static int 704 - rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) 715 + rpcauth_bindcred(struct rpc_task *task, const struct cred *cred, int flags) 705 716 { 706 717 struct rpc_rqst *req = task->tk_rqstp; 707 - struct rpc_cred *new; 718 + struct rpc_cred *new = NULL; 708 719 int lookupflags = 0; 720 + struct rpc_auth *auth = task->tk_client->cl_auth; 721 + struct auth_cred acred = { 722 + .cred = cred, 723 + }; 709 724 710 725 if (flags & RPC_TASK_ASYNC) 711 726 lookupflags |= RPCAUTH_LOOKUP_NEW; 712 - if (cred != NULL) 713 - new = cred->cr_ops->crbind(task, cred, lookupflags); 714 - else if (flags & RPC_TASK_ROOTCREDS) 727 + if (task->tk_op_cred) 728 + /* Task must use exactly this rpc_cred */ 729 + new = get_rpccred(task->tk_op_cred); 730 + else if (cred != NULL && cred != &machine_cred) 731 + new = auth->au_ops->lookup_cred(auth, &acred, lookupflags); 732 + else if (cred == &machine_cred) 733 + new = rpcauth_bind_machine_cred(task, lookupflags); 734 + 735 + /* If machine cred couldn't be bound, try a root cred */ 736 + if (new) 737 + ; 738 + else if (cred == &machine_cred || (flags & RPC_TASK_ROOTCREDS)) 715 739 new = rpcauth_bind_root_cred(task, lookupflags); 740 + else if (flags & RPC_TASK_NULLCREDS) 741 + new = authnull_ops.lookup_cred(NULL, NULL, 0); 716 742 else 717 743 new = rpcauth_bind_new_cred(task, lookupflags); 718 744 if (IS_ERR(new)) ··· 905 901 err = rpc_init_authunix(); 906 902 if (err < 0) 907 903 goto out1; 908 - err = rpc_init_generic_auth(); 909 - if (err < 0) 910 - goto out2; 911 904 err = register_shrinker(&rpc_cred_shrinker); 912 905 if (err < 0) 913 - goto out3; 906 + goto out2; 914 907 return 0; 915 - out3: 916 - rpc_destroy_generic_auth(); 917 908 out2: 918 909 rpc_destroy_authunix(); 919 910 out1: ··· 918 919 void rpcauth_remove_module(void) 919 920 { 920 921 rpc_destroy_authunix(); 921 - rpc_destroy_generic_auth(); 922 922 unregister_shrinker(&rpc_cred_shrinker); 923 923 }
-293
net/sunrpc/auth_generic.c
··· 1 - /* 2 - * Generic RPC credential 3 - * 4 - * Copyright (C) 2008, Trond Myklebust <Trond.Myklebust@netapp.com> 5 - */ 6 - 7 - #include <linux/err.h> 8 - #include <linux/slab.h> 9 - #include <linux/types.h> 10 - #include <linux/module.h> 11 - #include <linux/sched.h> 12 - #include <linux/sunrpc/auth.h> 13 - #include <linux/sunrpc/clnt.h> 14 - #include <linux/sunrpc/debug.h> 15 - #include <linux/sunrpc/sched.h> 16 - 17 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 18 - # define RPCDBG_FACILITY RPCDBG_AUTH 19 - #endif 20 - 21 - #define RPC_MACHINE_CRED_USERID GLOBAL_ROOT_UID 22 - #define RPC_MACHINE_CRED_GROUPID GLOBAL_ROOT_GID 23 - 24 - struct generic_cred { 25 - struct rpc_cred gc_base; 26 - struct auth_cred acred; 27 - }; 28 - 29 - static struct rpc_auth generic_auth; 30 - static const struct rpc_credops generic_credops; 31 - 32 - /* 33 - * Public call interface 34 - */ 35 - struct rpc_cred *rpc_lookup_cred(void) 36 - { 37 - return rpcauth_lookupcred(&generic_auth, 0); 38 - } 39 - EXPORT_SYMBOL_GPL(rpc_lookup_cred); 40 - 41 - struct rpc_cred * 42 - rpc_lookup_generic_cred(struct auth_cred *acred, int flags, gfp_t gfp) 43 - { 44 - return rpcauth_lookup_credcache(&generic_auth, acred, flags, gfp); 45 - } 46 - EXPORT_SYMBOL_GPL(rpc_lookup_generic_cred); 47 - 48 - struct rpc_cred *rpc_lookup_cred_nonblock(void) 49 - { 50 - return rpcauth_lookupcred(&generic_auth, RPCAUTH_LOOKUP_RCU); 51 - } 52 - EXPORT_SYMBOL_GPL(rpc_lookup_cred_nonblock); 53 - 54 - /* 55 - * Public call interface for looking up machine creds. 56 - */ 57 - struct rpc_cred *rpc_lookup_machine_cred(const char *service_name) 58 - { 59 - struct auth_cred acred = { 60 - .uid = RPC_MACHINE_CRED_USERID, 61 - .gid = RPC_MACHINE_CRED_GROUPID, 62 - .principal = service_name, 63 - .machine_cred = 1, 64 - }; 65 - 66 - dprintk("RPC: looking up machine cred for service %s\n", 67 - service_name); 68 - return generic_auth.au_ops->lookup_cred(&generic_auth, &acred, 0); 69 - } 70 - EXPORT_SYMBOL_GPL(rpc_lookup_machine_cred); 71 - 72 - static struct rpc_cred *generic_bind_cred(struct rpc_task *task, 73 - struct rpc_cred *cred, int lookupflags) 74 - { 75 - struct rpc_auth *auth = task->tk_client->cl_auth; 76 - struct auth_cred *acred = &container_of(cred, struct generic_cred, gc_base)->acred; 77 - 78 - return auth->au_ops->lookup_cred(auth, acred, lookupflags); 79 - } 80 - 81 - static int 82 - generic_hash_cred(struct auth_cred *acred, unsigned int hashbits) 83 - { 84 - return hash_64(from_kgid(&init_user_ns, acred->gid) | 85 - ((u64)from_kuid(&init_user_ns, acred->uid) << 86 - (sizeof(gid_t) * 8)), hashbits); 87 - } 88 - 89 - /* 90 - * Lookup generic creds for current process 91 - */ 92 - static struct rpc_cred * 93 - generic_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) 94 - { 95 - return rpcauth_lookup_credcache(&generic_auth, acred, flags, GFP_KERNEL); 96 - } 97 - 98 - static struct rpc_cred * 99 - generic_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t gfp) 100 - { 101 - struct generic_cred *gcred; 102 - 103 - gcred = kmalloc(sizeof(*gcred), gfp); 104 - if (gcred == NULL) 105 - return ERR_PTR(-ENOMEM); 106 - 107 - rpcauth_init_cred(&gcred->gc_base, acred, &generic_auth, &generic_credops); 108 - gcred->gc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; 109 - 110 - gcred->acred.uid = acred->uid; 111 - gcred->acred.gid = acred->gid; 112 - gcred->acred.group_info = acred->group_info; 113 - gcred->acred.ac_flags = 0; 114 - if (gcred->acred.group_info != NULL) 115 - get_group_info(gcred->acred.group_info); 116 - gcred->acred.machine_cred = acred->machine_cred; 117 - gcred->acred.principal = acred->principal; 118 - 119 - dprintk("RPC: allocated %s cred %p for uid %d gid %d\n", 120 - gcred->acred.machine_cred ? "machine" : "generic", 121 - gcred, 122 - from_kuid(&init_user_ns, acred->uid), 123 - from_kgid(&init_user_ns, acred->gid)); 124 - return &gcred->gc_base; 125 - } 126 - 127 - static void 128 - generic_free_cred(struct rpc_cred *cred) 129 - { 130 - struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 131 - 132 - dprintk("RPC: generic_free_cred %p\n", gcred); 133 - if (gcred->acred.group_info != NULL) 134 - put_group_info(gcred->acred.group_info); 135 - kfree(gcred); 136 - } 137 - 138 - static void 139 - generic_free_cred_callback(struct rcu_head *head) 140 - { 141 - struct rpc_cred *cred = container_of(head, struct rpc_cred, cr_rcu); 142 - generic_free_cred(cred); 143 - } 144 - 145 - static void 146 - generic_destroy_cred(struct rpc_cred *cred) 147 - { 148 - call_rcu(&cred->cr_rcu, generic_free_cred_callback); 149 - } 150 - 151 - static int 152 - machine_cred_match(struct auth_cred *acred, struct generic_cred *gcred, int flags) 153 - { 154 - if (!gcred->acred.machine_cred || 155 - gcred->acred.principal != acred->principal || 156 - !uid_eq(gcred->acred.uid, acred->uid) || 157 - !gid_eq(gcred->acred.gid, acred->gid)) 158 - return 0; 159 - return 1; 160 - } 161 - 162 - /* 163 - * Match credentials against current process creds. 164 - */ 165 - static int 166 - generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) 167 - { 168 - struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 169 - int i; 170 - 171 - if (acred->machine_cred) 172 - return machine_cred_match(acred, gcred, flags); 173 - 174 - if (!uid_eq(gcred->acred.uid, acred->uid) || 175 - !gid_eq(gcred->acred.gid, acred->gid) || 176 - gcred->acred.machine_cred != 0) 177 - goto out_nomatch; 178 - 179 - /* Optimisation in the case where pointers are identical... */ 180 - if (gcred->acred.group_info == acred->group_info) 181 - goto out_match; 182 - 183 - /* Slow path... */ 184 - if (gcred->acred.group_info->ngroups != acred->group_info->ngroups) 185 - goto out_nomatch; 186 - for (i = 0; i < gcred->acred.group_info->ngroups; i++) { 187 - if (!gid_eq(gcred->acred.group_info->gid[i], 188 - acred->group_info->gid[i])) 189 - goto out_nomatch; 190 - } 191 - out_match: 192 - return 1; 193 - out_nomatch: 194 - return 0; 195 - } 196 - 197 - int __init rpc_init_generic_auth(void) 198 - { 199 - return rpcauth_init_credcache(&generic_auth); 200 - } 201 - 202 - void rpc_destroy_generic_auth(void) 203 - { 204 - rpcauth_destroy_credcache(&generic_auth); 205 - } 206 - 207 - /* 208 - * Test the the current time (now) against the underlying credential key expiry 209 - * minus a timeout and setup notification. 210 - * 211 - * The normal case: 212 - * If 'now' is before the key expiry minus RPC_KEY_EXPIRE_TIMEO, set 213 - * the RPC_CRED_NOTIFY_TIMEOUT flag to setup the underlying credential 214 - * rpc_credops crmatch routine to notify this generic cred when it's key 215 - * expiration is within RPC_KEY_EXPIRE_TIMEO, and return 0. 216 - * 217 - * The error case: 218 - * If the underlying cred lookup fails, return -EACCES. 219 - * 220 - * The 'almost' error case: 221 - * If 'now' is within key expiry minus RPC_KEY_EXPIRE_TIMEO, but not within 222 - * key expiry minus RPC_KEY_EXPIRE_FAIL, set the RPC_CRED_EXPIRE_SOON bit 223 - * on the acred ac_flags and return 0. 224 - */ 225 - static int 226 - generic_key_timeout(struct rpc_auth *auth, struct rpc_cred *cred) 227 - { 228 - struct auth_cred *acred = &container_of(cred, struct generic_cred, 229 - gc_base)->acred; 230 - struct rpc_cred *tcred; 231 - int ret = 0; 232 - 233 - 234 - /* Fast track for non crkey_timeout (no key) underlying credentials */ 235 - if (auth->au_flags & RPCAUTH_AUTH_NO_CRKEY_TIMEOUT) 236 - return 0; 237 - 238 - /* Fast track for the normal case */ 239 - if (test_bit(RPC_CRED_NOTIFY_TIMEOUT, &acred->ac_flags)) 240 - return 0; 241 - 242 - /* lookup_cred either returns a valid referenced rpc_cred, or PTR_ERR */ 243 - tcred = auth->au_ops->lookup_cred(auth, acred, 0); 244 - if (IS_ERR(tcred)) 245 - return -EACCES; 246 - 247 - /* Test for the almost error case */ 248 - ret = tcred->cr_ops->crkey_timeout(tcred); 249 - if (ret != 0) { 250 - set_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags); 251 - ret = 0; 252 - } else { 253 - /* In case underlying cred key has been reset */ 254 - if (test_and_clear_bit(RPC_CRED_KEY_EXPIRE_SOON, 255 - &acred->ac_flags)) 256 - dprintk("RPC: UID %d Credential key reset\n", 257 - from_kuid(&init_user_ns, tcred->cr_uid)); 258 - /* set up fasttrack for the normal case */ 259 - set_bit(RPC_CRED_NOTIFY_TIMEOUT, &acred->ac_flags); 260 - } 261 - 262 - put_rpccred(tcred); 263 - return ret; 264 - } 265 - 266 - static const struct rpc_authops generic_auth_ops = { 267 - .owner = THIS_MODULE, 268 - .au_name = "Generic", 269 - .hash_cred = generic_hash_cred, 270 - .lookup_cred = generic_lookup_cred, 271 - .crcreate = generic_create_cred, 272 - .key_timeout = generic_key_timeout, 273 - }; 274 - 275 - static struct rpc_auth generic_auth = { 276 - .au_ops = &generic_auth_ops, 277 - .au_count = REFCOUNT_INIT(1), 278 - }; 279 - 280 - static bool generic_key_to_expire(struct rpc_cred *cred) 281 - { 282 - struct auth_cred *acred = &container_of(cred, struct generic_cred, 283 - gc_base)->acred; 284 - return test_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags); 285 - } 286 - 287 - static const struct rpc_credops generic_credops = { 288 - .cr_name = "Generic cred", 289 - .crdestroy = generic_destroy_cred, 290 - .crbind = generic_bind_cred, 291 - .crmatch = generic_match, 292 - .crkey_to_expire = generic_key_to_expire, 293 - };
+15 -32
net/sunrpc/auth_gss/auth_gss.c
··· 565 565 struct gss_cred *gss_cred = container_of(cred, 566 566 struct gss_cred, gc_base); 567 567 struct gss_upcall_msg *gss_new, *gss_msg; 568 - kuid_t uid = cred->cr_uid; 568 + kuid_t uid = cred->cr_cred->fsuid; 569 569 570 570 gss_new = gss_alloc_msg(gss_auth, uid, gss_cred->gc_principal); 571 571 if (IS_ERR(gss_new)) ··· 604 604 int err = 0; 605 605 606 606 dprintk("RPC: %5u %s for uid %u\n", 607 - task->tk_pid, __func__, from_kuid(&init_user_ns, cred->cr_uid)); 607 + task->tk_pid, __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid)); 608 608 gss_msg = gss_setup_upcall(gss_auth, cred); 609 609 if (PTR_ERR(gss_msg) == -EAGAIN) { 610 610 /* XXX: warning on the first, under the assumption we ··· 637 637 out: 638 638 dprintk("RPC: %5u %s for uid %u result %d\n", 639 639 task->tk_pid, __func__, 640 - from_kuid(&init_user_ns, cred->cr_uid), err); 640 + from_kuid(&init_user_ns, cred->cr_cred->fsuid), err); 641 641 return err; 642 642 } 643 643 ··· 653 653 int err; 654 654 655 655 dprintk("RPC: %s for uid %u\n", 656 - __func__, from_kuid(&init_user_ns, cred->cr_uid)); 656 + __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid)); 657 657 retry: 658 658 err = 0; 659 659 /* if gssd is down, just skip upcalling altogether */ ··· 701 701 gss_release_msg(gss_msg); 702 702 out: 703 703 dprintk("RPC: %s for uid %u result %d\n", 704 - __func__, from_kuid(&init_user_ns, cred->cr_uid), err); 704 + __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid), err); 705 705 return err; 706 706 } 707 707 ··· 1248 1248 new = kzalloc(sizeof(*gss_cred), GFP_NOIO); 1249 1249 if (new) { 1250 1250 struct auth_cred acred = { 1251 - .uid = gss_cred->gc_base.cr_uid, 1251 + .cred = gss_cred->gc_base.cr_cred, 1252 1252 }; 1253 1253 struct gss_cl_ctx *ctx = 1254 1254 rcu_dereference_protected(gss_cred->gc_ctx, 1); ··· 1343 1343 struct gss_cl_ctx *ctx = rcu_dereference_protected(gss_cred->gc_ctx, 1); 1344 1344 1345 1345 RCU_INIT_POINTER(gss_cred->gc_ctx, NULL); 1346 + put_cred(cred->cr_cred); 1346 1347 call_rcu(&cred->cr_rcu, gss_free_cred_callback); 1347 1348 if (ctx) 1348 1349 gss_put_ctx(ctx); ··· 1362 1361 static int 1363 1362 gss_hash_cred(struct auth_cred *acred, unsigned int hashbits) 1364 1363 { 1365 - return hash_64(from_kuid(&init_user_ns, acred->uid), hashbits); 1364 + return hash_64(from_kuid(&init_user_ns, acred->cred->fsuid), hashbits); 1366 1365 } 1367 1366 1368 1367 /* ··· 1382 1381 int err = -ENOMEM; 1383 1382 1384 1383 dprintk("RPC: %s for uid %d, flavor %d\n", 1385 - __func__, from_kuid(&init_user_ns, acred->uid), 1384 + __func__, from_kuid(&init_user_ns, acred->cred->fsuid), 1386 1385 auth->au_flavor); 1387 1386 1388 1387 if (!(cred = kzalloc(sizeof(*cred), gfp))) ··· 1395 1394 */ 1396 1395 cred->gc_base.cr_flags = 1UL << RPCAUTH_CRED_NEW; 1397 1396 cred->gc_service = gss_auth->service; 1398 - cred->gc_principal = NULL; 1399 - if (acred->machine_cred) 1400 - cred->gc_principal = acred->principal; 1397 + cred->gc_principal = acred->principal; 1401 1398 kref_get(&gss_auth->kref); 1402 1399 return &cred->gc_base; 1403 1400 ··· 1517 1518 if (gss_cred->gc_principal == NULL) 1518 1519 return 0; 1519 1520 ret = strcmp(acred->principal, gss_cred->gc_principal) == 0; 1520 - goto check_expire; 1521 - } 1522 - if (gss_cred->gc_principal != NULL) 1523 - return 0; 1524 - ret = uid_eq(rc->cr_uid, acred->uid); 1525 - 1526 - check_expire: 1527 - if (ret == 0) 1528 - return ret; 1529 - 1530 - /* Notify acred users of GSS context expiration timeout */ 1531 - if (test_bit(RPC_CRED_NOTIFY_TIMEOUT, &acred->ac_flags) && 1532 - (gss_key_timeout(rc) != 0)) { 1533 - /* test will now be done from generic cred */ 1534 - test_and_clear_bit(RPC_CRED_NOTIFY_TIMEOUT, &acred->ac_flags); 1535 - /* tell NFS layer that key will expire soon */ 1536 - set_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags); 1521 + } else { 1522 + if (gss_cred->gc_principal != NULL) 1523 + return 0; 1524 + ret = uid_eq(rc->cr_cred->fsuid, acred->cred->fsuid); 1537 1525 } 1538 1526 return ret; 1539 1527 } ··· 1593 1607 gc_base); 1594 1608 struct rpc_auth *auth = oldcred->cr_auth; 1595 1609 struct auth_cred acred = { 1596 - .uid = oldcred->cr_uid, 1610 + .cred = oldcred->cr_cred, 1597 1611 .principal = gss_cred->gc_principal, 1598 - .machine_cred = (gss_cred->gc_principal != NULL ? 1 : 0), 1599 1612 }; 1600 1613 struct rpc_cred *new; 1601 1614 ··· 2095 2110 .cr_name = "AUTH_GSS", 2096 2111 .crdestroy = gss_destroy_cred, 2097 2112 .cr_init = gss_cred_init, 2098 - .crbind = rpcauth_generic_bind_cred, 2099 2113 .crmatch = gss_match, 2100 2114 .crmarshal = gss_marshal, 2101 2115 .crrefresh = gss_refresh, ··· 2109 2125 static const struct rpc_credops gss_nullops = { 2110 2126 .cr_name = "AUTH_GSS", 2111 2127 .crdestroy = gss_destroy_nullcred, 2112 - .crbind = rpcauth_generic_bind_cred, 2113 2128 .crmatch = gss_match, 2114 2129 .crmarshal = gss_marshal, 2115 2130 .crrefresh = gss_refresh_null,
+1 -1
net/sunrpc/auth_gss/gss_mech_switch.c
··· 244 244 245 245 /** 246 246 * gss_mech_list_pseudoflavors - Discover registered GSS pseudoflavors 247 - * @array: array to fill in 247 + * @array_ptr: array to fill in 248 248 * @size: size of "array" 249 249 * 250 250 * Returns the number of array items filled in, or a negative errno.
-4
net/sunrpc/auth_null.c
··· 36 36 static struct rpc_cred * 37 37 nul_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) 38 38 { 39 - if (flags & RPCAUTH_LOOKUP_RCU) 40 - return &null_cred; 41 39 return get_rpccred(&null_cred); 42 40 } 43 41 ··· 114 116 struct rpc_auth null_auth = { 115 117 .au_cslack = NUL_CALLSLACK, 116 118 .au_rslack = NUL_REPLYSLACK, 117 - .au_flags = RPCAUTH_AUTH_NO_CRKEY_TIMEOUT, 118 119 .au_ops = &authnull_ops, 119 120 .au_flavor = RPC_AUTH_NULL, 120 121 .au_count = REFCOUNT_INIT(1), ··· 123 126 const struct rpc_credops null_credops = { 124 127 .cr_name = "AUTH_NULL", 125 128 .crdestroy = nul_destroy_cred, 126 - .crbind = rpcauth_generic_bind_cred, 127 129 .crmatch = nul_match, 128 130 .crmarshal = nul_marshal, 129 131 .crrefresh = nul_refresh,
+36 -76
net/sunrpc/auth_unix.c
··· 11 11 #include <linux/types.h> 12 12 #include <linux/sched.h> 13 13 #include <linux/module.h> 14 + #include <linux/mempool.h> 14 15 #include <linux/sunrpc/clnt.h> 15 16 #include <linux/sunrpc/auth.h> 16 17 #include <linux/user_namespace.h> 17 18 18 - struct unx_cred { 19 - struct rpc_cred uc_base; 20 - kgid_t uc_gid; 21 - kgid_t uc_gids[UNX_NGROUPS]; 22 - }; 23 - #define uc_uid uc_base.cr_uid 24 19 25 20 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 26 21 # define RPCDBG_FACILITY RPCDBG_AUTH ··· 23 28 24 29 static struct rpc_auth unix_auth; 25 30 static const struct rpc_credops unix_credops; 31 + static mempool_t *unix_pool; 26 32 27 33 static struct rpc_auth * 28 34 unx_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) ··· 38 42 unx_destroy(struct rpc_auth *auth) 39 43 { 40 44 dprintk("RPC: destroying UNIX authenticator %p\n", auth); 41 - rpcauth_clear_credcache(auth->au_credcache); 42 - } 43 - 44 - static int 45 - unx_hash_cred(struct auth_cred *acred, unsigned int hashbits) 46 - { 47 - return hash_64(from_kgid(&init_user_ns, acred->gid) | 48 - ((u64)from_kuid(&init_user_ns, acred->uid) << 49 - (sizeof(gid_t) * 8)), hashbits); 50 45 } 51 46 52 47 /* ··· 46 59 static struct rpc_cred * 47 60 unx_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) 48 61 { 49 - return rpcauth_lookup_credcache(auth, acred, flags, GFP_NOFS); 50 - } 51 - 52 - static struct rpc_cred * 53 - unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t gfp) 54 - { 55 - struct unx_cred *cred; 56 - unsigned int groups = 0; 57 - unsigned int i; 62 + struct rpc_cred *ret = mempool_alloc(unix_pool, GFP_NOFS); 58 63 59 64 dprintk("RPC: allocating UNIX cred for uid %d gid %d\n", 60 - from_kuid(&init_user_ns, acred->uid), 61 - from_kgid(&init_user_ns, acred->gid)); 65 + from_kuid(&init_user_ns, acred->cred->fsuid), 66 + from_kgid(&init_user_ns, acred->cred->fsgid)); 62 67 63 - if (!(cred = kmalloc(sizeof(*cred), gfp))) 64 - return ERR_PTR(-ENOMEM); 65 - 66 - rpcauth_init_cred(&cred->uc_base, acred, auth, &unix_credops); 67 - cred->uc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; 68 - 69 - if (acred->group_info != NULL) 70 - groups = acred->group_info->ngroups; 71 - if (groups > UNX_NGROUPS) 72 - groups = UNX_NGROUPS; 73 - 74 - cred->uc_gid = acred->gid; 75 - for (i = 0; i < groups; i++) 76 - cred->uc_gids[i] = acred->group_info->gid[i]; 77 - if (i < UNX_NGROUPS) 78 - cred->uc_gids[i] = INVALID_GID; 79 - 80 - return &cred->uc_base; 81 - } 82 - 83 - static void 84 - unx_free_cred(struct unx_cred *unx_cred) 85 - { 86 - dprintk("RPC: unx_free_cred %p\n", unx_cred); 87 - kfree(unx_cred); 68 + rpcauth_init_cred(ret, acred, auth, &unix_credops); 69 + ret->cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; 70 + return ret; 88 71 } 89 72 90 73 static void 91 74 unx_free_cred_callback(struct rcu_head *head) 92 75 { 93 - struct unx_cred *unx_cred = container_of(head, struct unx_cred, uc_base.cr_rcu); 94 - unx_free_cred(unx_cred); 76 + struct rpc_cred *rpc_cred = container_of(head, struct rpc_cred, cr_rcu); 77 + dprintk("RPC: unx_free_cred %p\n", rpc_cred); 78 + put_cred(rpc_cred->cr_cred); 79 + mempool_free(rpc_cred, unix_pool); 95 80 } 96 81 97 82 static void ··· 73 114 } 74 115 75 116 /* 76 - * Match credentials against current process creds. 77 - * The root_override argument takes care of cases where the caller may 78 - * request root creds (e.g. for NFS swapping). 117 + * Match credentials against current the auth_cred. 79 118 */ 80 119 static int 81 - unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) 120 + unx_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) 82 121 { 83 - struct unx_cred *cred = container_of(rcred, struct unx_cred, uc_base); 84 122 unsigned int groups = 0; 85 123 unsigned int i; 86 124 125 + if (cred->cr_cred == acred->cred) 126 + return 1; 87 127 88 - if (!uid_eq(cred->uc_uid, acred->uid) || !gid_eq(cred->uc_gid, acred->gid)) 128 + if (!uid_eq(cred->cr_cred->fsuid, acred->cred->fsuid) || !gid_eq(cred->cr_cred->fsgid, acred->cred->fsgid)) 89 129 return 0; 90 130 91 - if (acred->group_info != NULL) 92 - groups = acred->group_info->ngroups; 131 + if (acred->cred && acred->cred->group_info != NULL) 132 + groups = acred->cred->group_info->ngroups; 93 133 if (groups > UNX_NGROUPS) 94 134 groups = UNX_NGROUPS; 95 - for (i = 0; i < groups ; i++) 96 - if (!gid_eq(cred->uc_gids[i], acred->group_info->gid[i])) 97 - return 0; 98 - if (groups < UNX_NGROUPS && gid_valid(cred->uc_gids[groups])) 135 + if (cred->cr_cred->group_info == NULL) 136 + return groups == 0; 137 + if (groups != cred->cr_cred->group_info->ngroups) 99 138 return 0; 139 + 140 + for (i = 0; i < groups ; i++) 141 + if (!gid_eq(cred->cr_cred->group_info->gid[i], acred->cred->group_info->gid[i])) 142 + return 0; 100 143 return 1; 101 144 } 102 145 ··· 110 149 unx_marshal(struct rpc_task *task, __be32 *p) 111 150 { 112 151 struct rpc_clnt *clnt = task->tk_client; 113 - struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base); 152 + struct rpc_cred *cred = task->tk_rqstp->rq_cred; 114 153 __be32 *base, *hold; 115 154 int i; 155 + struct group_info *gi = cred->cr_cred->group_info; 116 156 117 157 *p++ = htonl(RPC_AUTH_UNIX); 118 158 base = p++; ··· 124 162 */ 125 163 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); 126 164 127 - *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid)); 128 - *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid)); 165 + *p++ = htonl((u32) from_kuid(&init_user_ns, cred->cr_cred->fsuid)); 166 + *p++ = htonl((u32) from_kgid(&init_user_ns, cred->cr_cred->fsgid)); 129 167 hold = p++; 130 - for (i = 0; i < UNX_NGROUPS && gid_valid(cred->uc_gids[i]); i++) 131 - *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i])); 168 + if (gi) 169 + for (i = 0; i < UNX_NGROUPS && i < gi->ngroups; i++) 170 + *p++ = htonl((u32) from_kgid(&init_user_ns, gi->gid[i])); 132 171 *hold = htonl(p - hold - 1); /* gid array length */ 133 172 *base = htonl((p - base - 1) << 2); /* cred length */ 134 173 ··· 176 213 177 214 int __init rpc_init_authunix(void) 178 215 { 179 - return rpcauth_init_credcache(&unix_auth); 216 + unix_pool = mempool_create_kmalloc_pool(16, sizeof(struct rpc_cred)); 217 + return unix_pool ? 0 : -ENOMEM; 180 218 } 181 219 182 220 void rpc_destroy_authunix(void) 183 221 { 184 - rpcauth_destroy_credcache(&unix_auth); 222 + mempool_destroy(unix_pool); 185 223 } 186 224 187 225 const struct rpc_authops authunix_ops = { ··· 191 227 .au_name = "UNIX", 192 228 .create = unx_create, 193 229 .destroy = unx_destroy, 194 - .hash_cred = unx_hash_cred, 195 230 .lookup_cred = unx_lookup_cred, 196 - .crcreate = unx_create_cred, 197 231 }; 198 232 199 233 static 200 234 struct rpc_auth unix_auth = { 201 235 .au_cslack = UNX_CALLSLACK, 202 236 .au_rslack = NUL_REPLYSLACK, 203 - .au_flags = RPCAUTH_AUTH_NO_CRKEY_TIMEOUT, 204 237 .au_ops = &authunix_ops, 205 238 .au_flavor = RPC_AUTH_UNIX, 206 239 .au_count = REFCOUNT_INIT(1), ··· 207 246 const struct rpc_credops unix_credops = { 208 247 .cr_name = "AUTH_UNIX", 209 248 .crdestroy = unx_destroy_cred, 210 - .crbind = rpcauth_generic_bind_cred, 211 249 .crmatch = unx_match, 212 250 .crmarshal = unx_marshal, 213 251 .crrefresh = unx_refresh,
+1 -1
net/sunrpc/backchannel_rqst.c
··· 197 197 /** 198 198 * xprt_destroy_backchannel - Destroys the backchannel preallocated structures. 199 199 * @xprt: the transport holding the preallocated strucures 200 - * @max_reqs the maximum number of preallocated structures to destroy 200 + * @max_reqs: the maximum number of preallocated structures to destroy 201 201 * 202 202 * Since these structures may have been allocated by multiple calls 203 203 * to xprt_setup_backchannel, we only destroy up to the maximum number
+13 -16
net/sunrpc/clnt.c
··· 627 627 new->cl_noretranstimeo = clnt->cl_noretranstimeo; 628 628 new->cl_discrtry = clnt->cl_discrtry; 629 629 new->cl_chatty = clnt->cl_chatty; 630 + new->cl_principal = clnt->cl_principal; 630 631 return new; 631 632 632 633 out_err: ··· 1030 1029 task->tk_msg.rpc_argp = msg->rpc_argp; 1031 1030 task->tk_msg.rpc_resp = msg->rpc_resp; 1032 1031 if (msg->rpc_cred != NULL) 1033 - task->tk_msg.rpc_cred = get_rpccred(msg->rpc_cred); 1032 + task->tk_msg.rpc_cred = get_cred(msg->rpc_cred); 1034 1033 } 1035 1034 } 1036 1035 ··· 2522 2521 .rpc_proc = &rpcproc_null, 2523 2522 }; 2524 2523 int err; 2525 - msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); 2526 - err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN); 2527 - put_rpccred(msg.rpc_cred); 2524 + err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN | 2525 + RPC_TASK_NULLCREDS); 2528 2526 return err; 2529 2527 } 2530 2528 ··· 2534 2534 { 2535 2535 struct rpc_message msg = { 2536 2536 .rpc_proc = &rpcproc_null, 2537 - .rpc_cred = cred, 2538 2537 }; 2539 2538 struct rpc_task_setup task_setup_data = { 2540 2539 .rpc_client = clnt, 2541 2540 .rpc_xprt = xprt, 2542 2541 .rpc_message = &msg, 2542 + .rpc_op_cred = cred, 2543 2543 .callback_ops = (ops != NULL) ? ops : &rpc_default_ops, 2544 2544 .callback_data = data, 2545 - .flags = flags, 2545 + .flags = flags | RPC_TASK_NULLCREDS, 2546 2546 }; 2547 2547 2548 2548 return rpc_run_task(&task_setup_data); ··· 2593 2593 void *dummy) 2594 2594 { 2595 2595 struct rpc_cb_add_xprt_calldata *data; 2596 - struct rpc_cred *cred; 2597 2596 struct rpc_task *task; 2598 2597 2599 2598 data = kmalloc(sizeof(*data), GFP_NOFS); ··· 2601 2602 data->xps = xprt_switch_get(xps); 2602 2603 data->xprt = xprt_get(xprt); 2603 2604 2604 - cred = authnull_ops.lookup_cred(NULL, NULL, 0); 2605 - task = rpc_call_null_helper(clnt, xprt, cred, 2606 - RPC_TASK_SOFT|RPC_TASK_SOFTCONN|RPC_TASK_ASYNC, 2605 + task = rpc_call_null_helper(clnt, xprt, NULL, 2606 + RPC_TASK_SOFT|RPC_TASK_SOFTCONN|RPC_TASK_ASYNC|RPC_TASK_NULLCREDS, 2607 2607 &rpc_cb_add_xprt_call_ops, data); 2608 - put_rpccred(cred); 2609 2608 if (IS_ERR(task)) 2610 2609 return PTR_ERR(task); 2611 2610 rpc_put_task(task); ··· 2634 2637 struct rpc_xprt *xprt, 2635 2638 void *data) 2636 2639 { 2637 - struct rpc_cred *cred; 2638 2640 struct rpc_task *task; 2639 2641 struct rpc_add_xprt_test *xtest = (struct rpc_add_xprt_test *)data; 2640 2642 int status = -EADDRINUSE; ··· 2645 2649 goto out_err; 2646 2650 2647 2651 /* Test the connection */ 2648 - cred = authnull_ops.lookup_cred(NULL, NULL, 0); 2649 - task = rpc_call_null_helper(clnt, xprt, cred, 2650 - RPC_TASK_SOFT | RPC_TASK_SOFTCONN, 2652 + task = rpc_call_null_helper(clnt, xprt, NULL, 2653 + RPC_TASK_SOFT | RPC_TASK_SOFTCONN | RPC_TASK_NULLCREDS, 2651 2654 NULL, NULL); 2652 - put_rpccred(cred); 2653 2655 if (IS_ERR(task)) { 2654 2656 status = PTR_ERR(task); 2655 2657 goto out_err; ··· 2660 2666 2661 2667 /* rpc_xprt_switch and rpc_xprt are deferrenced by add_xprt_test() */ 2662 2668 xtest->add_xprt_test(clnt, xprt, xtest->data); 2669 + 2670 + xprt_put(xprt); 2671 + xprt_switch_put(xps); 2663 2672 2664 2673 /* so that rpc_clnt_add_xprt does not call rpc_xprt_switch_add_xprt */ 2665 2674 return 1;
+3 -16
net/sunrpc/rpc_pipe.c
··· 1266 1266 * that this file will be there and have a certain format. 1267 1267 */ 1268 1268 static int 1269 - rpc_show_dummy_info(struct seq_file *m, void *v) 1269 + rpc_dummy_info_show(struct seq_file *m, void *v) 1270 1270 { 1271 1271 seq_printf(m, "RPC server: %s\n", utsname()->nodename); 1272 1272 seq_printf(m, "service: foo (1) version 0\n"); ··· 1275 1275 seq_printf(m, "port: 0\n"); 1276 1276 return 0; 1277 1277 } 1278 - 1279 - static int 1280 - rpc_dummy_info_open(struct inode *inode, struct file *file) 1281 - { 1282 - return single_open(file, rpc_show_dummy_info, NULL); 1283 - } 1284 - 1285 - static const struct file_operations rpc_dummy_info_operations = { 1286 - .owner = THIS_MODULE, 1287 - .open = rpc_dummy_info_open, 1288 - .read = seq_read, 1289 - .llseek = seq_lseek, 1290 - .release = single_release, 1291 - }; 1278 + DEFINE_SHOW_ATTRIBUTE(rpc_dummy_info); 1292 1279 1293 1280 static const struct rpc_filelist gssd_dummy_info_file[] = { 1294 1281 [0] = { 1295 1282 .name = "info", 1296 - .i_fop = &rpc_dummy_info_operations, 1283 + .i_fop = &rpc_dummy_info_fops, 1297 1284 .mode = S_IFREG | 0400, 1298 1285 }, 1299 1286 };
+10 -2
net/sunrpc/rpcb_clnt.c
··· 752 752 goto bailout_nofree; 753 753 } 754 754 755 - map = kzalloc(sizeof(struct rpcbind_args), GFP_ATOMIC); 755 + map = kzalloc(sizeof(struct rpcbind_args), GFP_NOFS); 756 756 if (!map) { 757 757 status = -ENOMEM; 758 758 dprintk("RPC: %5u %s: no memory available\n", ··· 770 770 case RPCBVERS_4: 771 771 case RPCBVERS_3: 772 772 map->r_netid = xprt->address_strings[RPC_DISPLAY_NETID]; 773 - map->r_addr = rpc_sockaddr2uaddr(sap, GFP_ATOMIC); 773 + map->r_addr = rpc_sockaddr2uaddr(sap, GFP_NOFS); 774 + if (!map->r_addr) { 775 + status = -ENOMEM; 776 + dprintk("RPC: %5u %s: no memory available\n", 777 + task->tk_pid, __func__); 778 + goto bailout_free_args; 779 + } 774 780 map->r_owner = ""; 775 781 break; 776 782 case RPCBVERS_2: ··· 799 793 rpc_put_task(child); 800 794 return; 801 795 796 + bailout_free_args: 797 + kfree(map); 802 798 bailout_release_client: 803 799 rpc_release_client(rpcb_clnt); 804 800 bailout_nofree:
+4 -1
net/sunrpc/sched.c
··· 997 997 998 998 task->tk_xprt = xprt_get(task_setup_data->rpc_xprt); 999 999 1000 + task->tk_op_cred = get_rpccred(task_setup_data->rpc_op_cred); 1001 + 1000 1002 if (task->tk_ops->rpc_call_prepare != NULL) 1001 1003 task->tk_action = rpc_prepare_task; 1002 1004 ··· 1056 1054 { 1057 1055 unsigned short tk_flags = task->tk_flags; 1058 1056 1057 + put_rpccred(task->tk_op_cred); 1059 1058 rpc_release_calldata(task->tk_ops, task->tk_calldata); 1060 1059 1061 1060 if (tk_flags & RPC_TASK_DYNAMIC) { ··· 1074 1071 { 1075 1072 xprt_release(task); 1076 1073 if (task->tk_msg.rpc_cred) { 1077 - put_rpccred(task->tk_msg.rpc_cred); 1074 + put_cred(task->tk_msg.rpc_cred); 1078 1075 task->tk_msg.rpc_cred = NULL; 1079 1076 } 1080 1077 rpc_task_release_client(task);
+2 -2
net/sunrpc/xprtmultipath.c
··· 383 383 /** 384 384 * xprt_iter_xchg_switch - Atomically swap out the rpc_xprt_switch 385 385 * @xpi: pointer to rpc_xprt_iter 386 - * @xps: pointer to a new rpc_xprt_switch or NULL 386 + * @newswitch: pointer to a new rpc_xprt_switch or NULL 387 387 * 388 388 * Swaps out the existing xpi->xpi_xpswitch with a new value. 389 389 */ ··· 401 401 402 402 /** 403 403 * xprt_iter_destroy - Destroys the xprt iterator 404 - * @xpi pointer to rpc_xprt_iter 404 + * @xpi: pointer to rpc_xprt_iter 405 405 */ 406 406 void xprt_iter_destroy(struct rpc_xprt_iter *xpi) 407 407 {
+1 -2
net/sunrpc/xprtrdma/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 obj-$(CONFIG_SUNRPC_XPRT_RDMA) += rpcrdma.o 3 3 4 - rpcrdma-y := transport.o rpc_rdma.o verbs.o \ 5 - fmr_ops.o frwr_ops.o \ 4 + rpcrdma-y := transport.o rpc_rdma.o verbs.o frwr_ops.o \ 6 5 svc_rdma.o svc_rdma_backchannel.o svc_rdma_transport.o \ 7 6 svc_rdma_sendto.o svc_rdma_recvfrom.o svc_rdma_rw.o \ 8 7 module.o
+10 -29
net/sunrpc/xprtrdma/backchannel.c
··· 5 5 * Support for backward direction RPCs on RPC/RDMA. 6 6 */ 7 7 8 - #include <linux/module.h> 9 8 #include <linux/sunrpc/xprt.h> 10 9 #include <linux/sunrpc/svc.h> 11 10 #include <linux/sunrpc/svc_xprt.h> ··· 19 20 20 21 #undef RPCRDMA_BACKCHANNEL_DEBUG 21 22 22 - static void rpcrdma_bc_free_rqst(struct rpcrdma_xprt *r_xprt, 23 - struct rpc_rqst *rqst) 24 - { 25 - struct rpcrdma_buffer *buf = &r_xprt->rx_buf; 26 - struct rpcrdma_req *req = rpcr_to_rdmar(rqst); 27 - 28 - spin_lock(&buf->rb_reqslock); 29 - list_del(&req->rl_all); 30 - spin_unlock(&buf->rb_reqslock); 31 - 32 - rpcrdma_destroy_req(req); 33 - } 34 - 35 23 static int rpcrdma_bc_setup_reqs(struct rpcrdma_xprt *r_xprt, 36 24 unsigned int count) 37 25 { 38 26 struct rpc_xprt *xprt = &r_xprt->rx_xprt; 27 + struct rpcrdma_req *req; 39 28 struct rpc_rqst *rqst; 40 29 unsigned int i; 41 30 42 31 for (i = 0; i < (count << 1); i++) { 43 32 struct rpcrdma_regbuf *rb; 44 - struct rpcrdma_req *req; 45 33 size_t size; 46 34 47 35 req = rpcrdma_create_req(r_xprt); ··· 54 68 return 0; 55 69 56 70 out_fail: 57 - rpcrdma_bc_free_rqst(r_xprt, rqst); 71 + rpcrdma_req_destroy(req); 58 72 return -ENOMEM; 59 73 } 60 74 ··· 87 101 goto out_free; 88 102 89 103 r_xprt->rx_buf.rb_bc_srv_max_requests = reqs; 90 - request_module("svcrdma"); 91 104 trace_xprtrdma_cb_setup(r_xprt, reqs); 92 105 return 0; 93 106 ··· 158 173 */ 159 174 int xprt_rdma_bc_send_reply(struct rpc_rqst *rqst) 160 175 { 161 - struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(rqst->rq_xprt); 176 + struct rpc_xprt *xprt = rqst->rq_xprt; 177 + struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); 162 178 struct rpcrdma_req *req = rpcr_to_rdmar(rqst); 163 179 int rc; 164 180 165 - if (!xprt_connected(rqst->rq_xprt)) 166 - goto drop_connection; 181 + if (!xprt_connected(xprt)) 182 + return -ENOTCONN; 167 183 168 - if (!xprt_request_get_cong(rqst->rq_xprt, rqst)) 184 + if (!xprt_request_get_cong(xprt, rqst)) 169 185 return -EBADSLT; 170 186 171 187 rc = rpcrdma_bc_marshal_reply(rqst); 172 188 if (rc < 0) 173 189 goto failed_marshal; 174 190 175 - rpcrdma_post_recvs(r_xprt, true); 176 191 if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req)) 177 192 goto drop_connection; 178 193 return 0; ··· 181 196 if (rc != -ENOTCONN) 182 197 return rc; 183 198 drop_connection: 184 - xprt_disconnect_done(rqst->rq_xprt); 199 + xprt_rdma_close(xprt); 185 200 return -ENOTCONN; 186 201 } 187 202 ··· 192 207 */ 193 208 void xprt_rdma_bc_destroy(struct rpc_xprt *xprt, unsigned int reqs) 194 209 { 195 - struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); 196 210 struct rpc_rqst *rqst, *tmp; 197 211 198 212 spin_lock(&xprt->bc_pa_lock); ··· 199 215 list_del(&rqst->rq_bc_pa_list); 200 216 spin_unlock(&xprt->bc_pa_lock); 201 217 202 - rpcrdma_bc_free_rqst(r_xprt, rqst); 218 + rpcrdma_req_destroy(rpcr_to_rdmar(rqst)); 203 219 204 220 spin_lock(&xprt->bc_pa_lock); 205 221 } ··· 214 230 { 215 231 struct rpcrdma_req *req = rpcr_to_rdmar(rqst); 216 232 struct rpc_xprt *xprt = rqst->rq_xprt; 217 - 218 - dprintk("RPC: %s: freeing rqst %p (req %p)\n", 219 - __func__, rqst, req); 220 233 221 234 rpcrdma_recv_buffer_put(req->rl_reply); 222 235 req->rl_reply = NULL; ··· 300 319 301 320 out_overflow: 302 321 pr_warn("RPC/RDMA backchannel overflow\n"); 303 - xprt_disconnect_done(xprt); 322 + xprt_force_disconnect(xprt); 304 323 /* This receive buffer gets reposted automatically 305 324 * when the connection is re-established. 306 325 */
-337
net/sunrpc/xprtrdma/fmr_ops.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Copyright (c) 2015, 2017 Oracle. All rights reserved. 4 - * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved. 5 - */ 6 - 7 - /* Lightweight memory registration using Fast Memory Regions (FMR). 8 - * Referred to sometimes as MTHCAFMR mode. 9 - * 10 - * FMR uses synchronous memory registration and deregistration. 11 - * FMR registration is known to be fast, but FMR deregistration 12 - * can take tens of usecs to complete. 13 - */ 14 - 15 - /* Normal operation 16 - * 17 - * A Memory Region is prepared for RDMA READ or WRITE using the 18 - * ib_map_phys_fmr verb (fmr_op_map). When the RDMA operation is 19 - * finished, the Memory Region is unmapped using the ib_unmap_fmr 20 - * verb (fmr_op_unmap). 21 - */ 22 - 23 - #include <linux/sunrpc/svc_rdma.h> 24 - 25 - #include "xprt_rdma.h" 26 - #include <trace/events/rpcrdma.h> 27 - 28 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 29 - # define RPCDBG_FACILITY RPCDBG_TRANS 30 - #endif 31 - 32 - /* Maximum scatter/gather per FMR */ 33 - #define RPCRDMA_MAX_FMR_SGES (64) 34 - 35 - /* Access mode of externally registered pages */ 36 - enum { 37 - RPCRDMA_FMR_ACCESS_FLAGS = IB_ACCESS_REMOTE_WRITE | 38 - IB_ACCESS_REMOTE_READ, 39 - }; 40 - 41 - bool 42 - fmr_is_supported(struct rpcrdma_ia *ia) 43 - { 44 - if (!ia->ri_device->ops.alloc_fmr) { 45 - pr_info("rpcrdma: 'fmr' mode is not supported by device %s\n", 46 - ia->ri_device->name); 47 - return false; 48 - } 49 - return true; 50 - } 51 - 52 - static void 53 - __fmr_unmap(struct rpcrdma_mr *mr) 54 - { 55 - LIST_HEAD(l); 56 - int rc; 57 - 58 - list_add(&mr->fmr.fm_mr->list, &l); 59 - rc = ib_unmap_fmr(&l); 60 - list_del(&mr->fmr.fm_mr->list); 61 - if (rc) 62 - pr_err("rpcrdma: final ib_unmap_fmr for %p failed %i\n", 63 - mr, rc); 64 - } 65 - 66 - /* Release an MR. 67 - */ 68 - static void 69 - fmr_op_release_mr(struct rpcrdma_mr *mr) 70 - { 71 - int rc; 72 - 73 - kfree(mr->fmr.fm_physaddrs); 74 - kfree(mr->mr_sg); 75 - 76 - /* In case this one was left mapped, try to unmap it 77 - * to prevent dealloc_fmr from failing with EBUSY 78 - */ 79 - __fmr_unmap(mr); 80 - 81 - rc = ib_dealloc_fmr(mr->fmr.fm_mr); 82 - if (rc) 83 - pr_err("rpcrdma: final ib_dealloc_fmr for %p returned %i\n", 84 - mr, rc); 85 - 86 - kfree(mr); 87 - } 88 - 89 - /* MRs are dynamically allocated, so simply clean up and release the MR. 90 - * A replacement MR will subsequently be allocated on demand. 91 - */ 92 - static void 93 - fmr_mr_recycle_worker(struct work_struct *work) 94 - { 95 - struct rpcrdma_mr *mr = container_of(work, struct rpcrdma_mr, mr_recycle); 96 - struct rpcrdma_xprt *r_xprt = mr->mr_xprt; 97 - 98 - trace_xprtrdma_mr_recycle(mr); 99 - 100 - trace_xprtrdma_mr_unmap(mr); 101 - ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 102 - mr->mr_sg, mr->mr_nents, mr->mr_dir); 103 - 104 - spin_lock(&r_xprt->rx_buf.rb_mrlock); 105 - list_del(&mr->mr_all); 106 - r_xprt->rx_stats.mrs_recycled++; 107 - spin_unlock(&r_xprt->rx_buf.rb_mrlock); 108 - fmr_op_release_mr(mr); 109 - } 110 - 111 - static int 112 - fmr_op_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr) 113 - { 114 - static struct ib_fmr_attr fmr_attr = { 115 - .max_pages = RPCRDMA_MAX_FMR_SGES, 116 - .max_maps = 1, 117 - .page_shift = PAGE_SHIFT 118 - }; 119 - 120 - mr->fmr.fm_physaddrs = kcalloc(RPCRDMA_MAX_FMR_SGES, 121 - sizeof(u64), GFP_KERNEL); 122 - if (!mr->fmr.fm_physaddrs) 123 - goto out_free; 124 - 125 - mr->mr_sg = kcalloc(RPCRDMA_MAX_FMR_SGES, 126 - sizeof(*mr->mr_sg), GFP_KERNEL); 127 - if (!mr->mr_sg) 128 - goto out_free; 129 - 130 - sg_init_table(mr->mr_sg, RPCRDMA_MAX_FMR_SGES); 131 - 132 - mr->fmr.fm_mr = ib_alloc_fmr(ia->ri_pd, RPCRDMA_FMR_ACCESS_FLAGS, 133 - &fmr_attr); 134 - if (IS_ERR(mr->fmr.fm_mr)) 135 - goto out_fmr_err; 136 - 137 - INIT_LIST_HEAD(&mr->mr_list); 138 - INIT_WORK(&mr->mr_recycle, fmr_mr_recycle_worker); 139 - return 0; 140 - 141 - out_fmr_err: 142 - dprintk("RPC: %s: ib_alloc_fmr returned %ld\n", __func__, 143 - PTR_ERR(mr->fmr.fm_mr)); 144 - 145 - out_free: 146 - kfree(mr->mr_sg); 147 - kfree(mr->fmr.fm_physaddrs); 148 - return -ENOMEM; 149 - } 150 - 151 - /* On success, sets: 152 - * ep->rep_attr.cap.max_send_wr 153 - * ep->rep_attr.cap.max_recv_wr 154 - * cdata->max_requests 155 - * ia->ri_max_segs 156 - */ 157 - static int 158 - fmr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep, 159 - struct rpcrdma_create_data_internal *cdata) 160 - { 161 - int max_qp_wr; 162 - 163 - max_qp_wr = ia->ri_device->attrs.max_qp_wr; 164 - max_qp_wr -= RPCRDMA_BACKWARD_WRS; 165 - max_qp_wr -= 1; 166 - if (max_qp_wr < RPCRDMA_MIN_SLOT_TABLE) 167 - return -ENOMEM; 168 - if (cdata->max_requests > max_qp_wr) 169 - cdata->max_requests = max_qp_wr; 170 - ep->rep_attr.cap.max_send_wr = cdata->max_requests; 171 - ep->rep_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS; 172 - ep->rep_attr.cap.max_send_wr += 1; /* for ib_drain_sq */ 173 - ep->rep_attr.cap.max_recv_wr = cdata->max_requests; 174 - ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS; 175 - ep->rep_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */ 176 - 177 - ia->ri_max_segs = max_t(unsigned int, 1, RPCRDMA_MAX_DATA_SEGS / 178 - RPCRDMA_MAX_FMR_SGES); 179 - ia->ri_max_segs += 2; /* segments for head and tail buffers */ 180 - return 0; 181 - } 182 - 183 - /* FMR mode conveys up to 64 pages of payload per chunk segment. 184 - */ 185 - static size_t 186 - fmr_op_maxpages(struct rpcrdma_xprt *r_xprt) 187 - { 188 - return min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS, 189 - RPCRDMA_MAX_HDR_SEGS * RPCRDMA_MAX_FMR_SGES); 190 - } 191 - 192 - /* Use the ib_map_phys_fmr() verb to register a memory region 193 - * for remote access via RDMA READ or RDMA WRITE. 194 - */ 195 - static struct rpcrdma_mr_seg * 196 - fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg, 197 - int nsegs, bool writing, struct rpcrdma_mr **out) 198 - { 199 - struct rpcrdma_mr_seg *seg1 = seg; 200 - int len, pageoff, i, rc; 201 - struct rpcrdma_mr *mr; 202 - u64 *dma_pages; 203 - 204 - mr = rpcrdma_mr_get(r_xprt); 205 - if (!mr) 206 - return ERR_PTR(-EAGAIN); 207 - 208 - pageoff = offset_in_page(seg1->mr_offset); 209 - seg1->mr_offset -= pageoff; /* start of page */ 210 - seg1->mr_len += pageoff; 211 - len = -pageoff; 212 - if (nsegs > RPCRDMA_MAX_FMR_SGES) 213 - nsegs = RPCRDMA_MAX_FMR_SGES; 214 - for (i = 0; i < nsegs;) { 215 - if (seg->mr_page) 216 - sg_set_page(&mr->mr_sg[i], 217 - seg->mr_page, 218 - seg->mr_len, 219 - offset_in_page(seg->mr_offset)); 220 - else 221 - sg_set_buf(&mr->mr_sg[i], seg->mr_offset, 222 - seg->mr_len); 223 - len += seg->mr_len; 224 - ++seg; 225 - ++i; 226 - /* Check for holes */ 227 - if ((i < nsegs && offset_in_page(seg->mr_offset)) || 228 - offset_in_page((seg-1)->mr_offset + (seg-1)->mr_len)) 229 - break; 230 - } 231 - mr->mr_dir = rpcrdma_data_dir(writing); 232 - 233 - mr->mr_nents = ib_dma_map_sg(r_xprt->rx_ia.ri_device, 234 - mr->mr_sg, i, mr->mr_dir); 235 - if (!mr->mr_nents) 236 - goto out_dmamap_err; 237 - trace_xprtrdma_mr_map(mr); 238 - 239 - for (i = 0, dma_pages = mr->fmr.fm_physaddrs; i < mr->mr_nents; i++) 240 - dma_pages[i] = sg_dma_address(&mr->mr_sg[i]); 241 - rc = ib_map_phys_fmr(mr->fmr.fm_mr, dma_pages, mr->mr_nents, 242 - dma_pages[0]); 243 - if (rc) 244 - goto out_maperr; 245 - 246 - mr->mr_handle = mr->fmr.fm_mr->rkey; 247 - mr->mr_length = len; 248 - mr->mr_offset = dma_pages[0] + pageoff; 249 - 250 - *out = mr; 251 - return seg; 252 - 253 - out_dmamap_err: 254 - pr_err("rpcrdma: failed to DMA map sg %p sg_nents %d\n", 255 - mr->mr_sg, i); 256 - rpcrdma_mr_put(mr); 257 - return ERR_PTR(-EIO); 258 - 259 - out_maperr: 260 - pr_err("rpcrdma: ib_map_phys_fmr %u@0x%llx+%i (%d) status %i\n", 261 - len, (unsigned long long)dma_pages[0], 262 - pageoff, mr->mr_nents, rc); 263 - rpcrdma_mr_unmap_and_put(mr); 264 - return ERR_PTR(-EIO); 265 - } 266 - 267 - /* Post Send WR containing the RPC Call message. 268 - */ 269 - static int 270 - fmr_op_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req) 271 - { 272 - return ib_post_send(ia->ri_id->qp, &req->rl_sendctx->sc_wr, NULL); 273 - } 274 - 275 - /* Invalidate all memory regions that were registered for "req". 276 - * 277 - * Sleeps until it is safe for the host CPU to access the 278 - * previously mapped memory regions. 279 - * 280 - * Caller ensures that @mrs is not empty before the call. This 281 - * function empties the list. 282 - */ 283 - static void 284 - fmr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct list_head *mrs) 285 - { 286 - struct rpcrdma_mr *mr; 287 - LIST_HEAD(unmap_list); 288 - int rc; 289 - 290 - /* ORDER: Invalidate all of the req's MRs first 291 - * 292 - * ib_unmap_fmr() is slow, so use a single call instead 293 - * of one call per mapped FMR. 294 - */ 295 - list_for_each_entry(mr, mrs, mr_list) { 296 - dprintk("RPC: %s: unmapping fmr %p\n", 297 - __func__, &mr->fmr); 298 - trace_xprtrdma_mr_localinv(mr); 299 - list_add_tail(&mr->fmr.fm_mr->list, &unmap_list); 300 - } 301 - r_xprt->rx_stats.local_inv_needed++; 302 - rc = ib_unmap_fmr(&unmap_list); 303 - if (rc) 304 - goto out_release; 305 - 306 - /* ORDER: Now DMA unmap all of the req's MRs, and return 307 - * them to the free MW list. 308 - */ 309 - while (!list_empty(mrs)) { 310 - mr = rpcrdma_mr_pop(mrs); 311 - list_del(&mr->fmr.fm_mr->list); 312 - rpcrdma_mr_unmap_and_put(mr); 313 - } 314 - 315 - return; 316 - 317 - out_release: 318 - pr_err("rpcrdma: ib_unmap_fmr failed (%i)\n", rc); 319 - 320 - while (!list_empty(mrs)) { 321 - mr = rpcrdma_mr_pop(mrs); 322 - list_del(&mr->fmr.fm_mr->list); 323 - rpcrdma_mr_recycle(mr); 324 - } 325 - } 326 - 327 - const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops = { 328 - .ro_map = fmr_op_map, 329 - .ro_send = fmr_op_send, 330 - .ro_unmap_sync = fmr_op_unmap_sync, 331 - .ro_open = fmr_op_open, 332 - .ro_maxpages = fmr_op_maxpages, 333 - .ro_init_mr = fmr_op_init_mr, 334 - .ro_release_mr = fmr_op_release_mr, 335 - .ro_displayname = "fmr", 336 - .ro_send_w_inv_ok = 0, 337 - };
+130 -79
net/sunrpc/xprtrdma/frwr_ops.c
··· 15 15 /* Normal operation 16 16 * 17 17 * A Memory Region is prepared for RDMA READ or WRITE using a FAST_REG 18 - * Work Request (frwr_op_map). When the RDMA operation is finished, this 18 + * Work Request (frwr_map). When the RDMA operation is finished, this 19 19 * Memory Region is invalidated using a LOCAL_INV Work Request 20 - * (frwr_op_unmap_sync). 20 + * (frwr_unmap_sync). 21 21 * 22 22 * Typically these Work Requests are not signaled, and neither are RDMA 23 23 * SEND Work Requests (with the exception of signaling occasionally to 24 24 * prevent provider work queue overflows). This greatly reduces HCA 25 25 * interrupt workload. 26 26 * 27 - * As an optimization, frwr_op_unmap marks MRs INVALID before the 27 + * As an optimization, frwr_unmap marks MRs INVALID before the 28 28 * LOCAL_INV WR is posted. If posting succeeds, the MR is placed on 29 29 * rb_mrs immediately so that no work (like managing a linked list 30 30 * under a spinlock) is needed in the completion upcall. 31 31 * 32 - * But this means that frwr_op_map() can occasionally encounter an MR 32 + * But this means that frwr_map() can occasionally encounter an MR 33 33 * that is INVALID but the LOCAL_INV WR has not completed. Work Queue 34 34 * ordering prevents a subsequent FAST_REG WR from executing against 35 35 * that MR while it is still being invalidated. ··· 57 57 * FLUSHED_LI: The MR was being invalidated when the QP entered ERROR 58 58 * state, and the pending WR was flushed. 59 59 * 60 - * When frwr_op_map encounters FLUSHED and VALID MRs, they are recovered 60 + * When frwr_map encounters FLUSHED and VALID MRs, they are recovered 61 61 * with ib_dereg_mr and then are re-initialized. Because MR recovery 62 62 * allocates fresh resources, it is deferred to a workqueue, and the 63 63 * recovered MRs are placed back on the rb_mrs list when recovery is 64 - * complete. frwr_op_map allocates another MR for the current RPC while 64 + * complete. frwr_map allocates another MR for the current RPC while 65 65 * the broken MR is reset. 66 66 * 67 - * To ensure that frwr_op_map doesn't encounter an MR that is marked 67 + * To ensure that frwr_map doesn't encounter an MR that is marked 68 68 * INVALID but that is about to be flushed due to a previous transport 69 69 * disconnect, the transport connect worker attempts to drain all 70 70 * pending send queue WRs before the transport is reconnected. ··· 80 80 # define RPCDBG_FACILITY RPCDBG_TRANS 81 81 #endif 82 82 83 - bool 84 - frwr_is_supported(struct rpcrdma_ia *ia) 83 + /** 84 + * frwr_is_supported - Check if device supports FRWR 85 + * @ia: interface adapter to check 86 + * 87 + * Returns true if device supports FRWR, otherwise false 88 + */ 89 + bool frwr_is_supported(struct rpcrdma_ia *ia) 85 90 { 86 91 struct ib_device_attr *attrs = &ia->ri_device->attrs; 87 92 ··· 102 97 return false; 103 98 } 104 99 105 - static void 106 - frwr_op_release_mr(struct rpcrdma_mr *mr) 100 + /** 101 + * frwr_release_mr - Destroy one MR 102 + * @mr: MR allocated by frwr_init_mr 103 + * 104 + */ 105 + void frwr_release_mr(struct rpcrdma_mr *mr) 107 106 { 108 107 int rc; 109 108 110 109 rc = ib_dereg_mr(mr->frwr.fr_mr); 111 110 if (rc) 112 - pr_err("rpcrdma: final ib_dereg_mr for %p returned %i\n", 113 - mr, rc); 111 + trace_xprtrdma_frwr_dereg(mr, rc); 114 112 kfree(mr->mr_sg); 115 113 kfree(mr); 116 114 } ··· 125 117 frwr_mr_recycle_worker(struct work_struct *work) 126 118 { 127 119 struct rpcrdma_mr *mr = container_of(work, struct rpcrdma_mr, mr_recycle); 128 - enum rpcrdma_frwr_state state = mr->frwr.fr_state; 129 120 struct rpcrdma_xprt *r_xprt = mr->mr_xprt; 130 121 131 122 trace_xprtrdma_mr_recycle(mr); 132 123 133 - if (state != FRWR_FLUSHED_LI) { 124 + if (mr->mr_dir != DMA_NONE) { 134 125 trace_xprtrdma_mr_unmap(mr); 135 126 ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 136 127 mr->mr_sg, mr->mr_nents, mr->mr_dir); 128 + mr->mr_dir = DMA_NONE; 137 129 } 138 130 139 131 spin_lock(&r_xprt->rx_buf.rb_mrlock); 140 132 list_del(&mr->mr_all); 141 133 r_xprt->rx_stats.mrs_recycled++; 142 134 spin_unlock(&r_xprt->rx_buf.rb_mrlock); 143 - frwr_op_release_mr(mr); 135 + 136 + frwr_release_mr(mr); 144 137 } 145 138 146 - static int 147 - frwr_op_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr) 139 + /** 140 + * frwr_init_mr - Initialize one MR 141 + * @ia: interface adapter 142 + * @mr: generic MR to prepare for FRWR 143 + * 144 + * Returns zero if successful. Otherwise a negative errno 145 + * is returned. 146 + */ 147 + int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr) 148 148 { 149 149 unsigned int depth = ia->ri_max_frwr_depth; 150 - struct rpcrdma_frwr *frwr = &mr->frwr; 150 + struct scatterlist *sg; 151 + struct ib_mr *frmr; 151 152 int rc; 152 153 153 - frwr->fr_mr = ib_alloc_mr(ia->ri_pd, ia->ri_mrtype, depth); 154 - if (IS_ERR(frwr->fr_mr)) 154 + frmr = ib_alloc_mr(ia->ri_pd, ia->ri_mrtype, depth); 155 + if (IS_ERR(frmr)) 155 156 goto out_mr_err; 156 157 157 - mr->mr_sg = kcalloc(depth, sizeof(*mr->mr_sg), GFP_KERNEL); 158 - if (!mr->mr_sg) 158 + sg = kcalloc(depth, sizeof(*sg), GFP_KERNEL); 159 + if (!sg) 159 160 goto out_list_err; 160 161 162 + mr->frwr.fr_mr = frmr; 163 + mr->frwr.fr_state = FRWR_IS_INVALID; 164 + mr->mr_dir = DMA_NONE; 161 165 INIT_LIST_HEAD(&mr->mr_list); 162 166 INIT_WORK(&mr->mr_recycle, frwr_mr_recycle_worker); 163 - sg_init_table(mr->mr_sg, depth); 164 - init_completion(&frwr->fr_linv_done); 167 + init_completion(&mr->frwr.fr_linv_done); 168 + 169 + sg_init_table(sg, depth); 170 + mr->mr_sg = sg; 165 171 return 0; 166 172 167 173 out_mr_err: 168 - rc = PTR_ERR(frwr->fr_mr); 169 - dprintk("RPC: %s: ib_alloc_mr status %i\n", 170 - __func__, rc); 174 + rc = PTR_ERR(frmr); 175 + trace_xprtrdma_frwr_alloc(mr, rc); 171 176 return rc; 172 177 173 178 out_list_err: 174 - rc = -ENOMEM; 175 179 dprintk("RPC: %s: sg allocation failure\n", 176 180 __func__); 177 - ib_dereg_mr(frwr->fr_mr); 178 - return rc; 181 + ib_dereg_mr(frmr); 182 + return -ENOMEM; 179 183 } 180 184 181 - /* On success, sets: 185 + /** 186 + * frwr_open - Prepare an endpoint for use with FRWR 187 + * @ia: interface adapter this endpoint will use 188 + * @ep: endpoint to prepare 189 + * @cdata: transport parameters 190 + * 191 + * On success, sets: 182 192 * ep->rep_attr.cap.max_send_wr 183 193 * ep->rep_attr.cap.max_recv_wr 184 194 * cdata->max_requests ··· 205 179 * And these FRWR-related fields: 206 180 * ia->ri_max_frwr_depth 207 181 * ia->ri_mrtype 182 + * 183 + * On failure, a negative errno is returned. 208 184 */ 209 - static int 210 - frwr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep, 211 - struct rpcrdma_create_data_internal *cdata) 185 + int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep, 186 + struct rpcrdma_create_data_internal *cdata) 212 187 { 213 188 struct ib_device_attr *attrs = &ia->ri_device->attrs; 214 189 int max_qp_wr, depth, delta; ··· 218 191 if (attrs->device_cap_flags & IB_DEVICE_SG_GAPS_REG) 219 192 ia->ri_mrtype = IB_MR_TYPE_SG_GAPS; 220 193 221 - ia->ri_max_frwr_depth = 222 - min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS, 223 - attrs->max_fast_reg_page_list_len); 224 - dprintk("RPC: %s: device's max FR page list len = %u\n", 194 + /* Quirk: Some devices advertise a large max_fast_reg_page_list_len 195 + * capability, but perform optimally when the MRs are not larger 196 + * than a page. 197 + */ 198 + if (attrs->max_sge_rd > 1) 199 + ia->ri_max_frwr_depth = attrs->max_sge_rd; 200 + else 201 + ia->ri_max_frwr_depth = attrs->max_fast_reg_page_list_len; 202 + if (ia->ri_max_frwr_depth > RPCRDMA_MAX_DATA_SEGS) 203 + ia->ri_max_frwr_depth = RPCRDMA_MAX_DATA_SEGS; 204 + dprintk("RPC: %s: max FR page list depth = %u\n", 225 205 __func__, ia->ri_max_frwr_depth); 226 206 227 207 /* Add room for frwr register and invalidate WRs. ··· 276 242 277 243 ia->ri_max_segs = max_t(unsigned int, 1, RPCRDMA_MAX_DATA_SEGS / 278 244 ia->ri_max_frwr_depth); 279 - ia->ri_max_segs += 2; /* segments for head and tail buffers */ 245 + /* Reply chunks require segments for head and tail buffers */ 246 + ia->ri_max_segs += 2; 247 + if (ia->ri_max_segs > RPCRDMA_MAX_HDR_SEGS) 248 + ia->ri_max_segs = RPCRDMA_MAX_HDR_SEGS; 280 249 return 0; 281 250 } 282 251 283 - /* FRWR mode conveys a list of pages per chunk segment. The 252 + /** 253 + * frwr_maxpages - Compute size of largest payload 254 + * @r_xprt: transport 255 + * 256 + * Returns maximum size of an RPC message, in pages. 257 + * 258 + * FRWR mode conveys a list of pages per chunk segment. The 284 259 * maximum length of that list is the FRWR page list depth. 285 260 */ 286 - static size_t 287 - frwr_op_maxpages(struct rpcrdma_xprt *r_xprt) 261 + size_t frwr_maxpages(struct rpcrdma_xprt *r_xprt) 288 262 { 289 263 struct rpcrdma_ia *ia = &r_xprt->rx_ia; 290 264 291 265 return min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS, 292 - RPCRDMA_MAX_HDR_SEGS * ia->ri_max_frwr_depth); 266 + (ia->ri_max_segs - 2) * ia->ri_max_frwr_depth); 293 267 } 294 268 295 269 static void ··· 374 332 trace_xprtrdma_wc_li_wake(wc, frwr); 375 333 } 376 334 377 - /* Post a REG_MR Work Request to register a memory region 335 + /** 336 + * frwr_map - Register a memory region 337 + * @r_xprt: controlling transport 338 + * @seg: memory region co-ordinates 339 + * @nsegs: number of segments remaining 340 + * @writing: true when RDMA Write will be used 341 + * @xid: XID of RPC using the registered memory 342 + * @out: initialized MR 343 + * 344 + * Prepare a REG_MR Work Request to register a memory region 378 345 * for remote access via RDMA READ or RDMA WRITE. 346 + * 347 + * Returns the next segment or a negative errno pointer. 348 + * On success, the prepared MR is planted in @out. 379 349 */ 380 - static struct rpcrdma_mr_seg * 381 - frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg, 382 - int nsegs, bool writing, struct rpcrdma_mr **out) 350 + struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, 351 + struct rpcrdma_mr_seg *seg, 352 + int nsegs, bool writing, u32 xid, 353 + struct rpcrdma_mr **out) 383 354 { 384 355 struct rpcrdma_ia *ia = &r_xprt->rx_ia; 385 356 bool holes_ok = ia->ri_mrtype == IB_MR_TYPE_SG_GAPS; ··· 439 384 mr->mr_nents = ib_dma_map_sg(ia->ri_device, mr->mr_sg, i, mr->mr_dir); 440 385 if (!mr->mr_nents) 441 386 goto out_dmamap_err; 442 - trace_xprtrdma_mr_map(mr); 443 387 444 388 ibmr = frwr->fr_mr; 445 389 n = ib_map_mr_sg(ibmr, mr->mr_sg, mr->mr_nents, NULL, PAGE_SIZE); 446 390 if (unlikely(n != mr->mr_nents)) 447 391 goto out_mapmr_err; 448 392 393 + ibmr->iova &= 0x00000000ffffffff; 394 + ibmr->iova |= ((u64)cpu_to_be32(xid)) << 32; 449 395 key = (u8)(ibmr->rkey & 0x000000FF); 450 396 ib_update_fast_reg_key(ibmr, ++key); 451 397 ··· 460 404 mr->mr_handle = ibmr->rkey; 461 405 mr->mr_length = ibmr->length; 462 406 mr->mr_offset = ibmr->iova; 407 + trace_xprtrdma_mr_map(mr); 463 408 464 409 *out = mr; 465 410 return seg; 466 411 467 412 out_dmamap_err: 468 - pr_err("rpcrdma: failed to DMA map sg %p sg_nents %d\n", 469 - mr->mr_sg, i); 470 413 frwr->fr_state = FRWR_IS_INVALID; 414 + trace_xprtrdma_frwr_sgerr(mr, i); 471 415 rpcrdma_mr_put(mr); 472 416 return ERR_PTR(-EIO); 473 417 474 418 out_mapmr_err: 475 - pr_err("rpcrdma: failed to map mr %p (%d/%d)\n", 476 - frwr->fr_mr, n, mr->mr_nents); 419 + trace_xprtrdma_frwr_maperr(mr, n); 477 420 rpcrdma_mr_recycle(mr); 478 421 return ERR_PTR(-EIO); 479 422 } 480 423 481 - /* Post Send WR containing the RPC Call message. 424 + /** 425 + * frwr_send - post Send WR containing the RPC Call message 426 + * @ia: interface adapter 427 + * @req: Prepared RPC Call 482 428 * 483 - * For FRMR, chain any FastReg WRs to the Send WR. Only a 429 + * For FRWR, chain any FastReg WRs to the Send WR. Only a 484 430 * single ib_post_send call is needed to register memory 485 431 * and then post the Send WR. 432 + * 433 + * Returns the result of ib_post_send. 486 434 */ 487 - static int 488 - frwr_op_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req) 435 + int frwr_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req) 489 436 { 490 437 struct ib_send_wr *post_wr; 491 438 struct rpcrdma_mr *mr; ··· 510 451 } 511 452 512 453 /* If ib_post_send fails, the next ->send_request for 513 - * @req will queue these MWs for recovery. 454 + * @req will queue these MRs for recovery. 514 455 */ 515 456 return ib_post_send(ia->ri_id->qp, post_wr, NULL); 516 457 } 517 458 518 - /* Handle a remotely invalidated mr on the @mrs list 459 + /** 460 + * frwr_reminv - handle a remotely invalidated mr on the @mrs list 461 + * @rep: Received reply 462 + * @mrs: list of MRs to check 463 + * 519 464 */ 520 - static void 521 - frwr_op_reminv(struct rpcrdma_rep *rep, struct list_head *mrs) 465 + void frwr_reminv(struct rpcrdma_rep *rep, struct list_head *mrs) 522 466 { 523 467 struct rpcrdma_mr *mr; 524 468 ··· 535 473 } 536 474 } 537 475 538 - /* Invalidate all memory regions that were registered for "req". 476 + /** 477 + * frwr_unmap_sync - invalidate memory regions that were registered for @req 478 + * @r_xprt: controlling transport 479 + * @mrs: list of MRs to process 539 480 * 540 481 * Sleeps until it is safe for the host CPU to access the 541 482 * previously mapped memory regions. ··· 546 481 * Caller ensures that @mrs is not empty before the call. This 547 482 * function empties the list. 548 483 */ 549 - static void 550 - frwr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct list_head *mrs) 484 + void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct list_head *mrs) 551 485 { 552 486 struct ib_send_wr *first, **prev, *last; 553 487 const struct ib_send_wr *bad_wr; ··· 625 561 mr = container_of(frwr, struct rpcrdma_mr, frwr); 626 562 bad_wr = bad_wr->next; 627 563 628 - list_del(&mr->mr_list); 629 - frwr_op_release_mr(mr); 564 + list_del_init(&mr->mr_list); 565 + rpcrdma_mr_recycle(mr); 630 566 } 631 567 } 632 - 633 - const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops = { 634 - .ro_map = frwr_op_map, 635 - .ro_send = frwr_op_send, 636 - .ro_reminv = frwr_op_reminv, 637 - .ro_unmap_sync = frwr_op_unmap_sync, 638 - .ro_open = frwr_op_open, 639 - .ro_maxpages = frwr_op_maxpages, 640 - .ro_init_mr = frwr_op_init_mr, 641 - .ro_release_mr = frwr_op_release_mr, 642 - .ro_displayname = "frwr", 643 - .ro_send_w_inv_ok = RPCRDMA_CMP_F_SND_W_INV_OK, 644 - };
+33 -45
net/sunrpc/xprtrdma/rpc_rdma.c
··· 218 218 ppages = xdrbuf->pages + (xdrbuf->page_base >> PAGE_SHIFT); 219 219 page_base = offset_in_page(xdrbuf->page_base); 220 220 while (len) { 221 - if (unlikely(!*ppages)) { 222 - /* XXX: Certain upper layer operations do 223 - * not provide receive buffer pages. 224 - */ 225 - *ppages = alloc_page(GFP_ATOMIC); 221 + /* ACL likes to be lazy in allocating pages - ACLs 222 + * are small by default but can get huge. 223 + */ 224 + if (unlikely(xdrbuf->flags & XDRBUF_SPARSE_PAGES)) { 225 + if (!*ppages) 226 + *ppages = alloc_page(GFP_ATOMIC); 226 227 if (!*ppages) 227 228 return -ENOBUFS; 228 229 } ··· 357 356 return nsegs; 358 357 359 358 do { 360 - seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, 361 - false, &mr); 359 + seg = frwr_map(r_xprt, seg, nsegs, false, rqst->rq_xid, &mr); 362 360 if (IS_ERR(seg)) 363 361 return PTR_ERR(seg); 364 362 rpcrdma_mr_push(mr, &req->rl_registered); ··· 365 365 if (encode_read_segment(xdr, mr, pos) < 0) 366 366 return -EMSGSIZE; 367 367 368 - trace_xprtrdma_read_chunk(rqst->rq_task, pos, mr, nsegs); 368 + trace_xprtrdma_chunk_read(rqst->rq_task, pos, mr, nsegs); 369 369 r_xprt->rx_stats.read_chunk_count++; 370 370 nsegs -= mr->mr_nents; 371 371 } while (nsegs); ··· 414 414 415 415 nchunks = 0; 416 416 do { 417 - seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, 418 - true, &mr); 417 + seg = frwr_map(r_xprt, seg, nsegs, true, rqst->rq_xid, &mr); 419 418 if (IS_ERR(seg)) 420 419 return PTR_ERR(seg); 421 420 rpcrdma_mr_push(mr, &req->rl_registered); ··· 422 423 if (encode_rdma_segment(xdr, mr) < 0) 423 424 return -EMSGSIZE; 424 425 425 - trace_xprtrdma_write_chunk(rqst->rq_task, mr, nsegs); 426 + trace_xprtrdma_chunk_write(rqst->rq_task, mr, nsegs); 426 427 r_xprt->rx_stats.write_chunk_count++; 427 428 r_xprt->rx_stats.total_rdma_request += mr->mr_length; 428 429 nchunks++; ··· 471 472 472 473 nchunks = 0; 473 474 do { 474 - seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, 475 - true, &mr); 475 + seg = frwr_map(r_xprt, seg, nsegs, true, rqst->rq_xid, &mr); 476 476 if (IS_ERR(seg)) 477 477 return PTR_ERR(seg); 478 478 rpcrdma_mr_push(mr, &req->rl_registered); ··· 479 481 if (encode_rdma_segment(xdr, mr) < 0) 480 482 return -EMSGSIZE; 481 483 482 - trace_xprtrdma_reply_chunk(rqst->rq_task, mr, nsegs); 484 + trace_xprtrdma_chunk_reply(rqst->rq_task, mr, nsegs); 483 485 r_xprt->rx_stats.reply_chunk_count++; 484 486 r_xprt->rx_stats.total_rdma_request += mr->mr_length; 485 487 nchunks++; ··· 665 667 666 668 out_mapping_err: 667 669 rpcrdma_unmap_sendctx(sc); 668 - pr_err("rpcrdma: Send mapping error\n"); 670 + trace_xprtrdma_dma_maperr(sge[sge_no].addr); 669 671 return false; 670 672 } 671 673 ··· 1186 1188 p = xdr_inline_decode(xdr, 2 * sizeof(*p)); 1187 1189 if (!p) 1188 1190 break; 1189 - dprintk("RPC: %5u: %s: server reports version error (%u-%u)\n", 1190 - rqst->rq_task->tk_pid, __func__, 1191 - be32_to_cpup(p), be32_to_cpu(*(p + 1))); 1191 + dprintk("RPC: %s: server reports " 1192 + "version error (%u-%u), xid %08x\n", __func__, 1193 + be32_to_cpup(p), be32_to_cpu(*(p + 1)), 1194 + be32_to_cpu(rep->rr_xid)); 1192 1195 break; 1193 1196 case err_chunk: 1194 - dprintk("RPC: %5u: %s: server reports header decoding error\n", 1195 - rqst->rq_task->tk_pid, __func__); 1197 + dprintk("RPC: %s: server reports " 1198 + "header decoding error, xid %08x\n", __func__, 1199 + be32_to_cpu(rep->rr_xid)); 1196 1200 break; 1197 1201 default: 1198 - dprintk("RPC: %5u: %s: server reports unrecognized error %d\n", 1199 - rqst->rq_task->tk_pid, __func__, be32_to_cpup(p)); 1202 + dprintk("RPC: %s: server reports " 1203 + "unrecognized error %d, xid %08x\n", __func__, 1204 + be32_to_cpup(p), be32_to_cpu(rep->rr_xid)); 1200 1205 } 1201 1206 1202 1207 r_xprt->rx_stats.bad_reply_count++; ··· 1249 1248 out_badheader: 1250 1249 trace_xprtrdma_reply_hdr(rep); 1251 1250 r_xprt->rx_stats.bad_reply_count++; 1252 - status = -EIO; 1253 1251 goto out; 1254 1252 } 1255 1253 ··· 1262 1262 * RPC has relinquished all its Send Queue entries. 1263 1263 */ 1264 1264 if (!list_empty(&req->rl_registered)) 1265 - r_xprt->rx_ia.ri_ops->ro_unmap_sync(r_xprt, 1266 - &req->rl_registered); 1265 + frwr_unmap_sync(r_xprt, &req->rl_registered); 1267 1266 1268 1267 /* Ensure that any DMA mapped pages associated with 1269 1268 * the Send of the RPC Call have been unmapped before ··· 1291 1292 1292 1293 trace_xprtrdma_defer_cmp(rep); 1293 1294 if (rep->rr_wc_flags & IB_WC_WITH_INVALIDATE) 1294 - r_xprt->rx_ia.ri_ops->ro_reminv(rep, &req->rl_registered); 1295 + frwr_reminv(rep, &req->rl_registered); 1295 1296 rpcrdma_release_rqst(r_xprt, req); 1296 1297 rpcrdma_complete_rqst(rep); 1297 1298 } ··· 1310 1311 struct rpc_rqst *rqst; 1311 1312 u32 credits; 1312 1313 __be32 *p; 1313 - 1314 - --buf->rb_posted_receives; 1315 - 1316 - if (rep->rr_hdrbuf.head[0].iov_len == 0) 1317 - goto out_badstatus; 1318 1314 1319 1315 /* Fixed transport header fields */ 1320 1316 xdr_init_decode(&rep->rr_stream, &rep->rr_hdrbuf, ··· 1350 1356 } 1351 1357 1352 1358 req = rpcr_to_rdmar(rqst); 1359 + if (req->rl_reply) { 1360 + trace_xprtrdma_leaked_rep(rqst, req->rl_reply); 1361 + rpcrdma_recv_buffer_put(req->rl_reply); 1362 + } 1353 1363 req->rl_reply = rep; 1354 1364 rep->rr_rqst = rqst; 1355 1365 clear_bit(RPCRDMA_REQ_F_PENDING, &req->rl_flags); 1356 1366 1357 1367 trace_xprtrdma_reply(rqst->rq_task, rep, req, credits); 1358 - 1359 - rpcrdma_post_recvs(r_xprt, false); 1360 - queue_work(rpcrdma_receive_wq, &rep->rr_work); 1368 + queue_work(buf->rb_completion_wq, &rep->rr_work); 1361 1369 return; 1362 1370 1363 1371 out_badversion: 1364 1372 trace_xprtrdma_reply_vers(rep); 1365 - goto repost; 1373 + goto out; 1366 1374 1367 - /* The RPC transaction has already been terminated, or the header 1368 - * is corrupt. 1369 - */ 1370 1375 out_norqst: 1371 1376 spin_unlock(&xprt->queue_lock); 1372 1377 trace_xprtrdma_reply_rqst(rep); 1373 - goto repost; 1378 + goto out; 1374 1379 1375 1380 out_shortreply: 1376 1381 trace_xprtrdma_reply_short(rep); 1377 1382 1378 - /* If no pending RPC transaction was matched, post a replacement 1379 - * receive buffer before returning. 1380 - */ 1381 - repost: 1382 - rpcrdma_post_recvs(r_xprt, false); 1383 - out_badstatus: 1383 + out: 1384 1384 rpcrdma_recv_buffer_put(rep); 1385 1385 }
+5 -3
net/sunrpc/xprtrdma/svc_rdma_backchannel.c
··· 200 200 svc_rdma_send_ctxt_put(rdma, ctxt); 201 201 goto drop_connection; 202 202 } 203 - return rc; 203 + return 0; 204 204 205 205 drop_connection: 206 206 dprintk("svcrdma: failed to send bc call\n"); 207 - xprt_disconnect_done(xprt); 208 207 return -ENOTCONN; 209 208 } 210 209 ··· 224 225 225 226 ret = -ENOTCONN; 226 227 rdma = container_of(sxprt, struct svcxprt_rdma, sc_xprt); 227 - if (!test_bit(XPT_DEAD, &sxprt->xpt_flags)) 228 + if (!test_bit(XPT_DEAD, &sxprt->xpt_flags)) { 228 229 ret = rpcrdma_bc_send_request(rdma, rqst); 230 + if (ret == -ENOTCONN) 231 + svc_close_xprt(sxprt); 232 + } 229 233 230 234 mutex_unlock(&sxprt->xpt_mutex); 231 235
+35 -56
net/sunrpc/xprtrdma/transport.c
··· 268 268 { 269 269 struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); 270 270 271 - trace_xprtrdma_inject_dsc(r_xprt); 271 + trace_xprtrdma_op_inject_dsc(r_xprt); 272 272 rdma_disconnect(r_xprt->rx_ia.ri_id); 273 273 } 274 274 ··· 284 284 { 285 285 struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); 286 286 287 - trace_xprtrdma_destroy(r_xprt); 287 + trace_xprtrdma_op_destroy(r_xprt); 288 288 289 289 cancel_delayed_work_sync(&r_xprt->rx_connect_worker); 290 290 ··· 318 318 struct sockaddr *sap; 319 319 int rc; 320 320 321 - if (args->addrlen > sizeof(xprt->addr)) { 322 - dprintk("RPC: %s: address too large\n", __func__); 321 + if (args->addrlen > sizeof(xprt->addr)) 323 322 return ERR_PTR(-EBADF); 324 - } 325 323 326 324 xprt = xprt_alloc(args->net, sizeof(struct rpcrdma_xprt), 0, 0); 327 - if (xprt == NULL) { 328 - dprintk("RPC: %s: couldn't allocate rpcrdma_xprt\n", 329 - __func__); 325 + if (!xprt) 330 326 return ERR_PTR(-ENOMEM); 331 - } 332 327 333 328 /* 60 second timeout, no retries */ 334 329 xprt->timeout = &xprt_rdma_default_timeout; ··· 394 399 INIT_DELAYED_WORK(&new_xprt->rx_connect_worker, 395 400 xprt_rdma_connect_worker); 396 401 397 - xprt->max_payload = new_xprt->rx_ia.ri_ops->ro_maxpages(new_xprt); 402 + xprt->max_payload = frwr_maxpages(new_xprt); 398 403 if (xprt->max_payload == 0) 399 404 goto out4; 400 405 xprt->max_payload <<= PAGE_SHIFT; ··· 418 423 out2: 419 424 rpcrdma_ia_close(&new_xprt->rx_ia); 420 425 out1: 421 - trace_xprtrdma_destroy(new_xprt); 426 + trace_xprtrdma_op_destroy(new_xprt); 422 427 xprt_rdma_free_addresses(xprt); 423 428 xprt_free(xprt); 424 429 return ERR_PTR(rc); ··· 428 433 * xprt_rdma_close - close a transport connection 429 434 * @xprt: transport context 430 435 * 431 - * Called during transport shutdown, reconnect, or device removal. 436 + * Called during autoclose or device removal. 437 + * 432 438 * Caller holds @xprt's send lock to prevent activity on this 433 439 * transport while the connection is torn down. 434 440 */ 435 - static void 436 - xprt_rdma_close(struct rpc_xprt *xprt) 441 + void xprt_rdma_close(struct rpc_xprt *xprt) 437 442 { 438 443 struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); 439 444 struct rpcrdma_ep *ep = &r_xprt->rx_ep; 440 445 struct rpcrdma_ia *ia = &r_xprt->rx_ia; 441 446 442 - dprintk("RPC: %s: closing xprt %p\n", __func__, xprt); 447 + might_sleep(); 448 + 449 + trace_xprtrdma_op_close(r_xprt); 450 + 451 + /* Prevent marshaling and sending of new requests */ 452 + xprt_clear_connected(xprt); 443 453 444 454 if (test_and_clear_bit(RPCRDMA_IAF_REMOVING, &ia->ri_flags)) { 445 - xprt_clear_connected(xprt); 446 455 rpcrdma_ia_remove(ia); 447 - return; 456 + goto out; 448 457 } 458 + 449 459 if (ep->rep_connected == -ENODEV) 450 460 return; 451 461 if (ep->rep_connected > 0) 452 462 xprt->reestablish_timeout = 0; 453 - xprt_disconnect_done(xprt); 454 463 rpcrdma_ep_disconnect(ep, ia); 455 464 456 465 /* Prepare @xprt for the next connection by reinitializing ··· 462 463 */ 463 464 r_xprt->rx_buf.rb_credits = 1; 464 465 xprt->cwnd = RPC_CWNDSHIFT; 466 + 467 + out: 468 + ++xprt->connect_cookie; 469 + xprt_disconnect_done(xprt); 465 470 } 466 471 467 472 /** ··· 528 525 { 529 526 struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); 530 527 528 + trace_xprtrdma_op_connect(r_xprt); 531 529 if (r_xprt->rx_ep.rep_connected != 0) { 532 530 /* Reconnect */ 533 531 schedule_delayed_work(&r_xprt->rx_connect_worker, ··· 663 659 664 660 rqst->rq_buffer = req->rl_sendbuf->rg_base; 665 661 rqst->rq_rbuffer = req->rl_recvbuf->rg_base; 666 - trace_xprtrdma_allocate(task, req); 662 + trace_xprtrdma_op_allocate(task, req); 667 663 return 0; 668 664 669 665 out_fail: 670 - trace_xprtrdma_allocate(task, NULL); 666 + trace_xprtrdma_op_allocate(task, NULL); 671 667 return -ENOMEM; 672 668 } 673 669 ··· 686 682 687 683 if (test_bit(RPCRDMA_REQ_F_PENDING, &req->rl_flags)) 688 684 rpcrdma_release_rqst(r_xprt, req); 689 - trace_xprtrdma_rpc_done(task, req); 685 + trace_xprtrdma_op_free(task, req); 690 686 } 691 687 692 688 /** ··· 700 696 * %-ENOTCONN if the caller should reconnect and call again 701 697 * %-EAGAIN if the caller should call again 702 698 * %-ENOBUFS if the caller should call again after a delay 703 - * %-EIO if a permanent error occurred and the request was not 704 - * sent. Do not try to send this message again. 699 + * %-EMSGSIZE if encoding ran out of buffer space. The request 700 + * was not sent. Do not try to send this message again. 701 + * %-EIO if an I/O error occurred. The request was not sent. 702 + * Do not try to send this message again. 705 703 */ 706 704 static int 707 705 xprt_rdma_send_request(struct rpc_rqst *rqst) ··· 719 713 #endif /* CONFIG_SUNRPC_BACKCHANNEL */ 720 714 721 715 if (!xprt_connected(xprt)) 722 - goto drop_connection; 716 + return -ENOTCONN; 723 717 724 718 if (!xprt_request_get_cong(xprt, rqst)) 725 719 return -EBADSLT; ··· 751 745 if (rc != -ENOTCONN) 752 746 return rc; 753 747 drop_connection: 754 - xprt_disconnect_done(xprt); 755 - return -ENOTCONN; /* implies disconnect */ 748 + xprt_rdma_close(xprt); 749 + return -ENOTCONN; 756 750 } 757 751 758 752 void xprt_rdma_print_stats(struct rpc_xprt *xprt, struct seq_file *seq) ··· 849 843 850 844 void xprt_rdma_cleanup(void) 851 845 { 852 - int rc; 853 - 854 - dprintk("RPCRDMA Module Removed, deregister RPC RDMA transport\n"); 855 846 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 856 847 if (sunrpc_table_header) { 857 848 unregister_sysctl_table(sunrpc_table_header); 858 849 sunrpc_table_header = NULL; 859 850 } 860 851 #endif 861 - rc = xprt_unregister_transport(&xprt_rdma); 862 - if (rc) 863 - dprintk("RPC: %s: xprt_unregister returned %i\n", 864 - __func__, rc); 865 852 866 - rpcrdma_destroy_wq(); 867 - 868 - rc = xprt_unregister_transport(&xprt_rdma_bc); 869 - if (rc) 870 - dprintk("RPC: %s: xprt_unregister(bc) returned %i\n", 871 - __func__, rc); 853 + xprt_unregister_transport(&xprt_rdma); 854 + xprt_unregister_transport(&xprt_rdma_bc); 872 855 } 873 856 874 857 int xprt_rdma_init(void) 875 858 { 876 859 int rc; 877 860 878 - rc = rpcrdma_alloc_wq(); 861 + rc = xprt_register_transport(&xprt_rdma); 879 862 if (rc) 880 863 return rc; 881 - 882 - rc = xprt_register_transport(&xprt_rdma); 883 - if (rc) { 884 - rpcrdma_destroy_wq(); 885 - return rc; 886 - } 887 864 888 865 rc = xprt_register_transport(&xprt_rdma_bc); 889 866 if (rc) { 890 867 xprt_unregister_transport(&xprt_rdma); 891 - rpcrdma_destroy_wq(); 892 868 return rc; 893 869 } 894 - 895 - dprintk("RPCRDMA Module Init, register RPC RDMA transport\n"); 896 - 897 - dprintk("Defaults:\n"); 898 - dprintk("\tSlots %d\n" 899 - "\tMaxInlineRead %d\n\tMaxInlineWrite %d\n", 900 - xprt_rdma_slot_table_entries, 901 - xprt_rdma_max_inline_read, xprt_rdma_max_inline_write); 902 - dprintk("\tPadding 0\n\tMemreg %d\n", xprt_rdma_memreg_strategy); 903 870 904 871 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 905 872 if (!sunrpc_table_header)
+105 -150
net/sunrpc/xprtrdma/verbs.c
··· 78 78 static void rpcrdma_mrs_destroy(struct rpcrdma_buffer *buf); 79 79 static int rpcrdma_create_rep(struct rpcrdma_xprt *r_xprt, bool temp); 80 80 static void rpcrdma_dma_unmap_regbuf(struct rpcrdma_regbuf *rb); 81 + static void rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp); 81 82 82 - struct workqueue_struct *rpcrdma_receive_wq __read_mostly; 83 - 84 - int 85 - rpcrdma_alloc_wq(void) 86 - { 87 - struct workqueue_struct *recv_wq; 88 - 89 - recv_wq = alloc_workqueue("xprtrdma_receive", 90 - WQ_MEM_RECLAIM | WQ_HIGHPRI, 91 - 0); 92 - if (!recv_wq) 93 - return -ENOMEM; 94 - 95 - rpcrdma_receive_wq = recv_wq; 96 - return 0; 97 - } 98 - 99 - void 100 - rpcrdma_destroy_wq(void) 101 - { 102 - struct workqueue_struct *wq; 103 - 104 - if (rpcrdma_receive_wq) { 105 - wq = rpcrdma_receive_wq; 106 - rpcrdma_receive_wq = NULL; 107 - destroy_workqueue(wq); 108 - } 109 - } 110 - 111 - /** 112 - * rpcrdma_disconnect_worker - Force a disconnect 113 - * @work: endpoint to be disconnected 114 - * 115 - * Provider callbacks can possibly run in an IRQ context. This function 116 - * is invoked in a worker thread to guarantee that disconnect wake-up 117 - * calls are always done in process context. 83 + /* Wait for outstanding transport work to finish. 118 84 */ 119 - static void 120 - rpcrdma_disconnect_worker(struct work_struct *work) 85 + static void rpcrdma_xprt_drain(struct rpcrdma_xprt *r_xprt) 121 86 { 122 - struct rpcrdma_ep *ep = container_of(work, struct rpcrdma_ep, 123 - rep_disconnect_worker.work); 124 - struct rpcrdma_xprt *r_xprt = 125 - container_of(ep, struct rpcrdma_xprt, rx_ep); 87 + struct rpcrdma_buffer *buf = &r_xprt->rx_buf; 88 + struct rpcrdma_ia *ia = &r_xprt->rx_ia; 126 89 127 - xprt_force_disconnect(&r_xprt->rx_xprt); 90 + /* Flush Receives, then wait for deferred Reply work 91 + * to complete. 92 + */ 93 + ib_drain_qp(ia->ri_id->qp); 94 + drain_workqueue(buf->rb_completion_wq); 95 + 96 + /* Deferred Reply processing might have scheduled 97 + * local invalidations. 98 + */ 99 + ib_drain_sq(ia->ri_id->qp); 128 100 } 129 101 130 102 /** ··· 115 143 rx_ep); 116 144 117 145 trace_xprtrdma_qp_event(r_xprt, event); 118 - pr_err("rpcrdma: %s on device %s connected to %s:%s\n", 119 - ib_event_msg(event->event), event->device->name, 120 - rpcrdma_addrstr(r_xprt), rpcrdma_portstr(r_xprt)); 121 - 122 - if (ep->rep_connected == 1) { 123 - ep->rep_connected = -EIO; 124 - schedule_delayed_work(&ep->rep_disconnect_worker, 0); 125 - wake_up_all(&ep->rep_connect_wait); 126 - } 127 146 } 128 147 129 148 /** ··· 152 189 struct ib_cqe *cqe = wc->wr_cqe; 153 190 struct rpcrdma_rep *rep = container_of(cqe, struct rpcrdma_rep, 154 191 rr_cqe); 192 + struct rpcrdma_xprt *r_xprt = rep->rr_rxprt; 155 193 156 - /* WARNING: Only wr_id and status are reliable at this point */ 194 + /* WARNING: Only wr_cqe and status are reliable at this point */ 157 195 trace_xprtrdma_wc_receive(wc); 196 + --r_xprt->rx_ep.rep_receive_count; 158 197 if (wc->status != IB_WC_SUCCESS) 159 - goto out_fail; 198 + goto out_flushed; 160 199 161 200 /* status == SUCCESS means all fields in wc are trustworthy */ 162 201 rpcrdma_set_xdrlen(&rep->rr_hdrbuf, wc->byte_len); ··· 169 204 rdmab_addr(rep->rr_rdmabuf), 170 205 wc->byte_len, DMA_FROM_DEVICE); 171 206 172 - out_schedule: 207 + rpcrdma_post_recvs(r_xprt, false); 173 208 rpcrdma_reply_handler(rep); 174 209 return; 175 210 176 - out_fail: 211 + out_flushed: 177 212 if (wc->status != IB_WC_WR_FLUSH_ERR) 178 213 pr_err("rpcrdma: Recv: %s (%u/0x%x)\n", 179 214 ib_wc_status_msg(wc->status), 180 215 wc->status, wc->vendor_err); 181 - rpcrdma_set_xdrlen(&rep->rr_hdrbuf, 0); 182 - goto out_schedule; 216 + rpcrdma_recv_buffer_put(rep); 183 217 } 184 218 185 219 static void ··· 280 316 ep->rep_connected = -EAGAIN; 281 317 goto disconnected; 282 318 case RDMA_CM_EVENT_DISCONNECTED: 283 - ++xprt->connect_cookie; 284 319 ep->rep_connected = -ECONNABORTED; 285 320 disconnected: 286 321 xprt_force_disconnect(xprt); ··· 289 326 break; 290 327 } 291 328 292 - dprintk("RPC: %s: %s:%s on %s/%s: %s\n", __func__, 329 + dprintk("RPC: %s: %s:%s on %s/frwr: %s\n", __func__, 293 330 rpcrdma_addrstr(r_xprt), rpcrdma_portstr(r_xprt), 294 - ia->ri_device->name, ia->ri_ops->ro_displayname, 295 - rdma_event_msg(event->event)); 331 + ia->ri_device->name, rdma_event_msg(event->event)); 296 332 return 0; 297 333 } 298 334 ··· 309 347 310 348 id = rdma_create_id(xprt->rx_xprt.xprt_net, rpcrdma_cm_event_handler, 311 349 xprt, RDMA_PS_TCP, IB_QPT_RC); 312 - if (IS_ERR(id)) { 313 - rc = PTR_ERR(id); 314 - dprintk("RPC: %s: rdma_create_id() failed %i\n", 315 - __func__, rc); 350 + if (IS_ERR(id)) 316 351 return id; 317 - } 318 352 319 353 ia->ri_async_rc = -ETIMEDOUT; 320 354 rc = rdma_resolve_addr(id, NULL, 321 355 (struct sockaddr *)&xprt->rx_xprt.addr, 322 356 RDMA_RESOLVE_TIMEOUT); 323 - if (rc) { 324 - dprintk("RPC: %s: rdma_resolve_addr() failed %i\n", 325 - __func__, rc); 357 + if (rc) 326 358 goto out; 327 - } 328 359 rc = wait_for_completion_interruptible_timeout(&ia->ri_done, wtimeout); 329 360 if (rc < 0) { 330 361 trace_xprtrdma_conn_tout(xprt); ··· 330 375 331 376 ia->ri_async_rc = -ETIMEDOUT; 332 377 rc = rdma_resolve_route(id, RDMA_RESOLVE_TIMEOUT); 333 - if (rc) { 334 - dprintk("RPC: %s: rdma_resolve_route() failed %i\n", 335 - __func__, rc); 378 + if (rc) 336 379 goto out; 337 - } 338 380 rc = wait_for_completion_interruptible_timeout(&ia->ri_done, wtimeout); 339 381 if (rc < 0) { 340 382 trace_xprtrdma_conn_tout(xprt); ··· 381 429 382 430 switch (xprt_rdma_memreg_strategy) { 383 431 case RPCRDMA_FRWR: 384 - if (frwr_is_supported(ia)) { 385 - ia->ri_ops = &rpcrdma_frwr_memreg_ops; 432 + if (frwr_is_supported(ia)) 386 433 break; 387 - } 388 - /*FALLTHROUGH*/ 389 - case RPCRDMA_MTHCAFMR: 390 - if (fmr_is_supported(ia)) { 391 - ia->ri_ops = &rpcrdma_fmr_memreg_ops; 392 - break; 393 - } 394 434 /*FALLTHROUGH*/ 395 435 default: 396 436 pr_err("rpcrdma: Device %s does not support memreg mode %d\n", ··· 425 481 * connection is already gone. 426 482 */ 427 483 if (ia->ri_id->qp) { 428 - ib_drain_qp(ia->ri_id->qp); 484 + rpcrdma_xprt_drain(r_xprt); 429 485 rdma_destroy_qp(ia->ri_id); 430 486 ia->ri_id->qp = NULL; 431 487 } ··· 496 552 } 497 553 ia->ri_max_send_sges = max_sge; 498 554 499 - rc = ia->ri_ops->ro_open(ia, ep, cdata); 555 + rc = frwr_open(ia, ep, cdata); 500 556 if (rc) 501 557 return rc; 502 558 ··· 523 579 cdata->max_requests >> 2); 524 580 ep->rep_send_count = ep->rep_send_batch; 525 581 init_waitqueue_head(&ep->rep_connect_wait); 526 - INIT_DELAYED_WORK(&ep->rep_disconnect_worker, 527 - rpcrdma_disconnect_worker); 582 + ep->rep_receive_count = 0; 528 583 529 584 sendcq = ib_alloc_cq(ia->ri_device, NULL, 530 585 ep->rep_attr.cap.max_send_wr + 1, 531 586 1, IB_POLL_WORKQUEUE); 532 587 if (IS_ERR(sendcq)) { 533 588 rc = PTR_ERR(sendcq); 534 - dprintk("RPC: %s: failed to create send CQ: %i\n", 535 - __func__, rc); 536 589 goto out1; 537 590 } 538 591 ··· 538 597 0, IB_POLL_WORKQUEUE); 539 598 if (IS_ERR(recvcq)) { 540 599 rc = PTR_ERR(recvcq); 541 - dprintk("RPC: %s: failed to create recv CQ: %i\n", 542 - __func__, rc); 543 600 goto out2; 544 601 } 545 602 ··· 550 611 /* Prepare RDMA-CM private message */ 551 612 pmsg->cp_magic = rpcrdma_cmp_magic; 552 613 pmsg->cp_version = RPCRDMA_CMP_VERSION; 553 - pmsg->cp_flags |= ia->ri_ops->ro_send_w_inv_ok; 614 + pmsg->cp_flags |= RPCRDMA_CMP_F_SND_W_INV_OK; 554 615 pmsg->cp_send_size = rpcrdma_encode_buffer_size(cdata->inline_wsize); 555 616 pmsg->cp_recv_size = rpcrdma_encode_buffer_size(cdata->inline_rsize); 556 617 ep->rep_remote_cma.private_data = pmsg; ··· 592 653 void 593 654 rpcrdma_ep_destroy(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia) 594 655 { 595 - cancel_delayed_work_sync(&ep->rep_disconnect_worker); 596 - 597 656 if (ia->ri_id && ia->ri_id->qp) { 598 657 rpcrdma_ep_disconnect(ep, ia); 599 658 rdma_destroy_qp(ia->ri_id); ··· 677 740 } 678 741 679 742 err = rdma_create_qp(id, ia->ri_pd, &ep->rep_attr); 680 - if (err) { 681 - dprintk("RPC: %s: rdma_create_qp returned %d\n", 682 - __func__, err); 743 + if (err) 683 744 goto out_destroy; 684 - } 685 745 686 746 /* Atomically replace the transport's ID and QP. */ 687 747 rc = 0; ··· 709 775 dprintk("RPC: %s: connecting...\n", __func__); 710 776 rc = rdma_create_qp(ia->ri_id, ia->ri_pd, &ep->rep_attr); 711 777 if (rc) { 712 - dprintk("RPC: %s: rdma_create_qp failed %i\n", 713 - __func__, rc); 714 778 rc = -ENETUNREACH; 715 779 goto out_noupdate; 716 780 } ··· 730 798 rpcrdma_post_recvs(r_xprt, true); 731 799 732 800 rc = rdma_connect(ia->ri_id, &ep->rep_remote_cma); 733 - if (rc) { 734 - dprintk("RPC: %s: rdma_connect() failed with %i\n", 735 - __func__, rc); 801 + if (rc) 736 802 goto out; 737 - } 738 803 739 804 wait_event_interruptible(ep->rep_connect_wait, ep->rep_connected != 0); 740 805 if (ep->rep_connected <= 0) { ··· 751 822 return rc; 752 823 } 753 824 754 - /* 755 - * rpcrdma_ep_disconnect 825 + /** 826 + * rpcrdma_ep_disconnect - Disconnect underlying transport 827 + * @ep: endpoint to disconnect 828 + * @ia: associated interface adapter 756 829 * 757 830 * This is separate from destroy to facilitate the ability 758 831 * to reconnect without recreating the endpoint. ··· 765 834 void 766 835 rpcrdma_ep_disconnect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia) 767 836 { 837 + struct rpcrdma_xprt *r_xprt = container_of(ep, struct rpcrdma_xprt, 838 + rx_ep); 768 839 int rc; 769 840 841 + /* returns without wait if ID is not connected */ 770 842 rc = rdma_disconnect(ia->ri_id); 771 843 if (!rc) 772 - /* returns without wait if not connected */ 773 844 wait_event_interruptible(ep->rep_connect_wait, 774 845 ep->rep_connected != 1); 775 846 else 776 847 ep->rep_connected = rc; 777 - trace_xprtrdma_disconnect(container_of(ep, struct rpcrdma_xprt, 778 - rx_ep), rc); 848 + trace_xprtrdma_disconnect(r_xprt, rc); 779 849 780 - ib_drain_qp(ia->ri_id->qp); 850 + rpcrdma_xprt_drain(r_xprt); 781 851 } 782 852 783 853 /* Fixed-size circular FIFO queue. This implementation is wait-free and ··· 966 1034 if (!mr) 967 1035 break; 968 1036 969 - rc = ia->ri_ops->ro_init_mr(ia, mr); 1037 + rc = frwr_init_mr(ia, mr); 970 1038 if (rc) { 971 1039 kfree(mr); 972 1040 break; ··· 1021 1089 req->rl_buffer = buffer; 1022 1090 INIT_LIST_HEAD(&req->rl_registered); 1023 1091 1024 - spin_lock(&buffer->rb_reqslock); 1092 + spin_lock(&buffer->rb_lock); 1025 1093 list_add(&req->rl_all, &buffer->rb_allreqs); 1026 - spin_unlock(&buffer->rb_reqslock); 1094 + spin_unlock(&buffer->rb_lock); 1027 1095 return req; 1028 1096 } 1029 1097 ··· 1066 1134 out_free: 1067 1135 kfree(rep); 1068 1136 out: 1069 - dprintk("RPC: %s: reply buffer %d alloc failed\n", 1070 - __func__, rc); 1071 1137 return rc; 1072 1138 } 1073 1139 ··· 1089 1159 1090 1160 INIT_LIST_HEAD(&buf->rb_send_bufs); 1091 1161 INIT_LIST_HEAD(&buf->rb_allreqs); 1092 - spin_lock_init(&buf->rb_reqslock); 1093 1162 for (i = 0; i < buf->rb_max_requests; i++) { 1094 1163 struct rpcrdma_req *req; 1095 1164 ··· 1103 1174 } 1104 1175 1105 1176 buf->rb_credits = 1; 1106 - buf->rb_posted_receives = 0; 1107 1177 INIT_LIST_HEAD(&buf->rb_recv_bufs); 1108 1178 1109 1179 rc = rpcrdma_sendctxs_create(r_xprt); 1110 1180 if (rc) 1181 + goto out; 1182 + 1183 + buf->rb_completion_wq = alloc_workqueue("rpcrdma-%s", 1184 + WQ_MEM_RECLAIM | WQ_HIGHPRI, 1185 + 0, 1186 + r_xprt->rx_xprt.address_strings[RPC_DISPLAY_ADDR]); 1187 + if (!buf->rb_completion_wq) 1111 1188 goto out; 1112 1189 1113 1190 return 0; ··· 1129 1194 kfree(rep); 1130 1195 } 1131 1196 1197 + /** 1198 + * rpcrdma_req_destroy - Destroy an rpcrdma_req object 1199 + * @req: unused object to be destroyed 1200 + * 1201 + * This function assumes that the caller prevents concurrent device 1202 + * unload and transport tear-down. 1203 + */ 1132 1204 void 1133 - rpcrdma_destroy_req(struct rpcrdma_req *req) 1205 + rpcrdma_req_destroy(struct rpcrdma_req *req) 1134 1206 { 1207 + list_del(&req->rl_all); 1208 + 1135 1209 rpcrdma_free_regbuf(req->rl_recvbuf); 1136 1210 rpcrdma_free_regbuf(req->rl_sendbuf); 1137 1211 rpcrdma_free_regbuf(req->rl_rdmabuf); ··· 1152 1208 { 1153 1209 struct rpcrdma_xprt *r_xprt = container_of(buf, struct rpcrdma_xprt, 1154 1210 rx_buf); 1155 - struct rpcrdma_ia *ia = rdmab_to_ia(buf); 1156 1211 struct rpcrdma_mr *mr; 1157 1212 unsigned int count; 1158 1213 ··· 1167 1224 if (!list_empty(&mr->mr_list)) 1168 1225 list_del(&mr->mr_list); 1169 1226 1170 - ia->ri_ops->ro_release_mr(mr); 1227 + frwr_release_mr(mr); 1171 1228 count++; 1172 1229 spin_lock(&buf->rb_mrlock); 1173 1230 } ··· 1177 1234 dprintk("RPC: %s: released %u MRs\n", __func__, count); 1178 1235 } 1179 1236 1237 + /** 1238 + * rpcrdma_buffer_destroy - Release all hw resources 1239 + * @buf: root control block for resources 1240 + * 1241 + * ORDERING: relies on a prior ib_drain_qp : 1242 + * - No more Send or Receive completions can occur 1243 + * - All MRs, reps, and reqs are returned to their free lists 1244 + */ 1180 1245 void 1181 1246 rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf) 1182 1247 { 1183 1248 cancel_delayed_work_sync(&buf->rb_refresh_worker); 1249 + 1250 + if (buf->rb_completion_wq) { 1251 + destroy_workqueue(buf->rb_completion_wq); 1252 + buf->rb_completion_wq = NULL; 1253 + } 1184 1254 1185 1255 rpcrdma_sendctxs_destroy(buf); 1186 1256 ··· 1206 1250 rpcrdma_destroy_rep(rep); 1207 1251 } 1208 1252 1209 - spin_lock(&buf->rb_reqslock); 1210 - while (!list_empty(&buf->rb_allreqs)) { 1253 + while (!list_empty(&buf->rb_send_bufs)) { 1211 1254 struct rpcrdma_req *req; 1212 1255 1213 - req = list_first_entry(&buf->rb_allreqs, 1214 - struct rpcrdma_req, rl_all); 1215 - list_del(&req->rl_all); 1216 - 1217 - spin_unlock(&buf->rb_reqslock); 1218 - rpcrdma_destroy_req(req); 1219 - spin_lock(&buf->rb_reqslock); 1256 + req = list_first_entry(&buf->rb_send_bufs, 1257 + struct rpcrdma_req, rl_list); 1258 + list_del(&req->rl_list); 1259 + rpcrdma_req_destroy(req); 1220 1260 } 1221 - spin_unlock(&buf->rb_reqslock); 1222 1261 1223 1262 rpcrdma_mrs_destroy(buf); 1224 1263 } ··· 1280 1329 { 1281 1330 struct rpcrdma_xprt *r_xprt = mr->mr_xprt; 1282 1331 1283 - trace_xprtrdma_mr_unmap(mr); 1284 - ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 1285 - mr->mr_sg, mr->mr_nents, mr->mr_dir); 1332 + if (mr->mr_dir != DMA_NONE) { 1333 + trace_xprtrdma_mr_unmap(mr); 1334 + ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 1335 + mr->mr_sg, mr->mr_nents, mr->mr_dir); 1336 + mr->mr_dir = DMA_NONE; 1337 + } 1286 1338 __rpcrdma_mr_put(&r_xprt->rx_buf, mr); 1287 1339 } 1288 1340 ··· 1364 1410 * 1365 1411 * xprtrdma uses a regbuf for posting an outgoing RDMA SEND, or for 1366 1412 * receiving the payload of RDMA RECV operations. During Long Calls 1367 - * or Replies they may be registered externally via ro_map. 1413 + * or Replies they may be registered externally via frwr_map. 1368 1414 */ 1369 1415 struct rpcrdma_regbuf * 1370 1416 rpcrdma_alloc_regbuf(size_t size, enum dma_data_direction direction, ··· 1400 1446 (void *)rb->rg_base, 1401 1447 rdmab_length(rb), 1402 1448 rb->rg_direction); 1403 - if (ib_dma_mapping_error(device, rdmab_addr(rb))) 1449 + if (ib_dma_mapping_error(device, rdmab_addr(rb))) { 1450 + trace_xprtrdma_dma_maperr(rdmab_addr(rb)); 1404 1451 return false; 1452 + } 1405 1453 1406 1454 rb->rg_device = device; 1407 1455 rb->rg_iov.lkey = ia->ri_pd->local_dma_lkey; ··· 1435 1479 kfree(rb); 1436 1480 } 1437 1481 1438 - /* 1439 - * Prepost any receive buffer, then post send. 1482 + /** 1483 + * rpcrdma_ep_post - Post WRs to a transport's Send Queue 1484 + * @ia: transport's device information 1485 + * @ep: transport's RDMA endpoint information 1486 + * @req: rpcrdma_req containing the Send WR to post 1440 1487 * 1441 - * Receive buffer is donated to hardware, reclaimed upon recv completion. 1488 + * Returns 0 if the post was successful, otherwise -ENOTCONN 1489 + * is returned. 1442 1490 */ 1443 1491 int 1444 1492 rpcrdma_ep_post(struct rpcrdma_ia *ia, ··· 1461 1501 --ep->rep_send_count; 1462 1502 } 1463 1503 1464 - rc = ia->ri_ops->ro_send(ia, req); 1504 + rc = frwr_send(ia, req); 1465 1505 trace_xprtrdma_post_send(req, rc); 1466 1506 if (rc) 1467 1507 return -ENOTCONN; 1468 1508 return 0; 1469 1509 } 1470 1510 1471 - /** 1472 - * rpcrdma_post_recvs - Maybe post some Receive buffers 1473 - * @r_xprt: controlling transport 1474 - * @temp: when true, allocate temp rpcrdma_rep objects 1475 - * 1476 - */ 1477 - void 1511 + static void 1478 1512 rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp) 1479 1513 { 1480 1514 struct rpcrdma_buffer *buf = &r_xprt->rx_buf; 1515 + struct rpcrdma_ep *ep = &r_xprt->rx_ep; 1481 1516 struct ib_recv_wr *wr, *bad_wr; 1482 1517 int needed, count, rc; 1483 1518 1484 1519 rc = 0; 1485 1520 count = 0; 1486 1521 needed = buf->rb_credits + (buf->rb_bc_srv_max_requests << 1); 1487 - if (buf->rb_posted_receives > needed) 1522 + if (ep->rep_receive_count > needed) 1488 1523 goto out; 1489 - needed -= buf->rb_posted_receives; 1524 + needed -= ep->rep_receive_count; 1490 1525 1491 1526 count = 0; 1492 1527 wr = NULL; ··· 1529 1574 --count; 1530 1575 } 1531 1576 } 1532 - buf->rb_posted_receives += count; 1577 + ep->rep_receive_count += count; 1533 1578 out: 1534 1579 trace_xprtrdma_post_recvs(r_xprt, count, rc); 1535 1580 }
+24 -56
net/sunrpc/xprtrdma/xprt_rdma.h
··· 66 66 * Interface Adapter -- one per transport instance 67 67 */ 68 68 struct rpcrdma_ia { 69 - const struct rpcrdma_memreg_ops *ri_ops; 70 69 struct ib_device *ri_device; 71 70 struct rdma_cm_id *ri_id; 72 71 struct ib_pd *ri_pd; ··· 80 81 bool ri_implicit_roundup; 81 82 enum ib_mr_type ri_mrtype; 82 83 unsigned long ri_flags; 83 - struct ib_qp_attr ri_qp_attr; 84 - struct ib_qp_init_attr ri_qp_init_attr; 85 84 }; 86 85 87 86 enum { ··· 98 101 wait_queue_head_t rep_connect_wait; 99 102 struct rpcrdma_connect_private rep_cm_private; 100 103 struct rdma_conn_param rep_remote_cma; 101 - struct delayed_work rep_disconnect_worker; 104 + int rep_receive_count; 102 105 }; 103 106 104 107 /* Pre-allocate extra Work Requests for handling backward receives ··· 259 262 }; 260 263 }; 261 264 262 - struct rpcrdma_fmr { 263 - struct ib_fmr *fm_mr; 264 - u64 *fm_physaddrs; 265 - }; 266 - 267 265 struct rpcrdma_mr { 268 266 struct list_head mr_list; 269 267 struct scatterlist *mr_sg; 270 268 int mr_nents; 271 269 enum dma_data_direction mr_dir; 272 - union { 273 - struct rpcrdma_fmr fmr; 274 - struct rpcrdma_frwr frwr; 275 - }; 270 + struct rpcrdma_frwr frwr; 276 271 struct rpcrdma_xprt *mr_xprt; 277 272 u32 mr_handle; 278 273 u32 mr_length; ··· 390 401 spinlock_t rb_lock; /* protect buf lists */ 391 402 struct list_head rb_send_bufs; 392 403 struct list_head rb_recv_bufs; 404 + struct list_head rb_allreqs; 405 + 393 406 unsigned long rb_flags; 394 407 u32 rb_max_requests; 395 408 u32 rb_credits; /* most recent credit grant */ 396 - int rb_posted_receives; 397 409 398 410 u32 rb_bc_srv_max_requests; 399 - spinlock_t rb_reqslock; /* protect rb_allreqs */ 400 - struct list_head rb_allreqs; 401 - 402 411 u32 rb_bc_max_requests; 403 412 413 + struct workqueue_struct *rb_completion_wq; 404 414 struct delayed_work rb_refresh_worker; 405 415 }; 406 - #define rdmab_to_ia(b) (&container_of((b), struct rpcrdma_xprt, rx_buf)->rx_ia) 407 416 408 417 /* rb_flags */ 409 418 enum { ··· 450 463 unsigned long nomsg_call_count; 451 464 unsigned long bcall_count; 452 465 }; 453 - 454 - /* 455 - * Per-registration mode operations 456 - */ 457 - struct rpcrdma_xprt; 458 - struct rpcrdma_memreg_ops { 459 - struct rpcrdma_mr_seg * 460 - (*ro_map)(struct rpcrdma_xprt *, 461 - struct rpcrdma_mr_seg *, int, bool, 462 - struct rpcrdma_mr **); 463 - int (*ro_send)(struct rpcrdma_ia *ia, 464 - struct rpcrdma_req *req); 465 - void (*ro_reminv)(struct rpcrdma_rep *rep, 466 - struct list_head *mrs); 467 - void (*ro_unmap_sync)(struct rpcrdma_xprt *, 468 - struct list_head *); 469 - int (*ro_open)(struct rpcrdma_ia *, 470 - struct rpcrdma_ep *, 471 - struct rpcrdma_create_data_internal *); 472 - size_t (*ro_maxpages)(struct rpcrdma_xprt *); 473 - int (*ro_init_mr)(struct rpcrdma_ia *, 474 - struct rpcrdma_mr *); 475 - void (*ro_release_mr)(struct rpcrdma_mr *mr); 476 - const char *ro_displayname; 477 - const int ro_send_w_inv_ok; 478 - }; 479 - 480 - extern const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops; 481 - extern const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops; 482 466 483 467 /* 484 468 * RPCRDMA transport -- encapsulates the structures above for ··· 502 544 int rpcrdma_ia_open(struct rpcrdma_xprt *xprt); 503 545 void rpcrdma_ia_remove(struct rpcrdma_ia *ia); 504 546 void rpcrdma_ia_close(struct rpcrdma_ia *); 505 - bool frwr_is_supported(struct rpcrdma_ia *); 506 - bool fmr_is_supported(struct rpcrdma_ia *); 507 - 508 - extern struct workqueue_struct *rpcrdma_receive_wq; 509 547 510 548 /* 511 549 * Endpoint calls - xprtrdma/verbs.c ··· 514 560 515 561 int rpcrdma_ep_post(struct rpcrdma_ia *, struct rpcrdma_ep *, 516 562 struct rpcrdma_req *); 517 - void rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp); 518 563 519 564 /* 520 565 * Buffer calls - xprtrdma/verbs.c 521 566 */ 522 567 struct rpcrdma_req *rpcrdma_create_req(struct rpcrdma_xprt *); 523 - void rpcrdma_destroy_req(struct rpcrdma_req *); 568 + void rpcrdma_req_destroy(struct rpcrdma_req *req); 524 569 int rpcrdma_buffer_create(struct rpcrdma_xprt *); 525 570 void rpcrdma_buffer_destroy(struct rpcrdma_buffer *); 526 571 struct rpcrdma_sendctx *rpcrdma_sendctx_get_locked(struct rpcrdma_buffer *buf); ··· 557 604 return __rpcrdma_dma_map_regbuf(ia, rb); 558 605 } 559 606 560 - int rpcrdma_alloc_wq(void); 561 - void rpcrdma_destroy_wq(void); 562 - 563 607 /* 564 608 * Wrappers for chunk registration, shared by read/write chunk code. 565 609 */ ··· 566 616 { 567 617 return writing ? DMA_FROM_DEVICE : DMA_TO_DEVICE; 568 618 } 619 + 620 + /* Memory registration calls xprtrdma/frwr_ops.c 621 + */ 622 + bool frwr_is_supported(struct rpcrdma_ia *); 623 + int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep, 624 + struct rpcrdma_create_data_internal *cdata); 625 + int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr); 626 + void frwr_release_mr(struct rpcrdma_mr *mr); 627 + size_t frwr_maxpages(struct rpcrdma_xprt *r_xprt); 628 + struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, 629 + struct rpcrdma_mr_seg *seg, 630 + int nsegs, bool writing, u32 xid, 631 + struct rpcrdma_mr **mr); 632 + int frwr_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req); 633 + void frwr_reminv(struct rpcrdma_rep *rep, struct list_head *mrs); 634 + void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, 635 + struct list_head *mrs); 569 636 570 637 /* 571 638 * RPC/RDMA protocol calls - xprtrdma/rpc_rdma.c ··· 620 653 extern unsigned int xprt_rdma_max_inline_read; 621 654 void xprt_rdma_format_addresses(struct rpc_xprt *xprt, struct sockaddr *sap); 622 655 void xprt_rdma_free_addresses(struct rpc_xprt *xprt); 656 + void xprt_rdma_close(struct rpc_xprt *xprt); 623 657 void xprt_rdma_print_stats(struct rpc_xprt *xprt, struct seq_file *seq); 624 658 int xprt_rdma_init(void); 625 659 void xprt_rdma_cleanup(void);
+2 -8
net/sunrpc/xprtsock.c
··· 68 68 static unsigned int xprt_min_resvport = RPC_DEF_MIN_RESVPORT; 69 69 static unsigned int xprt_max_resvport = RPC_DEF_MAX_RESVPORT; 70 70 71 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 72 - 73 71 #define XS_TCP_LINGER_TO (15U * HZ) 74 72 static unsigned int xs_tcp_fin_timeout __read_mostly = XS_TCP_LINGER_TO; 75 73 ··· 156 158 }, 157 159 { }, 158 160 }; 159 - 160 - #endif 161 161 162 162 /* 163 163 * Wait duration for a reply from the RPC portmapper. ··· 1585 1589 1586 1590 /** 1587 1591 * xs_udp_timer - called when a retransmit timeout occurs on a UDP transport 1592 + * @xprt: controlling transport 1588 1593 * @task: task that timed out 1589 1594 * 1590 1595 * Adjust the congestion window after a retransmit timeout has occurred. ··· 2243 2246 2244 2247 /** 2245 2248 * xs_tcp_setup_socket - create a TCP socket and connect to a remote endpoint 2249 + * @work: queued work item 2246 2250 * 2247 2251 * Invoked by a work queue tasklet. 2248 2252 */ ··· 3093 3095 */ 3094 3096 int init_socket_xprt(void) 3095 3097 { 3096 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 3097 3098 if (!sunrpc_table_header) 3098 3099 sunrpc_table_header = register_sysctl_table(sunrpc_table); 3099 - #endif 3100 3100 3101 3101 xprt_register_transport(&xs_local_transport); 3102 3102 xprt_register_transport(&xs_udp_transport); ··· 3110 3114 */ 3111 3115 void cleanup_socket_xprt(void) 3112 3116 { 3113 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 3114 3117 if (sunrpc_table_header) { 3115 3118 unregister_sysctl_table(sunrpc_table_header); 3116 3119 sunrpc_table_header = NULL; 3117 3120 } 3118 - #endif 3119 3121 3120 3122 xprt_unregister_transport(&xs_local_transport); 3121 3123 xprt_unregister_transport(&xs_udp_transport);