diff options
Diffstat (limited to 'fs/nfsd/nfs4callback.c')
| -rw-r--r-- | fs/nfsd/nfs4callback.c | 263 |
1 files changed, 221 insertions, 42 deletions
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 3fd23f7acec..24e8d78f8dd 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
| @@ -43,25 +43,30 @@ | |||
| 43 | #include <linux/sunrpc/xdr.h> | 43 | #include <linux/sunrpc/xdr.h> |
| 44 | #include <linux/sunrpc/svc.h> | 44 | #include <linux/sunrpc/svc.h> |
| 45 | #include <linux/sunrpc/clnt.h> | 45 | #include <linux/sunrpc/clnt.h> |
| 46 | #include <linux/sunrpc/svcsock.h> | ||
| 46 | #include <linux/nfsd/nfsd.h> | 47 | #include <linux/nfsd/nfsd.h> |
| 47 | #include <linux/nfsd/state.h> | 48 | #include <linux/nfsd/state.h> |
| 48 | #include <linux/sunrpc/sched.h> | 49 | #include <linux/sunrpc/sched.h> |
| 49 | #include <linux/nfs4.h> | 50 | #include <linux/nfs4.h> |
| 51 | #include <linux/sunrpc/xprtsock.h> | ||
| 50 | 52 | ||
| 51 | #define NFSDDBG_FACILITY NFSDDBG_PROC | 53 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 52 | 54 | ||
| 53 | #define NFSPROC4_CB_NULL 0 | 55 | #define NFSPROC4_CB_NULL 0 |
| 54 | #define NFSPROC4_CB_COMPOUND 1 | 56 | #define NFSPROC4_CB_COMPOUND 1 |
| 57 | #define NFS4_STATEID_SIZE 16 | ||
| 55 | 58 | ||
| 56 | /* Index of predefined Linux callback client operations */ | 59 | /* Index of predefined Linux callback client operations */ |
| 57 | 60 | ||
| 58 | enum { | 61 | enum { |
| 59 | NFSPROC4_CLNT_CB_NULL = 0, | 62 | NFSPROC4_CLNT_CB_NULL = 0, |
| 60 | NFSPROC4_CLNT_CB_RECALL, | 63 | NFSPROC4_CLNT_CB_RECALL, |
| 64 | NFSPROC4_CLNT_CB_SEQUENCE, | ||
| 61 | }; | 65 | }; |
| 62 | 66 | ||
| 63 | enum nfs_cb_opnum4 { | 67 | enum nfs_cb_opnum4 { |
| 64 | OP_CB_RECALL = 4, | 68 | OP_CB_RECALL = 4, |
| 69 | OP_CB_SEQUENCE = 11, | ||
| 65 | }; | 70 | }; |
| 66 | 71 | ||
| 67 | #define NFS4_MAXTAGLEN 20 | 72 | #define NFS4_MAXTAGLEN 20 |
| @@ -70,17 +75,29 @@ enum nfs_cb_opnum4 { | |||
| 70 | #define NFS4_dec_cb_null_sz 0 | 75 | #define NFS4_dec_cb_null_sz 0 |
| 71 | #define cb_compound_enc_hdr_sz 4 | 76 | #define cb_compound_enc_hdr_sz 4 |
| 72 | #define cb_compound_dec_hdr_sz (3 + (NFS4_MAXTAGLEN >> 2)) | 77 | #define cb_compound_dec_hdr_sz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 78 | #define sessionid_sz (NFS4_MAX_SESSIONID_LEN >> 2) | ||
| 79 | #define cb_sequence_enc_sz (sessionid_sz + 4 + \ | ||
| 80 | 1 /* no referring calls list yet */) | ||
| 81 | #define cb_sequence_dec_sz (op_dec_sz + sessionid_sz + 4) | ||
| 82 | |||
| 73 | #define op_enc_sz 1 | 83 | #define op_enc_sz 1 |
| 74 | #define op_dec_sz 2 | 84 | #define op_dec_sz 2 |
| 75 | #define enc_nfs4_fh_sz (1 + (NFS4_FHSIZE >> 2)) | 85 | #define enc_nfs4_fh_sz (1 + (NFS4_FHSIZE >> 2)) |
| 76 | #define enc_stateid_sz (NFS4_STATEID_SIZE >> 2) | 86 | #define enc_stateid_sz (NFS4_STATEID_SIZE >> 2) |
| 77 | #define NFS4_enc_cb_recall_sz (cb_compound_enc_hdr_sz + \ | 87 | #define NFS4_enc_cb_recall_sz (cb_compound_enc_hdr_sz + \ |
| 88 | cb_sequence_enc_sz + \ | ||
| 78 | 1 + enc_stateid_sz + \ | 89 | 1 + enc_stateid_sz + \ |
| 79 | enc_nfs4_fh_sz) | 90 | enc_nfs4_fh_sz) |
| 80 | 91 | ||
| 81 | #define NFS4_dec_cb_recall_sz (cb_compound_dec_hdr_sz + \ | 92 | #define NFS4_dec_cb_recall_sz (cb_compound_dec_hdr_sz + \ |
| 93 | cb_sequence_dec_sz + \ | ||
| 82 | op_dec_sz) | 94 | op_dec_sz) |
| 83 | 95 | ||
| 96 | struct nfs4_rpc_args { | ||
| 97 | void *args_op; | ||
| 98 | struct nfsd4_cb_sequence args_seq; | ||
| 99 | }; | ||
| 100 | |||
| 84 | /* | 101 | /* |
| 85 | * Generic encode routines from fs/nfs/nfs4xdr.c | 102 | * Generic encode routines from fs/nfs/nfs4xdr.c |
| 86 | */ | 103 | */ |
| @@ -137,11 +154,13 @@ xdr_error: \ | |||
| 137 | } while (0) | 154 | } while (0) |
| 138 | 155 | ||
| 139 | struct nfs4_cb_compound_hdr { | 156 | struct nfs4_cb_compound_hdr { |
| 140 | int status; | 157 | /* args */ |
| 141 | u32 ident; | 158 | u32 ident; /* minorversion 0 only */ |
| 142 | u32 nops; | 159 | u32 nops; |
| 143 | __be32 *nops_p; | 160 | __be32 *nops_p; |
| 144 | u32 minorversion; | 161 | u32 minorversion; |
| 162 | /* res */ | ||
| 163 | int status; | ||
| 145 | u32 taglen; | 164 | u32 taglen; |
| 146 | char *tag; | 165 | char *tag; |
| 147 | }; | 166 | }; |
| @@ -238,6 +257,27 @@ encode_cb_recall(struct xdr_stream *xdr, struct nfs4_delegation *dp, | |||
| 238 | hdr->nops++; | 257 | hdr->nops++; |
| 239 | } | 258 | } |
| 240 | 259 | ||
| 260 | static void | ||
| 261 | encode_cb_sequence(struct xdr_stream *xdr, struct nfsd4_cb_sequence *args, | ||
| 262 | struct nfs4_cb_compound_hdr *hdr) | ||
| 263 | { | ||
| 264 | __be32 *p; | ||
| 265 | |||
| 266 | if (hdr->minorversion == 0) | ||
| 267 | return; | ||
| 268 | |||
| 269 | RESERVE_SPACE(1 + NFS4_MAX_SESSIONID_LEN + 20); | ||
| 270 | |||
| 271 | WRITE32(OP_CB_SEQUENCE); | ||
| 272 | WRITEMEM(args->cbs_clp->cl_sessionid.data, NFS4_MAX_SESSIONID_LEN); | ||
| 273 | WRITE32(args->cbs_clp->cl_cb_seq_nr); | ||
| 274 | WRITE32(0); /* slotid, always 0 */ | ||
| 275 | WRITE32(0); /* highest slotid always 0 */ | ||
| 276 | WRITE32(0); /* cachethis always 0 */ | ||
| 277 | WRITE32(0); /* FIXME: support referring_call_lists */ | ||
| 278 | hdr->nops++; | ||
| 279 | } | ||
| 280 | |||
| 241 | static int | 281 | static int |
| 242 | nfs4_xdr_enc_cb_null(struct rpc_rqst *req, __be32 *p) | 282 | nfs4_xdr_enc_cb_null(struct rpc_rqst *req, __be32 *p) |
| 243 | { | 283 | { |
| @@ -249,15 +289,19 @@ nfs4_xdr_enc_cb_null(struct rpc_rqst *req, __be32 *p) | |||
| 249 | } | 289 | } |
| 250 | 290 | ||
| 251 | static int | 291 | static int |
| 252 | nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, __be32 *p, struct nfs4_delegation *args) | 292 | nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, __be32 *p, |
| 293 | struct nfs4_rpc_args *rpc_args) | ||
| 253 | { | 294 | { |
| 254 | struct xdr_stream xdr; | 295 | struct xdr_stream xdr; |
| 296 | struct nfs4_delegation *args = rpc_args->args_op; | ||
| 255 | struct nfs4_cb_compound_hdr hdr = { | 297 | struct nfs4_cb_compound_hdr hdr = { |
| 256 | .ident = args->dl_ident, | 298 | .ident = args->dl_ident, |
| 299 | .minorversion = rpc_args->args_seq.cbs_minorversion, | ||
| 257 | }; | 300 | }; |
| 258 | 301 | ||
| 259 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 302 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 260 | encode_cb_compound_hdr(&xdr, &hdr); | 303 | encode_cb_compound_hdr(&xdr, &hdr); |
| 304 | encode_cb_sequence(&xdr, &rpc_args->args_seq, &hdr); | ||
| 261 | encode_cb_recall(&xdr, args, &hdr); | 305 | encode_cb_recall(&xdr, args, &hdr); |
| 262 | encode_cb_nops(&hdr); | 306 | encode_cb_nops(&hdr); |
| 263 | return 0; | 307 | return 0; |
| @@ -299,6 +343,57 @@ decode_cb_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) | |||
| 299 | return 0; | 343 | return 0; |
| 300 | } | 344 | } |
| 301 | 345 | ||
| 346 | /* | ||
| 347 | * Our current back channel implmentation supports a single backchannel | ||
| 348 | * with a single slot. | ||
| 349 | */ | ||
| 350 | static int | ||
| 351 | decode_cb_sequence(struct xdr_stream *xdr, struct nfsd4_cb_sequence *res, | ||
| 352 | struct rpc_rqst *rqstp) | ||
| 353 | { | ||
| 354 | struct nfs4_sessionid id; | ||
| 355 | int status; | ||
| 356 | u32 dummy; | ||
| 357 | __be32 *p; | ||
| 358 | |||
| 359 | if (res->cbs_minorversion == 0) | ||
| 360 | return 0; | ||
| 361 | |||
| 362 | status = decode_cb_op_hdr(xdr, OP_CB_SEQUENCE); | ||
| 363 | if (status) | ||
| 364 | return status; | ||
| 365 | |||
| 366 | /* | ||
| 367 | * If the server returns different values for sessionID, slotID or | ||
| 368 | * sequence number, the server is looney tunes. | ||
| 369 | */ | ||
| 370 | status = -ESERVERFAULT; | ||
| 371 | |||
| 372 | READ_BUF(NFS4_MAX_SESSIONID_LEN + 16); | ||
| 373 | memcpy(id.data, p, NFS4_MAX_SESSIONID_LEN); | ||
| 374 | p += XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN); | ||
| 375 | if (memcmp(id.data, res->cbs_clp->cl_sessionid.data, | ||
| 376 | NFS4_MAX_SESSIONID_LEN)) { | ||
| 377 | dprintk("%s Invalid session id\n", __func__); | ||
| 378 | goto out; | ||
| 379 | } | ||
| 380 | READ32(dummy); | ||
| 381 | if (dummy != res->cbs_clp->cl_cb_seq_nr) { | ||
| 382 | dprintk("%s Invalid sequence number\n", __func__); | ||
| 383 | goto out; | ||
| 384 | } | ||
| 385 | READ32(dummy); /* slotid must be 0 */ | ||
| 386 | if (dummy != 0) { | ||
| 387 | dprintk("%s Invalid slotid\n", __func__); | ||
| 388 | goto out; | ||
| 389 | } | ||
| 390 | /* FIXME: process highest slotid and target highest slotid */ | ||
| 391 | status = 0; | ||
| 392 | out: | ||
| 393 | return status; | ||
| 394 | } | ||
| 395 | |||
| 396 | |||
| 302 | static int | 397 | static int |
| 303 | nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p) | 398 | nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p) |
| 304 | { | 399 | { |
| @@ -306,7 +401,8 @@ nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p) | |||
| 306 | } | 401 | } |
| 307 | 402 | ||
| 308 | static int | 403 | static int |
| 309 | nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p) | 404 | nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p, |
| 405 | struct nfsd4_cb_sequence *seq) | ||
| 310 | { | 406 | { |
| 311 | struct xdr_stream xdr; | 407 | struct xdr_stream xdr; |
| 312 | struct nfs4_cb_compound_hdr hdr; | 408 | struct nfs4_cb_compound_hdr hdr; |
| @@ -316,6 +412,11 @@ nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p) | |||
| 316 | status = decode_cb_compound_hdr(&xdr, &hdr); | 412 | status = decode_cb_compound_hdr(&xdr, &hdr); |
| 317 | if (status) | 413 | if (status) |
| 318 | goto out; | 414 | goto out; |
| 415 | if (seq) { | ||
| 416 | status = decode_cb_sequence(&xdr, seq, rqstp); | ||
| 417 | if (status) | ||
| 418 | goto out; | ||
| 419 | } | ||
| 319 | status = decode_cb_op_hdr(&xdr, OP_CB_RECALL); | 420 | status = decode_cb_op_hdr(&xdr, OP_CB_RECALL); |
| 320 | out: | 421 | out: |
| 321 | return status; | 422 | return status; |
| @@ -377,16 +478,15 @@ static int max_cb_time(void) | |||
| 377 | 478 | ||
| 378 | int setup_callback_client(struct nfs4_client *clp) | 479 | int setup_callback_client(struct nfs4_client *clp) |
| 379 | { | 480 | { |
| 380 | struct sockaddr_in addr; | ||
| 381 | struct nfs4_cb_conn *cb = &clp->cl_cb_conn; | 481 | struct nfs4_cb_conn *cb = &clp->cl_cb_conn; |
| 382 | struct rpc_timeout timeparms = { | 482 | struct rpc_timeout timeparms = { |
| 383 | .to_initval = max_cb_time(), | 483 | .to_initval = max_cb_time(), |
| 384 | .to_retries = 0, | 484 | .to_retries = 0, |
| 385 | }; | 485 | }; |
| 386 | struct rpc_create_args args = { | 486 | struct rpc_create_args args = { |
| 387 | .protocol = IPPROTO_TCP, | 487 | .protocol = XPRT_TRANSPORT_TCP, |
| 388 | .address = (struct sockaddr *)&addr, | 488 | .address = (struct sockaddr *) &cb->cb_addr, |
| 389 | .addrsize = sizeof(addr), | 489 | .addrsize = cb->cb_addrlen, |
| 390 | .timeout = &timeparms, | 490 | .timeout = &timeparms, |
| 391 | .program = &cb_program, | 491 | .program = &cb_program, |
| 392 | .prognumber = cb->cb_prog, | 492 | .prognumber = cb->cb_prog, |
| @@ -399,13 +499,10 @@ int setup_callback_client(struct nfs4_client *clp) | |||
| 399 | 499 | ||
| 400 | if (!clp->cl_principal && (clp->cl_flavor >= RPC_AUTH_GSS_KRB5)) | 500 | if (!clp->cl_principal && (clp->cl_flavor >= RPC_AUTH_GSS_KRB5)) |
| 401 | return -EINVAL; | 501 | return -EINVAL; |
| 402 | 502 | if (cb->cb_minorversion) { | |
| 403 | /* Initialize address */ | 503 | args.bc_xprt = clp->cl_cb_xprt; |
| 404 | memset(&addr, 0, sizeof(addr)); | 504 | args.protocol = XPRT_TRANSPORT_BC_TCP; |
| 405 | addr.sin_family = AF_INET; | 505 | } |
| 406 | addr.sin_port = htons(cb->cb_port); | ||
| 407 | addr.sin_addr.s_addr = htonl(cb->cb_addr); | ||
| 408 | |||
| 409 | /* Create RPC client */ | 506 | /* Create RPC client */ |
| 410 | client = rpc_create(&args); | 507 | client = rpc_create(&args); |
| 411 | if (IS_ERR(client)) { | 508 | if (IS_ERR(client)) { |
| @@ -439,42 +536,29 @@ static const struct rpc_call_ops nfsd4_cb_probe_ops = { | |||
| 439 | .rpc_call_done = nfsd4_cb_probe_done, | 536 | .rpc_call_done = nfsd4_cb_probe_done, |
| 440 | }; | 537 | }; |
| 441 | 538 | ||
| 442 | static struct rpc_cred *lookup_cb_cred(struct nfs4_cb_conn *cb) | 539 | static struct rpc_cred *callback_cred; |
| 443 | { | ||
| 444 | struct auth_cred acred = { | ||
| 445 | .machine_cred = 1 | ||
| 446 | }; | ||
| 447 | 540 | ||
| 448 | /* | 541 | int set_callback_cred(void) |
| 449 | * Note in the gss case this doesn't actually have to wait for a | 542 | { |
| 450 | * gss upcall (or any calls to the client); this just creates a | 543 | callback_cred = rpc_lookup_machine_cred(); |
| 451 | * non-uptodate cred which the rpc state machine will fill in with | 544 | if (!callback_cred) |
| 452 | * a refresh_upcall later. | 545 | return -ENOMEM; |
| 453 | */ | 546 | return 0; |
| 454 | return rpcauth_lookup_credcache(cb->cb_client->cl_auth, &acred, | ||
| 455 | RPCAUTH_LOOKUP_NEW); | ||
| 456 | } | 547 | } |
| 457 | 548 | ||
| 549 | |||
| 458 | void do_probe_callback(struct nfs4_client *clp) | 550 | void do_probe_callback(struct nfs4_client *clp) |
| 459 | { | 551 | { |
| 460 | struct nfs4_cb_conn *cb = &clp->cl_cb_conn; | 552 | struct nfs4_cb_conn *cb = &clp->cl_cb_conn; |
| 461 | struct rpc_message msg = { | 553 | struct rpc_message msg = { |
| 462 | .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL], | 554 | .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL], |
| 463 | .rpc_argp = clp, | 555 | .rpc_argp = clp, |
| 556 | .rpc_cred = callback_cred | ||
| 464 | }; | 557 | }; |
| 465 | struct rpc_cred *cred; | ||
| 466 | int status; | 558 | int status; |
| 467 | 559 | ||
| 468 | cred = lookup_cb_cred(cb); | ||
| 469 | if (IS_ERR(cred)) { | ||
| 470 | status = PTR_ERR(cred); | ||
| 471 | goto out; | ||
| 472 | } | ||
| 473 | cb->cb_cred = cred; | ||
| 474 | msg.rpc_cred = cb->cb_cred; | ||
| 475 | status = rpc_call_async(cb->cb_client, &msg, RPC_TASK_SOFT, | 560 | status = rpc_call_async(cb->cb_client, &msg, RPC_TASK_SOFT, |
| 476 | &nfsd4_cb_probe_ops, (void *)clp); | 561 | &nfsd4_cb_probe_ops, (void *)clp); |
| 477 | out: | ||
| 478 | if (status) { | 562 | if (status) { |
| 479 | warn_no_callback_path(clp, status); | 563 | warn_no_callback_path(clp, status); |
| 480 | put_nfs4_client(clp); | 564 | put_nfs4_client(clp); |
| @@ -503,11 +587,95 @@ nfsd4_probe_callback(struct nfs4_client *clp) | |||
| 503 | do_probe_callback(clp); | 587 | do_probe_callback(clp); |
| 504 | } | 588 | } |
| 505 | 589 | ||
| 590 | /* | ||
| 591 | * There's currently a single callback channel slot. | ||
| 592 | * If the slot is available, then mark it busy. Otherwise, set the | ||
| 593 | * thread for sleeping on the callback RPC wait queue. | ||
| 594 | */ | ||
| 595 | static int nfsd41_cb_setup_sequence(struct nfs4_client *clp, | ||
| 596 | struct rpc_task *task) | ||
| 597 | { | ||
| 598 | struct nfs4_rpc_args *args = task->tk_msg.rpc_argp; | ||
| 599 | u32 *ptr = (u32 *)clp->cl_sessionid.data; | ||
| 600 | int status = 0; | ||
| 601 | |||
| 602 | dprintk("%s: %u:%u:%u:%u\n", __func__, | ||
| 603 | ptr[0], ptr[1], ptr[2], ptr[3]); | ||
| 604 | |||
| 605 | if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) { | ||
| 606 | rpc_sleep_on(&clp->cl_cb_waitq, task, NULL); | ||
| 607 | dprintk("%s slot is busy\n", __func__); | ||
| 608 | status = -EAGAIN; | ||
| 609 | goto out; | ||
| 610 | } | ||
| 611 | |||
| 612 | /* | ||
| 613 | * We'll need the clp during XDR encoding and decoding, | ||
| 614 | * and the sequence during decoding to verify the reply | ||
| 615 | */ | ||
| 616 | args->args_seq.cbs_clp = clp; | ||
| 617 | task->tk_msg.rpc_resp = &args->args_seq; | ||
| 618 | |||
| 619 | out: | ||
| 620 | dprintk("%s status=%d\n", __func__, status); | ||
| 621 | return status; | ||
| 622 | } | ||
| 623 | |||
| 624 | /* | ||
| 625 | * TODO: cb_sequence should support referring call lists, cachethis, multiple | ||
| 626 | * slots, and mark callback channel down on communication errors. | ||
| 627 | */ | ||
| 628 | static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata) | ||
| 629 | { | ||
| 630 | struct nfs4_delegation *dp = calldata; | ||
| 631 | struct nfs4_client *clp = dp->dl_client; | ||
| 632 | struct nfs4_rpc_args *args = task->tk_msg.rpc_argp; | ||
| 633 | u32 minorversion = clp->cl_cb_conn.cb_minorversion; | ||
| 634 | int status = 0; | ||
| 635 | |||
| 636 | args->args_seq.cbs_minorversion = minorversion; | ||
| 637 | if (minorversion) { | ||
| 638 | status = nfsd41_cb_setup_sequence(clp, task); | ||
| 639 | if (status) { | ||
| 640 | if (status != -EAGAIN) { | ||
| 641 | /* terminate rpc task */ | ||
| 642 | task->tk_status = status; | ||
| 643 | task->tk_action = NULL; | ||
| 644 | } | ||
| 645 | return; | ||
| 646 | } | ||
| 647 | } | ||
| 648 | rpc_call_start(task); | ||
| 649 | } | ||
| 650 | |||
| 651 | static void nfsd4_cb_done(struct rpc_task *task, void *calldata) | ||
| 652 | { | ||
| 653 | struct nfs4_delegation *dp = calldata; | ||
| 654 | struct nfs4_client *clp = dp->dl_client; | ||
| 655 | |||
| 656 | dprintk("%s: minorversion=%d\n", __func__, | ||
| 657 | clp->cl_cb_conn.cb_minorversion); | ||
| 658 | |||
| 659 | if (clp->cl_cb_conn.cb_minorversion) { | ||
| 660 | /* No need for lock, access serialized in nfsd4_cb_prepare */ | ||
| 661 | ++clp->cl_cb_seq_nr; | ||
| 662 | clear_bit(0, &clp->cl_cb_slot_busy); | ||
| 663 | rpc_wake_up_next(&clp->cl_cb_waitq); | ||
| 664 | dprintk("%s: freed slot, new seqid=%d\n", __func__, | ||
| 665 | clp->cl_cb_seq_nr); | ||
| 666 | |||
| 667 | /* We're done looking into the sequence information */ | ||
| 668 | task->tk_msg.rpc_resp = NULL; | ||
| 669 | } | ||
| 670 | } | ||
| 671 | |||
| 506 | static void nfsd4_cb_recall_done(struct rpc_task *task, void *calldata) | 672 | static void nfsd4_cb_recall_done(struct rpc_task *task, void *calldata) |
| 507 | { | 673 | { |
| 508 | struct nfs4_delegation *dp = calldata; | 674 | struct nfs4_delegation *dp = calldata; |
| 509 | struct nfs4_client *clp = dp->dl_client; | 675 | struct nfs4_client *clp = dp->dl_client; |
| 510 | 676 | ||
| 677 | nfsd4_cb_done(task, calldata); | ||
| 678 | |||
| 511 | switch (task->tk_status) { | 679 | switch (task->tk_status) { |
| 512 | case -EIO: | 680 | case -EIO: |
| 513 | /* Network partition? */ | 681 | /* Network partition? */ |
| @@ -520,16 +688,19 @@ static void nfsd4_cb_recall_done(struct rpc_task *task, void *calldata) | |||
| 520 | break; | 688 | break; |
| 521 | default: | 689 | default: |
| 522 | /* success, or error we can't handle */ | 690 | /* success, or error we can't handle */ |
| 523 | return; | 691 | goto done; |
| 524 | } | 692 | } |
| 525 | if (dp->dl_retries--) { | 693 | if (dp->dl_retries--) { |
| 526 | rpc_delay(task, 2*HZ); | 694 | rpc_delay(task, 2*HZ); |
| 527 | task->tk_status = 0; | 695 | task->tk_status = 0; |
| 528 | rpc_restart_call(task); | 696 | rpc_restart_call(task); |
| 697 | return; | ||
| 529 | } else { | 698 | } else { |
| 530 | atomic_set(&clp->cl_cb_conn.cb_set, 0); | 699 | atomic_set(&clp->cl_cb_conn.cb_set, 0); |
| 531 | warn_no_callback_path(clp, task->tk_status); | 700 | warn_no_callback_path(clp, task->tk_status); |
| 532 | } | 701 | } |
| 702 | done: | ||
| 703 | kfree(task->tk_msg.rpc_argp); | ||
| 533 | } | 704 | } |
| 534 | 705 | ||
| 535 | static void nfsd4_cb_recall_release(void *calldata) | 706 | static void nfsd4_cb_recall_release(void *calldata) |
| @@ -542,6 +713,7 @@ static void nfsd4_cb_recall_release(void *calldata) | |||
| 542 | } | 713 | } |
| 543 | 714 | ||
| 544 | static const struct rpc_call_ops nfsd4_cb_recall_ops = { | 715 | static const struct rpc_call_ops nfsd4_cb_recall_ops = { |
| 716 | .rpc_call_prepare = nfsd4_cb_prepare, | ||
| 545 | .rpc_call_done = nfsd4_cb_recall_done, | 717 | .rpc_call_done = nfsd4_cb_recall_done, |
| 546 | .rpc_release = nfsd4_cb_recall_release, | 718 | .rpc_release = nfsd4_cb_recall_release, |
| 547 | }; | 719 | }; |
| @@ -554,17 +726,24 @@ nfsd4_cb_recall(struct nfs4_delegation *dp) | |||
| 554 | { | 726 | { |
| 555 | struct nfs4_client *clp = dp->dl_client; | 727 | struct nfs4_client *clp = dp->dl_client; |
| 556 | struct rpc_clnt *clnt = clp->cl_cb_conn.cb_client; | 728 | struct rpc_clnt *clnt = clp->cl_cb_conn.cb_client; |
| 729 | struct nfs4_rpc_args *args; | ||
| 557 | struct rpc_message msg = { | 730 | struct rpc_message msg = { |
| 558 | .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL], | 731 | .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL], |
| 559 | .rpc_argp = dp, | 732 | .rpc_cred = callback_cred |
| 560 | .rpc_cred = clp->cl_cb_conn.cb_cred | ||
| 561 | }; | 733 | }; |
| 562 | int status; | 734 | int status = -ENOMEM; |
| 563 | 735 | ||
| 736 | args = kzalloc(sizeof(*args), GFP_KERNEL); | ||
| 737 | if (!args) | ||
| 738 | goto out; | ||
| 739 | args->args_op = dp; | ||
| 740 | msg.rpc_argp = args; | ||
| 564 | dp->dl_retries = 1; | 741 | dp->dl_retries = 1; |
| 565 | status = rpc_call_async(clnt, &msg, RPC_TASK_SOFT, | 742 | status = rpc_call_async(clnt, &msg, RPC_TASK_SOFT, |
| 566 | &nfsd4_cb_recall_ops, dp); | 743 | &nfsd4_cb_recall_ops, dp); |
| 744 | out: | ||
| 567 | if (status) { | 745 | if (status) { |
| 746 | kfree(args); | ||
| 568 | put_nfs4_client(clp); | 747 | put_nfs4_client(clp); |
| 569 | nfs4_put_delegation(dp); | 748 | nfs4_put_delegation(dp); |
| 570 | } | 749 | } |
