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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'nfsd-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux

Pull nfsd updates from Chuck Lever:
"This release is mostly bug fixes, clean-ups, and optimizations.

One notable set of fixes addresses a subtle buffer overflow issue that
occurs if a small RPC Call message arrives in an oversized RPC record.
This is only possible on a framed RPC transport such as TCP.

Because NFSD shares the receive and send buffers in one set of pages,
an oversized RPC record steals pages from the send buffer that will be
used to construct the RPC Reply message. NFSD must not assume that a
full-sized buffer is always available to it; otherwise, it will walk
off the end of the send buffer while constructing its reply.

In this release, we also introduce the ability for the server to wait
a moment for clients to return delegations before it responds with
NFS4ERR_DELAY. This saves a retransmit and a network round- trip when
a delegation recall is needed. This work will be built upon in future
releases.

The NFS server adds another shrinker to its collection. Because
courtesy clients can linger for quite some time, they might be
freeable when the server host comes under memory pressure. A new
shrinker has been added that releases courtesy client resources during
low memory scenarios.

Lastly, of note: the maximum number of operations per NFSv4 COMPOUND
that NFSD can handle is increased from 16 to 50. There are NFSv4
client implementations that need more than 16 to successfully perform
a mount operation that uses a pathname with many components"

* tag 'nfsd-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (53 commits)
nfsd: extra checks when freeing delegation stateids
nfsd: make nfsd4_run_cb a bool return function
nfsd: fix comments about spinlock handling with delegations
nfsd: only fill out return pointer on success in nfsd4_lookup_stateid
NFSD: fix use-after-free on source server when doing inter-server copy
NFSD: Cap rsize_bop result based on send buffer size
NFSD: Rename the fields in copy_stateid_t
nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_file_cache_stats_fops
nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_reply_cache_stats_fops
nfsd: use DEFINE_SHOW_ATTRIBUTE to define client_info_fops
nfsd: use DEFINE_SHOW_ATTRIBUTE to define export_features_fops and supported_enctypes_fops
nfsd: use DEFINE_PROC_SHOW_ATTRIBUTE to define nfsd_proc_ops
NFSD: Pack struct nfsd4_compoundres
NFSD: Remove unused nfsd4_compoundargs::cachetype field
NFSD: Remove "inline" directives on op_rsize_bop helpers
NFSD: Clean up nfs4svc_encode_compoundres()
SUNRPC: Fix typo in xdr_buf_subsegment's kdoc comment
NFSD: Clean up WRITE arg decoders
NFSD: Use xdr_inline_decode() to decode NFSv3 symlinks
NFSD: Refactor common code out of dirlist helpers
...

+829 -400
+1 -1
fs/lockd/host.c
··· 164 164 host->h_addrbuf = nsm->sm_addrbuf; 165 165 host->net = ni->net; 166 166 host->h_cred = get_cred(ni->cred); 167 - strlcpy(host->nodename, utsname()->nodename, sizeof(host->nodename)); 167 + strscpy(host->nodename, utsname()->nodename, sizeof(host->nodename)); 168 168 169 169 out: 170 170 return host;
+24
fs/lockd/svc4proc.c
··· 521 521 .pc_decode = nlm4svc_decode_void, 522 522 .pc_encode = nlm4svc_encode_void, 523 523 .pc_argsize = sizeof(struct nlm_void), 524 + .pc_argzero = sizeof(struct nlm_void), 524 525 .pc_ressize = sizeof(struct nlm_void), 525 526 .pc_xdrressize = St, 526 527 .pc_name = "NULL", ··· 531 530 .pc_decode = nlm4svc_decode_testargs, 532 531 .pc_encode = nlm4svc_encode_testres, 533 532 .pc_argsize = sizeof(struct nlm_args), 533 + .pc_argzero = sizeof(struct nlm_args), 534 534 .pc_ressize = sizeof(struct nlm_res), 535 535 .pc_xdrressize = Ck+St+2+No+Rg, 536 536 .pc_name = "TEST", ··· 541 539 .pc_decode = nlm4svc_decode_lockargs, 542 540 .pc_encode = nlm4svc_encode_res, 543 541 .pc_argsize = sizeof(struct nlm_args), 542 + .pc_argzero = sizeof(struct nlm_args), 544 543 .pc_ressize = sizeof(struct nlm_res), 545 544 .pc_xdrressize = Ck+St, 546 545 .pc_name = "LOCK", ··· 551 548 .pc_decode = nlm4svc_decode_cancargs, 552 549 .pc_encode = nlm4svc_encode_res, 553 550 .pc_argsize = sizeof(struct nlm_args), 551 + .pc_argzero = sizeof(struct nlm_args), 554 552 .pc_ressize = sizeof(struct nlm_res), 555 553 .pc_xdrressize = Ck+St, 556 554 .pc_name = "CANCEL", ··· 561 557 .pc_decode = nlm4svc_decode_unlockargs, 562 558 .pc_encode = nlm4svc_encode_res, 563 559 .pc_argsize = sizeof(struct nlm_args), 560 + .pc_argzero = sizeof(struct nlm_args), 564 561 .pc_ressize = sizeof(struct nlm_res), 565 562 .pc_xdrressize = Ck+St, 566 563 .pc_name = "UNLOCK", ··· 571 566 .pc_decode = nlm4svc_decode_testargs, 572 567 .pc_encode = nlm4svc_encode_res, 573 568 .pc_argsize = sizeof(struct nlm_args), 569 + .pc_argzero = sizeof(struct nlm_args), 574 570 .pc_ressize = sizeof(struct nlm_res), 575 571 .pc_xdrressize = Ck+St, 576 572 .pc_name = "GRANTED", ··· 581 575 .pc_decode = nlm4svc_decode_testargs, 582 576 .pc_encode = nlm4svc_encode_void, 583 577 .pc_argsize = sizeof(struct nlm_args), 578 + .pc_argzero = sizeof(struct nlm_args), 584 579 .pc_ressize = sizeof(struct nlm_void), 585 580 .pc_xdrressize = St, 586 581 .pc_name = "TEST_MSG", ··· 591 584 .pc_decode = nlm4svc_decode_lockargs, 592 585 .pc_encode = nlm4svc_encode_void, 593 586 .pc_argsize = sizeof(struct nlm_args), 587 + .pc_argzero = sizeof(struct nlm_args), 594 588 .pc_ressize = sizeof(struct nlm_void), 595 589 .pc_xdrressize = St, 596 590 .pc_name = "LOCK_MSG", ··· 601 593 .pc_decode = nlm4svc_decode_cancargs, 602 594 .pc_encode = nlm4svc_encode_void, 603 595 .pc_argsize = sizeof(struct nlm_args), 596 + .pc_argzero = sizeof(struct nlm_args), 604 597 .pc_ressize = sizeof(struct nlm_void), 605 598 .pc_xdrressize = St, 606 599 .pc_name = "CANCEL_MSG", ··· 611 602 .pc_decode = nlm4svc_decode_unlockargs, 612 603 .pc_encode = nlm4svc_encode_void, 613 604 .pc_argsize = sizeof(struct nlm_args), 605 + .pc_argzero = sizeof(struct nlm_args), 614 606 .pc_ressize = sizeof(struct nlm_void), 615 607 .pc_xdrressize = St, 616 608 .pc_name = "UNLOCK_MSG", ··· 621 611 .pc_decode = nlm4svc_decode_testargs, 622 612 .pc_encode = nlm4svc_encode_void, 623 613 .pc_argsize = sizeof(struct nlm_args), 614 + .pc_argzero = sizeof(struct nlm_args), 624 615 .pc_ressize = sizeof(struct nlm_void), 625 616 .pc_xdrressize = St, 626 617 .pc_name = "GRANTED_MSG", ··· 631 620 .pc_decode = nlm4svc_decode_void, 632 621 .pc_encode = nlm4svc_encode_void, 633 622 .pc_argsize = sizeof(struct nlm_res), 623 + .pc_argzero = sizeof(struct nlm_res), 634 624 .pc_ressize = sizeof(struct nlm_void), 635 625 .pc_xdrressize = St, 636 626 .pc_name = "TEST_RES", ··· 641 629 .pc_decode = nlm4svc_decode_void, 642 630 .pc_encode = nlm4svc_encode_void, 643 631 .pc_argsize = sizeof(struct nlm_res), 632 + .pc_argzero = sizeof(struct nlm_res), 644 633 .pc_ressize = sizeof(struct nlm_void), 645 634 .pc_xdrressize = St, 646 635 .pc_name = "LOCK_RES", ··· 651 638 .pc_decode = nlm4svc_decode_void, 652 639 .pc_encode = nlm4svc_encode_void, 653 640 .pc_argsize = sizeof(struct nlm_res), 641 + .pc_argzero = sizeof(struct nlm_res), 654 642 .pc_ressize = sizeof(struct nlm_void), 655 643 .pc_xdrressize = St, 656 644 .pc_name = "CANCEL_RES", ··· 661 647 .pc_decode = nlm4svc_decode_void, 662 648 .pc_encode = nlm4svc_encode_void, 663 649 .pc_argsize = sizeof(struct nlm_res), 650 + .pc_argzero = sizeof(struct nlm_res), 664 651 .pc_ressize = sizeof(struct nlm_void), 665 652 .pc_xdrressize = St, 666 653 .pc_name = "UNLOCK_RES", ··· 671 656 .pc_decode = nlm4svc_decode_res, 672 657 .pc_encode = nlm4svc_encode_void, 673 658 .pc_argsize = sizeof(struct nlm_res), 659 + .pc_argzero = sizeof(struct nlm_res), 674 660 .pc_ressize = sizeof(struct nlm_void), 675 661 .pc_xdrressize = St, 676 662 .pc_name = "GRANTED_RES", ··· 681 665 .pc_decode = nlm4svc_decode_reboot, 682 666 .pc_encode = nlm4svc_encode_void, 683 667 .pc_argsize = sizeof(struct nlm_reboot), 668 + .pc_argzero = sizeof(struct nlm_reboot), 684 669 .pc_ressize = sizeof(struct nlm_void), 685 670 .pc_xdrressize = St, 686 671 .pc_name = "SM_NOTIFY", ··· 691 674 .pc_decode = nlm4svc_decode_void, 692 675 .pc_encode = nlm4svc_encode_void, 693 676 .pc_argsize = sizeof(struct nlm_void), 677 + .pc_argzero = sizeof(struct nlm_void), 694 678 .pc_ressize = sizeof(struct nlm_void), 695 679 .pc_xdrressize = 0, 696 680 .pc_name = "UNUSED", ··· 701 683 .pc_decode = nlm4svc_decode_void, 702 684 .pc_encode = nlm4svc_encode_void, 703 685 .pc_argsize = sizeof(struct nlm_void), 686 + .pc_argzero = sizeof(struct nlm_void), 704 687 .pc_ressize = sizeof(struct nlm_void), 705 688 .pc_xdrressize = 0, 706 689 .pc_name = "UNUSED", ··· 711 692 .pc_decode = nlm4svc_decode_void, 712 693 .pc_encode = nlm4svc_encode_void, 713 694 .pc_argsize = sizeof(struct nlm_void), 695 + .pc_argzero = sizeof(struct nlm_void), 714 696 .pc_ressize = sizeof(struct nlm_void), 715 697 .pc_xdrressize = 0, 716 698 .pc_name = "UNUSED", ··· 721 701 .pc_decode = nlm4svc_decode_shareargs, 722 702 .pc_encode = nlm4svc_encode_shareres, 723 703 .pc_argsize = sizeof(struct nlm_args), 704 + .pc_argzero = sizeof(struct nlm_args), 724 705 .pc_ressize = sizeof(struct nlm_res), 725 706 .pc_xdrressize = Ck+St+1, 726 707 .pc_name = "SHARE", ··· 731 710 .pc_decode = nlm4svc_decode_shareargs, 732 711 .pc_encode = nlm4svc_encode_shareres, 733 712 .pc_argsize = sizeof(struct nlm_args), 713 + .pc_argzero = sizeof(struct nlm_args), 734 714 .pc_ressize = sizeof(struct nlm_res), 735 715 .pc_xdrressize = Ck+St+1, 736 716 .pc_name = "UNSHARE", ··· 741 719 .pc_decode = nlm4svc_decode_lockargs, 742 720 .pc_encode = nlm4svc_encode_res, 743 721 .pc_argsize = sizeof(struct nlm_args), 722 + .pc_argzero = sizeof(struct nlm_args), 744 723 .pc_ressize = sizeof(struct nlm_res), 745 724 .pc_xdrressize = Ck+St, 746 725 .pc_name = "NM_LOCK", ··· 751 728 .pc_decode = nlm4svc_decode_notify, 752 729 .pc_encode = nlm4svc_encode_void, 753 730 .pc_argsize = sizeof(struct nlm_args), 731 + .pc_argzero = sizeof(struct nlm_args), 754 732 .pc_ressize = sizeof(struct nlm_void), 755 733 .pc_xdrressize = St, 756 734 .pc_name = "FREE_ALL",
+24
fs/lockd/svcproc.c
··· 555 555 .pc_decode = nlmsvc_decode_void, 556 556 .pc_encode = nlmsvc_encode_void, 557 557 .pc_argsize = sizeof(struct nlm_void), 558 + .pc_argzero = sizeof(struct nlm_void), 558 559 .pc_ressize = sizeof(struct nlm_void), 559 560 .pc_xdrressize = St, 560 561 .pc_name = "NULL", ··· 565 564 .pc_decode = nlmsvc_decode_testargs, 566 565 .pc_encode = nlmsvc_encode_testres, 567 566 .pc_argsize = sizeof(struct nlm_args), 567 + .pc_argzero = sizeof(struct nlm_args), 568 568 .pc_ressize = sizeof(struct nlm_res), 569 569 .pc_xdrressize = Ck+St+2+No+Rg, 570 570 .pc_name = "TEST", ··· 575 573 .pc_decode = nlmsvc_decode_lockargs, 576 574 .pc_encode = nlmsvc_encode_res, 577 575 .pc_argsize = sizeof(struct nlm_args), 576 + .pc_argzero = sizeof(struct nlm_args), 578 577 .pc_ressize = sizeof(struct nlm_res), 579 578 .pc_xdrressize = Ck+St, 580 579 .pc_name = "LOCK", ··· 585 582 .pc_decode = nlmsvc_decode_cancargs, 586 583 .pc_encode = nlmsvc_encode_res, 587 584 .pc_argsize = sizeof(struct nlm_args), 585 + .pc_argzero = sizeof(struct nlm_args), 588 586 .pc_ressize = sizeof(struct nlm_res), 589 587 .pc_xdrressize = Ck+St, 590 588 .pc_name = "CANCEL", ··· 595 591 .pc_decode = nlmsvc_decode_unlockargs, 596 592 .pc_encode = nlmsvc_encode_res, 597 593 .pc_argsize = sizeof(struct nlm_args), 594 + .pc_argzero = sizeof(struct nlm_args), 598 595 .pc_ressize = sizeof(struct nlm_res), 599 596 .pc_xdrressize = Ck+St, 600 597 .pc_name = "UNLOCK", ··· 605 600 .pc_decode = nlmsvc_decode_testargs, 606 601 .pc_encode = nlmsvc_encode_res, 607 602 .pc_argsize = sizeof(struct nlm_args), 603 + .pc_argzero = sizeof(struct nlm_args), 608 604 .pc_ressize = sizeof(struct nlm_res), 609 605 .pc_xdrressize = Ck+St, 610 606 .pc_name = "GRANTED", ··· 615 609 .pc_decode = nlmsvc_decode_testargs, 616 610 .pc_encode = nlmsvc_encode_void, 617 611 .pc_argsize = sizeof(struct nlm_args), 612 + .pc_argzero = sizeof(struct nlm_args), 618 613 .pc_ressize = sizeof(struct nlm_void), 619 614 .pc_xdrressize = St, 620 615 .pc_name = "TEST_MSG", ··· 625 618 .pc_decode = nlmsvc_decode_lockargs, 626 619 .pc_encode = nlmsvc_encode_void, 627 620 .pc_argsize = sizeof(struct nlm_args), 621 + .pc_argzero = sizeof(struct nlm_args), 628 622 .pc_ressize = sizeof(struct nlm_void), 629 623 .pc_xdrressize = St, 630 624 .pc_name = "LOCK_MSG", ··· 635 627 .pc_decode = nlmsvc_decode_cancargs, 636 628 .pc_encode = nlmsvc_encode_void, 637 629 .pc_argsize = sizeof(struct nlm_args), 630 + .pc_argzero = sizeof(struct nlm_args), 638 631 .pc_ressize = sizeof(struct nlm_void), 639 632 .pc_xdrressize = St, 640 633 .pc_name = "CANCEL_MSG", ··· 645 636 .pc_decode = nlmsvc_decode_unlockargs, 646 637 .pc_encode = nlmsvc_encode_void, 647 638 .pc_argsize = sizeof(struct nlm_args), 639 + .pc_argzero = sizeof(struct nlm_args), 648 640 .pc_ressize = sizeof(struct nlm_void), 649 641 .pc_xdrressize = St, 650 642 .pc_name = "UNLOCK_MSG", ··· 655 645 .pc_decode = nlmsvc_decode_testargs, 656 646 .pc_encode = nlmsvc_encode_void, 657 647 .pc_argsize = sizeof(struct nlm_args), 648 + .pc_argzero = sizeof(struct nlm_args), 658 649 .pc_ressize = sizeof(struct nlm_void), 659 650 .pc_xdrressize = St, 660 651 .pc_name = "GRANTED_MSG", ··· 665 654 .pc_decode = nlmsvc_decode_void, 666 655 .pc_encode = nlmsvc_encode_void, 667 656 .pc_argsize = sizeof(struct nlm_res), 657 + .pc_argzero = sizeof(struct nlm_res), 668 658 .pc_ressize = sizeof(struct nlm_void), 669 659 .pc_xdrressize = St, 670 660 .pc_name = "TEST_RES", ··· 675 663 .pc_decode = nlmsvc_decode_void, 676 664 .pc_encode = nlmsvc_encode_void, 677 665 .pc_argsize = sizeof(struct nlm_res), 666 + .pc_argzero = sizeof(struct nlm_res), 678 667 .pc_ressize = sizeof(struct nlm_void), 679 668 .pc_xdrressize = St, 680 669 .pc_name = "LOCK_RES", ··· 685 672 .pc_decode = nlmsvc_decode_void, 686 673 .pc_encode = nlmsvc_encode_void, 687 674 .pc_argsize = sizeof(struct nlm_res), 675 + .pc_argzero = sizeof(struct nlm_res), 688 676 .pc_ressize = sizeof(struct nlm_void), 689 677 .pc_xdrressize = St, 690 678 .pc_name = "CANCEL_RES", ··· 695 681 .pc_decode = nlmsvc_decode_void, 696 682 .pc_encode = nlmsvc_encode_void, 697 683 .pc_argsize = sizeof(struct nlm_res), 684 + .pc_argzero = sizeof(struct nlm_res), 698 685 .pc_ressize = sizeof(struct nlm_void), 699 686 .pc_xdrressize = St, 700 687 .pc_name = "UNLOCK_RES", ··· 705 690 .pc_decode = nlmsvc_decode_res, 706 691 .pc_encode = nlmsvc_encode_void, 707 692 .pc_argsize = sizeof(struct nlm_res), 693 + .pc_argzero = sizeof(struct nlm_res), 708 694 .pc_ressize = sizeof(struct nlm_void), 709 695 .pc_xdrressize = St, 710 696 .pc_name = "GRANTED_RES", ··· 715 699 .pc_decode = nlmsvc_decode_reboot, 716 700 .pc_encode = nlmsvc_encode_void, 717 701 .pc_argsize = sizeof(struct nlm_reboot), 702 + .pc_argzero = sizeof(struct nlm_reboot), 718 703 .pc_ressize = sizeof(struct nlm_void), 719 704 .pc_xdrressize = St, 720 705 .pc_name = "SM_NOTIFY", ··· 725 708 .pc_decode = nlmsvc_decode_void, 726 709 .pc_encode = nlmsvc_encode_void, 727 710 .pc_argsize = sizeof(struct nlm_void), 711 + .pc_argzero = sizeof(struct nlm_void), 728 712 .pc_ressize = sizeof(struct nlm_void), 729 713 .pc_xdrressize = St, 730 714 .pc_name = "UNUSED", ··· 735 717 .pc_decode = nlmsvc_decode_void, 736 718 .pc_encode = nlmsvc_encode_void, 737 719 .pc_argsize = sizeof(struct nlm_void), 720 + .pc_argzero = sizeof(struct nlm_void), 738 721 .pc_ressize = sizeof(struct nlm_void), 739 722 .pc_xdrressize = St, 740 723 .pc_name = "UNUSED", ··· 745 726 .pc_decode = nlmsvc_decode_void, 746 727 .pc_encode = nlmsvc_encode_void, 747 728 .pc_argsize = sizeof(struct nlm_void), 729 + .pc_argzero = sizeof(struct nlm_void), 748 730 .pc_ressize = sizeof(struct nlm_void), 749 731 .pc_xdrressize = St, 750 732 .pc_name = "UNUSED", ··· 755 735 .pc_decode = nlmsvc_decode_shareargs, 756 736 .pc_encode = nlmsvc_encode_shareres, 757 737 .pc_argsize = sizeof(struct nlm_args), 738 + .pc_argzero = sizeof(struct nlm_args), 758 739 .pc_ressize = sizeof(struct nlm_res), 759 740 .pc_xdrressize = Ck+St+1, 760 741 .pc_name = "SHARE", ··· 765 744 .pc_decode = nlmsvc_decode_shareargs, 766 745 .pc_encode = nlmsvc_encode_shareres, 767 746 .pc_argsize = sizeof(struct nlm_args), 747 + .pc_argzero = sizeof(struct nlm_args), 768 748 .pc_ressize = sizeof(struct nlm_res), 769 749 .pc_xdrressize = Ck+St+1, 770 750 .pc_name = "UNSHARE", ··· 775 753 .pc_decode = nlmsvc_decode_lockargs, 776 754 .pc_encode = nlmsvc_encode_res, 777 755 .pc_argsize = sizeof(struct nlm_args), 756 + .pc_argzero = sizeof(struct nlm_args), 778 757 .pc_ressize = sizeof(struct nlm_res), 779 758 .pc_xdrressize = Ck+St, 780 759 .pc_name = "NM_LOCK", ··· 785 762 .pc_decode = nlmsvc_decode_notify, 786 763 .pc_encode = nlmsvc_encode_void, 787 764 .pc_argsize = sizeof(struct nlm_args), 765 + .pc_argzero = sizeof(struct nlm_args), 788 766 .pc_ressize = sizeof(struct nlm_void), 789 767 .pc_xdrressize = 0, 790 768 .pc_name = "FREE_ALL",
+1
fs/nfs/callback_xdr.c
··· 1065 1065 .pc_func = nfs4_callback_compound, 1066 1066 .pc_encode = nfs4_encode_void, 1067 1067 .pc_argsize = 256, 1068 + .pc_argzero = 256, 1068 1069 .pc_ressize = 256, 1069 1070 .pc_xdrressize = NFS4_CALLBACK_BUFSIZE, 1070 1071 .pc_name = "COMPOUND",
+1 -1
fs/nfsd/cache.h
··· 84 84 void nfsd_reply_cache_shutdown(struct nfsd_net *); 85 85 int nfsd_cache_lookup(struct svc_rqst *); 86 86 void nfsd_cache_update(struct svc_rqst *, int, __be32 *); 87 - int nfsd_reply_cache_stats_open(struct inode *, struct file *); 87 + int nfsd_reply_cache_stats_show(struct seq_file *m, void *v); 88 88 89 89 #endif /* NFSCACHE_H */
+1 -6
fs/nfsd/filecache.c
··· 1212 1212 * scraping this file for info should test the labels to ensure they're 1213 1213 * getting the correct field. 1214 1214 */ 1215 - static int nfsd_file_cache_stats_show(struct seq_file *m, void *v) 1215 + int nfsd_file_cache_stats_show(struct seq_file *m, void *v) 1216 1216 { 1217 1217 unsigned long releases = 0, pages_flushed = 0, evictions = 0; 1218 1218 unsigned long hits = 0, acquisitions = 0; ··· 1258 1258 seq_printf(m, "mean age (ms): -\n"); 1259 1259 seq_printf(m, "pages flushed: %lu\n", pages_flushed); 1260 1260 return 0; 1261 - } 1262 - 1263 - int nfsd_file_cache_stats_open(struct inode *inode, struct file *file) 1264 - { 1265 - return single_open(file, nfsd_file_cache_stats_show, NULL); 1266 1261 }
+1 -1
fs/nfsd/filecache.h
··· 60 60 unsigned int may_flags, struct nfsd_file **nfp); 61 61 __be32 nfsd_file_create(struct svc_rqst *rqstp, struct svc_fh *fhp, 62 62 unsigned int may_flags, struct nfsd_file **nfp); 63 - int nfsd_file_cache_stats_open(struct inode *, struct file *); 63 + int nfsd_file_cache_stats_show(struct seq_file *m, void *v); 64 64 #endif /* _FS_NFSD_FILECACHE_H */
+4
fs/nfsd/netns.h
··· 192 192 193 193 atomic_t nfs4_client_count; 194 194 int nfs4_max_clients; 195 + 196 + atomic_t nfsd_courtesy_clients; 197 + struct shrinker nfsd_client_shrinker; 198 + struct delayed_work nfsd_shrinker_work; 195 199 }; 196 200 197 201 /* Simple check to find out if a given net was properly initialized */
+5
fs/nfsd/nfs2acl.c
··· 331 331 .pc_decode = nfssvc_decode_voidarg, 332 332 .pc_encode = nfssvc_encode_voidres, 333 333 .pc_argsize = sizeof(struct nfsd_voidargs), 334 + .pc_argzero = sizeof(struct nfsd_voidargs), 334 335 .pc_ressize = sizeof(struct nfsd_voidres), 335 336 .pc_cachetype = RC_NOCACHE, 336 337 .pc_xdrressize = ST, ··· 343 342 .pc_encode = nfsaclsvc_encode_getaclres, 344 343 .pc_release = nfsaclsvc_release_getacl, 345 344 .pc_argsize = sizeof(struct nfsd3_getaclargs), 345 + .pc_argzero = sizeof(struct nfsd3_getaclargs), 346 346 .pc_ressize = sizeof(struct nfsd3_getaclres), 347 347 .pc_cachetype = RC_NOCACHE, 348 348 .pc_xdrressize = ST+1+2*(1+ACL), ··· 355 353 .pc_encode = nfssvc_encode_attrstatres, 356 354 .pc_release = nfssvc_release_attrstat, 357 355 .pc_argsize = sizeof(struct nfsd3_setaclargs), 356 + .pc_argzero = sizeof(struct nfsd3_setaclargs), 358 357 .pc_ressize = sizeof(struct nfsd_attrstat), 359 358 .pc_cachetype = RC_NOCACHE, 360 359 .pc_xdrressize = ST+AT, ··· 367 364 .pc_encode = nfssvc_encode_attrstatres, 368 365 .pc_release = nfssvc_release_attrstat, 369 366 .pc_argsize = sizeof(struct nfsd_fhandle), 367 + .pc_argzero = sizeof(struct nfsd_fhandle), 370 368 .pc_ressize = sizeof(struct nfsd_attrstat), 371 369 .pc_cachetype = RC_NOCACHE, 372 370 .pc_xdrressize = ST+AT, ··· 379 375 .pc_encode = nfsaclsvc_encode_accessres, 380 376 .pc_release = nfsaclsvc_release_access, 381 377 .pc_argsize = sizeof(struct nfsd3_accessargs), 378 + .pc_argzero = sizeof(struct nfsd3_accessargs), 382 379 .pc_ressize = sizeof(struct nfsd3_accessres), 383 380 .pc_cachetype = RC_NOCACHE, 384 381 .pc_xdrressize = ST+AT+1,
+3
fs/nfsd/nfs3acl.c
··· 252 252 .pc_decode = nfssvc_decode_voidarg, 253 253 .pc_encode = nfssvc_encode_voidres, 254 254 .pc_argsize = sizeof(struct nfsd_voidargs), 255 + .pc_argzero = sizeof(struct nfsd_voidargs), 255 256 .pc_ressize = sizeof(struct nfsd_voidres), 256 257 .pc_cachetype = RC_NOCACHE, 257 258 .pc_xdrressize = ST, ··· 264 263 .pc_encode = nfs3svc_encode_getaclres, 265 264 .pc_release = nfs3svc_release_getacl, 266 265 .pc_argsize = sizeof(struct nfsd3_getaclargs), 266 + .pc_argzero = sizeof(struct nfsd3_getaclargs), 267 267 .pc_ressize = sizeof(struct nfsd3_getaclres), 268 268 .pc_cachetype = RC_NOCACHE, 269 269 .pc_xdrressize = ST+1+2*(1+ACL), ··· 276 274 .pc_encode = nfs3svc_encode_setaclres, 277 275 .pc_release = nfs3svc_release_fhandle, 278 276 .pc_argsize = sizeof(struct nfsd3_setaclargs), 277 + .pc_argzero = sizeof(struct nfsd3_setaclargs), 279 278 .pc_ressize = sizeof(struct nfsd3_attrstat), 280 279 .pc_cachetype = RC_NOCACHE, 281 280 .pc_xdrressize = ST+pAT,
+29 -14
fs/nfsd/nfs3proc.c
··· 150 150 { 151 151 struct nfsd3_readargs *argp = rqstp->rq_argp; 152 152 struct nfsd3_readres *resp = rqstp->rq_resp; 153 - u32 max_blocksize = svc_max_payload(rqstp); 154 153 unsigned int len; 155 154 int v; 156 155 ··· 158 159 (unsigned long) argp->count, 159 160 (unsigned long long) argp->offset); 160 161 161 - argp->count = min_t(u32, argp->count, max_blocksize); 162 + argp->count = min_t(u32, argp->count, svc_max_payload(rqstp)); 163 + argp->count = min_t(u32, argp->count, rqstp->rq_res.buflen); 162 164 if (argp->offset > (u64)OFFSET_MAX) 163 165 argp->offset = (u64)OFFSET_MAX; 164 166 if (argp->offset + argp->count > (u64)OFFSET_MAX) ··· 563 563 { 564 564 struct xdr_buf *buf = &resp->dirlist; 565 565 struct xdr_stream *xdr = &resp->xdr; 566 - 567 - count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp)); 566 + unsigned int sendbuf = min_t(unsigned int, rqstp->rq_res.buflen, 567 + svc_max_payload(rqstp)); 568 568 569 569 memset(buf, 0, sizeof(*buf)); 570 570 571 571 /* Reserve room for the NULL ptr & eof flag (-2 words) */ 572 - buf->buflen = count - XDR_UNIT * 2; 572 + buf->buflen = clamp(count, (u32)(XDR_UNIT * 2), sendbuf); 573 + buf->buflen -= XDR_UNIT * 2; 573 574 buf->pages = rqstp->rq_next_page; 574 575 rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT; 575 576 576 - /* This is xdr_init_encode(), but it assumes that 577 - * the head kvec has already been consumed. */ 578 - xdr_set_scratch_buffer(xdr, NULL, 0); 579 - xdr->buf = buf; 580 - xdr->page_ptr = buf->pages; 581 - xdr->iov = NULL; 582 - xdr->p = page_address(*buf->pages); 583 - xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE); 584 - xdr->rqst = NULL; 577 + xdr_init_encode_pages(xdr, buf, buf->pages, NULL); 585 578 } 586 579 587 580 /* ··· 801 808 .pc_decode = nfssvc_decode_voidarg, 802 809 .pc_encode = nfssvc_encode_voidres, 803 810 .pc_argsize = sizeof(struct nfsd_voidargs), 811 + .pc_argzero = sizeof(struct nfsd_voidargs), 804 812 .pc_ressize = sizeof(struct nfsd_voidres), 805 813 .pc_cachetype = RC_NOCACHE, 806 814 .pc_xdrressize = ST, ··· 813 819 .pc_encode = nfs3svc_encode_getattrres, 814 820 .pc_release = nfs3svc_release_fhandle, 815 821 .pc_argsize = sizeof(struct nfsd_fhandle), 822 + .pc_argzero = sizeof(struct nfsd_fhandle), 816 823 .pc_ressize = sizeof(struct nfsd3_attrstatres), 817 824 .pc_cachetype = RC_NOCACHE, 818 825 .pc_xdrressize = ST+AT, ··· 825 830 .pc_encode = nfs3svc_encode_wccstatres, 826 831 .pc_release = nfs3svc_release_fhandle, 827 832 .pc_argsize = sizeof(struct nfsd3_sattrargs), 833 + .pc_argzero = sizeof(struct nfsd3_sattrargs), 828 834 .pc_ressize = sizeof(struct nfsd3_wccstatres), 829 835 .pc_cachetype = RC_REPLBUFF, 830 836 .pc_xdrressize = ST+WC, ··· 837 841 .pc_encode = nfs3svc_encode_lookupres, 838 842 .pc_release = nfs3svc_release_fhandle2, 839 843 .pc_argsize = sizeof(struct nfsd3_diropargs), 844 + .pc_argzero = sizeof(struct nfsd3_diropargs), 840 845 .pc_ressize = sizeof(struct nfsd3_diropres), 841 846 .pc_cachetype = RC_NOCACHE, 842 847 .pc_xdrressize = ST+FH+pAT+pAT, ··· 849 852 .pc_encode = nfs3svc_encode_accessres, 850 853 .pc_release = nfs3svc_release_fhandle, 851 854 .pc_argsize = sizeof(struct nfsd3_accessargs), 855 + .pc_argzero = sizeof(struct nfsd3_accessargs), 852 856 .pc_ressize = sizeof(struct nfsd3_accessres), 853 857 .pc_cachetype = RC_NOCACHE, 854 858 .pc_xdrressize = ST+pAT+1, ··· 861 863 .pc_encode = nfs3svc_encode_readlinkres, 862 864 .pc_release = nfs3svc_release_fhandle, 863 865 .pc_argsize = sizeof(struct nfsd_fhandle), 866 + .pc_argzero = sizeof(struct nfsd_fhandle), 864 867 .pc_ressize = sizeof(struct nfsd3_readlinkres), 865 868 .pc_cachetype = RC_NOCACHE, 866 869 .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4, ··· 873 874 .pc_encode = nfs3svc_encode_readres, 874 875 .pc_release = nfs3svc_release_fhandle, 875 876 .pc_argsize = sizeof(struct nfsd3_readargs), 877 + .pc_argzero = sizeof(struct nfsd3_readargs), 876 878 .pc_ressize = sizeof(struct nfsd3_readres), 877 879 .pc_cachetype = RC_NOCACHE, 878 880 .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4, ··· 885 885 .pc_encode = nfs3svc_encode_writeres, 886 886 .pc_release = nfs3svc_release_fhandle, 887 887 .pc_argsize = sizeof(struct nfsd3_writeargs), 888 + .pc_argzero = sizeof(struct nfsd3_writeargs), 888 889 .pc_ressize = sizeof(struct nfsd3_writeres), 889 890 .pc_cachetype = RC_REPLBUFF, 890 891 .pc_xdrressize = ST+WC+4, ··· 897 896 .pc_encode = nfs3svc_encode_createres, 898 897 .pc_release = nfs3svc_release_fhandle2, 899 898 .pc_argsize = sizeof(struct nfsd3_createargs), 899 + .pc_argzero = sizeof(struct nfsd3_createargs), 900 900 .pc_ressize = sizeof(struct nfsd3_createres), 901 901 .pc_cachetype = RC_REPLBUFF, 902 902 .pc_xdrressize = ST+(1+FH+pAT)+WC, ··· 909 907 .pc_encode = nfs3svc_encode_createres, 910 908 .pc_release = nfs3svc_release_fhandle2, 911 909 .pc_argsize = sizeof(struct nfsd3_mkdirargs), 910 + .pc_argzero = sizeof(struct nfsd3_mkdirargs), 912 911 .pc_ressize = sizeof(struct nfsd3_createres), 913 912 .pc_cachetype = RC_REPLBUFF, 914 913 .pc_xdrressize = ST+(1+FH+pAT)+WC, ··· 921 918 .pc_encode = nfs3svc_encode_createres, 922 919 .pc_release = nfs3svc_release_fhandle2, 923 920 .pc_argsize = sizeof(struct nfsd3_symlinkargs), 921 + .pc_argzero = sizeof(struct nfsd3_symlinkargs), 924 922 .pc_ressize = sizeof(struct nfsd3_createres), 925 923 .pc_cachetype = RC_REPLBUFF, 926 924 .pc_xdrressize = ST+(1+FH+pAT)+WC, ··· 933 929 .pc_encode = nfs3svc_encode_createres, 934 930 .pc_release = nfs3svc_release_fhandle2, 935 931 .pc_argsize = sizeof(struct nfsd3_mknodargs), 932 + .pc_argzero = sizeof(struct nfsd3_mknodargs), 936 933 .pc_ressize = sizeof(struct nfsd3_createres), 937 934 .pc_cachetype = RC_REPLBUFF, 938 935 .pc_xdrressize = ST+(1+FH+pAT)+WC, ··· 945 940 .pc_encode = nfs3svc_encode_wccstatres, 946 941 .pc_release = nfs3svc_release_fhandle, 947 942 .pc_argsize = sizeof(struct nfsd3_diropargs), 943 + .pc_argzero = sizeof(struct nfsd3_diropargs), 948 944 .pc_ressize = sizeof(struct nfsd3_wccstatres), 949 945 .pc_cachetype = RC_REPLBUFF, 950 946 .pc_xdrressize = ST+WC, ··· 957 951 .pc_encode = nfs3svc_encode_wccstatres, 958 952 .pc_release = nfs3svc_release_fhandle, 959 953 .pc_argsize = sizeof(struct nfsd3_diropargs), 954 + .pc_argzero = sizeof(struct nfsd3_diropargs), 960 955 .pc_ressize = sizeof(struct nfsd3_wccstatres), 961 956 .pc_cachetype = RC_REPLBUFF, 962 957 .pc_xdrressize = ST+WC, ··· 969 962 .pc_encode = nfs3svc_encode_renameres, 970 963 .pc_release = nfs3svc_release_fhandle2, 971 964 .pc_argsize = sizeof(struct nfsd3_renameargs), 965 + .pc_argzero = sizeof(struct nfsd3_renameargs), 972 966 .pc_ressize = sizeof(struct nfsd3_renameres), 973 967 .pc_cachetype = RC_REPLBUFF, 974 968 .pc_xdrressize = ST+WC+WC, ··· 981 973 .pc_encode = nfs3svc_encode_linkres, 982 974 .pc_release = nfs3svc_release_fhandle2, 983 975 .pc_argsize = sizeof(struct nfsd3_linkargs), 976 + .pc_argzero = sizeof(struct nfsd3_linkargs), 984 977 .pc_ressize = sizeof(struct nfsd3_linkres), 985 978 .pc_cachetype = RC_REPLBUFF, 986 979 .pc_xdrressize = ST+pAT+WC, ··· 993 984 .pc_encode = nfs3svc_encode_readdirres, 994 985 .pc_release = nfs3svc_release_fhandle, 995 986 .pc_argsize = sizeof(struct nfsd3_readdirargs), 987 + .pc_argzero = sizeof(struct nfsd3_readdirargs), 996 988 .pc_ressize = sizeof(struct nfsd3_readdirres), 997 989 .pc_cachetype = RC_NOCACHE, 998 990 .pc_name = "READDIR", ··· 1004 994 .pc_encode = nfs3svc_encode_readdirres, 1005 995 .pc_release = nfs3svc_release_fhandle, 1006 996 .pc_argsize = sizeof(struct nfsd3_readdirplusargs), 997 + .pc_argzero = sizeof(struct nfsd3_readdirplusargs), 1007 998 .pc_ressize = sizeof(struct nfsd3_readdirres), 1008 999 .pc_cachetype = RC_NOCACHE, 1009 1000 .pc_name = "READDIRPLUS", ··· 1014 1003 .pc_decode = nfs3svc_decode_fhandleargs, 1015 1004 .pc_encode = nfs3svc_encode_fsstatres, 1016 1005 .pc_argsize = sizeof(struct nfsd3_fhandleargs), 1006 + .pc_argzero = sizeof(struct nfsd3_fhandleargs), 1017 1007 .pc_ressize = sizeof(struct nfsd3_fsstatres), 1018 1008 .pc_cachetype = RC_NOCACHE, 1019 1009 .pc_xdrressize = ST+pAT+2*6+1, ··· 1025 1013 .pc_decode = nfs3svc_decode_fhandleargs, 1026 1014 .pc_encode = nfs3svc_encode_fsinfores, 1027 1015 .pc_argsize = sizeof(struct nfsd3_fhandleargs), 1016 + .pc_argzero = sizeof(struct nfsd3_fhandleargs), 1028 1017 .pc_ressize = sizeof(struct nfsd3_fsinfores), 1029 1018 .pc_cachetype = RC_NOCACHE, 1030 1019 .pc_xdrressize = ST+pAT+12, ··· 1036 1023 .pc_decode = nfs3svc_decode_fhandleargs, 1037 1024 .pc_encode = nfs3svc_encode_pathconfres, 1038 1025 .pc_argsize = sizeof(struct nfsd3_fhandleargs), 1026 + .pc_argzero = sizeof(struct nfsd3_fhandleargs), 1039 1027 .pc_ressize = sizeof(struct nfsd3_pathconfres), 1040 1028 .pc_cachetype = RC_NOCACHE, 1041 1029 .pc_xdrressize = ST+pAT+6, ··· 1048 1034 .pc_encode = nfs3svc_encode_commitres, 1049 1035 .pc_release = nfs3svc_release_fhandle, 1050 1036 .pc_argsize = sizeof(struct nfsd3_commitargs), 1037 + .pc_argzero = sizeof(struct nfsd3_commitargs), 1051 1038 .pc_ressize = sizeof(struct nfsd3_commitres), 1052 1039 .pc_cachetype = RC_NOCACHE, 1053 1040 .pc_xdrressize = ST+WC+2,
+4 -14
fs/nfsd/nfs3xdr.c
··· 571 571 args->count = max_blocksize; 572 572 args->len = max_blocksize; 573 573 } 574 - if (!xdr_stream_subsegment(xdr, &args->payload, args->count)) 575 - return false; 576 574 577 - return true; 575 + return xdr_stream_subsegment(xdr, &args->payload, args->count); 578 576 } 579 577 580 578 bool ··· 614 616 { 615 617 struct nfsd3_symlinkargs *args = rqstp->rq_argp; 616 618 struct kvec *head = rqstp->rq_arg.head; 617 - struct kvec *tail = rqstp->rq_arg.tail; 618 - size_t remaining; 619 619 620 620 if (!svcxdr_decode_diropargs3(xdr, &args->ffh, &args->fname, &args->flen)) 621 621 return false; ··· 622 626 if (xdr_stream_decode_u32(xdr, &args->tlen) < 0) 623 627 return false; 624 628 625 - /* request sanity */ 626 - remaining = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len; 627 - remaining -= xdr_stream_pos(xdr); 628 - if (remaining < xdr_align_size(args->tlen)) 629 - return false; 630 - 631 - args->first.iov_base = xdr->p; 629 + /* symlink_data */ 632 630 args->first.iov_len = head->iov_len - xdr_stream_pos(xdr); 633 - 634 - return true; 631 + args->first.iov_base = xdr_inline_decode(xdr, args->tlen); 632 + return args->first.iov_base != NULL; 635 633 } 636 634 637 635 bool
+12 -2
fs/nfsd/nfs4callback.c
··· 1371 1371 cb->cb_holds_slot = false; 1372 1372 } 1373 1373 1374 - void nfsd4_run_cb(struct nfsd4_callback *cb) 1374 + /** 1375 + * nfsd4_run_cb - queue up a callback job to run 1376 + * @cb: callback to queue 1377 + * 1378 + * Kick off a callback to do its thing. Returns false if it was already 1379 + * on a queue, true otherwise. 1380 + */ 1381 + bool nfsd4_run_cb(struct nfsd4_callback *cb) 1375 1382 { 1376 1383 struct nfs4_client *clp = cb->cb_clp; 1384 + bool queued; 1377 1385 1378 1386 nfsd41_cb_inflight_begin(clp); 1379 - if (!nfsd4_queue_cb(cb)) 1387 + queued = nfsd4_queue_cb(cb); 1388 + if (!queued) 1380 1389 nfsd41_cb_inflight_end(clp); 1390 + return queued; 1381 1391 }
+4 -4
fs/nfsd/nfs4idmap.c
··· 82 82 new->id = itm->id; 83 83 new->type = itm->type; 84 84 85 - strlcpy(new->name, itm->name, sizeof(new->name)); 86 - strlcpy(new->authname, itm->authname, sizeof(new->authname)); 85 + strscpy(new->name, itm->name, sizeof(new->name)); 86 + strscpy(new->authname, itm->authname, sizeof(new->authname)); 87 87 } 88 88 89 89 static void ··· 548 548 return nfserr_badowner; 549 549 memcpy(key.name, name, namelen); 550 550 key.name[namelen] = '\0'; 551 - strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname)); 551 + strscpy(key.authname, rqst_authname(rqstp), sizeof(key.authname)); 552 552 ret = idmap_lookup(rqstp, nametoid_lookup, &key, nn->nametoid_cache, &item); 553 553 if (ret == -ENOENT) 554 554 return nfserr_badowner; ··· 584 584 int ret; 585 585 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); 586 586 587 - strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname)); 587 + strscpy(key.authname, rqst_authname(rqstp), sizeof(key.authname)); 588 588 ret = idmap_lookup(rqstp, idtoname_lookup, &key, nn->idtoname_cache, &item); 589 589 if (ret == -ENOENT) 590 590 return encode_ascii_id(xdr, id);
+1 -1
fs/nfsd/nfs4layouts.c
··· 658 658 ktime_t now, cutoff; 659 659 const struct nfsd4_layout_ops *ops; 660 660 661 - 661 + trace_nfsd_cb_layout_done(&ls->ls_stid.sc_stateid, task); 662 662 switch (task->tk_status) { 663 663 case 0: 664 664 case -NFS4ERR_DELAY:
+133 -93
fs/nfsd/nfs4proc.c
··· 141 141 static __be32 142 142 do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open, int accmode) 143 143 { 144 - __be32 status; 145 144 146 145 if (open->op_truncate && 147 146 !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) ··· 155 156 if (open->op_share_deny & NFS4_SHARE_DENY_READ) 156 157 accmode |= NFSD_MAY_WRITE; 157 158 158 - status = fh_verify(rqstp, current_fh, S_IFREG, accmode); 159 - 160 - return status; 159 + return fh_verify(rqstp, current_fh, S_IFREG, accmode); 161 160 } 162 161 163 162 static __be32 nfsd_check_obj_isreg(struct svc_fh *fh) ··· 451 454 do_open_fhandle(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_open *open) 452 455 { 453 456 struct svc_fh *current_fh = &cstate->current_fh; 454 - __be32 status; 455 457 int accmode = 0; 456 458 457 459 /* We don't know the target directory, and therefore can not ··· 475 479 if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH) 476 480 accmode = NFSD_MAY_OWNER_OVERRIDE; 477 481 478 - status = do_open_permission(rqstp, current_fh, open, accmode); 479 - 480 - return status; 482 + return do_open_permission(rqstp, current_fh, open, accmode); 481 483 } 482 484 483 485 static void ··· 662 668 nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, 663 669 union nfsd4_op_u *u) 664 670 { 665 - __be32 status; 666 - 667 671 fh_put(&cstate->current_fh); 668 - status = exp_pseudoroot(rqstp, &cstate->current_fh); 669 - return status; 672 + 673 + return exp_pseudoroot(rqstp, &cstate->current_fh); 670 674 } 671 675 672 676 static __be32 ··· 1335 1343 return 0; 1336 1344 } 1337 1345 if (work) { 1338 - strlcpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1); 1346 + strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1); 1339 1347 refcount_set(&work->nsui_refcnt, 2); 1340 1348 work->nsui_busy = true; 1341 1349 list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list); ··· 1613 1621 static int nfsd4_cb_offload_done(struct nfsd4_callback *cb, 1614 1622 struct rpc_task *task) 1615 1623 { 1624 + struct nfsd4_cb_offload *cbo = 1625 + container_of(cb, struct nfsd4_cb_offload, co_cb); 1626 + 1627 + trace_nfsd_cb_offload_done(&cbo->co_res.cb_stateid, task); 1616 1628 return 1; 1617 1629 } 1618 1630 ··· 1764 1768 filp = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh, 1765 1769 &copy->stateid); 1766 1770 if (IS_ERR(filp)) { 1767 - nfserr = nfserr_offload_denied; 1771 + switch (PTR_ERR(filp)) { 1772 + case -EBADF: 1773 + nfserr = nfserr_wrong_type; 1774 + break; 1775 + default: 1776 + nfserr = nfserr_offload_denied; 1777 + } 1768 1778 nfsd4_interssc_disconnect(copy->ss_mnt); 1769 1779 goto do_callback; 1770 1780 } ··· 1828 1826 if (!nfs4_init_copy_state(nn, copy)) 1829 1827 goto out_err; 1830 1828 refcount_set(&async_copy->refcount, 1); 1831 - memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.stid, 1829 + memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.cs_stid, 1832 1830 sizeof(copy->cp_res.cb_stateid)); 1833 1831 dup_copy_fields(copy, async_copy); 1834 1832 async_copy->copy_task = kthread_create(nfsd4_do_async_copy, ··· 1864 1862 1865 1863 spin_lock(&clp->async_lock); 1866 1864 list_for_each_entry(copy, &clp->async_copies, copies) { 1867 - if (memcmp(&copy->cp_stateid.stid, stateid, NFS4_STATEID_SIZE)) 1865 + if (memcmp(&copy->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE)) 1868 1866 continue; 1869 1867 refcount_inc(&copy->refcount); 1870 1868 spin_unlock(&clp->async_lock); ··· 1918 1916 cps = nfs4_alloc_init_cpntf_state(nn, stid); 1919 1917 if (!cps) 1920 1918 goto out; 1921 - memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.stid, sizeof(stateid_t)); 1919 + memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.cs_stid, sizeof(stateid_t)); 1922 1920 memcpy(&cps->cp_p_stateid, &stid->sc_stateid, sizeof(stateid_t)); 1923 1921 memcpy(&cps->cp_p_clid, &clp->cl_clientid, sizeof(clientid_t)); 1924 1922 ··· 2635 2633 status = nfserr_minor_vers_mismatch; 2636 2634 if (nfsd_minorversion(nn, args->minorversion, NFSD_TEST) <= 0) 2637 2635 goto out; 2638 - status = nfserr_resource; 2639 - if (args->opcnt > NFSD_MAX_OPS_PER_COMPOUND) 2640 - goto out; 2641 2636 2642 2637 status = nfs41_check_op_ordering(args); 2643 2638 if (status) { ··· 2647 2648 2648 2649 rqstp->rq_lease_breaker = (void **)&cstate->clp; 2649 2650 2650 - trace_nfsd_compound(rqstp, args->opcnt); 2651 + trace_nfsd_compound(rqstp, args->tag, args->taglen, args->client_opcnt); 2651 2652 while (!status && resp->opcnt < args->opcnt) { 2652 2653 op = &args->ops[resp->opcnt++]; 2654 + 2655 + if (unlikely(resp->opcnt == NFSD_MAX_OPS_PER_COMPOUND)) { 2656 + /* If there are still more operations to process, 2657 + * stop here and report NFS4ERR_RESOURCE. */ 2658 + if (cstate->minorversion == 0 && 2659 + args->client_opcnt > resp->opcnt) { 2660 + op->status = nfserr_resource; 2661 + goto encode_op; 2662 + } 2663 + } 2653 2664 2654 2665 /* 2655 2666 * The XDR decode routines may have pre-set op->status; ··· 2736 2727 status = op->status; 2737 2728 } 2738 2729 2739 - trace_nfsd_compound_status(args->opcnt, resp->opcnt, status, 2740 - nfsd4_op_name(op->opnum)); 2730 + trace_nfsd_compound_status(args->client_opcnt, resp->opcnt, 2731 + status, nfsd4_op_name(op->opnum)); 2741 2732 2742 2733 nfsd4_cstate_clear_replay(cstate); 2743 2734 nfsd4_increment_op_stats(op->opnum); ··· 2771 2762 2772 2763 #define op_encode_channel_attrs_maxsz (6 + 1 + 1) 2773 2764 2774 - static inline u32 nfsd4_only_status_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2765 + /* 2766 + * The _rsize() helpers are invoked by the NFSv4 COMPOUND decoder, which 2767 + * is called before sunrpc sets rq_res.buflen. Thus we have to compute 2768 + * the maximum payload size here, based on transport limits and the size 2769 + * of the remaining space in the rq_pages array. 2770 + */ 2771 + static u32 nfsd4_max_payload(const struct svc_rqst *rqstp) 2772 + { 2773 + u32 buflen; 2774 + 2775 + buflen = (rqstp->rq_page_end - rqstp->rq_next_page) * PAGE_SIZE; 2776 + buflen -= rqstp->rq_auth_slack; 2777 + buflen -= rqstp->rq_res.head[0].iov_len; 2778 + return min_t(u32, buflen, svc_max_payload(rqstp)); 2779 + } 2780 + 2781 + static u32 nfsd4_only_status_rsize(const struct svc_rqst *rqstp, 2782 + const struct nfsd4_op *op) 2775 2783 { 2776 2784 return (op_encode_hdr_size) * sizeof(__be32); 2777 2785 } 2778 2786 2779 - static inline u32 nfsd4_status_stateid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2787 + static u32 nfsd4_status_stateid_rsize(const struct svc_rqst *rqstp, 2788 + const struct nfsd4_op *op) 2780 2789 { 2781 2790 return (op_encode_hdr_size + op_encode_stateid_maxsz)* sizeof(__be32); 2782 2791 } 2783 2792 2784 - static inline u32 nfsd4_access_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2793 + static u32 nfsd4_access_rsize(const struct svc_rqst *rqstp, 2794 + const struct nfsd4_op *op) 2785 2795 { 2786 2796 /* ac_supported, ac_resp_access */ 2787 2797 return (op_encode_hdr_size + 2)* sizeof(__be32); 2788 2798 } 2789 2799 2790 - static inline u32 nfsd4_commit_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2800 + static u32 nfsd4_commit_rsize(const struct svc_rqst *rqstp, 2801 + const struct nfsd4_op *op) 2791 2802 { 2792 2803 return (op_encode_hdr_size + op_encode_verifier_maxsz) * sizeof(__be32); 2793 2804 } 2794 2805 2795 - static inline u32 nfsd4_create_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2806 + static u32 nfsd4_create_rsize(const struct svc_rqst *rqstp, 2807 + const struct nfsd4_op *op) 2796 2808 { 2797 2809 return (op_encode_hdr_size + op_encode_change_info_maxsz 2798 2810 + nfs4_fattr_bitmap_maxsz) * sizeof(__be32); ··· 2824 2794 * the op prematurely if the estimate is too large. We may turn off splice 2825 2795 * reads unnecessarily. 2826 2796 */ 2827 - static inline u32 nfsd4_getattr_rsize(struct svc_rqst *rqstp, 2828 - struct nfsd4_op *op) 2797 + static u32 nfsd4_getattr_rsize(const struct svc_rqst *rqstp, 2798 + const struct nfsd4_op *op) 2829 2799 { 2830 - u32 *bmap = op->u.getattr.ga_bmval; 2800 + const u32 *bmap = op->u.getattr.ga_bmval; 2831 2801 u32 bmap0 = bmap[0], bmap1 = bmap[1], bmap2 = bmap[2]; 2832 2802 u32 ret = 0; 2833 2803 2834 2804 if (bmap0 & FATTR4_WORD0_ACL) 2835 - return svc_max_payload(rqstp); 2805 + return nfsd4_max_payload(rqstp); 2836 2806 if (bmap0 & FATTR4_WORD0_FS_LOCATIONS) 2837 - return svc_max_payload(rqstp); 2807 + return nfsd4_max_payload(rqstp); 2838 2808 2839 2809 if (bmap1 & FATTR4_WORD1_OWNER) { 2840 2810 ret += IDMAP_NAMESZ + 4; ··· 2862 2832 return ret; 2863 2833 } 2864 2834 2865 - static inline u32 nfsd4_getfh_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2835 + static u32 nfsd4_getfh_rsize(const struct svc_rqst *rqstp, 2836 + const struct nfsd4_op *op) 2866 2837 { 2867 2838 return (op_encode_hdr_size + 1) * sizeof(__be32) + NFS4_FHSIZE; 2868 2839 } 2869 2840 2870 - static inline u32 nfsd4_link_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2841 + static u32 nfsd4_link_rsize(const struct svc_rqst *rqstp, 2842 + const struct nfsd4_op *op) 2871 2843 { 2872 2844 return (op_encode_hdr_size + op_encode_change_info_maxsz) 2873 2845 * sizeof(__be32); 2874 2846 } 2875 2847 2876 - static inline u32 nfsd4_lock_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2848 + static u32 nfsd4_lock_rsize(const struct svc_rqst *rqstp, 2849 + const struct nfsd4_op *op) 2877 2850 { 2878 2851 return (op_encode_hdr_size + op_encode_lock_denied_maxsz) 2879 2852 * sizeof(__be32); 2880 2853 } 2881 2854 2882 - static inline u32 nfsd4_open_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2855 + static u32 nfsd4_open_rsize(const struct svc_rqst *rqstp, 2856 + const struct nfsd4_op *op) 2883 2857 { 2884 2858 return (op_encode_hdr_size + op_encode_stateid_maxsz 2885 2859 + op_encode_change_info_maxsz + 1 ··· 2891 2857 + op_encode_delegation_maxsz) * sizeof(__be32); 2892 2858 } 2893 2859 2894 - static inline u32 nfsd4_read_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2860 + static u32 nfsd4_read_rsize(const struct svc_rqst *rqstp, 2861 + const struct nfsd4_op *op) 2895 2862 { 2896 - u32 maxcount = 0, rlen = 0; 2897 - 2898 - maxcount = svc_max_payload(rqstp); 2899 - rlen = min(op->u.read.rd_length, maxcount); 2863 + u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); 2900 2864 2901 2865 return (op_encode_hdr_size + 2 + XDR_QUADLEN(rlen)) * sizeof(__be32); 2902 2866 } 2903 2867 2904 - static inline u32 nfsd4_read_plus_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2868 + static u32 nfsd4_read_plus_rsize(const struct svc_rqst *rqstp, 2869 + const struct nfsd4_op *op) 2905 2870 { 2906 - u32 maxcount = svc_max_payload(rqstp); 2907 - u32 rlen = min(op->u.read.rd_length, maxcount); 2871 + u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); 2908 2872 /* 2909 2873 * If we detect that the file changed during hole encoding, then we 2910 2874 * recover by encoding the remaining reply as data. This means we need ··· 2913 2881 return (op_encode_hdr_size + 2 + seg_len + XDR_QUADLEN(rlen)) * sizeof(__be32); 2914 2882 } 2915 2883 2916 - static inline u32 nfsd4_readdir_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2884 + static u32 nfsd4_readdir_rsize(const struct svc_rqst *rqstp, 2885 + const struct nfsd4_op *op) 2917 2886 { 2918 - u32 maxcount = 0, rlen = 0; 2919 - 2920 - maxcount = svc_max_payload(rqstp); 2921 - rlen = min(op->u.readdir.rd_maxcount, maxcount); 2887 + u32 rlen = min(op->u.readdir.rd_maxcount, nfsd4_max_payload(rqstp)); 2922 2888 2923 2889 return (op_encode_hdr_size + op_encode_verifier_maxsz + 2924 2890 XDR_QUADLEN(rlen)) * sizeof(__be32); 2925 2891 } 2926 2892 2927 - static inline u32 nfsd4_readlink_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2893 + static u32 nfsd4_readlink_rsize(const struct svc_rqst *rqstp, 2894 + const struct nfsd4_op *op) 2928 2895 { 2929 2896 return (op_encode_hdr_size + 1) * sizeof(__be32) + PAGE_SIZE; 2930 2897 } 2931 2898 2932 - static inline u32 nfsd4_remove_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2899 + static u32 nfsd4_remove_rsize(const struct svc_rqst *rqstp, 2900 + const struct nfsd4_op *op) 2933 2901 { 2934 2902 return (op_encode_hdr_size + op_encode_change_info_maxsz) 2935 2903 * sizeof(__be32); 2936 2904 } 2937 2905 2938 - static inline u32 nfsd4_rename_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2906 + static u32 nfsd4_rename_rsize(const struct svc_rqst *rqstp, 2907 + const struct nfsd4_op *op) 2939 2908 { 2940 2909 return (op_encode_hdr_size + op_encode_change_info_maxsz 2941 2910 + op_encode_change_info_maxsz) * sizeof(__be32); 2942 2911 } 2943 2912 2944 - static inline u32 nfsd4_sequence_rsize(struct svc_rqst *rqstp, 2945 - struct nfsd4_op *op) 2913 + static u32 nfsd4_sequence_rsize(const struct svc_rqst *rqstp, 2914 + const struct nfsd4_op *op) 2946 2915 { 2947 2916 return (op_encode_hdr_size 2948 2917 + XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) * sizeof(__be32); 2949 2918 } 2950 2919 2951 - static inline u32 nfsd4_test_stateid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2920 + static u32 nfsd4_test_stateid_rsize(const struct svc_rqst *rqstp, 2921 + const struct nfsd4_op *op) 2952 2922 { 2953 2923 return (op_encode_hdr_size + 1 + op->u.test_stateid.ts_num_ids) 2954 2924 * sizeof(__be32); 2955 2925 } 2956 2926 2957 - static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2927 + static u32 nfsd4_setattr_rsize(const struct svc_rqst *rqstp, 2928 + const struct nfsd4_op *op) 2958 2929 { 2959 2930 return (op_encode_hdr_size + nfs4_fattr_bitmap_maxsz) * sizeof(__be32); 2960 2931 } 2961 2932 2962 - static inline u32 nfsd4_secinfo_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2933 + static u32 nfsd4_secinfo_rsize(const struct svc_rqst *rqstp, 2934 + const struct nfsd4_op *op) 2963 2935 { 2964 2936 return (op_encode_hdr_size + RPC_AUTH_MAXFLAVOR * 2965 2937 (4 + XDR_QUADLEN(GSS_OID_MAX_LEN))) * sizeof(__be32); 2966 2938 } 2967 2939 2968 - static inline u32 nfsd4_setclientid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2940 + static u32 nfsd4_setclientid_rsize(const struct svc_rqst *rqstp, 2941 + const struct nfsd4_op *op) 2969 2942 { 2970 2943 return (op_encode_hdr_size + 2 + XDR_QUADLEN(NFS4_VERIFIER_SIZE)) * 2971 2944 sizeof(__be32); 2972 2945 } 2973 2946 2974 - static inline u32 nfsd4_write_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2947 + static u32 nfsd4_write_rsize(const struct svc_rqst *rqstp, 2948 + const struct nfsd4_op *op) 2975 2949 { 2976 2950 return (op_encode_hdr_size + 2 + op_encode_verifier_maxsz) * sizeof(__be32); 2977 2951 } 2978 2952 2979 - static inline u32 nfsd4_exchange_id_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2953 + static u32 nfsd4_exchange_id_rsize(const struct svc_rqst *rqstp, 2954 + const struct nfsd4_op *op) 2980 2955 { 2981 2956 return (op_encode_hdr_size + 2 + 1 + /* eir_clientid, eir_sequenceid */\ 2982 2957 1 + 1 + /* eir_flags, spr_how */\ ··· 2997 2958 0 /* ignored eir_server_impl_id contents */) * sizeof(__be32); 2998 2959 } 2999 2960 3000 - static inline u32 nfsd4_bind_conn_to_session_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2961 + static u32 nfsd4_bind_conn_to_session_rsize(const struct svc_rqst *rqstp, 2962 + const struct nfsd4_op *op) 3001 2963 { 3002 2964 return (op_encode_hdr_size + \ 3003 2965 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + /* bctsr_sessid */\ 3004 2966 2 /* bctsr_dir, use_conn_in_rdma_mode */) * sizeof(__be32); 3005 2967 } 3006 2968 3007 - static inline u32 nfsd4_create_session_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2969 + static u32 nfsd4_create_session_rsize(const struct svc_rqst *rqstp, 2970 + const struct nfsd4_op *op) 3008 2971 { 3009 2972 return (op_encode_hdr_size + \ 3010 2973 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + /* sessionid */\ ··· 3015 2974 op_encode_channel_attrs_maxsz) * sizeof(__be32); 3016 2975 } 3017 2976 3018 - static inline u32 nfsd4_copy_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 2977 + static u32 nfsd4_copy_rsize(const struct svc_rqst *rqstp, 2978 + const struct nfsd4_op *op) 3019 2979 { 3020 2980 return (op_encode_hdr_size + 3021 2981 1 /* wr_callback */ + ··· 3028 2986 1 /* cr_synchronous */) * sizeof(__be32); 3029 2987 } 3030 2988 3031 - static inline u32 nfsd4_offload_status_rsize(struct svc_rqst *rqstp, 3032 - struct nfsd4_op *op) 2989 + static u32 nfsd4_offload_status_rsize(const struct svc_rqst *rqstp, 2990 + const struct nfsd4_op *op) 3033 2991 { 3034 2992 return (op_encode_hdr_size + 3035 2993 2 /* osr_count */ + 3036 2994 1 /* osr_complete<1> optional 0 for now */) * sizeof(__be32); 3037 2995 } 3038 2996 3039 - static inline u32 nfsd4_copy_notify_rsize(struct svc_rqst *rqstp, 3040 - struct nfsd4_op *op) 2997 + static u32 nfsd4_copy_notify_rsize(const struct svc_rqst *rqstp, 2998 + const struct nfsd4_op *op) 3041 2999 { 3042 3000 return (op_encode_hdr_size + 3043 3001 3 /* cnr_lease_time */ + ··· 3052 3010 } 3053 3011 3054 3012 #ifdef CONFIG_NFSD_PNFS 3055 - static inline u32 nfsd4_getdeviceinfo_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 3013 + static u32 nfsd4_getdeviceinfo_rsize(const struct svc_rqst *rqstp, 3014 + const struct nfsd4_op *op) 3056 3015 { 3057 - u32 maxcount = 0, rlen = 0; 3058 - 3059 - maxcount = svc_max_payload(rqstp); 3060 - rlen = min(op->u.getdeviceinfo.gd_maxcount, maxcount); 3016 + u32 rlen = min(op->u.getdeviceinfo.gd_maxcount, nfsd4_max_payload(rqstp)); 3061 3017 3062 3018 return (op_encode_hdr_size + 3063 3019 1 /* gd_layout_type*/ + ··· 3068 3028 * so we need to define an arbitrary upper bound here. 3069 3029 */ 3070 3030 #define MAX_LAYOUT_SIZE 128 3071 - static inline u32 nfsd4_layoutget_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 3031 + static u32 nfsd4_layoutget_rsize(const struct svc_rqst *rqstp, 3032 + const struct nfsd4_op *op) 3072 3033 { 3073 3034 return (op_encode_hdr_size + 3074 3035 1 /* logr_return_on_close */ + ··· 3078 3037 MAX_LAYOUT_SIZE) * sizeof(__be32); 3079 3038 } 3080 3039 3081 - static inline u32 nfsd4_layoutcommit_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 3040 + static u32 nfsd4_layoutcommit_rsize(const struct svc_rqst *rqstp, 3041 + const struct nfsd4_op *op) 3082 3042 { 3083 3043 return (op_encode_hdr_size + 3084 3044 1 /* locr_newsize */ + 3085 3045 2 /* ns_size */) * sizeof(__be32); 3086 3046 } 3087 3047 3088 - static inline u32 nfsd4_layoutreturn_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 3048 + static u32 nfsd4_layoutreturn_rsize(const struct svc_rqst *rqstp, 3049 + const struct nfsd4_op *op) 3089 3050 { 3090 3051 return (op_encode_hdr_size + 3091 3052 1 /* lrs_stateid */ + ··· 3096 3053 #endif /* CONFIG_NFSD_PNFS */ 3097 3054 3098 3055 3099 - static inline u32 nfsd4_seek_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 3056 + static u32 nfsd4_seek_rsize(const struct svc_rqst *rqstp, 3057 + const struct nfsd4_op *op) 3100 3058 { 3101 3059 return (op_encode_hdr_size + 3) * sizeof(__be32); 3102 3060 } 3103 3061 3104 - static inline u32 nfsd4_getxattr_rsize(struct svc_rqst *rqstp, 3105 - struct nfsd4_op *op) 3062 + static u32 nfsd4_getxattr_rsize(const struct svc_rqst *rqstp, 3063 + const struct nfsd4_op *op) 3106 3064 { 3107 - u32 maxcount, rlen; 3108 - 3109 - maxcount = svc_max_payload(rqstp); 3110 - rlen = min_t(u32, XATTR_SIZE_MAX, maxcount); 3065 + u32 rlen = min_t(u32, XATTR_SIZE_MAX, nfsd4_max_payload(rqstp)); 3111 3066 3112 3067 return (op_encode_hdr_size + 1 + XDR_QUADLEN(rlen)) * sizeof(__be32); 3113 3068 } 3114 3069 3115 - static inline u32 nfsd4_setxattr_rsize(struct svc_rqst *rqstp, 3116 - struct nfsd4_op *op) 3070 + static u32 nfsd4_setxattr_rsize(const struct svc_rqst *rqstp, 3071 + const struct nfsd4_op *op) 3117 3072 { 3118 3073 return (op_encode_hdr_size + op_encode_change_info_maxsz) 3119 3074 * sizeof(__be32); 3120 3075 } 3121 - static inline u32 nfsd4_listxattrs_rsize(struct svc_rqst *rqstp, 3122 - struct nfsd4_op *op) 3076 + static u32 nfsd4_listxattrs_rsize(const struct svc_rqst *rqstp, 3077 + const struct nfsd4_op *op) 3123 3078 { 3124 - u32 maxcount, rlen; 3125 - 3126 - maxcount = svc_max_payload(rqstp); 3127 - rlen = min(op->u.listxattrs.lsxa_maxcount, maxcount); 3079 + u32 rlen = min(op->u.listxattrs.lsxa_maxcount, nfsd4_max_payload(rqstp)); 3128 3080 3129 3081 return (op_encode_hdr_size + 4 + XDR_QUADLEN(rlen)) * sizeof(__be32); 3130 3082 } 3131 3083 3132 - static inline u32 nfsd4_removexattr_rsize(struct svc_rqst *rqstp, 3133 - struct nfsd4_op *op) 3084 + static u32 nfsd4_removexattr_rsize(const struct svc_rqst *rqstp, 3085 + const struct nfsd4_op *op) 3134 3086 { 3135 3087 return (op_encode_hdr_size + op_encode_change_info_maxsz) 3136 3088 * sizeof(__be32); ··· 3614 3576 .pc_decode = nfssvc_decode_voidarg, 3615 3577 .pc_encode = nfssvc_encode_voidres, 3616 3578 .pc_argsize = sizeof(struct nfsd_voidargs), 3579 + .pc_argzero = sizeof(struct nfsd_voidargs), 3617 3580 .pc_ressize = sizeof(struct nfsd_voidres), 3618 3581 .pc_cachetype = RC_NOCACHE, 3619 3582 .pc_xdrressize = 1, ··· 3625 3586 .pc_decode = nfs4svc_decode_compoundargs, 3626 3587 .pc_encode = nfs4svc_encode_compoundres, 3627 3588 .pc_argsize = sizeof(struct nfsd4_compoundargs), 3589 + .pc_argzero = offsetof(struct nfsd4_compoundargs, iops), 3628 3590 .pc_ressize = sizeof(struct nfsd4_compoundres), 3629 3591 .pc_release = nfsd4_release_compoundargs, 3630 3592 .pc_cachetype = RC_NOCACHE,
+8 -6
fs/nfsd/nfs4recover.c
··· 807 807 if (get_user(namelen, &ci->cc_name.cn_len)) 808 808 return -EFAULT; 809 809 name.data = memdup_user(&ci->cc_name.cn_id, namelen); 810 - if (IS_ERR_OR_NULL(name.data)) 811 - return -EFAULT; 810 + if (IS_ERR(name.data)) 811 + return PTR_ERR(name.data); 812 812 name.len = namelen; 813 813 get_user(princhashlen, &ci->cc_princhash.cp_len); 814 814 if (princhashlen > 0) { 815 815 princhash.data = memdup_user( 816 816 &ci->cc_princhash.cp_data, 817 817 princhashlen); 818 - if (IS_ERR_OR_NULL(princhash.data)) 819 - return -EFAULT; 818 + if (IS_ERR(princhash.data)) { 819 + kfree(name.data); 820 + return PTR_ERR(princhash.data); 821 + } 820 822 princhash.len = princhashlen; 821 823 } else 822 824 princhash.len = 0; ··· 829 827 if (get_user(namelen, &cnm->cn_len)) 830 828 return -EFAULT; 831 829 name.data = memdup_user(&cnm->cn_id, namelen); 832 - if (IS_ERR_OR_NULL(name.data)) 833 - return -EFAULT; 830 + if (IS_ERR(name.data)) 831 + return PTR_ERR(name.data); 834 832 name.len = namelen; 835 833 } 836 834 if (name.len > 5 && memcmp(name.data, "hash:", 5) == 0) {
+173 -45
fs/nfsd/nfs4state.c
··· 160 160 return clp->cl_time == 0; 161 161 } 162 162 163 + static void nfsd4_dec_courtesy_client_count(struct nfsd_net *nn, 164 + struct nfs4_client *clp) 165 + { 166 + if (clp->cl_state != NFSD4_ACTIVE) 167 + atomic_add_unless(&nn->nfsd_courtesy_clients, -1, 0); 168 + } 169 + 163 170 static __be32 get_client_locked(struct nfs4_client *clp) 164 171 { 165 172 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); ··· 176 169 if (is_client_expired(clp)) 177 170 return nfserr_expired; 178 171 atomic_inc(&clp->cl_rpc_users); 172 + nfsd4_dec_courtesy_client_count(nn, clp); 179 173 clp->cl_state = NFSD4_ACTIVE; 180 174 return nfs_ok; 181 175 } ··· 198 190 199 191 list_move_tail(&clp->cl_lru, &nn->client_lru); 200 192 clp->cl_time = ktime_get_boottime_seconds(); 193 + nfsd4_dec_courtesy_client_count(nn, clp); 201 194 clp->cl_state = NFSD4_ACTIVE; 202 195 } 203 196 ··· 366 357 static int 367 358 nfsd4_cb_notify_lock_done(struct nfsd4_callback *cb, struct rpc_task *task) 368 359 { 360 + trace_nfsd_cb_notify_lock_done(&zero_stateid, task); 361 + 369 362 /* 370 363 * Since this is just an optimization, we don't try very hard if it 371 364 * turns out not to succeed. We'll requeue it on NFS4ERR_DELAY, and ··· 974 963 * Create a unique stateid_t to represent each COPY. 975 964 */ 976 965 static int nfs4_init_cp_state(struct nfsd_net *nn, copy_stateid_t *stid, 977 - unsigned char sc_type) 966 + unsigned char cs_type) 978 967 { 979 968 int new_id; 980 969 981 - stid->stid.si_opaque.so_clid.cl_boot = (u32)nn->boot_time; 982 - stid->stid.si_opaque.so_clid.cl_id = nn->s2s_cp_cl_id; 983 - stid->sc_type = sc_type; 970 + stid->cs_stid.si_opaque.so_clid.cl_boot = (u32)nn->boot_time; 971 + stid->cs_stid.si_opaque.so_clid.cl_id = nn->s2s_cp_cl_id; 972 + stid->cs_type = cs_type; 984 973 985 974 idr_preload(GFP_KERNEL); 986 975 spin_lock(&nn->s2s_cp_lock); 987 976 new_id = idr_alloc_cyclic(&nn->s2s_cp_stateids, stid, 0, 0, GFP_NOWAIT); 988 - stid->stid.si_opaque.so_id = new_id; 989 - stid->stid.si_generation = 1; 977 + stid->cs_stid.si_opaque.so_id = new_id; 978 + stid->cs_stid.si_generation = 1; 990 979 spin_unlock(&nn->s2s_cp_lock); 991 980 idr_preload_end(); 992 981 if (new_id < 0) ··· 1008 997 if (!cps) 1009 998 return NULL; 1010 999 cps->cpntf_time = ktime_get_boottime_seconds(); 1011 - refcount_set(&cps->cp_stateid.sc_count, 1); 1000 + refcount_set(&cps->cp_stateid.cs_count, 1); 1012 1001 if (!nfs4_init_cp_state(nn, &cps->cp_stateid, NFS4_COPYNOTIFY_STID)) 1013 1002 goto out_free; 1014 1003 spin_lock(&nn->s2s_cp_lock); ··· 1024 1013 { 1025 1014 struct nfsd_net *nn; 1026 1015 1027 - WARN_ON_ONCE(copy->cp_stateid.sc_type != NFS4_COPY_STID); 1016 + WARN_ON_ONCE(copy->cp_stateid.cs_type != NFS4_COPY_STID); 1028 1017 nn = net_generic(copy->cp_clp->net, nfsd_net_id); 1029 1018 spin_lock(&nn->s2s_cp_lock); 1030 1019 idr_remove(&nn->s2s_cp_stateids, 1031 - copy->cp_stateid.stid.si_opaque.so_id); 1020 + copy->cp_stateid.cs_stid.si_opaque.so_id); 1032 1021 spin_unlock(&nn->s2s_cp_lock); 1033 1022 } 1034 1023 ··· 1060 1049 1061 1050 static void nfs4_free_deleg(struct nfs4_stid *stid) 1062 1051 { 1052 + struct nfs4_delegation *dp = delegstateid(stid); 1053 + 1054 + WARN_ON_ONCE(!list_empty(&stid->sc_cp_list)); 1055 + WARN_ON_ONCE(!list_empty(&dp->dl_perfile)); 1056 + WARN_ON_ONCE(!list_empty(&dp->dl_perclnt)); 1057 + WARN_ON_ONCE(!list_empty(&dp->dl_recall_lru)); 1063 1058 kmem_cache_free(deleg_slab, stid); 1064 1059 atomic_long_dec(&num_delegations); 1065 1060 } ··· 1479 1462 release_all_access(stp); 1480 1463 if (stp->st_stateowner) 1481 1464 nfs4_put_stateowner(stp->st_stateowner); 1465 + WARN_ON(!list_empty(&stid->sc_cp_list)); 1482 1466 kmem_cache_free(stateid_slab, stid); 1483 1467 } 1484 1468 ··· 2251 2233 if (clp->cl_cb_conn.cb_xprt) 2252 2234 svc_xprt_put(clp->cl_cb_conn.cb_xprt); 2253 2235 atomic_add_unless(&nn->nfs4_client_count, -1, 0); 2236 + nfsd4_dec_courtesy_client_count(nn, clp); 2254 2237 free_client(clp); 2255 2238 wake_up_all(&expiry_wq); 2256 2239 } ··· 2497 2478 2498 2479 static int client_info_show(struct seq_file *m, void *v) 2499 2480 { 2500 - struct inode *inode = m->private; 2481 + struct inode *inode = file_inode(m->file); 2501 2482 struct nfs4_client *clp; 2502 2483 u64 clid; 2503 2484 ··· 2537 2518 return 0; 2538 2519 } 2539 2520 2540 - static int client_info_open(struct inode *inode, struct file *file) 2541 - { 2542 - return single_open(file, client_info_show, inode); 2543 - } 2544 - 2545 - static const struct file_operations client_info_fops = { 2546 - .open = client_info_open, 2547 - .read = seq_read, 2548 - .llseek = seq_lseek, 2549 - .release = single_release, 2550 - }; 2521 + DEFINE_SHOW_ATTRIBUTE(client_info); 2551 2522 2552 2523 static void *states_start(struct seq_file *s, loff_t *pos) 2553 2524 __acquires(&clp->cl_lock) ··· 4346 4337 return -ENOMEM; 4347 4338 } 4348 4339 4349 - void nfsd4_init_leases_net(struct nfsd_net *nn) 4340 + static unsigned long 4341 + nfsd_courtesy_client_count(struct shrinker *shrink, struct shrink_control *sc) 4342 + { 4343 + int cnt; 4344 + struct nfsd_net *nn = container_of(shrink, 4345 + struct nfsd_net, nfsd_client_shrinker); 4346 + 4347 + cnt = atomic_read(&nn->nfsd_courtesy_clients); 4348 + if (cnt > 0) 4349 + mod_delayed_work(laundry_wq, &nn->nfsd_shrinker_work, 0); 4350 + return (unsigned long)cnt; 4351 + } 4352 + 4353 + static unsigned long 4354 + nfsd_courtesy_client_scan(struct shrinker *shrink, struct shrink_control *sc) 4355 + { 4356 + return SHRINK_STOP; 4357 + } 4358 + 4359 + int 4360 + nfsd4_init_leases_net(struct nfsd_net *nn) 4350 4361 { 4351 4362 struct sysinfo si; 4352 4363 u64 max_clients; ··· 4385 4356 max_clients = (u64)si.totalram * si.mem_unit / (1024 * 1024 * 1024); 4386 4357 max_clients *= NFS4_CLIENTS_PER_GB; 4387 4358 nn->nfs4_max_clients = max_t(int, max_clients, NFS4_CLIENTS_PER_GB); 4359 + 4360 + atomic_set(&nn->nfsd_courtesy_clients, 0); 4361 + nn->nfsd_client_shrinker.scan_objects = nfsd_courtesy_client_scan; 4362 + nn->nfsd_client_shrinker.count_objects = nfsd_courtesy_client_count; 4363 + nn->nfsd_client_shrinker.seeks = DEFAULT_SEEKS; 4364 + return register_shrinker(&nn->nfsd_client_shrinker, "nfsd-client"); 4365 + } 4366 + 4367 + void 4368 + nfsd4_leases_net_shutdown(struct nfsd_net *nn) 4369 + { 4370 + unregister_shrinker(&nn->nfsd_client_shrinker); 4388 4371 } 4389 4372 4390 4373 static void init_nfs4_replay(struct nfs4_replay *rp) ··· 4756 4715 return ret; 4757 4716 } 4758 4717 4718 + static bool nfsd4_deleg_present(const struct inode *inode) 4719 + { 4720 + struct file_lock_context *ctx = smp_load_acquire(&inode->i_flctx); 4721 + 4722 + return ctx && !list_empty_careful(&ctx->flc_lease); 4723 + } 4724 + 4725 + /** 4726 + * nfsd_wait_for_delegreturn - wait for delegations to be returned 4727 + * @rqstp: the RPC transaction being executed 4728 + * @inode: in-core inode of the file being waited for 4729 + * 4730 + * The timeout prevents deadlock if all nfsd threads happen to be 4731 + * tied up waiting for returning delegations. 4732 + * 4733 + * Return values: 4734 + * %true: delegation was returned 4735 + * %false: timed out waiting for delegreturn 4736 + */ 4737 + bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp, struct inode *inode) 4738 + { 4739 + long __maybe_unused timeo; 4740 + 4741 + timeo = wait_var_event_timeout(inode, !nfsd4_deleg_present(inode), 4742 + NFSD_DELEGRETURN_TIMEOUT); 4743 + trace_nfsd_delegret_wakeup(rqstp, inode, timeo); 4744 + return timeo > 0; 4745 + } 4746 + 4759 4747 static void nfsd4_cb_recall_prepare(struct nfsd4_callback *cb) 4760 4748 { 4761 4749 struct nfs4_delegation *dp = cb_to_delegation(cb); ··· 4812 4742 struct rpc_task *task) 4813 4743 { 4814 4744 struct nfs4_delegation *dp = cb_to_delegation(cb); 4745 + 4746 + trace_nfsd_cb_recall_done(&dp->dl_stid.sc_stateid, task); 4815 4747 4816 4748 if (dp->dl_stid.sc_type == NFS4_CLOSED_DELEG_STID || 4817 4749 dp->dl_stid.sc_type == NFS4_REVOKED_DELEG_STID) ··· 4860 4788 * We're assuming the state code never drops its reference 4861 4789 * without first removing the lease. Since we're in this lease 4862 4790 * callback (and since the lease code is serialized by the 4863 - * i_lock) we know the server hasn't removed the lease yet, and 4791 + * flc_lock) we know the server hasn't removed the lease yet, and 4864 4792 * we know it's safe to take a reference. 4865 4793 */ 4866 4794 refcount_inc(&dp->dl_stid.sc_count); 4867 - nfsd4_run_cb(&dp->dl_recall); 4795 + WARN_ON_ONCE(!nfsd4_run_cb(&dp->dl_recall)); 4868 4796 } 4869 4797 4870 - /* Called from break_lease() with i_lock held. */ 4798 + /* Called from break_lease() with flc_lock held. */ 4871 4799 static bool 4872 4800 nfsd_break_deleg_cb(struct file_lock *fl) 4873 4801 { 4874 - bool ret = false; 4875 4802 struct nfs4_delegation *dp = (struct nfs4_delegation *)fl->fl_owner; 4876 4803 struct nfs4_file *fp = dp->dl_stid.sc_file; 4877 4804 struct nfs4_client *clp = dp->dl_stid.sc_client; ··· 4896 4825 fp->fi_had_conflict = true; 4897 4826 nfsd_break_one_deleg(dp); 4898 4827 spin_unlock(&fp->fi_lock); 4899 - return ret; 4828 + return false; 4900 4829 } 4901 4830 4902 4831 /** ··· 5949 5878 goto exp_client; 5950 5879 if (!state_expired(lt, clp->cl_time)) 5951 5880 break; 5952 - if (!atomic_read(&clp->cl_rpc_users)) 5881 + if (!atomic_read(&clp->cl_rpc_users)) { 5882 + if (clp->cl_state == NFSD4_ACTIVE) 5883 + atomic_inc(&nn->nfsd_courtesy_clients); 5953 5884 clp->cl_state = NFSD4_COURTESY; 5885 + } 5954 5886 if (!client_has_state(clp)) 5955 5887 goto exp_client; 5956 5888 if (!nfs4_anylock_blockers(clp)) ··· 5968 5894 spin_unlock(&nn->client_lock); 5969 5895 } 5970 5896 5897 + static void 5898 + nfs4_get_courtesy_client_reaplist(struct nfsd_net *nn, 5899 + struct list_head *reaplist) 5900 + { 5901 + unsigned int maxreap = 0, reapcnt = 0; 5902 + struct list_head *pos, *next; 5903 + struct nfs4_client *clp; 5904 + 5905 + maxreap = NFSD_CLIENT_MAX_TRIM_PER_RUN; 5906 + INIT_LIST_HEAD(reaplist); 5907 + 5908 + spin_lock(&nn->client_lock); 5909 + list_for_each_safe(pos, next, &nn->client_lru) { 5910 + clp = list_entry(pos, struct nfs4_client, cl_lru); 5911 + if (clp->cl_state == NFSD4_ACTIVE) 5912 + break; 5913 + if (reapcnt >= maxreap) 5914 + break; 5915 + if (!mark_client_expired_locked(clp)) { 5916 + list_add(&clp->cl_lru, reaplist); 5917 + reapcnt++; 5918 + } 5919 + } 5920 + spin_unlock(&nn->client_lock); 5921 + } 5922 + 5923 + static void 5924 + nfs4_process_client_reaplist(struct list_head *reaplist) 5925 + { 5926 + struct list_head *pos, *next; 5927 + struct nfs4_client *clp; 5928 + 5929 + list_for_each_safe(pos, next, reaplist) { 5930 + clp = list_entry(pos, struct nfs4_client, cl_lru); 5931 + trace_nfsd_clid_purged(&clp->cl_clientid); 5932 + list_del_init(&clp->cl_lru); 5933 + expire_client(clp); 5934 + } 5935 + } 5936 + 5971 5937 static time64_t 5972 5938 nfs4_laundromat(struct nfsd_net *nn) 5973 5939 { 5974 - struct nfs4_client *clp; 5975 5940 struct nfs4_openowner *oo; 5976 5941 struct nfs4_delegation *dp; 5977 5942 struct nfs4_ol_stateid *stp; ··· 6033 5920 spin_lock(&nn->s2s_cp_lock); 6034 5921 idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) { 6035 5922 cps = container_of(cps_t, struct nfs4_cpntf_state, cp_stateid); 6036 - if (cps->cp_stateid.sc_type == NFS4_COPYNOTIFY_STID && 5923 + if (cps->cp_stateid.cs_type == NFS4_COPYNOTIFY_STID && 6037 5924 state_expired(&lt, cps->cpntf_time)) 6038 5925 _free_cpntf_state_locked(nn, cps); 6039 5926 } 6040 5927 spin_unlock(&nn->s2s_cp_lock); 6041 5928 nfs4_get_client_reaplist(nn, &reaplist, &lt); 6042 - list_for_each_safe(pos, next, &reaplist) { 6043 - clp = list_entry(pos, struct nfs4_client, cl_lru); 6044 - trace_nfsd_clid_purged(&clp->cl_clientid); 6045 - list_del_init(&clp->cl_lru); 6046 - expire_client(clp); 6047 - } 5929 + nfs4_process_client_reaplist(&reaplist); 5930 + 6048 5931 spin_lock(&state_lock); 6049 5932 list_for_each_safe(pos, next, &nn->del_recall_lru) { 6050 5933 dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); ··· 6121 6012 6122 6013 t = nfs4_laundromat(nn); 6123 6014 queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ); 6015 + } 6016 + 6017 + static void 6018 + courtesy_client_reaper(struct work_struct *reaper) 6019 + { 6020 + struct list_head reaplist; 6021 + struct delayed_work *dwork = to_delayed_work(reaper); 6022 + struct nfsd_net *nn = container_of(dwork, struct nfsd_net, 6023 + nfsd_shrinker_work); 6024 + 6025 + nfs4_get_courtesy_client_reaplist(nn, &reaplist); 6026 + nfs4_process_client_reaplist(&reaplist); 6124 6027 } 6125 6028 6126 6029 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) ··· 6270 6149 struct nfs4_stid **s, struct nfsd_net *nn) 6271 6150 { 6272 6151 __be32 status; 6152 + struct nfs4_stid *stid; 6273 6153 bool return_revoked = false; 6274 6154 6275 6155 /* ··· 6293 6171 } 6294 6172 if (status) 6295 6173 return status; 6296 - *s = find_stateid_by_type(cstate->clp, stateid, typemask); 6297 - if (!*s) 6174 + stid = find_stateid_by_type(cstate->clp, stateid, typemask); 6175 + if (!stid) 6298 6176 return nfserr_bad_stateid; 6299 - if (((*s)->sc_type == NFS4_REVOKED_DELEG_STID) && !return_revoked) { 6300 - nfs4_put_stid(*s); 6177 + if ((stid->sc_type == NFS4_REVOKED_DELEG_STID) && !return_revoked) { 6178 + nfs4_put_stid(stid); 6301 6179 if (cstate->minorversion) 6302 6180 return nfserr_deleg_revoked; 6303 6181 return nfserr_bad_stateid; 6304 6182 } 6183 + *s = stid; 6305 6184 return nfs_ok; 6306 6185 } 6307 6186 ··· 6367 6244 static void 6368 6245 _free_cpntf_state_locked(struct nfsd_net *nn, struct nfs4_cpntf_state *cps) 6369 6246 { 6370 - WARN_ON_ONCE(cps->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID); 6371 - if (!refcount_dec_and_test(&cps->cp_stateid.sc_count)) 6247 + WARN_ON_ONCE(cps->cp_stateid.cs_type != NFS4_COPYNOTIFY_STID); 6248 + if (!refcount_dec_and_test(&cps->cp_stateid.cs_count)) 6372 6249 return; 6373 6250 list_del(&cps->cp_list); 6374 6251 idr_remove(&nn->s2s_cp_stateids, 6375 - cps->cp_stateid.stid.si_opaque.so_id); 6252 + cps->cp_stateid.cs_stid.si_opaque.so_id); 6376 6253 kfree(cps); 6377 6254 } 6378 6255 /* ··· 6394 6271 if (cps_t) { 6395 6272 state = container_of(cps_t, struct nfs4_cpntf_state, 6396 6273 cp_stateid); 6397 - if (state->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID) { 6274 + if (state->cp_stateid.cs_type != NFS4_COPYNOTIFY_STID) { 6398 6275 state = NULL; 6399 6276 goto unlock; 6400 6277 } 6401 6278 if (!clp) 6402 - refcount_inc(&state->cp_stateid.sc_count); 6279 + refcount_inc(&state->cp_stateid.cs_count); 6403 6280 else 6404 6281 _free_cpntf_state_locked(nn, state); 6405 6282 } ··· 6807 6684 struct nfs4_client *clp = s->st_stid.sc_client; 6808 6685 bool unhashed; 6809 6686 LIST_HEAD(reaplist); 6687 + struct nfs4_ol_stateid *stp; 6810 6688 6811 6689 spin_lock(&clp->cl_lock); 6812 6690 unhashed = unhash_open_stateid(s, &reaplist); ··· 6816 6692 if (unhashed) 6817 6693 put_ol_stateid_locked(s, &reaplist); 6818 6694 spin_unlock(&clp->cl_lock); 6695 + list_for_each_entry(stp, &reaplist, st_locks) 6696 + nfs4_free_cpntf_statelist(clp->net, &stp->st_stid); 6819 6697 free_ol_stateid_reaplist(&reaplist); 6820 6698 } else { 6821 6699 spin_unlock(&clp->cl_lock); ··· 6901 6775 if (status) 6902 6776 goto put_stateid; 6903 6777 6778 + wake_up_var(d_inode(cstate->current_fh.fh_dentry)); 6904 6779 destroy_delegation(dp); 6905 6780 put_stateid: 6906 6781 nfs4_put_stid(&dp->dl_stid); ··· 7957 7830 INIT_LIST_HEAD(&nn->blocked_locks_lru); 7958 7831 7959 7832 INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main); 7833 + INIT_DELAYED_WORK(&nn->nfsd_shrinker_work, courtesy_client_reaper); 7960 7834 get_net(net); 7961 7835 7962 7836 return 0;
+67 -35
fs/nfsd/nfs4xdr.c
··· 42 42 #include <linux/sunrpc/svcauth_gss.h> 43 43 #include <linux/sunrpc/addr.h> 44 44 #include <linux/xattr.h> 45 + #include <linux/vmalloc.h> 46 + 45 47 #include <uapi/linux/xattr.h> 46 48 47 49 #include "idmap.h" ··· 793 791 return nfserr_bad_xdr; 794 792 if (xdr_stream_decode_u32(argp->xdr, &commit->co_count) < 0) 795 793 return nfserr_bad_xdr; 794 + memset(&commit->co_verf, 0, sizeof(commit->co_verf)); 796 795 return nfs_ok; 797 796 } 798 797 ··· 802 799 { 803 800 __be32 *p, status; 804 801 802 + memset(create, 0, sizeof(*create)); 805 803 if (xdr_stream_decode_u32(argp->xdr, &create->cr_type) < 0) 806 804 return nfserr_bad_xdr; 807 805 switch (create->cr_type) { ··· 852 848 static inline __be32 853 849 nfsd4_decode_getattr(struct nfsd4_compoundargs *argp, struct nfsd4_getattr *getattr) 854 850 { 851 + memset(getattr, 0, sizeof(*getattr)); 855 852 return nfsd4_decode_bitmap4(argp, getattr->ga_bmval, 856 853 ARRAY_SIZE(getattr->ga_bmval)); 857 854 } ··· 860 855 static __be32 861 856 nfsd4_decode_link(struct nfsd4_compoundargs *argp, struct nfsd4_link *link) 862 857 { 858 + memset(link, 0, sizeof(*link)); 863 859 return nfsd4_decode_component4(argp, &link->li_name, &link->li_namelen); 864 860 } 865 861 ··· 909 903 static __be32 910 904 nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) 911 905 { 906 + memset(lock, 0, sizeof(*lock)); 912 907 if (xdr_stream_decode_u32(argp->xdr, &lock->lk_type) < 0) 913 908 return nfserr_bad_xdr; 914 909 if ((lock->lk_type < NFS4_READ_LT) || (lock->lk_type > NFS4_WRITEW_LT)) ··· 926 919 static __be32 927 920 nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt) 928 921 { 922 + memset(lockt, 0, sizeof(*lockt)); 929 923 if (xdr_stream_decode_u32(argp->xdr, &lockt->lt_type) < 0) 930 924 return nfserr_bad_xdr; 931 925 if ((lockt->lt_type < NFS4_READ_LT) || (lockt->lt_type > NFS4_WRITEW_LT)) ··· 1148 1140 __be32 status; 1149 1141 u32 dummy; 1150 1142 1151 - memset(open->op_bmval, 0, sizeof(open->op_bmval)); 1152 - open->op_iattr.ia_valid = 0; 1153 - open->op_openowner = NULL; 1143 + memset(open, 0, sizeof(*open)); 1154 1144 1155 - open->op_xdr_error = 0; 1156 1145 if (xdr_stream_decode_u32(argp->xdr, &open->op_seqid) < 0) 1157 1146 return nfserr_bad_xdr; 1158 1147 /* deleg_want is ignored */ ··· 1184 1179 if (xdr_stream_decode_u32(argp->xdr, &open_conf->oc_seqid) < 0) 1185 1180 return nfserr_bad_xdr; 1186 1181 1182 + memset(&open_conf->oc_resp_stateid, 0, 1183 + sizeof(open_conf->oc_resp_stateid)); 1187 1184 return nfs_ok; 1188 1185 } 1189 1186 ··· 1194 1187 { 1195 1188 __be32 status; 1196 1189 1190 + memset(open_down, 0, sizeof(*open_down)); 1197 1191 status = nfsd4_decode_stateid4(argp, &open_down->od_stateid); 1198 1192 if (status) 1199 1193 return status; ··· 1224 1216 if (!putfh->pf_fhval) 1225 1217 return nfserr_jukebox; 1226 1218 1219 + putfh->no_verify = false; 1227 1220 return nfs_ok; 1228 1221 } 1229 1222 ··· 1241 1232 { 1242 1233 __be32 status; 1243 1234 1235 + memset(read, 0, sizeof(*read)); 1244 1236 status = nfsd4_decode_stateid4(argp, &read->rd_stateid); 1245 1237 if (status) 1246 1238 return status; ··· 1258 1248 { 1259 1249 __be32 status; 1260 1250 1251 + memset(readdir, 0, sizeof(*readdir)); 1261 1252 if (xdr_stream_decode_u64(argp->xdr, &readdir->rd_cookie) < 0) 1262 1253 return nfserr_bad_xdr; 1263 1254 status = nfsd4_decode_verifier4(argp, &readdir->rd_verf); ··· 1278 1267 static __be32 1279 1268 nfsd4_decode_remove(struct nfsd4_compoundargs *argp, struct nfsd4_remove *remove) 1280 1269 { 1270 + memset(&remove->rm_cinfo, 0, sizeof(remove->rm_cinfo)); 1281 1271 return nfsd4_decode_component4(argp, &remove->rm_name, &remove->rm_namelen); 1282 1272 } 1283 1273 ··· 1287 1275 { 1288 1276 __be32 status; 1289 1277 1278 + memset(rename, 0, sizeof(*rename)); 1290 1279 status = nfsd4_decode_component4(argp, &rename->rn_sname, &rename->rn_snamelen); 1291 1280 if (status) 1292 1281 return status; ··· 1304 1291 nfsd4_decode_secinfo(struct nfsd4_compoundargs *argp, 1305 1292 struct nfsd4_secinfo *secinfo) 1306 1293 { 1294 + secinfo->si_exp = NULL; 1307 1295 return nfsd4_decode_component4(argp, &secinfo->si_name, &secinfo->si_namelen); 1308 1296 } 1309 1297 ··· 1313 1299 { 1314 1300 __be32 status; 1315 1301 1302 + memset(setattr, 0, sizeof(*setattr)); 1316 1303 status = nfsd4_decode_stateid4(argp, &setattr->sa_stateid); 1317 1304 if (status) 1318 1305 return status; ··· 1327 1312 nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid *setclientid) 1328 1313 { 1329 1314 __be32 *p, status; 1315 + 1316 + memset(setclientid, 0, sizeof(*setclientid)); 1330 1317 1331 1318 if (argp->minorversion >= 1) 1332 1319 return nfserr_notsupp; ··· 1386 1369 { 1387 1370 __be32 *p, status; 1388 1371 1372 + memset(verify, 0, sizeof(*verify)); 1373 + 1389 1374 status = nfsd4_decode_bitmap4(argp, verify->ve_bmval, 1390 1375 ARRAY_SIZE(verify->ve_bmval)); 1391 1376 if (status) ··· 1427 1408 if (!xdr_stream_subsegment(argp->xdr, &write->wr_payload, write->wr_buflen)) 1428 1409 return nfserr_bad_xdr; 1429 1410 1411 + write->wr_bytes_written = 0; 1412 + write->wr_how_written = 0; 1413 + memset(&write->wr_verifier, 0, sizeof(write->wr_verifier)); 1430 1414 return nfs_ok; 1431 1415 } 1432 1416 ··· 1454 1432 1455 1433 static __be32 nfsd4_decode_backchannel_ctl(struct nfsd4_compoundargs *argp, struct nfsd4_backchannel_ctl *bc) 1456 1434 { 1435 + memset(bc, 0, sizeof(*bc)); 1457 1436 if (xdr_stream_decode_u32(argp->xdr, &bc->bc_cb_program) < 0) 1458 1437 return nfserr_bad_xdr; 1459 1438 return nfsd4_decode_cb_sec(argp, &bc->bc_cb_sec); ··· 1465 1442 u32 use_conn_in_rdma_mode; 1466 1443 __be32 status; 1467 1444 1445 + memset(bcts, 0, sizeof(*bcts)); 1468 1446 status = nfsd4_decode_sessionid4(argp, &bcts->sessionid); 1469 1447 if (status) 1470 1448 return status; ··· 1607 1583 { 1608 1584 __be32 status; 1609 1585 1586 + memset(exid, 0, sizeof(*exid)); 1610 1587 status = nfsd4_decode_verifier4(argp, &exid->verifier); 1611 1588 if (status) 1612 1589 return status; ··· 1660 1635 { 1661 1636 __be32 status; 1662 1637 1638 + memset(sess, 0, sizeof(*sess)); 1663 1639 status = nfsd4_decode_clientid4(argp, &sess->clientid); 1664 1640 if (status) 1665 1641 return status; ··· 1676 1650 return status; 1677 1651 if (xdr_stream_decode_u32(argp->xdr, &sess->callback_prog) < 0) 1678 1652 return nfserr_bad_xdr; 1679 - status = nfsd4_decode_cb_sec(argp, &sess->cb_sec); 1680 - if (status) 1681 - return status; 1682 - 1683 - return nfs_ok; 1653 + return nfsd4_decode_cb_sec(argp, &sess->cb_sec); 1684 1654 } 1685 1655 1686 1656 static __be32 ··· 1700 1678 { 1701 1679 __be32 status; 1702 1680 1681 + memset(gdev, 0, sizeof(*gdev)); 1703 1682 status = nfsd4_decode_deviceid4(argp, &gdev->gd_devid); 1704 1683 if (status) 1705 1684 return status; ··· 1721 1698 { 1722 1699 __be32 *p, status; 1723 1700 1701 + memset(lcp, 0, sizeof(*lcp)); 1724 1702 if (xdr_stream_decode_u64(argp->xdr, &lcp->lc_seg.offset) < 0) 1725 1703 return nfserr_bad_xdr; 1726 1704 if (xdr_stream_decode_u64(argp->xdr, &lcp->lc_seg.length) < 0) ··· 1757 1733 { 1758 1734 __be32 status; 1759 1735 1736 + memset(lgp, 0, sizeof(*lgp)); 1760 1737 if (xdr_stream_decode_u32(argp->xdr, &lgp->lg_signal) < 0) 1761 1738 return nfserr_bad_xdr; 1762 1739 if (xdr_stream_decode_u32(argp->xdr, &lgp->lg_layout_type) < 0) ··· 1783 1758 nfsd4_decode_layoutreturn(struct nfsd4_compoundargs *argp, 1784 1759 struct nfsd4_layoutreturn *lrp) 1785 1760 { 1761 + memset(lrp, 0, sizeof(*lrp)); 1786 1762 if (xdr_stream_decode_bool(argp->xdr, &lrp->lr_reclaim) < 0) 1787 1763 return nfserr_bad_xdr; 1788 1764 if (xdr_stream_decode_u32(argp->xdr, &lrp->lr_layout_type) < 0) ··· 1799 1773 { 1800 1774 if (xdr_stream_decode_u32(argp->xdr, &sin->sin_style) < 0) 1801 1775 return nfserr_bad_xdr; 1776 + 1777 + sin->sin_exp = NULL; 1802 1778 return nfs_ok; 1803 1779 } 1804 1780 ··· 1821 1793 seq->maxslots = be32_to_cpup(p++); 1822 1794 seq->cachethis = be32_to_cpup(p); 1823 1795 1796 + seq->status_flags = 0; 1824 1797 return nfs_ok; 1825 1798 } 1826 1799 ··· 1832 1803 __be32 status; 1833 1804 u32 i; 1834 1805 1806 + memset(test_stateid, 0, sizeof(*test_stateid)); 1835 1807 if (xdr_stream_decode_u32(argp->xdr, &test_stateid->ts_num_ids) < 0) 1836 1808 return nfserr_bad_xdr; 1837 1809 ··· 1930 1900 struct nl4_server *ns_dummy; 1931 1901 __be32 status; 1932 1902 1903 + memset(copy, 0, sizeof(*copy)); 1933 1904 status = nfsd4_decode_stateid4(argp, &copy->cp_src_stateid); 1934 1905 if (status) 1935 1906 return status; ··· 1986 1955 { 1987 1956 __be32 status; 1988 1957 1958 + memset(cn, 0, sizeof(*cn)); 1989 1959 cn->cpn_src = svcxdr_tmpalloc(argp, sizeof(*cn->cpn_src)); 1990 1960 if (cn->cpn_src == NULL) 1991 1961 return nfserr_jukebox; ··· 2004 1972 nfsd4_decode_offload_status(struct nfsd4_compoundargs *argp, 2005 1973 struct nfsd4_offload_status *os) 2006 1974 { 1975 + os->count = 0; 1976 + os->status = 0; 2007 1977 return nfsd4_decode_stateid4(argp, &os->stateid); 2008 1978 } 2009 1979 ··· 2022 1988 if (xdr_stream_decode_u32(argp->xdr, &seek->seek_whence) < 0) 2023 1989 return nfserr_bad_xdr; 2024 1990 1991 + seek->seek_eof = 0; 1992 + seek->seek_pos = 0; 2025 1993 return nfs_ok; 2026 1994 } 2027 1995 ··· 2159 2123 __be32 status; 2160 2124 u32 maxcount; 2161 2125 2126 + memset(getxattr, 0, sizeof(*getxattr)); 2162 2127 status = nfsd4_decode_xattr_name(argp, &getxattr->getxa_name); 2163 2128 if (status) 2164 2129 return status; ··· 2168 2131 maxcount = min_t(u32, XATTR_SIZE_MAX, maxcount); 2169 2132 2170 2133 getxattr->getxa_len = maxcount; 2171 - 2172 - return status; 2134 + return nfs_ok; 2173 2135 } 2174 2136 2175 2137 static __be32 ··· 2177 2141 { 2178 2142 u32 flags, maxcount, size; 2179 2143 __be32 status; 2144 + 2145 + memset(setxattr, 0, sizeof(*setxattr)); 2180 2146 2181 2147 if (xdr_stream_decode_u32(argp->xdr, &flags) < 0) 2182 2148 return nfserr_bad_xdr; ··· 2218 2180 { 2219 2181 u32 maxcount; 2220 2182 2183 + memset(listxattrs, 0, sizeof(*listxattrs)); 2184 + 2221 2185 if (xdr_stream_decode_u64(argp->xdr, &listxattrs->lsxa_cookie) < 0) 2222 2186 return nfserr_bad_xdr; 2223 2187 ··· 2247 2207 nfsd4_decode_removexattr(struct nfsd4_compoundargs *argp, 2248 2208 struct nfsd4_removexattr *removexattr) 2249 2209 { 2210 + memset(removexattr, 0, sizeof(*removexattr)); 2250 2211 return nfsd4_decode_xattr_name(argp, &removexattr->rmxa_name); 2251 2212 } 2252 2213 ··· 2398 2357 2399 2358 if (xdr_stream_decode_u32(argp->xdr, &argp->minorversion) < 0) 2400 2359 return false; 2401 - if (xdr_stream_decode_u32(argp->xdr, &argp->opcnt) < 0) 2360 + if (xdr_stream_decode_u32(argp->xdr, &argp->client_opcnt) < 0) 2402 2361 return false; 2403 - 2404 - /* 2405 - * NFS4ERR_RESOURCE is a more helpful error than GARBAGE_ARGS 2406 - * here, so we return success at the xdr level so that 2407 - * nfsd4_proc can handle this is an NFS-level error. 2408 - */ 2409 - if (argp->opcnt > NFSD_MAX_OPS_PER_COMPOUND) 2410 - return true; 2362 + argp->opcnt = min_t(u32, argp->client_opcnt, 2363 + NFSD_MAX_OPS_PER_COMPOUND); 2411 2364 2412 2365 if (argp->opcnt > ARRAY_SIZE(argp->iops)) { 2413 - argp->ops = kzalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL); 2366 + argp->ops = vcalloc(argp->opcnt, sizeof(*argp->ops)); 2414 2367 if (!argp->ops) { 2415 2368 argp->ops = argp->iops; 2416 - dprintk("nfsd: couldn't allocate room for COMPOUND\n"); 2417 2369 return false; 2418 2370 } 2419 2371 } ··· 2808 2774 } 2809 2775 2810 2776 2811 - static int get_parent_attributes(struct svc_export *exp, struct kstat *stat) 2777 + static int nfsd4_get_mounted_on_ino(struct svc_export *exp, u64 *pino) 2812 2778 { 2813 2779 struct path path = exp->ex_path; 2780 + struct kstat stat; 2814 2781 int err; 2815 2782 2816 2783 path_get(&path); ··· 2819 2784 if (path.dentry != path.mnt->mnt_root) 2820 2785 break; 2821 2786 } 2822 - err = vfs_getattr(&path, stat, STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT); 2787 + err = vfs_getattr(&path, &stat, STATX_INO, AT_STATX_SYNC_AS_STAT); 2823 2788 path_put(&path); 2789 + if (!err) 2790 + *pino = stat.ino; 2824 2791 return err; 2825 2792 } 2826 2793 ··· 3319 3282 *p++ = cpu_to_be32(stat.btime.tv_nsec); 3320 3283 } 3321 3284 if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) { 3322 - struct kstat parent_stat; 3323 3285 u64 ino = stat.ino; 3324 3286 3325 3287 p = xdr_reserve_space(xdr, 8); 3326 3288 if (!p) 3327 3289 goto out_resource; 3328 3290 /* 3329 - * Get parent's attributes if not ignoring crossmount 3330 - * and this is the root of a cross-mounted filesystem. 3291 + * Get ino of mountpoint in parent filesystem, if not ignoring 3292 + * crossmount and this is the root of a cross-mounted 3293 + * filesystem. 3331 3294 */ 3332 3295 if (ignore_crossmnt == 0 && 3333 3296 dentry == exp->ex_path.mnt->mnt_root) { 3334 - err = get_parent_attributes(exp, &parent_stat); 3297 + err = nfsd4_get_mounted_on_ino(exp, &ino); 3335 3298 if (err) 3336 3299 goto out_nfserr; 3337 - ino = parent_stat.ino; 3338 3300 } 3339 3301 p = xdr_encode_hyper(p, ino); 3340 3302 } ··· 4030 3994 } 4031 3995 if (resp->xdr->buf->page_len && splice_ok) { 4032 3996 WARN_ON_ONCE(1); 4033 - return nfserr_resource; 3997 + return nfserr_serverfault; 4034 3998 } 4035 3999 xdr_commit_encode(xdr); 4036 4000 ··· 5430 5394 struct nfsd4_compoundargs *args = rqstp->rq_argp; 5431 5395 5432 5396 if (args->ops != args->iops) { 5433 - kfree(args->ops); 5397 + vfree(args->ops); 5434 5398 args->ops = args->iops; 5435 5399 } 5436 5400 while (args->to_free) { ··· 5459 5423 nfs4svc_encode_compoundres(struct svc_rqst *rqstp, struct xdr_stream *xdr) 5460 5424 { 5461 5425 struct nfsd4_compoundres *resp = rqstp->rq_resp; 5462 - struct xdr_buf *buf = xdr->buf; 5463 5426 __be32 *p; 5464 - 5465 - WARN_ON_ONCE(buf->len != buf->head[0].iov_len + buf->page_len + 5466 - buf->tail[0].iov_len); 5467 5427 5468 5428 /* 5469 5429 * Send buffer space for the following items is reserved
+3 -10
fs/nfsd/nfscache.c
··· 604 604 * scraping this file for info should test the labels to ensure they're 605 605 * getting the correct field. 606 606 */ 607 - static int nfsd_reply_cache_stats_show(struct seq_file *m, void *v) 607 + int nfsd_reply_cache_stats_show(struct seq_file *m, void *v) 608 608 { 609 - struct nfsd_net *nn = m->private; 609 + struct nfsd_net *nn = net_generic(file_inode(m->file)->i_sb->s_fs_info, 610 + nfsd_net_id); 610 611 611 612 seq_printf(m, "max entries: %u\n", nn->max_drc_entries); 612 613 seq_printf(m, "num entries: %u\n", ··· 626 625 seq_printf(m, "longest chain len: %u\n", nn->longest_chain); 627 626 seq_printf(m, "cachesize at longest: %u\n", nn->longest_chain_cachesize); 628 627 return 0; 629 - } 630 - 631 - int nfsd_reply_cache_stats_open(struct inode *inode, struct file *file) 632 - { 633 - struct nfsd_net *nn = net_generic(file_inode(file)->i_sb->s_fs_info, 634 - nfsd_net_id); 635 - 636 - return single_open(file, nfsd_reply_cache_stats_show, nn); 637 628 }
+14 -40
fs/nfsd/nfsctl.c
··· 185 185 return 0; 186 186 } 187 187 188 - static int export_features_open(struct inode *inode, struct file *file) 189 - { 190 - return single_open(file, export_features_show, NULL); 191 - } 192 - 193 - static const struct file_operations export_features_operations = { 194 - .open = export_features_open, 195 - .read = seq_read, 196 - .llseek = seq_lseek, 197 - .release = single_release, 198 - }; 188 + DEFINE_SHOW_ATTRIBUTE(export_features); 199 189 200 190 #if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE) 201 191 static int supported_enctypes_show(struct seq_file *m, void *v) ··· 194 204 return 0; 195 205 } 196 206 197 - static int supported_enctypes_open(struct inode *inode, struct file *file) 198 - { 199 - return single_open(file, supported_enctypes_show, NULL); 200 - } 201 - 202 - static const struct file_operations supported_enctypes_ops = { 203 - .open = supported_enctypes_open, 204 - .read = seq_read, 205 - .llseek = seq_lseek, 206 - .release = single_release, 207 - }; 207 + DEFINE_SHOW_ATTRIBUTE(supported_enctypes); 208 208 #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */ 209 209 210 210 static const struct file_operations pool_stats_operations = { ··· 204 224 .release = nfsd_pool_stats_release, 205 225 }; 206 226 207 - static const struct file_operations reply_cache_stats_operations = { 208 - .open = nfsd_reply_cache_stats_open, 209 - .read = seq_read, 210 - .llseek = seq_lseek, 211 - .release = single_release, 212 - }; 227 + DEFINE_SHOW_ATTRIBUTE(nfsd_reply_cache_stats); 213 228 214 - static const struct file_operations filecache_ops = { 215 - .open = nfsd_file_cache_stats_open, 216 - .read = seq_read, 217 - .llseek = seq_lseek, 218 - .release = single_release, 219 - }; 229 + DEFINE_SHOW_ATTRIBUTE(nfsd_file_cache_stats); 220 230 221 231 /*----------------------------------------------------------------------------*/ 222 232 /* ··· 1335 1365 /* Per-export io stats use same ops as exports file */ 1336 1366 [NFSD_Export_Stats] = {"export_stats", &exports_nfsd_operations, S_IRUGO}, 1337 1367 [NFSD_Export_features] = {"export_features", 1338 - &export_features_operations, S_IRUGO}, 1368 + &export_features_fops, S_IRUGO}, 1339 1369 [NFSD_FO_UnlockIP] = {"unlock_ip", 1340 1370 &transaction_ops, S_IWUSR|S_IRUSR}, 1341 1371 [NFSD_FO_UnlockFS] = {"unlock_filesystem", ··· 1344 1374 [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, 1345 1375 [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, 1346 1376 [NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO}, 1347 - [NFSD_Reply_Cache_Stats] = {"reply_cache_stats", &reply_cache_stats_operations, S_IRUGO}, 1377 + [NFSD_Reply_Cache_Stats] = {"reply_cache_stats", 1378 + &nfsd_reply_cache_stats_fops, S_IRUGO}, 1348 1379 [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, 1349 1380 [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, 1350 1381 [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO}, 1351 1382 [NFSD_MaxConnections] = {"max_connections", &transaction_ops, S_IWUSR|S_IRUGO}, 1352 - [NFSD_Filecache] = {"filecache", &filecache_ops, S_IRUGO}, 1383 + [NFSD_Filecache] = {"filecache", &nfsd_file_cache_stats_fops, S_IRUGO}, 1353 1384 #if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE) 1354 - [NFSD_SupportedEnctypes] = {"supported_krb5_enctypes", &supported_enctypes_ops, S_IRUGO}, 1385 + [NFSD_SupportedEnctypes] = {"supported_krb5_enctypes", 1386 + &supported_enctypes_fops, S_IRUGO}, 1355 1387 #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */ 1356 1388 #ifdef CONFIG_NFSD_V4 1357 1389 [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, ··· 1453 1481 goto out_idmap_error; 1454 1482 nn->nfsd_versions = NULL; 1455 1483 nn->nfsd4_minorversions = NULL; 1484 + retval = nfsd4_init_leases_net(nn); 1485 + if (retval) 1486 + goto out_drc_error; 1456 1487 retval = nfsd_reply_cache_init(nn); 1457 1488 if (retval) 1458 1489 goto out_drc_error; 1459 - nfsd4_init_leases_net(nn); 1460 - 1461 1490 get_random_bytes(&nn->siphash_key, sizeof(nn->siphash_key)); 1462 1491 seqlock_init(&nn->writeverf_lock); 1463 1492 ··· 1480 1507 nfsd_idmap_shutdown(net); 1481 1508 nfsd_export_shutdown(net); 1482 1509 nfsd_netns_free_versions(net_generic(net, nfsd_net_id)); 1510 + nfsd4_leases_net_shutdown(nn); 1483 1511 } 1484 1512 1485 1513 static struct pernet_operations nfsd_net_ops = {
+11 -2
fs/nfsd/nfsd.h
··· 164 164 bool nfsd4_spo_must_allow(struct svc_rqst *rqstp); 165 165 int nfsd4_create_laundry_wq(void); 166 166 void nfsd4_destroy_laundry_wq(void); 167 + bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp, struct inode *inode); 167 168 #else 168 169 static inline int nfsd4_init_slabs(void) { return 0; } 169 170 static inline void nfsd4_free_slabs(void) { } ··· 180 179 } 181 180 static inline int nfsd4_create_laundry_wq(void) { return 0; }; 182 181 static inline void nfsd4_destroy_laundry_wq(void) {}; 182 + static inline bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp, 183 + struct inode *inode) 184 + { 185 + return false; 186 + } 183 187 #endif 184 188 185 189 /* ··· 349 343 #define NFSD_COURTESY_CLIENT_TIMEOUT (24 * 60 * 60) /* seconds */ 350 344 #define NFSD_CLIENT_MAX_TRIM_PER_RUN 128 351 345 #define NFS4_CLIENTS_PER_GB 1024 346 + #define NFSD_DELEGRETURN_TIMEOUT (HZ / 34) /* 30ms */ 352 347 353 348 /* 354 349 * The following attributes are currently not supported by the NFSv4 server: ··· 505 498 extern void nfsd4_ssc_init_umount_work(struct nfsd_net *nn); 506 499 #endif 507 500 508 - extern void nfsd4_init_leases_net(struct nfsd_net *nn); 501 + extern int nfsd4_init_leases_net(struct nfsd_net *nn); 502 + extern void nfsd4_leases_net_shutdown(struct nfsd_net *nn); 509 503 510 504 #else /* CONFIG_NFSD_V4 */ 511 505 static inline int nfsd4_is_junction(struct dentry *dentry) ··· 514 506 return 0; 515 507 } 516 508 517 - static inline void nfsd4_init_leases_net(struct nfsd_net *nn) {}; 509 + static inline int nfsd4_init_leases_net(struct nfsd_net *nn) { return 0; }; 510 + static inline void nfsd4_leases_net_shutdown(struct nfsd_net *nn) {}; 518 511 519 512 #define register_cld_notifier() 0 520 513 #define unregister_cld_notifier() do { } while(0)
+1 -7
fs/nfsd/nfsfh.c
··· 392 392 skip_pseudoflavor_check: 393 393 /* Finally, check access permissions. */ 394 394 error = nfsd_permission(rqstp, exp, dentry, access); 395 - 396 - if (error) { 397 - dprintk("fh_verify: %pd2 permission failure, " 398 - "acc=%x, error=%d\n", 399 - dentry, 400 - access, ntohl(error)); 401 - } 395 + trace_nfsd_fh_verify_err(rqstp, fhp, type, access, error); 402 396 out: 403 397 if (error == nfserr_stale) 404 398 nfsd_stats_fh_stale_inc(exp);
+24 -15
fs/nfsd/nfsproc.c
··· 185 185 argp->count, argp->offset); 186 186 187 187 argp->count = min_t(u32, argp->count, NFSSVC_MAXBLKSIZE_V2); 188 + argp->count = min_t(u32, argp->count, rqstp->rq_res.buflen); 188 189 189 190 v = 0; 190 191 len = argp->count; ··· 391 390 resp->status = nfs_ok; 392 391 if (!inode) { 393 392 /* File doesn't exist. Create it and set attrs */ 394 - resp->status = nfsd_create_locked(rqstp, dirfhp, argp->name, 395 - argp->len, &attrs, type, rdev, 396 - newfhp); 393 + resp->status = nfsd_create_locked(rqstp, dirfhp, &attrs, type, 394 + rdev, newfhp); 397 395 } else if (type == S_IFREG) { 398 396 dprintk("nfsd: existing %s, valid=%x, size=%ld\n", 399 397 argp->name, attr->ia_valid, (long) attr->ia_size); ··· 567 567 struct xdr_buf *buf = &resp->dirlist; 568 568 struct xdr_stream *xdr = &resp->xdr; 569 569 570 - count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp)); 571 - 572 570 memset(buf, 0, sizeof(*buf)); 573 571 574 572 /* Reserve room for the NULL ptr & eof flag (-2 words) */ 575 - buf->buflen = count - XDR_UNIT * 2; 573 + buf->buflen = clamp(count, (u32)(XDR_UNIT * 2), (u32)PAGE_SIZE); 574 + buf->buflen -= XDR_UNIT * 2; 576 575 buf->pages = rqstp->rq_next_page; 577 576 rqstp->rq_next_page++; 578 577 579 - /* This is xdr_init_encode(), but it assumes that 580 - * the head kvec has already been consumed. */ 581 - xdr_set_scratch_buffer(xdr, NULL, 0); 582 - xdr->buf = buf; 583 - xdr->page_ptr = buf->pages; 584 - xdr->iov = NULL; 585 - xdr->p = page_address(*buf->pages); 586 - xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE); 587 - xdr->rqst = NULL; 578 + xdr_init_encode_pages(xdr, buf, buf->pages, NULL); 588 579 } 589 580 590 581 /* ··· 637 646 .pc_decode = nfssvc_decode_voidarg, 638 647 .pc_encode = nfssvc_encode_voidres, 639 648 .pc_argsize = sizeof(struct nfsd_voidargs), 649 + .pc_argzero = sizeof(struct nfsd_voidargs), 640 650 .pc_ressize = sizeof(struct nfsd_voidres), 641 651 .pc_cachetype = RC_NOCACHE, 642 652 .pc_xdrressize = 0, ··· 649 657 .pc_encode = nfssvc_encode_attrstatres, 650 658 .pc_release = nfssvc_release_attrstat, 651 659 .pc_argsize = sizeof(struct nfsd_fhandle), 660 + .pc_argzero = sizeof(struct nfsd_fhandle), 652 661 .pc_ressize = sizeof(struct nfsd_attrstat), 653 662 .pc_cachetype = RC_NOCACHE, 654 663 .pc_xdrressize = ST+AT, ··· 661 668 .pc_encode = nfssvc_encode_attrstatres, 662 669 .pc_release = nfssvc_release_attrstat, 663 670 .pc_argsize = sizeof(struct nfsd_sattrargs), 671 + .pc_argzero = sizeof(struct nfsd_sattrargs), 664 672 .pc_ressize = sizeof(struct nfsd_attrstat), 665 673 .pc_cachetype = RC_REPLBUFF, 666 674 .pc_xdrressize = ST+AT, ··· 672 678 .pc_decode = nfssvc_decode_voidarg, 673 679 .pc_encode = nfssvc_encode_voidres, 674 680 .pc_argsize = sizeof(struct nfsd_voidargs), 681 + .pc_argzero = sizeof(struct nfsd_voidargs), 675 682 .pc_ressize = sizeof(struct nfsd_voidres), 676 683 .pc_cachetype = RC_NOCACHE, 677 684 .pc_xdrressize = 0, ··· 684 689 .pc_encode = nfssvc_encode_diropres, 685 690 .pc_release = nfssvc_release_diropres, 686 691 .pc_argsize = sizeof(struct nfsd_diropargs), 692 + .pc_argzero = sizeof(struct nfsd_diropargs), 687 693 .pc_ressize = sizeof(struct nfsd_diropres), 688 694 .pc_cachetype = RC_NOCACHE, 689 695 .pc_xdrressize = ST+FH+AT, ··· 695 699 .pc_decode = nfssvc_decode_fhandleargs, 696 700 .pc_encode = nfssvc_encode_readlinkres, 697 701 .pc_argsize = sizeof(struct nfsd_fhandle), 702 + .pc_argzero = sizeof(struct nfsd_fhandle), 698 703 .pc_ressize = sizeof(struct nfsd_readlinkres), 699 704 .pc_cachetype = RC_NOCACHE, 700 705 .pc_xdrressize = ST+1+NFS_MAXPATHLEN/4, ··· 707 710 .pc_encode = nfssvc_encode_readres, 708 711 .pc_release = nfssvc_release_readres, 709 712 .pc_argsize = sizeof(struct nfsd_readargs), 713 + .pc_argzero = sizeof(struct nfsd_readargs), 710 714 .pc_ressize = sizeof(struct nfsd_readres), 711 715 .pc_cachetype = RC_NOCACHE, 712 716 .pc_xdrressize = ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4, ··· 718 720 .pc_decode = nfssvc_decode_voidarg, 719 721 .pc_encode = nfssvc_encode_voidres, 720 722 .pc_argsize = sizeof(struct nfsd_voidargs), 723 + .pc_argzero = sizeof(struct nfsd_voidargs), 721 724 .pc_ressize = sizeof(struct nfsd_voidres), 722 725 .pc_cachetype = RC_NOCACHE, 723 726 .pc_xdrressize = 0, ··· 730 731 .pc_encode = nfssvc_encode_attrstatres, 731 732 .pc_release = nfssvc_release_attrstat, 732 733 .pc_argsize = sizeof(struct nfsd_writeargs), 734 + .pc_argzero = sizeof(struct nfsd_writeargs), 733 735 .pc_ressize = sizeof(struct nfsd_attrstat), 734 736 .pc_cachetype = RC_REPLBUFF, 735 737 .pc_xdrressize = ST+AT, ··· 742 742 .pc_encode = nfssvc_encode_diropres, 743 743 .pc_release = nfssvc_release_diropres, 744 744 .pc_argsize = sizeof(struct nfsd_createargs), 745 + .pc_argzero = sizeof(struct nfsd_createargs), 745 746 .pc_ressize = sizeof(struct nfsd_diropres), 746 747 .pc_cachetype = RC_REPLBUFF, 747 748 .pc_xdrressize = ST+FH+AT, ··· 753 752 .pc_decode = nfssvc_decode_diropargs, 754 753 .pc_encode = nfssvc_encode_statres, 755 754 .pc_argsize = sizeof(struct nfsd_diropargs), 755 + .pc_argzero = sizeof(struct nfsd_diropargs), 756 756 .pc_ressize = sizeof(struct nfsd_stat), 757 757 .pc_cachetype = RC_REPLSTAT, 758 758 .pc_xdrressize = ST, ··· 764 762 .pc_decode = nfssvc_decode_renameargs, 765 763 .pc_encode = nfssvc_encode_statres, 766 764 .pc_argsize = sizeof(struct nfsd_renameargs), 765 + .pc_argzero = sizeof(struct nfsd_renameargs), 767 766 .pc_ressize = sizeof(struct nfsd_stat), 768 767 .pc_cachetype = RC_REPLSTAT, 769 768 .pc_xdrressize = ST, ··· 775 772 .pc_decode = nfssvc_decode_linkargs, 776 773 .pc_encode = nfssvc_encode_statres, 777 774 .pc_argsize = sizeof(struct nfsd_linkargs), 775 + .pc_argzero = sizeof(struct nfsd_linkargs), 778 776 .pc_ressize = sizeof(struct nfsd_stat), 779 777 .pc_cachetype = RC_REPLSTAT, 780 778 .pc_xdrressize = ST, ··· 786 782 .pc_decode = nfssvc_decode_symlinkargs, 787 783 .pc_encode = nfssvc_encode_statres, 788 784 .pc_argsize = sizeof(struct nfsd_symlinkargs), 785 + .pc_argzero = sizeof(struct nfsd_symlinkargs), 789 786 .pc_ressize = sizeof(struct nfsd_stat), 790 787 .pc_cachetype = RC_REPLSTAT, 791 788 .pc_xdrressize = ST, ··· 798 793 .pc_encode = nfssvc_encode_diropres, 799 794 .pc_release = nfssvc_release_diropres, 800 795 .pc_argsize = sizeof(struct nfsd_createargs), 796 + .pc_argzero = sizeof(struct nfsd_createargs), 801 797 .pc_ressize = sizeof(struct nfsd_diropres), 802 798 .pc_cachetype = RC_REPLBUFF, 803 799 .pc_xdrressize = ST+FH+AT, ··· 809 803 .pc_decode = nfssvc_decode_diropargs, 810 804 .pc_encode = nfssvc_encode_statres, 811 805 .pc_argsize = sizeof(struct nfsd_diropargs), 806 + .pc_argzero = sizeof(struct nfsd_diropargs), 812 807 .pc_ressize = sizeof(struct nfsd_stat), 813 808 .pc_cachetype = RC_REPLSTAT, 814 809 .pc_xdrressize = ST, ··· 820 813 .pc_decode = nfssvc_decode_readdirargs, 821 814 .pc_encode = nfssvc_encode_readdirres, 822 815 .pc_argsize = sizeof(struct nfsd_readdirargs), 816 + .pc_argzero = sizeof(struct nfsd_readdirargs), 823 817 .pc_ressize = sizeof(struct nfsd_readdirres), 824 818 .pc_cachetype = RC_NOCACHE, 825 819 .pc_name = "READDIR", ··· 830 822 .pc_decode = nfssvc_decode_fhandleargs, 831 823 .pc_encode = nfssvc_encode_statfsres, 832 824 .pc_argsize = sizeof(struct nfsd_fhandle), 825 + .pc_argzero = sizeof(struct nfsd_fhandle), 833 826 .pc_ressize = sizeof(struct nfsd_statfsres), 834 827 .pc_cachetype = RC_NOCACHE, 835 828 .pc_xdrressize = ST+5,
+1 -1
fs/nfsd/nfssvc.c
··· 799 799 if (nrservs == 0 && nn->nfsd_serv == NULL) 800 800 goto out; 801 801 802 - strlcpy(nn->nfsd_name, utsname()->nodename, 802 + strscpy(nn->nfsd_name, utsname()->nodename, 803 803 sizeof(nn->nfsd_name)); 804 804 805 805 error = nfsd_create_serv(net);
+1 -3
fs/nfsd/nfsxdr.c
··· 338 338 return false; 339 339 if (args->len > NFSSVC_MAXBLKSIZE_V2) 340 340 return false; 341 - if (!xdr_stream_subsegment(xdr, &args->payload, args->len)) 342 - return false; 343 341 344 - return true; 342 + return xdr_stream_subsegment(xdr, &args->payload, args->len); 345 343 } 346 344 347 345 bool
+5 -6
fs/nfsd/state.h
··· 57 57 } stateid_t; 58 58 59 59 typedef struct { 60 - stateid_t stid; 60 + stateid_t cs_stid; 61 61 #define NFS4_COPY_STID 1 62 62 #define NFS4_COPYNOTIFY_STID 2 63 - unsigned char sc_type; 64 - refcount_t sc_count; 63 + unsigned char cs_type; 64 + refcount_t cs_count; 65 65 } copy_stateid_t; 66 66 67 67 struct nfsd4_callback { ··· 175 175 /* Maximum number of slots per session. 160 is useful for long haul TCP */ 176 176 #define NFSD_MAX_SLOTS_PER_SESSION 160 177 177 /* Maximum number of operations per session compound */ 178 - #define NFSD_MAX_OPS_PER_COMPOUND 16 178 + #define NFSD_MAX_OPS_PER_COMPOUND 50 179 179 /* Maximum session per slot cache size */ 180 180 #define NFSD_SLOT_CACHE_SIZE 2048 181 181 /* Maximum number of NFSD_SLOT_CACHE_SIZE slots per session */ ··· 692 692 extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *); 693 693 extern void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp, 694 694 const struct nfsd4_callback_ops *ops, enum nfsd4_cb_op op); 695 - extern void nfsd4_run_cb(struct nfsd4_callback *cb); 695 + extern bool nfsd4_run_cb(struct nfsd4_callback *cb); 696 696 extern int nfsd4_create_callback_queue(void); 697 697 extern void nfsd4_destroy_callback_queue(void); 698 698 extern void nfsd4_shutdown_callback(struct nfs4_client *); 699 699 extern void nfsd4_shutdown_copy(struct nfs4_client *clp); 700 - extern void nfsd4_prepare_cb_recall(struct nfs4_delegation *dp); 701 700 extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name, 702 701 struct xdr_netobj princhash, struct nfsd_net *nn); 703 702 extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn);
+2 -12
fs/nfsd/stats.c
··· 32 32 .program = &nfsd_program, 33 33 }; 34 34 35 - static int nfsd_proc_show(struct seq_file *seq, void *v) 35 + static int nfsd_show(struct seq_file *seq, void *v) 36 36 { 37 37 int i; 38 38 ··· 72 72 return 0; 73 73 } 74 74 75 - static int nfsd_proc_open(struct inode *inode, struct file *file) 76 - { 77 - return single_open(file, nfsd_proc_show, NULL); 78 - } 79 - 80 - static const struct proc_ops nfsd_proc_ops = { 81 - .proc_open = nfsd_proc_open, 82 - .proc_read = seq_read, 83 - .proc_lseek = seq_lseek, 84 - .proc_release = single_release, 85 - }; 75 + DEFINE_PROC_SHOW_ATTRIBUTE(nfsd); 86 76 87 77 int nfsd_percpu_counters_init(struct percpu_counter counters[], int num) 88 78 {
+121 -10
fs/nfsd/trace.h
··· 84 84 { NFSD_MAY_64BIT_COOKIE, "64BIT_COOKIE" }) 85 85 86 86 TRACE_EVENT(nfsd_compound, 87 - TP_PROTO(const struct svc_rqst *rqst, 88 - u32 args_opcnt), 89 - TP_ARGS(rqst, args_opcnt), 87 + TP_PROTO( 88 + const struct svc_rqst *rqst, 89 + const char *tag, 90 + u32 taglen, 91 + u32 opcnt 92 + ), 93 + TP_ARGS(rqst, tag, taglen, opcnt), 90 94 TP_STRUCT__entry( 91 95 __field(u32, xid) 92 - __field(u32, args_opcnt) 96 + __field(u32, opcnt) 97 + __string_len(tag, tag, taglen) 93 98 ), 94 99 TP_fast_assign( 95 100 __entry->xid = be32_to_cpu(rqst->rq_xid); 96 - __entry->args_opcnt = args_opcnt; 101 + __entry->opcnt = opcnt; 102 + __assign_str_len(tag, tag, taglen); 97 103 ), 98 - TP_printk("xid=0x%08x opcnt=%u", 99 - __entry->xid, __entry->args_opcnt) 104 + TP_printk("xid=0x%08x opcnt=%u tag=%s", 105 + __entry->xid, __entry->opcnt, __get_str(tag) 106 + ) 100 107 ) 101 108 102 109 TRACE_EVENT(nfsd_compound_status, ··· 202 195 __sockaddr(client, rqstp->rq_xprt->xpt_remotelen) 203 196 __field(u32, xid) 204 197 __field(u32, fh_hash) 205 - __field(void *, inode) 198 + __field(const void *, inode) 206 199 __field(unsigned long, type) 207 200 __field(unsigned long, access) 208 201 ), ··· 218 211 __entry->type = type; 219 212 __entry->access = access; 220 213 ), 221 - TP_printk("xid=0x%08x fh_hash=0x%08x inode=%p type=%s access=%s", 222 - __entry->xid, __entry->fh_hash, __entry->inode, 214 + TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s", 215 + __entry->xid, __entry->fh_hash, 223 216 show_fs_file_type(__entry->type), 224 217 show_nfsd_may_flags(__entry->access) 218 + ) 219 + ); 220 + 221 + TRACE_EVENT_CONDITION(nfsd_fh_verify_err, 222 + TP_PROTO( 223 + const struct svc_rqst *rqstp, 224 + const struct svc_fh *fhp, 225 + umode_t type, 226 + int access, 227 + __be32 error 228 + ), 229 + TP_ARGS(rqstp, fhp, type, access, error), 230 + TP_CONDITION(error), 231 + TP_STRUCT__entry( 232 + __field(unsigned int, netns_ino) 233 + __sockaddr(server, rqstp->rq_xprt->xpt_remotelen) 234 + __sockaddr(client, rqstp->rq_xprt->xpt_remotelen) 235 + __field(u32, xid) 236 + __field(u32, fh_hash) 237 + __field(const void *, inode) 238 + __field(unsigned long, type) 239 + __field(unsigned long, access) 240 + __field(int, error) 241 + ), 242 + TP_fast_assign( 243 + __entry->netns_ino = SVC_NET(rqstp)->ns.inum; 244 + __assign_sockaddr(server, &rqstp->rq_xprt->xpt_local, 245 + rqstp->rq_xprt->xpt_locallen); 246 + __assign_sockaddr(client, &rqstp->rq_xprt->xpt_remote, 247 + rqstp->rq_xprt->xpt_remotelen); 248 + __entry->xid = be32_to_cpu(rqstp->rq_xid); 249 + __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle); 250 + __entry->inode = d_inode(fhp->fh_dentry); 251 + __entry->type = type; 252 + __entry->access = access; 253 + __entry->error = be32_to_cpu(error); 254 + ), 255 + TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s error=%d", 256 + __entry->xid, __entry->fh_hash, 257 + show_fs_file_type(__entry->type), 258 + show_nfsd_may_flags(__entry->access), 259 + __entry->error 225 260 ) 226 261 ); 227 262 ··· 537 488 #include "state.h" 538 489 #include "filecache.h" 539 490 #include "vfs.h" 491 + 492 + TRACE_EVENT(nfsd_delegret_wakeup, 493 + TP_PROTO( 494 + const struct svc_rqst *rqstp, 495 + const struct inode *inode, 496 + long timeo 497 + ), 498 + TP_ARGS(rqstp, inode, timeo), 499 + TP_STRUCT__entry( 500 + __field(u32, xid) 501 + __field(const void *, inode) 502 + __field(long, timeo) 503 + ), 504 + TP_fast_assign( 505 + __entry->xid = be32_to_cpu(rqstp->rq_xid); 506 + __entry->inode = inode; 507 + __entry->timeo = timeo; 508 + ), 509 + TP_printk("xid=0x%08x inode=%p%s", 510 + __entry->xid, __entry->inode, 511 + __entry->timeo == 0 ? " (timed out)" : "" 512 + ) 513 + ); 540 514 541 515 DECLARE_EVENT_CLASS(nfsd_stateid_class, 542 516 TP_PROTO(stateid_t *stp), ··· 1470 1398 __entry->si_id, __entry->si_generation, 1471 1399 __entry->fh_hash, __entry->count, __entry->status) 1472 1400 ); 1401 + 1402 + DECLARE_EVENT_CLASS(nfsd_cb_done_class, 1403 + TP_PROTO( 1404 + const stateid_t *stp, 1405 + const struct rpc_task *task 1406 + ), 1407 + TP_ARGS(stp, task), 1408 + TP_STRUCT__entry( 1409 + __field(u32, cl_boot) 1410 + __field(u32, cl_id) 1411 + __field(u32, si_id) 1412 + __field(u32, si_generation) 1413 + __field(int, status) 1414 + ), 1415 + TP_fast_assign( 1416 + __entry->cl_boot = stp->si_opaque.so_clid.cl_boot; 1417 + __entry->cl_id = stp->si_opaque.so_clid.cl_id; 1418 + __entry->si_id = stp->si_opaque.so_id; 1419 + __entry->si_generation = stp->si_generation; 1420 + __entry->status = task->tk_status; 1421 + ), 1422 + TP_printk("client %08x:%08x stateid %08x:%08x status=%d", 1423 + __entry->cl_boot, __entry->cl_id, __entry->si_id, 1424 + __entry->si_generation, __entry->status 1425 + ) 1426 + ); 1427 + 1428 + #define DEFINE_NFSD_CB_DONE_EVENT(name) \ 1429 + DEFINE_EVENT(nfsd_cb_done_class, name, \ 1430 + TP_PROTO( \ 1431 + const stateid_t *stp, \ 1432 + const struct rpc_task *task \ 1433 + ), \ 1434 + TP_ARGS(stp, task)) 1435 + 1436 + DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_recall_done); 1437 + DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_notify_lock_done); 1438 + DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_layout_done); 1439 + DEFINE_NFSD_CB_DONE_EVENT(nfsd_cb_offload_done); 1473 1440 1474 1441 #endif /* _NFSD_TRACE_H */ 1475 1442
+84 -44
fs/nfsd/vfs.c
··· 343 343 return nfserrno(get_write_access(inode)); 344 344 } 345 345 346 - /* 347 - * Set various file attributes. After this call fhp needs an fh_put. 346 + static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap) 347 + { 348 + int host_err; 349 + 350 + if (iap->ia_valid & ATTR_SIZE) { 351 + /* 352 + * RFC5661, Section 18.30.4: 353 + * Changing the size of a file with SETATTR indirectly 354 + * changes the time_modify and change attributes. 355 + * 356 + * (and similar for the older RFCs) 357 + */ 358 + struct iattr size_attr = { 359 + .ia_valid = ATTR_SIZE | ATTR_CTIME | ATTR_MTIME, 360 + .ia_size = iap->ia_size, 361 + }; 362 + 363 + if (iap->ia_size < 0) 364 + return -EFBIG; 365 + 366 + host_err = notify_change(&init_user_ns, dentry, &size_attr, NULL); 367 + if (host_err) 368 + return host_err; 369 + iap->ia_valid &= ~ATTR_SIZE; 370 + 371 + /* 372 + * Avoid the additional setattr call below if the only other 373 + * attribute that the client sends is the mtime, as we update 374 + * it as part of the size change above. 375 + */ 376 + if ((iap->ia_valid & ~ATTR_MTIME) == 0) 377 + return 0; 378 + } 379 + 380 + if (!iap->ia_valid) 381 + return 0; 382 + 383 + iap->ia_valid |= ATTR_CTIME; 384 + return notify_change(&init_user_ns, dentry, iap, NULL); 385 + } 386 + 387 + /** 388 + * nfsd_setattr - Set various file attributes. 389 + * @rqstp: controlling RPC transaction 390 + * @fhp: filehandle of target 391 + * @attr: attributes to set 392 + * @check_guard: set to 1 if guardtime is a valid timestamp 393 + * @guardtime: do not act if ctime.tv_sec does not match this timestamp 394 + * 395 + * This call may adjust the contents of @attr (in particular, this 396 + * call may change the bits in the na_iattr.ia_valid field). 397 + * 398 + * Returns nfs_ok on success, otherwise an NFS status code is 399 + * returned. Caller must release @fhp by calling fh_put in either 400 + * case. 348 401 */ 349 402 __be32 350 403 nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, ··· 410 357 int accmode = NFSD_MAY_SATTR; 411 358 umode_t ftype = 0; 412 359 __be32 err; 413 - int host_err = 0; 360 + int host_err; 414 361 bool get_write_count; 415 362 bool size_change = (iap->ia_valid & ATTR_SIZE); 363 + int retries; 416 364 417 365 if (iap->ia_valid & ATTR_SIZE) { 418 366 accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE; ··· 468 414 } 469 415 470 416 inode_lock(inode); 471 - if (size_change) { 472 - /* 473 - * RFC5661, Section 18.30.4: 474 - * Changing the size of a file with SETATTR indirectly 475 - * changes the time_modify and change attributes. 476 - * 477 - * (and similar for the older RFCs) 478 - */ 479 - struct iattr size_attr = { 480 - .ia_valid = ATTR_SIZE | ATTR_CTIME | ATTR_MTIME, 481 - .ia_size = iap->ia_size, 482 - }; 483 - 484 - host_err = -EFBIG; 485 - if (iap->ia_size < 0) 486 - goto out_unlock; 487 - 488 - host_err = notify_change(&init_user_ns, dentry, &size_attr, NULL); 489 - if (host_err) 490 - goto out_unlock; 491 - iap->ia_valid &= ~ATTR_SIZE; 492 - 493 - /* 494 - * Avoid the additional setattr call below if the only other 495 - * attribute that the client sends is the mtime, as we update 496 - * it as part of the size change above. 497 - */ 498 - if ((iap->ia_valid & ~ATTR_MTIME) == 0) 499 - goto out_unlock; 417 + for (retries = 1;;) { 418 + host_err = __nfsd_setattr(dentry, iap); 419 + if (host_err != -EAGAIN || !retries--) 420 + break; 421 + if (!nfsd_wait_for_delegreturn(rqstp, inode)) 422 + break; 500 423 } 501 - 502 - if (iap->ia_valid) { 503 - iap->ia_valid |= ATTR_CTIME; 504 - host_err = notify_change(&init_user_ns, dentry, iap, NULL); 505 - } 506 - 507 - out_unlock: 508 424 if (attr->na_seclabel && attr->na_seclabel->len) 509 425 attr->na_labelerr = security_inode_setsecctx(dentry, 510 426 attr->na_seclabel->data, attr->na_seclabel->len); ··· 1279 1255 /* The parent directory should already be locked: */ 1280 1256 __be32 1281 1257 nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp, 1282 - char *fname, int flen, struct nfsd_attrs *attrs, 1258 + struct nfsd_attrs *attrs, 1283 1259 int type, dev_t rdev, struct svc_fh *resfhp) 1284 1260 { 1285 1261 struct dentry *dentry, *dchild; ··· 1406 1382 if (err) 1407 1383 goto out_unlock; 1408 1384 fh_fill_pre_attrs(fhp); 1409 - err = nfsd_create_locked(rqstp, fhp, fname, flen, attrs, type, 1410 - rdev, resfhp); 1385 + err = nfsd_create_locked(rqstp, fhp, attrs, type, rdev, resfhp); 1411 1386 fh_fill_post_attrs(fhp); 1412 1387 out_unlock: 1413 1388 inode_unlock(dentry->d_inode); ··· 1696 1673 .new_dir = tdir, 1697 1674 .new_dentry = ndentry, 1698 1675 }; 1699 - host_err = vfs_rename(&rd); 1676 + int retries; 1677 + 1678 + for (retries = 1;;) { 1679 + host_err = vfs_rename(&rd); 1680 + if (host_err != -EAGAIN || !retries--) 1681 + break; 1682 + if (!nfsd_wait_for_delegreturn(rqstp, d_inode(odentry))) 1683 + break; 1684 + } 1700 1685 if (!host_err) { 1701 1686 host_err = commit_metadata(tfhp); 1702 1687 if (!host_err) ··· 1788 1757 1789 1758 fh_fill_pre_attrs(fhp); 1790 1759 if (type != S_IFDIR) { 1760 + int retries; 1761 + 1791 1762 if (rdentry->d_sb->s_export_op->flags & EXPORT_OP_CLOSE_BEFORE_UNLINK) 1792 1763 nfsd_close_cached_files(rdentry); 1793 - host_err = vfs_unlink(&init_user_ns, dirp, rdentry, NULL); 1764 + 1765 + for (retries = 1;;) { 1766 + host_err = vfs_unlink(&init_user_ns, dirp, rdentry, NULL); 1767 + if (host_err != -EAGAIN || !retries--) 1768 + break; 1769 + if (!nfsd_wait_for_delegreturn(rqstp, rinode)) 1770 + break; 1771 + } 1794 1772 } else { 1795 1773 host_err = vfs_rmdir(&init_user_ns, dirp, rdentry); 1796 1774 }
+2 -2
fs/nfsd/vfs.h
··· 79 79 u64 count, bool sync); 80 80 #endif /* CONFIG_NFSD_V4 */ 81 81 __be32 nfsd_create_locked(struct svc_rqst *, struct svc_fh *, 82 - char *name, int len, struct nfsd_attrs *attrs, 83 - int type, dev_t rdev, struct svc_fh *res); 82 + struct nfsd_attrs *attrs, int type, dev_t rdev, 83 + struct svc_fh *res); 84 84 __be32 nfsd_create(struct svc_rqst *, struct svc_fh *, 85 85 char *name, int len, struct nfsd_attrs *attrs, 86 86 int type, dev_t rdev, struct svc_fh *res);
+5 -4
fs/nfsd/xdr4.h
··· 717 717 struct svcxdr_tmpbuf *to_free; 718 718 struct svc_rqst *rqstp; 719 719 720 - u32 taglen; 721 720 char * tag; 721 + u32 taglen; 722 722 u32 minorversion; 723 + u32 client_opcnt; 723 724 u32 opcnt; 724 725 struct nfsd4_op *ops; 725 726 struct nfsd4_op iops[8]; 726 - int cachetype; 727 727 }; 728 728 729 729 struct nfsd4_compoundres { ··· 732 732 struct svc_rqst * rqstp; 733 733 734 734 __be32 *statusp; 735 - u32 taglen; 736 735 char * tag; 736 + u32 taglen; 737 737 u32 opcnt; 738 738 739 739 struct nfsd4_compound_state cstate; ··· 888 888 u32 op_flags; 889 889 char *op_name; 890 890 /* Try to get response size before operation */ 891 - u32 (*op_rsize_bop)(struct svc_rqst *, struct nfsd4_op *); 891 + u32 (*op_rsize_bop)(const struct svc_rqst *rqstp, 892 + const struct nfsd4_op *op); 892 893 void (*op_get_currentstateid)(struct nfsd4_compound_state *, 893 894 union nfsd4_op_u *); 894 895 void (*op_set_currentstateid)(struct nfsd4_compound_state *,
+16 -4
include/linux/sunrpc/svc.h
··· 472 472 /* XDR free result: */ 473 473 void (*pc_release)(struct svc_rqst *); 474 474 unsigned int pc_argsize; /* argument struct size */ 475 + unsigned int pc_argzero; /* how much of argument to clear */ 475 476 unsigned int pc_ressize; /* result struct size */ 476 477 unsigned int pc_cachetype; /* cache info (NFS) */ 477 478 unsigned int pc_xdrressize; /* maximum size of XDR reply */ ··· 545 544 } 546 545 547 546 /** 548 - * svcxdr_init_decode - Prepare an xdr_stream for svc Call decoding 547 + * svcxdr_init_decode - Prepare an xdr_stream for Call decoding 549 548 * @rqstp: controlling server RPC transaction context 550 549 * 550 + * This function currently assumes the RPC header in rq_arg has 551 + * already been decoded. Upon return, xdr->p points to the 552 + * location of the upper layer header. 551 553 */ 552 554 static inline void svcxdr_init_decode(struct svc_rqst *rqstp) 553 555 { 554 556 struct xdr_stream *xdr = &rqstp->rq_arg_stream; 555 - struct kvec *argv = rqstp->rq_arg.head; 557 + struct xdr_buf *buf = &rqstp->rq_arg; 558 + struct kvec *argv = buf->head; 556 559 557 - xdr_init_decode(xdr, &rqstp->rq_arg, argv->iov_base, NULL); 560 + /* 561 + * svc_getnl() and friends do not keep the xdr_buf's ::len 562 + * field up to date. Refresh that field before initializing 563 + * the argument decoding stream. 564 + */ 565 + buf->len = buf->head->iov_len + buf->page_len + buf->tail->iov_len; 566 + 567 + xdr_init_decode(xdr, buf, argv->iov_base, NULL); 558 568 xdr_set_scratch_page(xdr, rqstp->rq_scratch_page); 559 569 } 560 570 ··· 588 576 xdr->end = resv->iov_base + PAGE_SIZE - rqstp->rq_auth_slack; 589 577 buf->len = resv->iov_len; 590 578 xdr->page_ptr = buf->pages - 1; 591 - buf->buflen = PAGE_SIZE * (1 + rqstp->rq_page_end - buf->pages); 579 + buf->buflen = PAGE_SIZE * (rqstp->rq_page_end - buf->pages); 592 580 buf->buflen -= rqstp->rq_auth_slack; 593 581 xdr->rqst = NULL; 594 582 }
+2
include/linux/sunrpc/xdr.h
··· 240 240 241 241 extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, 242 242 __be32 *p, struct rpc_rqst *rqst); 243 + extern void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, 244 + struct page **pages, struct rpc_rqst *rqst); 243 245 extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes); 244 246 extern int xdr_reserve_space_vec(struct xdr_stream *xdr, struct kvec *vec, 245 247 size_t nbytes);
+18 -16
net/sunrpc/svc.c
··· 1205 1205 goto err_bad_proc; 1206 1206 1207 1207 /* Initialize storage for argp and resp */ 1208 - memset(rqstp->rq_argp, 0, procp->pc_argsize); 1208 + memset(rqstp->rq_argp, 0, procp->pc_argzero); 1209 1209 memset(rqstp->rq_resp, 0, procp->pc_ressize); 1210 1210 1211 1211 /* Bump per-procedure stats counter */ ··· 1434 1434 { 1435 1435 struct kvec *argv = &rqstp->rq_arg.head[0]; 1436 1436 struct kvec *resv = &rqstp->rq_res.head[0]; 1437 - struct svc_serv *serv = rqstp->rq_server; 1438 - u32 dir; 1437 + __be32 dir; 1439 1438 1440 1439 #if IS_ENABLED(CONFIG_FAIL_SUNRPC) 1441 1440 if (!fail_sunrpc.ignore_server_disconnect && ··· 1449 1450 rqstp->rq_next_page = &rqstp->rq_respages[1]; 1450 1451 resv->iov_base = page_address(rqstp->rq_respages[0]); 1451 1452 resv->iov_len = 0; 1452 - rqstp->rq_res.pages = rqstp->rq_respages + 1; 1453 + rqstp->rq_res.pages = rqstp->rq_next_page; 1453 1454 rqstp->rq_res.len = 0; 1454 1455 rqstp->rq_res.page_base = 0; 1455 1456 rqstp->rq_res.page_len = 0; ··· 1457 1458 rqstp->rq_res.tail[0].iov_base = NULL; 1458 1459 rqstp->rq_res.tail[0].iov_len = 0; 1459 1460 1460 - dir = svc_getnl(argv); 1461 - if (dir != 0) { 1462 - /* direction != CALL */ 1463 - svc_printk(rqstp, "bad direction %d, dropping request\n", dir); 1464 - serv->sv_stats->rpcbadfmt++; 1461 + dir = svc_getu32(argv); 1462 + if (dir != rpc_call) 1463 + goto out_baddir; 1464 + if (!svc_process_common(rqstp, argv, resv)) 1465 1465 goto out_drop; 1466 - } 1466 + return svc_send(rqstp); 1467 1467 1468 - /* Returns 1 for send, 0 for drop */ 1469 - if (likely(svc_process_common(rqstp, argv, resv))) 1470 - return svc_send(rqstp); 1471 - 1468 + out_baddir: 1469 + svc_printk(rqstp, "bad direction 0x%08x, dropping request\n", 1470 + be32_to_cpu(dir)); 1471 + rqstp->rq_server->sv_stats->rpcbadfmt++; 1472 1472 out_drop: 1473 1473 svc_drop(rqstp); 1474 1474 return 0; ··· 1554 1556 EXPORT_SYMBOL_GPL(bc_svc_process); 1555 1557 #endif /* CONFIG_SUNRPC_BACKCHANNEL */ 1556 1558 1557 - /* 1558 - * Return (transport-specific) limit on the rpc payload. 1559 + /** 1560 + * svc_max_payload - Return transport-specific limit on the RPC payload 1561 + * @rqstp: RPC transaction context 1562 + * 1563 + * Returns the maximum number of payload bytes the current transport 1564 + * allows. 1559 1565 */ 1560 1566 u32 svc_max_payload(const struct svc_rqst *rqstp) 1561 1567 {
+23 -1
net/sunrpc/xdr.c
··· 947 947 EXPORT_SYMBOL_GPL(xdr_init_encode); 948 948 949 949 /** 950 + * xdr_init_encode_pages - Initialize an xdr_stream for encoding into pages 951 + * @xdr: pointer to xdr_stream struct 952 + * @buf: pointer to XDR buffer into which to encode data 953 + * @pages: list of pages to decode into 954 + * @rqst: pointer to controlling rpc_rqst, for debugging 955 + * 956 + */ 957 + void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, 958 + struct page **pages, struct rpc_rqst *rqst) 959 + { 960 + xdr_reset_scratch_buffer(xdr); 961 + 962 + xdr->buf = buf; 963 + xdr->page_ptr = pages; 964 + xdr->iov = NULL; 965 + xdr->p = page_address(*pages); 966 + xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE); 967 + xdr->rqst = rqst; 968 + } 969 + EXPORT_SYMBOL_GPL(xdr_init_encode_pages); 970 + 971 + /** 950 972 * __xdr_commit_encode - Ensure all data is written to buffer 951 973 * @xdr: pointer to xdr_stream 952 974 * ··· 1597 1575 * 1598 1576 * @buf and @subbuf may be pointers to the same struct xdr_buf. 1599 1577 * 1600 - * Returns -1 if base of length are out of bounds. 1578 + * Returns -1 if base or length are out of bounds. 1601 1579 */ 1602 1580 int xdr_buf_subsegment(const struct xdr_buf *buf, struct xdr_buf *subbuf, 1603 1581 unsigned int base, unsigned int len)