diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-07-31 14:29:08 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-08-04 08:54:09 -0400 |
commit | a17c2153d2e271b0cbacae9bed83b0eaa41db7e1 (patch) | |
tree | 3c5a73090987278e51aee1a9f185ebe40a00bd65 /net | |
parent | 8572b8e2e3c5f3d990122348c4d2c64dad338611 (diff) |
SUNRPC: Move the bound cred to struct rpc_rqst
This will allow us to save the original generic cred in rpc_message, so
that if we migrate from one server to another, we can generate a new bound
cred without having to punt back to the NFS layer.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/auth.c | 43 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 22 | ||||
-rw-r--r-- | net/sunrpc/auth_null.c | 2 | ||||
-rw-r--r-- | net/sunrpc/auth_unix.c | 6 | ||||
-rw-r--r-- | net/sunrpc/clnt.c | 91 | ||||
-rw-r--r-- | net/sunrpc/sched.c | 2 | ||||
-rw-r--r-- | net/sunrpc/xprt.c | 2 |
7 files changed, 83 insertions, 85 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index d8968faf5ccf..95721426296d 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -477,9 +477,10 @@ rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags) | |||
477 | return rpcauth_lookupcred(auth, lookupflags); | 477 | return rpcauth_lookupcred(auth, lookupflags); |
478 | } | 478 | } |
479 | 479 | ||
480 | int | 480 | static int |
481 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) | 481 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) |
482 | { | 482 | { |
483 | struct rpc_rqst *req = task->tk_rqstp; | ||
483 | struct rpc_cred *new; | 484 | struct rpc_cred *new; |
484 | int lookupflags = 0; | 485 | int lookupflags = 0; |
485 | 486 | ||
@@ -493,9 +494,9 @@ rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) | |||
493 | new = rpcauth_bind_new_cred(task, lookupflags); | 494 | new = rpcauth_bind_new_cred(task, lookupflags); |
494 | if (IS_ERR(new)) | 495 | if (IS_ERR(new)) |
495 | return PTR_ERR(new); | 496 | return PTR_ERR(new); |
496 | if (task->tk_msg.rpc_cred != NULL) | 497 | if (req->rq_cred != NULL) |
497 | put_rpccred(task->tk_msg.rpc_cred); | 498 | put_rpccred(req->rq_cred); |
498 | task->tk_msg.rpc_cred = new; | 499 | req->rq_cred = new; |
499 | return 0; | 500 | return 0; |
500 | } | 501 | } |
501 | 502 | ||
@@ -535,22 +536,10 @@ out_nodestroy: | |||
535 | } | 536 | } |
536 | EXPORT_SYMBOL_GPL(put_rpccred); | 537 | EXPORT_SYMBOL_GPL(put_rpccred); |
537 | 538 | ||
538 | void | ||
539 | rpcauth_unbindcred(struct rpc_task *task) | ||
540 | { | ||
541 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | ||
542 | |||
543 | dprintk("RPC: %5u releasing %s cred %p\n", | ||
544 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | ||
545 | |||
546 | put_rpccred(cred); | ||
547 | task->tk_msg.rpc_cred = NULL; | ||
548 | } | ||
549 | |||
550 | __be32 * | 539 | __be32 * |
551 | rpcauth_marshcred(struct rpc_task *task, __be32 *p) | 540 | rpcauth_marshcred(struct rpc_task *task, __be32 *p) |
552 | { | 541 | { |
553 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 542 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
554 | 543 | ||
555 | dprintk("RPC: %5u marshaling %s cred %p\n", | 544 | dprintk("RPC: %5u marshaling %s cred %p\n", |
556 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | 545 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); |
@@ -561,7 +550,7 @@ rpcauth_marshcred(struct rpc_task *task, __be32 *p) | |||
561 | __be32 * | 550 | __be32 * |
562 | rpcauth_checkverf(struct rpc_task *task, __be32 *p) | 551 | rpcauth_checkverf(struct rpc_task *task, __be32 *p) |
563 | { | 552 | { |
564 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 553 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
565 | 554 | ||
566 | dprintk("RPC: %5u validating %s cred %p\n", | 555 | dprintk("RPC: %5u validating %s cred %p\n", |
567 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | 556 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); |
@@ -573,7 +562,7 @@ int | |||
573 | rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, | 562 | rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, |
574 | __be32 *data, void *obj) | 563 | __be32 *data, void *obj) |
575 | { | 564 | { |
576 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 565 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
577 | 566 | ||
578 | dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", | 567 | dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", |
579 | task->tk_pid, cred->cr_ops->cr_name, cred); | 568 | task->tk_pid, cred->cr_ops->cr_name, cred); |
@@ -587,7 +576,7 @@ int | |||
587 | rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, | 576 | rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, |
588 | __be32 *data, void *obj) | 577 | __be32 *data, void *obj) |
589 | { | 578 | { |
590 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 579 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
591 | 580 | ||
592 | dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", | 581 | dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", |
593 | task->tk_pid, cred->cr_ops->cr_name, cred); | 582 | task->tk_pid, cred->cr_ops->cr_name, cred); |
@@ -601,13 +590,21 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, | |||
601 | int | 590 | int |
602 | rpcauth_refreshcred(struct rpc_task *task) | 591 | rpcauth_refreshcred(struct rpc_task *task) |
603 | { | 592 | { |
604 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 593 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
605 | int err; | 594 | int err; |
606 | 595 | ||
596 | cred = task->tk_rqstp->rq_cred; | ||
597 | if (cred == NULL) { | ||
598 | err = rpcauth_bindcred(task, task->tk_msg.rpc_cred, task->tk_flags); | ||
599 | if (err < 0) | ||
600 | goto out; | ||
601 | cred = task->tk_rqstp->rq_cred; | ||
602 | }; | ||
607 | dprintk("RPC: %5u refreshing %s cred %p\n", | 603 | dprintk("RPC: %5u refreshing %s cred %p\n", |
608 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | 604 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); |
609 | 605 | ||
610 | err = cred->cr_ops->crrefresh(task); | 606 | err = cred->cr_ops->crrefresh(task); |
607 | out: | ||
611 | if (err < 0) | 608 | if (err < 0) |
612 | task->tk_status = err; | 609 | task->tk_status = err; |
613 | return err; | 610 | return err; |
@@ -616,7 +613,7 @@ rpcauth_refreshcred(struct rpc_task *task) | |||
616 | void | 613 | void |
617 | rpcauth_invalcred(struct rpc_task *task) | 614 | rpcauth_invalcred(struct rpc_task *task) |
618 | { | 615 | { |
619 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 616 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
620 | 617 | ||
621 | dprintk("RPC: %5u invalidating %s cred %p\n", | 618 | dprintk("RPC: %5u invalidating %s cred %p\n", |
622 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | 619 | task->tk_pid, cred->cr_auth->au_ops->au_name, cred); |
@@ -627,7 +624,7 @@ rpcauth_invalcred(struct rpc_task *task) | |||
627 | int | 624 | int |
628 | rpcauth_uptodatecred(struct rpc_task *task) | 625 | rpcauth_uptodatecred(struct rpc_task *task) |
629 | { | 626 | { |
630 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 627 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
631 | 628 | ||
632 | return cred == NULL || | 629 | return cred == NULL || |
633 | test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; | 630 | test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; |
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 8da2a0e68574..096e1260bc67 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -373,7 +373,7 @@ gss_handle_downcall_result(struct gss_cred *gss_cred, struct gss_upcall_msg *gss | |||
373 | static void | 373 | static void |
374 | gss_upcall_callback(struct rpc_task *task) | 374 | gss_upcall_callback(struct rpc_task *task) |
375 | { | 375 | { |
376 | struct gss_cred *gss_cred = container_of(task->tk_msg.rpc_cred, | 376 | struct gss_cred *gss_cred = container_of(task->tk_rqstp->rq_cred, |
377 | struct gss_cred, gc_base); | 377 | struct gss_cred, gc_base); |
378 | struct gss_upcall_msg *gss_msg = gss_cred->gc_upcall; | 378 | struct gss_upcall_msg *gss_msg = gss_cred->gc_upcall; |
379 | struct inode *inode = &gss_msg->inode->vfs_inode; | 379 | struct inode *inode = &gss_msg->inode->vfs_inode; |
@@ -502,7 +502,7 @@ static void warn_gssd(void) | |||
502 | static inline int | 502 | static inline int |
503 | gss_refresh_upcall(struct rpc_task *task) | 503 | gss_refresh_upcall(struct rpc_task *task) |
504 | { | 504 | { |
505 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 505 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
506 | struct gss_auth *gss_auth = container_of(cred->cr_auth, | 506 | struct gss_auth *gss_auth = container_of(cred->cr_auth, |
507 | struct gss_auth, rpc_auth); | 507 | struct gss_auth, rpc_auth); |
508 | struct gss_cred *gss_cred = container_of(cred, | 508 | struct gss_cred *gss_cred = container_of(cred, |
@@ -1064,12 +1064,12 @@ out: | |||
1064 | static __be32 * | 1064 | static __be32 * |
1065 | gss_marshal(struct rpc_task *task, __be32 *p) | 1065 | gss_marshal(struct rpc_task *task, __be32 *p) |
1066 | { | 1066 | { |
1067 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 1067 | struct rpc_rqst *req = task->tk_rqstp; |
1068 | struct rpc_cred *cred = req->rq_cred; | ||
1068 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, | 1069 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
1069 | gc_base); | 1070 | gc_base); |
1070 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); | 1071 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
1071 | __be32 *cred_len; | 1072 | __be32 *cred_len; |
1072 | struct rpc_rqst *req = task->tk_rqstp; | ||
1073 | u32 maj_stat = 0; | 1073 | u32 maj_stat = 0; |
1074 | struct xdr_netobj mic; | 1074 | struct xdr_netobj mic; |
1075 | struct kvec iov; | 1075 | struct kvec iov; |
@@ -1119,7 +1119,7 @@ out_put_ctx: | |||
1119 | 1119 | ||
1120 | static int gss_renew_cred(struct rpc_task *task) | 1120 | static int gss_renew_cred(struct rpc_task *task) |
1121 | { | 1121 | { |
1122 | struct rpc_cred *oldcred = task->tk_msg.rpc_cred; | 1122 | struct rpc_cred *oldcred = task->tk_rqstp->rq_cred; |
1123 | struct gss_cred *gss_cred = container_of(oldcred, | 1123 | struct gss_cred *gss_cred = container_of(oldcred, |
1124 | struct gss_cred, | 1124 | struct gss_cred, |
1125 | gc_base); | 1125 | gc_base); |
@@ -1133,7 +1133,7 @@ static int gss_renew_cred(struct rpc_task *task) | |||
1133 | new = gss_lookup_cred(auth, &acred, RPCAUTH_LOOKUP_NEW); | 1133 | new = gss_lookup_cred(auth, &acred, RPCAUTH_LOOKUP_NEW); |
1134 | if (IS_ERR(new)) | 1134 | if (IS_ERR(new)) |
1135 | return PTR_ERR(new); | 1135 | return PTR_ERR(new); |
1136 | task->tk_msg.rpc_cred = new; | 1136 | task->tk_rqstp->rq_cred = new; |
1137 | put_rpccred(oldcred); | 1137 | put_rpccred(oldcred); |
1138 | return 0; | 1138 | return 0; |
1139 | } | 1139 | } |
@@ -1161,7 +1161,7 @@ static int gss_cred_is_negative_entry(struct rpc_cred *cred) | |||
1161 | static int | 1161 | static int |
1162 | gss_refresh(struct rpc_task *task) | 1162 | gss_refresh(struct rpc_task *task) |
1163 | { | 1163 | { |
1164 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 1164 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
1165 | int ret = 0; | 1165 | int ret = 0; |
1166 | 1166 | ||
1167 | if (gss_cred_is_negative_entry(cred)) | 1167 | if (gss_cred_is_negative_entry(cred)) |
@@ -1172,7 +1172,7 @@ gss_refresh(struct rpc_task *task) | |||
1172 | ret = gss_renew_cred(task); | 1172 | ret = gss_renew_cred(task); |
1173 | if (ret < 0) | 1173 | if (ret < 0) |
1174 | goto out; | 1174 | goto out; |
1175 | cred = task->tk_msg.rpc_cred; | 1175 | cred = task->tk_rqstp->rq_cred; |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | if (test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags)) | 1178 | if (test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags)) |
@@ -1191,7 +1191,7 @@ gss_refresh_null(struct rpc_task *task) | |||
1191 | static __be32 * | 1191 | static __be32 * |
1192 | gss_validate(struct rpc_task *task, __be32 *p) | 1192 | gss_validate(struct rpc_task *task, __be32 *p) |
1193 | { | 1193 | { |
1194 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 1194 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
1195 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); | 1195 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
1196 | __be32 seq; | 1196 | __be32 seq; |
1197 | struct kvec iov; | 1197 | struct kvec iov; |
@@ -1400,7 +1400,7 @@ static int | |||
1400 | gss_wrap_req(struct rpc_task *task, | 1400 | gss_wrap_req(struct rpc_task *task, |
1401 | kxdrproc_t encode, void *rqstp, __be32 *p, void *obj) | 1401 | kxdrproc_t encode, void *rqstp, __be32 *p, void *obj) |
1402 | { | 1402 | { |
1403 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 1403 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
1404 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, | 1404 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
1405 | gc_base); | 1405 | gc_base); |
1406 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); | 1406 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
@@ -1503,7 +1503,7 @@ static int | |||
1503 | gss_unwrap_resp(struct rpc_task *task, | 1503 | gss_unwrap_resp(struct rpc_task *task, |
1504 | kxdrproc_t decode, void *rqstp, __be32 *p, void *obj) | 1504 | kxdrproc_t decode, void *rqstp, __be32 *p, void *obj) |
1505 | { | 1505 | { |
1506 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 1506 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
1507 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, | 1507 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
1508 | gc_base); | 1508 | gc_base); |
1509 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); | 1509 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c index 1db618f56ecb..a5c36c01707b 100644 --- a/net/sunrpc/auth_null.c +++ b/net/sunrpc/auth_null.c | |||
@@ -75,7 +75,7 @@ nul_marshal(struct rpc_task *task, __be32 *p) | |||
75 | static int | 75 | static int |
76 | nul_refresh(struct rpc_task *task) | 76 | nul_refresh(struct rpc_task *task) |
77 | { | 77 | { |
78 | set_bit(RPCAUTH_CRED_UPTODATE, &task->tk_msg.rpc_cred->cr_flags); | 78 | set_bit(RPCAUTH_CRED_UPTODATE, &task->tk_rqstp->rq_cred->cr_flags); |
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | 81 | ||
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index d5e37dbf207b..4cb70dc6e7ad 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
@@ -140,7 +140,7 @@ static __be32 * | |||
140 | unx_marshal(struct rpc_task *task, __be32 *p) | 140 | unx_marshal(struct rpc_task *task, __be32 *p) |
141 | { | 141 | { |
142 | struct rpc_clnt *clnt = task->tk_client; | 142 | struct rpc_clnt *clnt = task->tk_client; |
143 | struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base); | 143 | struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base); |
144 | __be32 *base, *hold; | 144 | __be32 *base, *hold; |
145 | int i; | 145 | int i; |
146 | 146 | ||
@@ -173,7 +173,7 @@ unx_marshal(struct rpc_task *task, __be32 *p) | |||
173 | static int | 173 | static int |
174 | unx_refresh(struct rpc_task *task) | 174 | unx_refresh(struct rpc_task *task) |
175 | { | 175 | { |
176 | set_bit(RPCAUTH_CRED_UPTODATE, &task->tk_msg.rpc_cred->cr_flags); | 176 | set_bit(RPCAUTH_CRED_UPTODATE, &task->tk_rqstp->rq_cred->cr_flags); |
177 | return 0; | 177 | return 0; |
178 | } | 178 | } |
179 | 179 | ||
@@ -196,7 +196,7 @@ unx_validate(struct rpc_task *task, __be32 *p) | |||
196 | printk("RPC: giant verf size: %u\n", size); | 196 | printk("RPC: giant verf size: %u\n", size); |
197 | return NULL; | 197 | return NULL; |
198 | } | 198 | } |
199 | task->tk_msg.rpc_cred->cr_auth->au_rslack = (size >> 2) + 2; | 199 | task->tk_rqstp->rq_cred->cr_auth->au_rslack = (size >> 2) + 2; |
200 | p += (size >> 2); | 200 | p += (size >> 2); |
201 | 201 | ||
202 | return p; | 202 | return p; |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index f34b5e3823c0..2388d83b68ff 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -605,8 +605,8 @@ rpc_task_set_rpc_message(struct rpc_task *task, const struct rpc_message *msg) | |||
605 | task->tk_msg.rpc_proc = msg->rpc_proc; | 605 | task->tk_msg.rpc_proc = msg->rpc_proc; |
606 | task->tk_msg.rpc_argp = msg->rpc_argp; | 606 | task->tk_msg.rpc_argp = msg->rpc_argp; |
607 | task->tk_msg.rpc_resp = msg->rpc_resp; | 607 | task->tk_msg.rpc_resp = msg->rpc_resp; |
608 | /* Bind the user cred */ | 608 | if (msg->rpc_cred != NULL) |
609 | task->tk_status = rpcauth_bindcred(task, msg->rpc_cred, task->tk_flags); | 609 | task->tk_msg.rpc_cred = get_rpccred(msg->rpc_cred); |
610 | } | 610 | } |
611 | } | 611 | } |
612 | 612 | ||
@@ -909,11 +909,6 @@ call_reserve(struct rpc_task *task) | |||
909 | { | 909 | { |
910 | dprint_status(task); | 910 | dprint_status(task); |
911 | 911 | ||
912 | if (!rpcauth_uptodatecred(task)) { | ||
913 | task->tk_action = call_refresh; | ||
914 | return; | ||
915 | } | ||
916 | |||
917 | task->tk_status = 0; | 912 | task->tk_status = 0; |
918 | task->tk_action = call_reserveresult; | 913 | task->tk_action = call_reserveresult; |
919 | xprt_reserve(task); | 914 | xprt_reserve(task); |
@@ -977,7 +972,7 @@ call_reserveresult(struct rpc_task *task) | |||
977 | static void | 972 | static void |
978 | call_allocate(struct rpc_task *task) | 973 | call_allocate(struct rpc_task *task) |
979 | { | 974 | { |
980 | unsigned int slack = task->tk_msg.rpc_cred->cr_auth->au_cslack; | 975 | unsigned int slack = task->tk_client->cl_auth->au_cslack; |
981 | struct rpc_rqst *req = task->tk_rqstp; | 976 | struct rpc_rqst *req = task->tk_rqstp; |
982 | struct rpc_xprt *xprt = task->tk_xprt; | 977 | struct rpc_xprt *xprt = task->tk_xprt; |
983 | struct rpc_procinfo *proc = task->tk_msg.rpc_proc; | 978 | struct rpc_procinfo *proc = task->tk_msg.rpc_proc; |
@@ -985,7 +980,7 @@ call_allocate(struct rpc_task *task) | |||
985 | dprint_status(task); | 980 | dprint_status(task); |
986 | 981 | ||
987 | task->tk_status = 0; | 982 | task->tk_status = 0; |
988 | task->tk_action = call_bind; | 983 | task->tk_action = call_refresh; |
989 | 984 | ||
990 | if (req->rq_buffer) | 985 | if (req->rq_buffer) |
991 | return; | 986 | return; |
@@ -1022,6 +1017,47 @@ call_allocate(struct rpc_task *task) | |||
1022 | rpc_exit(task, -ERESTARTSYS); | 1017 | rpc_exit(task, -ERESTARTSYS); |
1023 | } | 1018 | } |
1024 | 1019 | ||
1020 | /* | ||
1021 | * 2a. Bind and/or refresh the credentials | ||
1022 | */ | ||
1023 | static void | ||
1024 | call_refresh(struct rpc_task *task) | ||
1025 | { | ||
1026 | dprint_status(task); | ||
1027 | |||
1028 | task->tk_action = call_refreshresult; | ||
1029 | task->tk_status = 0; | ||
1030 | task->tk_client->cl_stats->rpcauthrefresh++; | ||
1031 | rpcauth_refreshcred(task); | ||
1032 | } | ||
1033 | |||
1034 | /* | ||
1035 | * 2b. Process the results of a credential refresh | ||
1036 | */ | ||
1037 | static void | ||
1038 | call_refreshresult(struct rpc_task *task) | ||
1039 | { | ||
1040 | int status = task->tk_status; | ||
1041 | |||
1042 | dprint_status(task); | ||
1043 | |||
1044 | task->tk_status = 0; | ||
1045 | task->tk_action = call_bind; | ||
1046 | if (status >= 0 && rpcauth_uptodatecred(task)) | ||
1047 | return; | ||
1048 | switch (status) { | ||
1049 | case -EACCES: | ||
1050 | rpc_exit(task, -EACCES); | ||
1051 | return; | ||
1052 | case -ENOMEM: | ||
1053 | rpc_exit(task, -ENOMEM); | ||
1054 | return; | ||
1055 | case -ETIMEDOUT: | ||
1056 | rpc_delay(task, 3*HZ); | ||
1057 | } | ||
1058 | task->tk_action = call_refresh; | ||
1059 | } | ||
1060 | |||
1025 | static inline int | 1061 | static inline int |
1026 | rpc_task_need_encode(struct rpc_task *task) | 1062 | rpc_task_need_encode(struct rpc_task *task) |
1027 | { | 1063 | { |
@@ -1557,43 +1593,6 @@ out_retry: | |||
1557 | } | 1593 | } |
1558 | } | 1594 | } |
1559 | 1595 | ||
1560 | /* | ||
1561 | * 8. Refresh the credentials if rejected by the server | ||
1562 | */ | ||
1563 | static void | ||
1564 | call_refresh(struct rpc_task *task) | ||
1565 | { | ||
1566 | dprint_status(task); | ||
1567 | |||
1568 | task->tk_action = call_refreshresult; | ||
1569 | task->tk_status = 0; | ||
1570 | task->tk_client->cl_stats->rpcauthrefresh++; | ||
1571 | rpcauth_refreshcred(task); | ||
1572 | } | ||
1573 | |||
1574 | /* | ||
1575 | * 8a. Process the results of a credential refresh | ||
1576 | */ | ||
1577 | static void | ||
1578 | call_refreshresult(struct rpc_task *task) | ||
1579 | { | ||
1580 | int status = task->tk_status; | ||
1581 | |||
1582 | dprint_status(task); | ||
1583 | |||
1584 | task->tk_status = 0; | ||
1585 | task->tk_action = call_reserve; | ||
1586 | if (status >= 0 && rpcauth_uptodatecred(task)) | ||
1587 | return; | ||
1588 | if (status == -EACCES) { | ||
1589 | rpc_exit(task, -EACCES); | ||
1590 | return; | ||
1591 | } | ||
1592 | task->tk_action = call_refresh; | ||
1593 | if (status != -ETIMEDOUT) | ||
1594 | rpc_delay(task, 3*HZ); | ||
1595 | } | ||
1596 | |||
1597 | static __be32 * | 1596 | static __be32 * |
1598 | rpc_encode_header(struct rpc_task *task) | 1597 | rpc_encode_header(struct rpc_task *task) |
1599 | { | 1598 | { |
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index a42296db2ecd..f6db6131fb2e 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -864,7 +864,7 @@ void rpc_put_task(struct rpc_task *task) | |||
864 | if (task->tk_rqstp) | 864 | if (task->tk_rqstp) |
865 | xprt_release(task); | 865 | xprt_release(task); |
866 | if (task->tk_msg.rpc_cred) | 866 | if (task->tk_msg.rpc_cred) |
867 | rpcauth_unbindcred(task); | 867 | put_rpccred(task->tk_msg.rpc_cred); |
868 | rpc_task_release_client(task); | 868 | rpc_task_release_client(task); |
869 | if (task->tk_workqueue != NULL) { | 869 | if (task->tk_workqueue != NULL) { |
870 | INIT_WORK(&task->u.tk_work, rpc_async_release); | 870 | INIT_WORK(&task->u.tk_work, rpc_async_release); |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index dcd0132396ba..70297836a191 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -1032,6 +1032,8 @@ void xprt_release(struct rpc_task *task) | |||
1032 | spin_unlock_bh(&xprt->transport_lock); | 1032 | spin_unlock_bh(&xprt->transport_lock); |
1033 | if (req->rq_buffer) | 1033 | if (req->rq_buffer) |
1034 | xprt->ops->buf_free(req->rq_buffer); | 1034 | xprt->ops->buf_free(req->rq_buffer); |
1035 | if (req->rq_cred != NULL) | ||
1036 | put_rpccred(req->rq_cred); | ||
1035 | task->tk_rqstp = NULL; | 1037 | task->tk_rqstp = NULL; |
1036 | if (req->rq_release_snd_buf) | 1038 | if (req->rq_release_snd_buf) |
1037 | req->rq_release_snd_buf(req); | 1039 | req->rq_release_snd_buf(req); |