| .. | .. |
|---|
| 76 | 76 | |
|---|
| 77 | 77 | /* Set up the missing parts of the file_lock structure */ |
|---|
| 78 | 78 | lock->fl.fl_file = file->f_file; |
|---|
| 79 | | - lock->fl.fl_owner = (fl_owner_t) host; |
|---|
| 79 | + lock->fl.fl_pid = current->tgid; |
|---|
| 80 | 80 | lock->fl.fl_lmops = &nlmsvc_lock_operations; |
|---|
| 81 | + nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid); |
|---|
| 82 | + if (!lock->fl.fl_owner) { |
|---|
| 83 | + /* lockowner allocation has failed */ |
|---|
| 84 | + nlmsvc_release_host(host); |
|---|
| 85 | + return nlm_lck_denied_nolocks; |
|---|
| 86 | + } |
|---|
| 81 | 87 | } |
|---|
| 82 | 88 | |
|---|
| 83 | 89 | return 0; |
|---|
| .. | .. |
|---|
| 125 | 131 | dprintk("lockd: TEST status %d vers %d\n", |
|---|
| 126 | 132 | ntohl(resp->status), rqstp->rq_vers); |
|---|
| 127 | 133 | |
|---|
| 134 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 128 | 135 | nlmsvc_release_host(host); |
|---|
| 129 | 136 | nlm_release_file(file); |
|---|
| 130 | 137 | return rc; |
|---|
| .. | .. |
|---|
| 173 | 180 | else |
|---|
| 174 | 181 | dprintk("lockd: LOCK status %d\n", ntohl(resp->status)); |
|---|
| 175 | 182 | |
|---|
| 183 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 176 | 184 | nlmsvc_release_host(host); |
|---|
| 177 | 185 | nlm_release_file(file); |
|---|
| 178 | 186 | return rc; |
|---|
| .. | .. |
|---|
| 210 | 218 | resp->status = cast_status(nlmsvc_cancel_blocked(net, file, &argp->lock)); |
|---|
| 211 | 219 | |
|---|
| 212 | 220 | dprintk("lockd: CANCEL status %d\n", ntohl(resp->status)); |
|---|
| 221 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 213 | 222 | nlmsvc_release_host(host); |
|---|
| 214 | 223 | nlm_release_file(file); |
|---|
| 215 | 224 | return rpc_success; |
|---|
| .. | .. |
|---|
| 250 | 259 | resp->status = cast_status(nlmsvc_unlock(net, file, &argp->lock)); |
|---|
| 251 | 260 | |
|---|
| 252 | 261 | dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status)); |
|---|
| 262 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 253 | 263 | nlmsvc_release_host(host); |
|---|
| 254 | 264 | nlm_release_file(file); |
|---|
| 255 | 265 | return rpc_success; |
|---|
| .. | .. |
|---|
| 408 | 418 | resp->status = cast_status(nlmsvc_share_file(host, file, argp)); |
|---|
| 409 | 419 | |
|---|
| 410 | 420 | dprintk("lockd: SHARE status %d\n", ntohl(resp->status)); |
|---|
| 421 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 411 | 422 | nlmsvc_release_host(host); |
|---|
| 412 | 423 | nlm_release_file(file); |
|---|
| 413 | 424 | return rpc_success; |
|---|
| .. | .. |
|---|
| 442 | 453 | resp->status = cast_status(nlmsvc_unshare_file(host, file, argp)); |
|---|
| 443 | 454 | |
|---|
| 444 | 455 | dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status)); |
|---|
| 456 | + nlmsvc_release_lockowner(&argp->lock); |
|---|
| 445 | 457 | nlmsvc_release_host(host); |
|---|
| 446 | 458 | nlm_release_file(file); |
|---|
| 447 | 459 | return rpc_success; |
|---|
| .. | .. |
|---|
| 517 | 529 | return rpc_success; |
|---|
| 518 | 530 | } |
|---|
| 519 | 531 | |
|---|
| 532 | +static __be32 |
|---|
| 533 | +nlmsvc_proc_unused(struct svc_rqst *rqstp) |
|---|
| 534 | +{ |
|---|
| 535 | + return rpc_proc_unavail; |
|---|
| 536 | +} |
|---|
| 537 | + |
|---|
| 520 | 538 | /* |
|---|
| 521 | 539 | * NLM Server procedures. |
|---|
| 522 | 540 | */ |
|---|
| 523 | 541 | |
|---|
| 524 | | -#define nlmsvc_encode_norep nlmsvc_encode_void |
|---|
| 525 | | -#define nlmsvc_decode_norep nlmsvc_decode_void |
|---|
| 526 | | -#define nlmsvc_decode_testres nlmsvc_decode_void |
|---|
| 527 | | -#define nlmsvc_decode_lockres nlmsvc_decode_void |
|---|
| 528 | | -#define nlmsvc_decode_unlockres nlmsvc_decode_void |
|---|
| 529 | | -#define nlmsvc_decode_cancelres nlmsvc_decode_void |
|---|
| 530 | | -#define nlmsvc_decode_grantedres nlmsvc_decode_void |
|---|
| 531 | | - |
|---|
| 532 | | -#define nlmsvc_proc_none nlmsvc_proc_null |
|---|
| 533 | | -#define nlmsvc_proc_test_res nlmsvc_proc_null |
|---|
| 534 | | -#define nlmsvc_proc_lock_res nlmsvc_proc_null |
|---|
| 535 | | -#define nlmsvc_proc_cancel_res nlmsvc_proc_null |
|---|
| 536 | | -#define nlmsvc_proc_unlock_res nlmsvc_proc_null |
|---|
| 537 | | - |
|---|
| 538 | 542 | struct nlm_void { int dummy; }; |
|---|
| 539 | | - |
|---|
| 540 | | -#define PROC(name, xargt, xrest, argt, rest, respsize) \ |
|---|
| 541 | | - { .pc_func = nlmsvc_proc_##name, \ |
|---|
| 542 | | - .pc_decode = nlmsvc_decode_##xargt, \ |
|---|
| 543 | | - .pc_encode = nlmsvc_encode_##xrest, \ |
|---|
| 544 | | - .pc_release = NULL, \ |
|---|
| 545 | | - .pc_argsize = sizeof(struct nlm_##argt), \ |
|---|
| 546 | | - .pc_ressize = sizeof(struct nlm_##rest), \ |
|---|
| 547 | | - .pc_xdrressize = respsize, \ |
|---|
| 548 | | - } |
|---|
| 549 | 543 | |
|---|
| 550 | 544 | #define Ck (1+XDR_QUADLEN(NLM_MAXCOOKIELEN)) /* cookie */ |
|---|
| 551 | 545 | #define St 1 /* status */ |
|---|
| 552 | 546 | #define No (1+1024/4) /* Net Obj */ |
|---|
| 553 | 547 | #define Rg 2 /* range - offset + size */ |
|---|
| 554 | 548 | |
|---|
| 555 | | -const struct svc_procedure nlmsvc_procedures[] = { |
|---|
| 556 | | - PROC(null, void, void, void, void, 1), |
|---|
| 557 | | - PROC(test, testargs, testres, args, res, Ck+St+2+No+Rg), |
|---|
| 558 | | - PROC(lock, lockargs, res, args, res, Ck+St), |
|---|
| 559 | | - PROC(cancel, cancargs, res, args, res, Ck+St), |
|---|
| 560 | | - PROC(unlock, unlockargs, res, args, res, Ck+St), |
|---|
| 561 | | - PROC(granted, testargs, res, args, res, Ck+St), |
|---|
| 562 | | - PROC(test_msg, testargs, norep, args, void, 1), |
|---|
| 563 | | - PROC(lock_msg, lockargs, norep, args, void, 1), |
|---|
| 564 | | - PROC(cancel_msg, cancargs, norep, args, void, 1), |
|---|
| 565 | | - PROC(unlock_msg, unlockargs, norep, args, void, 1), |
|---|
| 566 | | - PROC(granted_msg, testargs, norep, args, void, 1), |
|---|
| 567 | | - PROC(test_res, testres, norep, res, void, 1), |
|---|
| 568 | | - PROC(lock_res, lockres, norep, res, void, 1), |
|---|
| 569 | | - PROC(cancel_res, cancelres, norep, res, void, 1), |
|---|
| 570 | | - PROC(unlock_res, unlockres, norep, res, void, 1), |
|---|
| 571 | | - PROC(granted_res, res, norep, res, void, 1), |
|---|
| 572 | | - /* statd callback */ |
|---|
| 573 | | - PROC(sm_notify, reboot, void, reboot, void, 1), |
|---|
| 574 | | - PROC(none, void, void, void, void, 1), |
|---|
| 575 | | - PROC(none, void, void, void, void, 1), |
|---|
| 576 | | - PROC(none, void, void, void, void, 1), |
|---|
| 577 | | - PROC(share, shareargs, shareres, args, res, Ck+St+1), |
|---|
| 578 | | - PROC(unshare, shareargs, shareres, args, res, Ck+St+1), |
|---|
| 579 | | - PROC(nm_lock, lockargs, res, args, res, Ck+St), |
|---|
| 580 | | - PROC(free_all, notify, void, args, void, 0), |
|---|
| 581 | | - |
|---|
| 549 | +const struct svc_procedure nlmsvc_procedures[24] = { |
|---|
| 550 | + [NLMPROC_NULL] = { |
|---|
| 551 | + .pc_func = nlmsvc_proc_null, |
|---|
| 552 | + .pc_decode = nlmsvc_decode_void, |
|---|
| 553 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 554 | + .pc_argsize = sizeof(struct nlm_void), |
|---|
| 555 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 556 | + .pc_xdrressize = St, |
|---|
| 557 | + }, |
|---|
| 558 | + [NLMPROC_TEST] = { |
|---|
| 559 | + .pc_func = nlmsvc_proc_test, |
|---|
| 560 | + .pc_decode = nlmsvc_decode_testargs, |
|---|
| 561 | + .pc_encode = nlmsvc_encode_testres, |
|---|
| 562 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 563 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 564 | + .pc_xdrressize = Ck+St+2+No+Rg, |
|---|
| 565 | + }, |
|---|
| 566 | + [NLMPROC_LOCK] = { |
|---|
| 567 | + .pc_func = nlmsvc_proc_lock, |
|---|
| 568 | + .pc_decode = nlmsvc_decode_lockargs, |
|---|
| 569 | + .pc_encode = nlmsvc_encode_res, |
|---|
| 570 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 571 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 572 | + .pc_xdrressize = Ck+St, |
|---|
| 573 | + }, |
|---|
| 574 | + [NLMPROC_CANCEL] = { |
|---|
| 575 | + .pc_func = nlmsvc_proc_cancel, |
|---|
| 576 | + .pc_decode = nlmsvc_decode_cancargs, |
|---|
| 577 | + .pc_encode = nlmsvc_encode_res, |
|---|
| 578 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 579 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 580 | + .pc_xdrressize = Ck+St, |
|---|
| 581 | + }, |
|---|
| 582 | + [NLMPROC_UNLOCK] = { |
|---|
| 583 | + .pc_func = nlmsvc_proc_unlock, |
|---|
| 584 | + .pc_decode = nlmsvc_decode_unlockargs, |
|---|
| 585 | + .pc_encode = nlmsvc_encode_res, |
|---|
| 586 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 587 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 588 | + .pc_xdrressize = Ck+St, |
|---|
| 589 | + }, |
|---|
| 590 | + [NLMPROC_GRANTED] = { |
|---|
| 591 | + .pc_func = nlmsvc_proc_granted, |
|---|
| 592 | + .pc_decode = nlmsvc_decode_testargs, |
|---|
| 593 | + .pc_encode = nlmsvc_encode_res, |
|---|
| 594 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 595 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 596 | + .pc_xdrressize = Ck+St, |
|---|
| 597 | + }, |
|---|
| 598 | + [NLMPROC_TEST_MSG] = { |
|---|
| 599 | + .pc_func = nlmsvc_proc_test_msg, |
|---|
| 600 | + .pc_decode = nlmsvc_decode_testargs, |
|---|
| 601 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 602 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 603 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 604 | + .pc_xdrressize = St, |
|---|
| 605 | + }, |
|---|
| 606 | + [NLMPROC_LOCK_MSG] = { |
|---|
| 607 | + .pc_func = nlmsvc_proc_lock_msg, |
|---|
| 608 | + .pc_decode = nlmsvc_decode_lockargs, |
|---|
| 609 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 610 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 611 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 612 | + .pc_xdrressize = St, |
|---|
| 613 | + }, |
|---|
| 614 | + [NLMPROC_CANCEL_MSG] = { |
|---|
| 615 | + .pc_func = nlmsvc_proc_cancel_msg, |
|---|
| 616 | + .pc_decode = nlmsvc_decode_cancargs, |
|---|
| 617 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 618 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 619 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 620 | + .pc_xdrressize = St, |
|---|
| 621 | + }, |
|---|
| 622 | + [NLMPROC_UNLOCK_MSG] = { |
|---|
| 623 | + .pc_func = nlmsvc_proc_unlock_msg, |
|---|
| 624 | + .pc_decode = nlmsvc_decode_unlockargs, |
|---|
| 625 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 626 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 627 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 628 | + .pc_xdrressize = St, |
|---|
| 629 | + }, |
|---|
| 630 | + [NLMPROC_GRANTED_MSG] = { |
|---|
| 631 | + .pc_func = nlmsvc_proc_granted_msg, |
|---|
| 632 | + .pc_decode = nlmsvc_decode_testargs, |
|---|
| 633 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 634 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 635 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 636 | + .pc_xdrressize = St, |
|---|
| 637 | + }, |
|---|
| 638 | + [NLMPROC_TEST_RES] = { |
|---|
| 639 | + .pc_func = nlmsvc_proc_null, |
|---|
| 640 | + .pc_decode = nlmsvc_decode_void, |
|---|
| 641 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 642 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 643 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 644 | + .pc_xdrressize = St, |
|---|
| 645 | + }, |
|---|
| 646 | + [NLMPROC_LOCK_RES] = { |
|---|
| 647 | + .pc_func = nlmsvc_proc_null, |
|---|
| 648 | + .pc_decode = nlmsvc_decode_void, |
|---|
| 649 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 650 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 651 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 652 | + .pc_xdrressize = St, |
|---|
| 653 | + }, |
|---|
| 654 | + [NLMPROC_CANCEL_RES] = { |
|---|
| 655 | + .pc_func = nlmsvc_proc_null, |
|---|
| 656 | + .pc_decode = nlmsvc_decode_void, |
|---|
| 657 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 658 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 659 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 660 | + .pc_xdrressize = St, |
|---|
| 661 | + }, |
|---|
| 662 | + [NLMPROC_UNLOCK_RES] = { |
|---|
| 663 | + .pc_func = nlmsvc_proc_null, |
|---|
| 664 | + .pc_decode = nlmsvc_decode_void, |
|---|
| 665 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 666 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 667 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 668 | + .pc_xdrressize = St, |
|---|
| 669 | + }, |
|---|
| 670 | + [NLMPROC_GRANTED_RES] = { |
|---|
| 671 | + .pc_func = nlmsvc_proc_granted_res, |
|---|
| 672 | + .pc_decode = nlmsvc_decode_res, |
|---|
| 673 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 674 | + .pc_argsize = sizeof(struct nlm_res), |
|---|
| 675 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 676 | + .pc_xdrressize = St, |
|---|
| 677 | + }, |
|---|
| 678 | + [NLMPROC_NSM_NOTIFY] = { |
|---|
| 679 | + .pc_func = nlmsvc_proc_sm_notify, |
|---|
| 680 | + .pc_decode = nlmsvc_decode_reboot, |
|---|
| 681 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 682 | + .pc_argsize = sizeof(struct nlm_reboot), |
|---|
| 683 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 684 | + .pc_xdrressize = St, |
|---|
| 685 | + }, |
|---|
| 686 | + [17] = { |
|---|
| 687 | + .pc_func = nlmsvc_proc_unused, |
|---|
| 688 | + .pc_decode = nlmsvc_decode_void, |
|---|
| 689 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 690 | + .pc_argsize = sizeof(struct nlm_void), |
|---|
| 691 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 692 | + .pc_xdrressize = St, |
|---|
| 693 | + }, |
|---|
| 694 | + [18] = { |
|---|
| 695 | + .pc_func = nlmsvc_proc_unused, |
|---|
| 696 | + .pc_decode = nlmsvc_decode_void, |
|---|
| 697 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 698 | + .pc_argsize = sizeof(struct nlm_void), |
|---|
| 699 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 700 | + .pc_xdrressize = St, |
|---|
| 701 | + }, |
|---|
| 702 | + [19] = { |
|---|
| 703 | + .pc_func = nlmsvc_proc_unused, |
|---|
| 704 | + .pc_decode = nlmsvc_decode_void, |
|---|
| 705 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 706 | + .pc_argsize = sizeof(struct nlm_void), |
|---|
| 707 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 708 | + .pc_xdrressize = St, |
|---|
| 709 | + }, |
|---|
| 710 | + [NLMPROC_SHARE] = { |
|---|
| 711 | + .pc_func = nlmsvc_proc_share, |
|---|
| 712 | + .pc_decode = nlmsvc_decode_shareargs, |
|---|
| 713 | + .pc_encode = nlmsvc_encode_shareres, |
|---|
| 714 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 715 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 716 | + .pc_xdrressize = Ck+St+1, |
|---|
| 717 | + }, |
|---|
| 718 | + [NLMPROC_UNSHARE] = { |
|---|
| 719 | + .pc_func = nlmsvc_proc_unshare, |
|---|
| 720 | + .pc_decode = nlmsvc_decode_shareargs, |
|---|
| 721 | + .pc_encode = nlmsvc_encode_shareres, |
|---|
| 722 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 723 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 724 | + .pc_xdrressize = Ck+St+1, |
|---|
| 725 | + }, |
|---|
| 726 | + [NLMPROC_NM_LOCK] = { |
|---|
| 727 | + .pc_func = nlmsvc_proc_nm_lock, |
|---|
| 728 | + .pc_decode = nlmsvc_decode_lockargs, |
|---|
| 729 | + .pc_encode = nlmsvc_encode_res, |
|---|
| 730 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 731 | + .pc_ressize = sizeof(struct nlm_res), |
|---|
| 732 | + .pc_xdrressize = Ck+St, |
|---|
| 733 | + }, |
|---|
| 734 | + [NLMPROC_FREE_ALL] = { |
|---|
| 735 | + .pc_func = nlmsvc_proc_free_all, |
|---|
| 736 | + .pc_decode = nlmsvc_decode_notify, |
|---|
| 737 | + .pc_encode = nlmsvc_encode_void, |
|---|
| 738 | + .pc_argsize = sizeof(struct nlm_args), |
|---|
| 739 | + .pc_ressize = sizeof(struct nlm_void), |
|---|
| 740 | + .pc_xdrressize = 0, |
|---|
| 741 | + }, |
|---|
| 582 | 742 | }; |
|---|