Commit e31a1b662f40fd460e982ef87582c66c51596cd0
Committed by
J. Bruce Fields
1 parent
5bf8c6911f
Exists in
master
and in
7 other branches
nfsd: nfs4xdr decode_stateid helper function
Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Showing 1 changed file with 55 additions and 44 deletions Side-by-side Diff
fs/nfsd/nfs4xdr.c
... | ... | @@ -413,6 +413,18 @@ |
413 | 413 | } |
414 | 414 | |
415 | 415 | static __be32 |
416 | +nfsd4_decode_stateid(struct nfsd4_compoundargs *argp, stateid_t *sid) | |
417 | +{ | |
418 | + DECODE_HEAD; | |
419 | + | |
420 | + READ_BUF(sizeof(stateid_t)); | |
421 | + READ32(sid->si_generation); | |
422 | + COPYMEM(&sid->si_opaque, sizeof(stateid_opaque_t)); | |
423 | + | |
424 | + DECODE_TAIL; | |
425 | +} | |
426 | + | |
427 | +static __be32 | |
416 | 428 | nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access) |
417 | 429 | { |
418 | 430 | DECODE_HEAD; |
419 | 431 | |
... | ... | @@ -429,10 +441,9 @@ |
429 | 441 | DECODE_HEAD; |
430 | 442 | |
431 | 443 | close->cl_stateowner = NULL; |
432 | - READ_BUF(4 + sizeof(stateid_t)); | |
444 | + READ_BUF(4); | |
433 | 445 | READ32(close->cl_seqid); |
434 | - READ32(close->cl_stateid.si_generation); | |
435 | - COPYMEM(&close->cl_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
446 | + return nfsd4_decode_stateid(argp, &close->cl_stateid); | |
436 | 447 | |
437 | 448 | DECODE_TAIL; |
438 | 449 | } |
... | ... | @@ -493,13 +504,7 @@ |
493 | 504 | static inline __be32 |
494 | 505 | nfsd4_decode_delegreturn(struct nfsd4_compoundargs *argp, struct nfsd4_delegreturn *dr) |
495 | 506 | { |
496 | - DECODE_HEAD; | |
497 | - | |
498 | - READ_BUF(sizeof(stateid_t)); | |
499 | - READ32(dr->dr_stateid.si_generation); | |
500 | - COPYMEM(&dr->dr_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
501 | - | |
502 | - DECODE_TAIL; | |
507 | + return nfsd4_decode_stateid(argp, &dr->dr_stateid); | |
503 | 508 | } |
504 | 509 | |
505 | 510 | static inline __be32 |
506 | 511 | |
507 | 512 | |
... | ... | @@ -542,20 +547,22 @@ |
542 | 547 | READ32(lock->lk_is_new); |
543 | 548 | |
544 | 549 | if (lock->lk_is_new) { |
545 | - READ_BUF(36); | |
550 | + READ_BUF(4); | |
546 | 551 | READ32(lock->lk_new_open_seqid); |
547 | - READ32(lock->lk_new_open_stateid.si_generation); | |
548 | - | |
549 | - COPYMEM(&lock->lk_new_open_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
552 | + status = nfsd4_decode_stateid(argp, &lock->lk_new_open_stateid); | |
553 | + if (status) | |
554 | + return status; | |
555 | + READ_BUF(8 + sizeof(clientid_t)); | |
550 | 556 | READ32(lock->lk_new_lock_seqid); |
551 | 557 | COPYMEM(&lock->lk_new_clientid, sizeof(clientid_t)); |
552 | 558 | READ32(lock->lk_new_owner.len); |
553 | 559 | READ_BUF(lock->lk_new_owner.len); |
554 | 560 | READMEM(lock->lk_new_owner.data, lock->lk_new_owner.len); |
555 | 561 | } else { |
556 | - READ_BUF(20); | |
557 | - READ32(lock->lk_old_lock_stateid.si_generation); | |
558 | - COPYMEM(&lock->lk_old_lock_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
562 | + status = nfsd4_decode_stateid(argp, &lock->lk_old_lock_stateid); | |
563 | + if (status) | |
564 | + return status; | |
565 | + READ_BUF(4); | |
559 | 566 | READ32(lock->lk_old_lock_seqid); |
560 | 567 | } |
561 | 568 | |
562 | 569 | |
... | ... | @@ -587,13 +594,15 @@ |
587 | 594 | DECODE_HEAD; |
588 | 595 | |
589 | 596 | locku->lu_stateowner = NULL; |
590 | - READ_BUF(24 + sizeof(stateid_t)); | |
597 | + READ_BUF(8); | |
591 | 598 | READ32(locku->lu_type); |
592 | 599 | if ((locku->lu_type < NFS4_READ_LT) || (locku->lu_type > NFS4_WRITEW_LT)) |
593 | 600 | goto xdr_error; |
594 | 601 | READ32(locku->lu_seqid); |
595 | - READ32(locku->lu_stateid.si_generation); | |
596 | - COPYMEM(&locku->lu_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
602 | + status = nfsd4_decode_stateid(argp, &locku->lu_stateid); | |
603 | + if (status) | |
604 | + return status; | |
605 | + READ_BUF(16); | |
597 | 606 | READ64(locku->lu_offset); |
598 | 607 | READ64(locku->lu_length); |
599 | 608 | |
... | ... | @@ -678,10 +687,10 @@ |
678 | 687 | READ32(open->op_delegate_type); |
679 | 688 | break; |
680 | 689 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
681 | - READ_BUF(sizeof(stateid_t) + 4); | |
682 | - READ32(open->op_delegate_stateid.si_generation); | |
683 | - COPYMEM(&open->op_delegate_stateid.si_opaque, | |
684 | - sizeof(stateid_opaque_t)); | |
690 | + status = nfsd4_decode_stateid(argp, &open->op_delegate_stateid); | |
691 | + if (status) | |
692 | + return status; | |
693 | + READ_BUF(4); | |
685 | 694 | READ32(open->op_fname.len); |
686 | 695 | READ_BUF(open->op_fname.len); |
687 | 696 | SAVEMEM(open->op_fname.data, open->op_fname.len); |
... | ... | @@ -701,9 +710,10 @@ |
701 | 710 | DECODE_HEAD; |
702 | 711 | |
703 | 712 | open_conf->oc_stateowner = NULL; |
704 | - READ_BUF(4 + sizeof(stateid_t)); | |
705 | - READ32(open_conf->oc_req_stateid.si_generation); | |
706 | - COPYMEM(&open_conf->oc_req_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
713 | + status = nfsd4_decode_stateid(argp, &open_conf->oc_req_stateid); | |
714 | + if (status) | |
715 | + return status; | |
716 | + READ_BUF(4); | |
707 | 717 | READ32(open_conf->oc_seqid); |
708 | 718 | |
709 | 719 | DECODE_TAIL; |
... | ... | @@ -715,9 +725,10 @@ |
715 | 725 | DECODE_HEAD; |
716 | 726 | |
717 | 727 | open_down->od_stateowner = NULL; |
718 | - READ_BUF(12 + sizeof(stateid_t)); | |
719 | - READ32(open_down->od_stateid.si_generation); | |
720 | - COPYMEM(&open_down->od_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
728 | + status = nfsd4_decode_stateid(argp, &open_down->od_stateid); | |
729 | + if (status) | |
730 | + return status; | |
731 | + READ_BUF(12); | |
721 | 732 | READ32(open_down->od_seqid); |
722 | 733 | READ32(open_down->od_share_access); |
723 | 734 | READ32(open_down->od_share_deny); |
... | ... | @@ -745,9 +756,10 @@ |
745 | 756 | { |
746 | 757 | DECODE_HEAD; |
747 | 758 | |
748 | - READ_BUF(sizeof(stateid_t) + 12); | |
749 | - READ32(read->rd_stateid.si_generation); | |
750 | - COPYMEM(&read->rd_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
759 | + status = nfsd4_decode_stateid(argp, &read->rd_stateid); | |
760 | + if (status) | |
761 | + return status; | |
762 | + READ_BUF(12); | |
751 | 763 | READ64(read->rd_offset); |
752 | 764 | READ32(read->rd_length); |
753 | 765 | |
754 | 766 | |
... | ... | @@ -836,15 +848,13 @@ |
836 | 848 | static __be32 |
837 | 849 | nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *setattr) |
838 | 850 | { |
839 | - DECODE_HEAD; | |
851 | + __be32 status; | |
840 | 852 | |
841 | - READ_BUF(sizeof(stateid_t)); | |
842 | - READ32(setattr->sa_stateid.si_generation); | |
843 | - COPYMEM(&setattr->sa_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
844 | - if ((status = nfsd4_decode_fattr(argp, setattr->sa_bmval, &setattr->sa_iattr, &setattr->sa_acl))) | |
845 | - goto out; | |
846 | - | |
847 | - DECODE_TAIL; | |
853 | + status = nfsd4_decode_stateid(argp, &setattr->sa_stateid); | |
854 | + if (status) | |
855 | + return status; | |
856 | + return nfsd4_decode_fattr(argp, setattr->sa_bmval, | |
857 | + &setattr->sa_iattr, &setattr->sa_acl); | |
848 | 858 | } |
849 | 859 | |
850 | 860 | static __be32 |
... | ... | @@ -929,9 +939,10 @@ |
929 | 939 | int len; |
930 | 940 | DECODE_HEAD; |
931 | 941 | |
932 | - READ_BUF(sizeof(stateid_opaque_t) + 20); | |
933 | - READ32(write->wr_stateid.si_generation); | |
934 | - COPYMEM(&write->wr_stateid.si_opaque, sizeof(stateid_opaque_t)); | |
942 | + status = nfsd4_decode_stateid(argp, &write->wr_stateid); | |
943 | + if (status) | |
944 | + return status; | |
945 | + READ_BUF(16); | |
935 | 946 | READ64(write->wr_offset); |
936 | 947 | READ32(write->wr_stable_how); |
937 | 948 | if (write->wr_stable_how > 2) |