| .. | .. |
|---|
| 46 | 46 | |
|---|
| 47 | 47 | /* Set up the missing parts of the file_lock structure */ |
|---|
| 48 | 48 | lock->fl.fl_file = file->f_file; |
|---|
| 49 | | - lock->fl.fl_owner = (fl_owner_t) host; |
|---|
| 49 | + lock->fl.fl_pid = current->tgid; |
|---|
| 50 | 50 | lock->fl.fl_lmops = &nlmsvc_lock_operations; |
|---|
| 51 | + nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid); |
|---|
| 52 | + if (!lock->fl.fl_owner) { |
|---|
| 53 | + /* lockowner allocation has failed */ |
|---|
| 54 | + nlmsvc_release_host(host); |
|---|
| 55 | + return nlm_lck_denied_nolocks; |
|---|
| 56 | + } |
|---|
| 51 | 57 | } |
|---|
| 52 | 58 | |
|---|
| 53 | 59 | return 0; |
|---|
| .. | .. |
|---|
| 94 | 100 | else |
|---|
| 95 | 101 | dprintk("lockd: TEST4 status %d\n", ntohl(resp->status)); |
|---|
| 96 | 102 | |
|---|
| 103 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 97 | 104 | nlmsvc_release_host(host); |
|---|
| 98 | 105 | nlm_release_file(file); |
|---|
| 99 | 106 | return rc; |
|---|
| .. | .. |
|---|
| 142 | 149 | else |
|---|
| 143 | 150 | dprintk("lockd: LOCK status %d\n", ntohl(resp->status)); |
|---|
| 144 | 151 | |
|---|
| 152 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 145 | 153 | nlmsvc_release_host(host); |
|---|
| 146 | 154 | nlm_release_file(file); |
|---|
| 147 | 155 | return rc; |
|---|
| .. | .. |
|---|
| 178 | 186 | resp->status = nlmsvc_cancel_blocked(SVC_NET(rqstp), file, &argp->lock); |
|---|
| 179 | 187 | |
|---|
| 180 | 188 | dprintk("lockd: CANCEL status %d\n", ntohl(resp->status)); |
|---|
| 189 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 181 | 190 | nlmsvc_release_host(host); |
|---|
| 182 | 191 | nlm_release_file(file); |
|---|
| 183 | 192 | return rpc_success; |
|---|
| .. | .. |
|---|
| 217 | 226 | resp->status = nlmsvc_unlock(SVC_NET(rqstp), file, &argp->lock); |
|---|
| 218 | 227 | |
|---|
| 219 | 228 | dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status)); |
|---|
| 229 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 220 | 230 | nlmsvc_release_host(host); |
|---|
| 221 | 231 | nlm_release_file(file); |
|---|
| 222 | 232 | return rpc_success; |
|---|
| .. | .. |
|---|
| 365 | 375 | resp->status = nlmsvc_share_file(host, file, argp); |
|---|
| 366 | 376 | |
|---|
| 367 | 377 | dprintk("lockd: SHARE status %d\n", ntohl(resp->status)); |
|---|
| 378 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 368 | 379 | nlmsvc_release_host(host); |
|---|
| 369 | 380 | nlm_release_file(file); |
|---|
| 370 | 381 | return rpc_success; |
|---|
| .. | .. |
|---|
| 399 | 410 | resp->status = nlmsvc_unshare_file(host, file, argp); |
|---|
| 400 | 411 | |
|---|
| 401 | 412 | dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status)); |
|---|
| 413 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 402 | 414 | nlmsvc_release_host(host); |
|---|
| 403 | 415 | nlm_release_file(file); |
|---|
| 404 | 416 | return rpc_success; |
|---|
| .. | .. |
|---|
| 474 | 486 | return rpc_success; |
|---|
| 475 | 487 | } |
|---|
| 476 | 488 | |
|---|
| 489 | +static __be32 |
|---|
| 490 | +nlm4svc_proc_unused(struct svc_rqst *rqstp) |
|---|
| 491 | +{ |
|---|
| 492 | + return rpc_proc_unavail; |
|---|
| 493 | +} |
|---|
| 494 | + |
|---|
| 477 | 495 | |
|---|
| 478 | 496 | /* |
|---|
| 479 | 497 | * NLM Server procedures. |
|---|
| 480 | 498 | */ |
|---|
| 481 | 499 | |
|---|
| 482 | | -#define nlm4svc_encode_norep nlm4svc_encode_void |
|---|
| 483 | | -#define nlm4svc_decode_norep nlm4svc_decode_void |
|---|
| 484 | | -#define nlm4svc_decode_testres nlm4svc_decode_void |
|---|
| 485 | | -#define nlm4svc_decode_lockres nlm4svc_decode_void |
|---|
| 486 | | -#define nlm4svc_decode_unlockres nlm4svc_decode_void |
|---|
| 487 | | -#define nlm4svc_decode_cancelres nlm4svc_decode_void |
|---|
| 488 | | -#define nlm4svc_decode_grantedres nlm4svc_decode_void |
|---|
| 489 | | - |
|---|
| 490 | | -#define nlm4svc_proc_none nlm4svc_proc_null |
|---|
| 491 | | -#define nlm4svc_proc_test_res nlm4svc_proc_null |
|---|
| 492 | | -#define nlm4svc_proc_lock_res nlm4svc_proc_null |
|---|
| 493 | | -#define nlm4svc_proc_cancel_res nlm4svc_proc_null |
|---|
| 494 | | -#define nlm4svc_proc_unlock_res nlm4svc_proc_null |
|---|
| 495 | | - |
|---|
| 496 | 500 | struct nlm_void { int dummy; }; |
|---|
| 497 | 501 | |
|---|
| 498 | | -#define PROC(name, xargt, xrest, argt, rest, respsize) \ |
|---|
| 499 | | - { .pc_func = nlm4svc_proc_##name, \ |
|---|
| 500 | | - .pc_decode = nlm4svc_decode_##xargt, \ |
|---|
| 501 | | - .pc_encode = nlm4svc_encode_##xrest, \ |
|---|
| 502 | | - .pc_release = NULL, \ |
|---|
| 503 | | - .pc_argsize = sizeof(struct nlm_##argt), \ |
|---|
| 504 | | - .pc_ressize = sizeof(struct nlm_##rest), \ |
|---|
| 505 | | - .pc_xdrressize = respsize, \ |
|---|
| 506 | | - } |
|---|
| 507 | 502 | #define Ck (1+XDR_QUADLEN(NLM_MAXCOOKIELEN)) /* cookie */ |
|---|
| 508 | 503 | #define No (1+1024/4) /* netobj */ |
|---|
| 509 | 504 | #define St 1 /* status */ |
|---|
| 510 | 505 | #define Rg 4 /* range (offset + length) */ |
|---|
| 511 | | -const struct svc_procedure nlmsvc_procedures4[] = { |
|---|
| 512 | | - PROC(null, void, void, void, void, 1), |
|---|
| 513 | | - PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), |
|---|
| 514 | | - PROC(lock, lockargs, res, args, res, Ck+St), |
|---|
| 515 | | - PROC(cancel, cancargs, res, args, res, Ck+St), |
|---|
| 516 | | - PROC(unlock, unlockargs, res, args, res, Ck+St), |
|---|
| 517 | | - PROC(granted, testargs, res, args, res, Ck+St), |
|---|
| 518 | | - PROC(test_msg, testargs, norep, args, void, 1), |
|---|
| 519 | | - PROC(lock_msg, lockargs, norep, args, void, 1), |
|---|
| 520 | | - PROC(cancel_msg, cancargs, norep, args, void, 1), |
|---|
| 521 | | - PROC(unlock_msg, unlockargs, norep, args, void, 1), |
|---|
| 522 | | - PROC(granted_msg, testargs, norep, args, void, 1), |
|---|
| 523 | | - PROC(test_res, testres, norep, res, void, 1), |
|---|
| 524 | | - PROC(lock_res, lockres, norep, res, void, 1), |
|---|
| 525 | | - PROC(cancel_res, cancelres, norep, res, void, 1), |
|---|
| 526 | | - PROC(unlock_res, unlockres, norep, res, void, 1), |
|---|
| 527 | | - PROC(granted_res, res, norep, res, void, 1), |
|---|
| 528 | | - /* statd callback */ |
|---|
| 529 | | - PROC(sm_notify, reboot, void, reboot, void, 1), |
|---|
| 530 | | - PROC(none, void, void, void, void, 0), |
|---|
| 531 | | - PROC(none, void, void, void, void, 0), |
|---|
| 532 | | - PROC(none, void, void, void, void, 0), |
|---|
| 533 | | - PROC(share, shareargs, shareres, args, res, Ck+St+1), |
|---|
| 534 | | - PROC(unshare, shareargs, shareres, args, res, Ck+St+1), |
|---|
| 535 | | - PROC(nm_lock, lockargs, res, args, res, Ck+St), |
|---|
| 536 | | - PROC(free_all, notify, void, args, void, 1), |
|---|
| 537 | 506 | |
|---|
| 507 | +const struct svc_procedure nlmsvc_procedures4[24] = { |
|---|
| 508 | + [NLMPROC_NULL] = { |
|---|
| 509 | + .pc_func = nlm4svc_proc_null, |
|---|
| 510 | + .pc_decode = nlm4svc_decode_void, |
|---|
| 511 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 512 | + .pc_argsize = sizeof(struct nlm_void), |
|---|
| 513 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 514 | + .pc_xdrressize = St, |
|---|
| 515 | + }, |
|---|
| 516 | + [NLMPROC_TEST] = { |
|---|
| 517 | + .pc_func = nlm4svc_proc_test, |
|---|
| 518 | + .pc_decode = nlm4svc_decode_testargs, |
|---|
| 519 | + .pc_encode = nlm4svc_encode_testres, |
|---|
| 520 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 521 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 522 | + .pc_xdrressize = Ck+St+2+No+Rg, |
|---|
| 523 | + }, |
|---|
| 524 | + [NLMPROC_LOCK] = { |
|---|
| 525 | + .pc_func = nlm4svc_proc_lock, |
|---|
| 526 | + .pc_decode = nlm4svc_decode_lockargs, |
|---|
| 527 | + .pc_encode = nlm4svc_encode_res, |
|---|
| 528 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 529 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 530 | + .pc_xdrressize = Ck+St, |
|---|
| 531 | + }, |
|---|
| 532 | + [NLMPROC_CANCEL] = { |
|---|
| 533 | + .pc_func = nlm4svc_proc_cancel, |
|---|
| 534 | + .pc_decode = nlm4svc_decode_cancargs, |
|---|
| 535 | + .pc_encode = nlm4svc_encode_res, |
|---|
| 536 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 537 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 538 | + .pc_xdrressize = Ck+St, |
|---|
| 539 | + }, |
|---|
| 540 | + [NLMPROC_UNLOCK] = { |
|---|
| 541 | + .pc_func = nlm4svc_proc_unlock, |
|---|
| 542 | + .pc_decode = nlm4svc_decode_unlockargs, |
|---|
| 543 | + .pc_encode = nlm4svc_encode_res, |
|---|
| 544 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 545 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 546 | + .pc_xdrressize = Ck+St, |
|---|
| 547 | + }, |
|---|
| 548 | + [NLMPROC_GRANTED] = { |
|---|
| 549 | + .pc_func = nlm4svc_proc_granted, |
|---|
| 550 | + .pc_decode = nlm4svc_decode_testargs, |
|---|
| 551 | + .pc_encode = nlm4svc_encode_res, |
|---|
| 552 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 553 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 554 | + .pc_xdrressize = Ck+St, |
|---|
| 555 | + }, |
|---|
| 556 | + [NLMPROC_TEST_MSG] = { |
|---|
| 557 | + .pc_func = nlm4svc_proc_test_msg, |
|---|
| 558 | + .pc_decode = nlm4svc_decode_testargs, |
|---|
| 559 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 560 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 561 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 562 | + .pc_xdrressize = St, |
|---|
| 563 | + }, |
|---|
| 564 | + [NLMPROC_LOCK_MSG] = { |
|---|
| 565 | + .pc_func = nlm4svc_proc_lock_msg, |
|---|
| 566 | + .pc_decode = nlm4svc_decode_lockargs, |
|---|
| 567 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 568 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 569 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 570 | + .pc_xdrressize = St, |
|---|
| 571 | + }, |
|---|
| 572 | + [NLMPROC_CANCEL_MSG] = { |
|---|
| 573 | + .pc_func = nlm4svc_proc_cancel_msg, |
|---|
| 574 | + .pc_decode = nlm4svc_decode_cancargs, |
|---|
| 575 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 576 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 577 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 578 | + .pc_xdrressize = St, |
|---|
| 579 | + }, |
|---|
| 580 | + [NLMPROC_UNLOCK_MSG] = { |
|---|
| 581 | + .pc_func = nlm4svc_proc_unlock_msg, |
|---|
| 582 | + .pc_decode = nlm4svc_decode_unlockargs, |
|---|
| 583 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 584 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 585 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 586 | + .pc_xdrressize = St, |
|---|
| 587 | + }, |
|---|
| 588 | + [NLMPROC_GRANTED_MSG] = { |
|---|
| 589 | + .pc_func = nlm4svc_proc_granted_msg, |
|---|
| 590 | + .pc_decode = nlm4svc_decode_testargs, |
|---|
| 591 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 592 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 593 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 594 | + .pc_xdrressize = St, |
|---|
| 595 | + }, |
|---|
| 596 | + [NLMPROC_TEST_RES] = { |
|---|
| 597 | + .pc_func = nlm4svc_proc_null, |
|---|
| 598 | + .pc_decode = nlm4svc_decode_void, |
|---|
| 599 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 600 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 601 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 602 | + .pc_xdrressize = St, |
|---|
| 603 | + }, |
|---|
| 604 | + [NLMPROC_LOCK_RES] = { |
|---|
| 605 | + .pc_func = nlm4svc_proc_null, |
|---|
| 606 | + .pc_decode = nlm4svc_decode_void, |
|---|
| 607 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 608 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 609 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 610 | + .pc_xdrressize = St, |
|---|
| 611 | + }, |
|---|
| 612 | + [NLMPROC_CANCEL_RES] = { |
|---|
| 613 | + .pc_func = nlm4svc_proc_null, |
|---|
| 614 | + .pc_decode = nlm4svc_decode_void, |
|---|
| 615 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 616 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 617 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 618 | + .pc_xdrressize = St, |
|---|
| 619 | + }, |
|---|
| 620 | + [NLMPROC_UNLOCK_RES] = { |
|---|
| 621 | + .pc_func = nlm4svc_proc_null, |
|---|
| 622 | + .pc_decode = nlm4svc_decode_void, |
|---|
| 623 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 624 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 625 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 626 | + .pc_xdrressize = St, |
|---|
| 627 | + }, |
|---|
| 628 | + [NLMPROC_GRANTED_RES] = { |
|---|
| 629 | + .pc_func = nlm4svc_proc_granted_res, |
|---|
| 630 | + .pc_decode = nlm4svc_decode_res, |
|---|
| 631 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 632 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 633 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 634 | + .pc_xdrressize = St, |
|---|
| 635 | + }, |
|---|
| 636 | + [NLMPROC_NSM_NOTIFY] = { |
|---|
| 637 | + .pc_func = nlm4svc_proc_sm_notify, |
|---|
| 638 | + .pc_decode = nlm4svc_decode_reboot, |
|---|
| 639 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 640 | + .pc_argsize = sizeof(struct nlm_reboot), |
|---|
| 641 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 642 | + .pc_xdrressize = St, |
|---|
| 643 | + }, |
|---|
| 644 | + [17] = { |
|---|
| 645 | + .pc_func = nlm4svc_proc_unused, |
|---|
| 646 | + .pc_decode = nlm4svc_decode_void, |
|---|
| 647 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 648 | + .pc_argsize = sizeof(struct nlm_void), |
|---|
| 649 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 650 | + .pc_xdrressize = 0, |
|---|
| 651 | + }, |
|---|
| 652 | + [18] = { |
|---|
| 653 | + .pc_func = nlm4svc_proc_unused, |
|---|
| 654 | + .pc_decode = nlm4svc_decode_void, |
|---|
| 655 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 656 | + .pc_argsize = sizeof(struct nlm_void), |
|---|
| 657 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 658 | + .pc_xdrressize = 0, |
|---|
| 659 | + }, |
|---|
| 660 | + [19] = { |
|---|
| 661 | + .pc_func = nlm4svc_proc_unused, |
|---|
| 662 | + .pc_decode = nlm4svc_decode_void, |
|---|
| 663 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 664 | + .pc_argsize = sizeof(struct nlm_void), |
|---|
| 665 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 666 | + .pc_xdrressize = 0, |
|---|
| 667 | + }, |
|---|
| 668 | + [NLMPROC_SHARE] = { |
|---|
| 669 | + .pc_func = nlm4svc_proc_share, |
|---|
| 670 | + .pc_decode = nlm4svc_decode_shareargs, |
|---|
| 671 | + .pc_encode = nlm4svc_encode_shareres, |
|---|
| 672 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 673 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 674 | + .pc_xdrressize = Ck+St+1, |
|---|
| 675 | + }, |
|---|
| 676 | + [NLMPROC_UNSHARE] = { |
|---|
| 677 | + .pc_func = nlm4svc_proc_unshare, |
|---|
| 678 | + .pc_decode = nlm4svc_decode_shareargs, |
|---|
| 679 | + .pc_encode = nlm4svc_encode_shareres, |
|---|
| 680 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 681 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 682 | + .pc_xdrressize = Ck+St+1, |
|---|
| 683 | + }, |
|---|
| 684 | + [NLMPROC_NM_LOCK] = { |
|---|
| 685 | + .pc_func = nlm4svc_proc_nm_lock, |
|---|
| 686 | + .pc_decode = nlm4svc_decode_lockargs, |
|---|
| 687 | + .pc_encode = nlm4svc_encode_res, |
|---|
| 688 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 689 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 690 | + .pc_xdrressize = Ck+St, |
|---|
| 691 | + }, |
|---|
| 692 | + [NLMPROC_FREE_ALL] = { |
|---|
| 693 | + .pc_func = nlm4svc_proc_free_all, |
|---|
| 694 | + .pc_decode = nlm4svc_decode_notify, |
|---|
| 695 | + .pc_encode = nlm4svc_encode_void, |
|---|
| 696 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 697 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 698 | + .pc_xdrressize = St, |
|---|
| 699 | + }, |
|---|
| 538 | 700 | }; |
|---|