nfs4proc.c (781fde1a2ba2391f31142f46f964cf1148ca1791) | nfs4proc.c (76ce4dcec0dc08a032db916841ddc4e3998be317) |
---|---|
1/* 2 * Server-side procedures for NFSv4. 3 * 4 * Copyright (c) 2002 The Regents of the University of Michigan. 5 * All rights reserved. 6 * 7 * Kendrick Smith <kmsmith@umich.edu> 8 * Andy Adamson <andros@umich.edu> --- 2757 unchanged lines hidden (view full) --- 2766#define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) 2767 2768#define op_encode_ace_maxsz (3 + nfs4_owner_maxsz) 2769#define op_encode_delegation_maxsz (1 + op_encode_stateid_maxsz + 1 + \ 2770 op_encode_ace_maxsz) 2771 2772#define op_encode_channel_attrs_maxsz (6 + 1 + 1) 2773 | 1/* 2 * Server-side procedures for NFSv4. 3 * 4 * Copyright (c) 2002 The Regents of the University of Michigan. 5 * All rights reserved. 6 * 7 * Kendrick Smith <kmsmith@umich.edu> 8 * Andy Adamson <andros@umich.edu> --- 2757 unchanged lines hidden (view full) --- 2766#define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) 2767 2768#define op_encode_ace_maxsz (3 + nfs4_owner_maxsz) 2769#define op_encode_delegation_maxsz (1 + op_encode_stateid_maxsz + 1 + \ 2770 op_encode_ace_maxsz) 2771 2772#define op_encode_channel_attrs_maxsz (6 + 1 + 1) 2773 |
2774/* 2775 * The _rsize() helpers are invoked by the NFSv4 COMPOUND decoder, which 2776 * is called before sunrpc sets rq_res.buflen. Thus we have to compute 2777 * the maximum payload size here, based on transport limits and the size 2778 * of the remaining space in the rq_pages array. 2779 */ 2780static u32 nfsd4_max_payload(const struct svc_rqst *rqstp) 2781{ 2782 u32 buflen; 2783 2784 buflen = (rqstp->rq_page_end - rqstp->rq_next_page) * PAGE_SIZE; 2785 buflen -= rqstp->rq_auth_slack; 2786 buflen -= rqstp->rq_res.head[0].iov_len; 2787 return min_t(u32, buflen, svc_max_payload(rqstp)); 2788} 2789 |
|
2774static u32 nfsd4_only_status_rsize(const struct svc_rqst *rqstp, 2775 const struct nfsd4_op *op) 2776{ 2777 return (op_encode_hdr_size) * sizeof(__be32); 2778} 2779 2780static u32 nfsd4_status_stateid_rsize(const struct svc_rqst *rqstp, 2781 const struct nfsd4_op *op) --- 29 unchanged lines hidden (view full) --- 2811static u32 nfsd4_getattr_rsize(const struct svc_rqst *rqstp, 2812 const struct nfsd4_op *op) 2813{ 2814 const u32 *bmap = op->u.getattr.ga_bmval; 2815 u32 bmap0 = bmap[0], bmap1 = bmap[1], bmap2 = bmap[2]; 2816 u32 ret = 0; 2817 2818 if (bmap0 & FATTR4_WORD0_ACL) | 2790static u32 nfsd4_only_status_rsize(const struct svc_rqst *rqstp, 2791 const struct nfsd4_op *op) 2792{ 2793 return (op_encode_hdr_size) * sizeof(__be32); 2794} 2795 2796static u32 nfsd4_status_stateid_rsize(const struct svc_rqst *rqstp, 2797 const struct nfsd4_op *op) --- 29 unchanged lines hidden (view full) --- 2827static u32 nfsd4_getattr_rsize(const struct svc_rqst *rqstp, 2828 const struct nfsd4_op *op) 2829{ 2830 const u32 *bmap = op->u.getattr.ga_bmval; 2831 u32 bmap0 = bmap[0], bmap1 = bmap[1], bmap2 = bmap[2]; 2832 u32 ret = 0; 2833 2834 if (bmap0 & FATTR4_WORD0_ACL) |
2819 return svc_max_payload(rqstp); | 2835 return nfsd4_max_payload(rqstp); |
2820 if (bmap0 & FATTR4_WORD0_FS_LOCATIONS) | 2836 if (bmap0 & FATTR4_WORD0_FS_LOCATIONS) |
2821 return svc_max_payload(rqstp); | 2837 return nfsd4_max_payload(rqstp); |
2822 2823 if (bmap1 & FATTR4_WORD1_OWNER) { 2824 ret += IDMAP_NAMESZ + 4; 2825 bmap1 &= ~FATTR4_WORD1_OWNER; 2826 } 2827 if (bmap1 & FATTR4_WORD1_OWNER_GROUP) { 2828 ret += IDMAP_NAMESZ + 4; 2829 bmap1 &= ~FATTR4_WORD1_OWNER_GROUP; --- 43 unchanged lines hidden (view full) --- 2873 + op_encode_change_info_maxsz + 1 2874 + nfs4_fattr_bitmap_maxsz 2875 + op_encode_delegation_maxsz) * sizeof(__be32); 2876} 2877 2878static u32 nfsd4_read_rsize(const struct svc_rqst *rqstp, 2879 const struct nfsd4_op *op) 2880{ | 2838 2839 if (bmap1 & FATTR4_WORD1_OWNER) { 2840 ret += IDMAP_NAMESZ + 4; 2841 bmap1 &= ~FATTR4_WORD1_OWNER; 2842 } 2843 if (bmap1 & FATTR4_WORD1_OWNER_GROUP) { 2844 ret += IDMAP_NAMESZ + 4; 2845 bmap1 &= ~FATTR4_WORD1_OWNER_GROUP; --- 43 unchanged lines hidden (view full) --- 2889 + op_encode_change_info_maxsz + 1 2890 + nfs4_fattr_bitmap_maxsz 2891 + op_encode_delegation_maxsz) * sizeof(__be32); 2892} 2893 2894static u32 nfsd4_read_rsize(const struct svc_rqst *rqstp, 2895 const struct nfsd4_op *op) 2896{ |
2881 u32 maxcount = 0, rlen = 0; | 2897 u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); |
2882 | 2898 |
2883 maxcount = svc_max_payload(rqstp); 2884 rlen = min(op->u.read.rd_length, maxcount); 2885 | |
2886 return (op_encode_hdr_size + 2 + XDR_QUADLEN(rlen)) * sizeof(__be32); 2887} 2888 2889static u32 nfsd4_read_plus_rsize(const struct svc_rqst *rqstp, 2890 const struct nfsd4_op *op) 2891{ | 2899 return (op_encode_hdr_size + 2 + XDR_QUADLEN(rlen)) * sizeof(__be32); 2900} 2901 2902static u32 nfsd4_read_plus_rsize(const struct svc_rqst *rqstp, 2903 const struct nfsd4_op *op) 2904{ |
2892 u32 maxcount = svc_max_payload(rqstp); 2893 u32 rlen = min(op->u.read.rd_length, maxcount); | 2905 u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); |
2894 /* 2895 * If we detect that the file changed during hole encoding, then we 2896 * recover by encoding the remaining reply as data. This means we need 2897 * to set aside enough room to encode two data segments. 2898 */ 2899 u32 seg_len = 2 * (1 + 2 + 1); 2900 2901 return (op_encode_hdr_size + 2 + seg_len + XDR_QUADLEN(rlen)) * sizeof(__be32); 2902} 2903 2904static u32 nfsd4_readdir_rsize(const struct svc_rqst *rqstp, 2905 const struct nfsd4_op *op) 2906{ | 2906 /* 2907 * If we detect that the file changed during hole encoding, then we 2908 * recover by encoding the remaining reply as data. This means we need 2909 * to set aside enough room to encode two data segments. 2910 */ 2911 u32 seg_len = 2 * (1 + 2 + 1); 2912 2913 return (op_encode_hdr_size + 2 + seg_len + XDR_QUADLEN(rlen)) * sizeof(__be32); 2914} 2915 2916static u32 nfsd4_readdir_rsize(const struct svc_rqst *rqstp, 2917 const struct nfsd4_op *op) 2918{ |
2907 u32 maxcount = 0, rlen = 0; | 2919 u32 rlen = min(op->u.readdir.rd_maxcount, nfsd4_max_payload(rqstp)); |
2908 | 2920 |
2909 maxcount = svc_max_payload(rqstp); 2910 rlen = min(op->u.readdir.rd_maxcount, maxcount); 2911 | |
2912 return (op_encode_hdr_size + op_encode_verifier_maxsz + 2913 XDR_QUADLEN(rlen)) * sizeof(__be32); 2914} 2915 2916static u32 nfsd4_readlink_rsize(const struct svc_rqst *rqstp, 2917 const struct nfsd4_op *op) 2918{ 2919 return (op_encode_hdr_size + 1) * sizeof(__be32) + PAGE_SIZE; --- 121 unchanged lines hidden (view full) --- 3041 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) /*nl4_loc + nl4_loc_sz */) 3042 * sizeof(__be32); 3043} 3044 3045#ifdef CONFIG_NFSD_PNFS 3046static u32 nfsd4_getdeviceinfo_rsize(const struct svc_rqst *rqstp, 3047 const struct nfsd4_op *op) 3048{ | 2921 return (op_encode_hdr_size + op_encode_verifier_maxsz + 2922 XDR_QUADLEN(rlen)) * sizeof(__be32); 2923} 2924 2925static u32 nfsd4_readlink_rsize(const struct svc_rqst *rqstp, 2926 const struct nfsd4_op *op) 2927{ 2928 return (op_encode_hdr_size + 1) * sizeof(__be32) + PAGE_SIZE; --- 121 unchanged lines hidden (view full) --- 3050 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) /*nl4_loc + nl4_loc_sz */) 3051 * sizeof(__be32); 3052} 3053 3054#ifdef CONFIG_NFSD_PNFS 3055static u32 nfsd4_getdeviceinfo_rsize(const struct svc_rqst *rqstp, 3056 const struct nfsd4_op *op) 3057{ |
3049 u32 maxcount = 0, rlen = 0; | 3058 u32 rlen = min(op->u.getdeviceinfo.gd_maxcount, nfsd4_max_payload(rqstp)); |
3050 | 3059 |
3051 maxcount = svc_max_payload(rqstp); 3052 rlen = min(op->u.getdeviceinfo.gd_maxcount, maxcount); 3053 | |
3054 return (op_encode_hdr_size + 3055 1 /* gd_layout_type*/ + 3056 XDR_QUADLEN(rlen) + 3057 2 /* gd_notify_types */) * sizeof(__be32); 3058} 3059 3060/* 3061 * At this stage we don't really know what layout driver will handle the request, --- 32 unchanged lines hidden (view full) --- 3094 const struct nfsd4_op *op) 3095{ 3096 return (op_encode_hdr_size + 3) * sizeof(__be32); 3097} 3098 3099static u32 nfsd4_getxattr_rsize(const struct svc_rqst *rqstp, 3100 const struct nfsd4_op *op) 3101{ | 3060 return (op_encode_hdr_size + 3061 1 /* gd_layout_type*/ + 3062 XDR_QUADLEN(rlen) + 3063 2 /* gd_notify_types */) * sizeof(__be32); 3064} 3065 3066/* 3067 * At this stage we don't really know what layout driver will handle the request, --- 32 unchanged lines hidden (view full) --- 3100 const struct nfsd4_op *op) 3101{ 3102 return (op_encode_hdr_size + 3) * sizeof(__be32); 3103} 3104 3105static u32 nfsd4_getxattr_rsize(const struct svc_rqst *rqstp, 3106 const struct nfsd4_op *op) 3107{ |
3102 u32 maxcount, rlen; | 3108 u32 rlen = min_t(u32, XATTR_SIZE_MAX, nfsd4_max_payload(rqstp)); |
3103 | 3109 |
3104 maxcount = svc_max_payload(rqstp); 3105 rlen = min_t(u32, XATTR_SIZE_MAX, maxcount); 3106 | |
3107 return (op_encode_hdr_size + 1 + XDR_QUADLEN(rlen)) * sizeof(__be32); 3108} 3109 3110static u32 nfsd4_setxattr_rsize(const struct svc_rqst *rqstp, 3111 const struct nfsd4_op *op) 3112{ 3113 return (op_encode_hdr_size + op_encode_change_info_maxsz) 3114 * sizeof(__be32); 3115} 3116static u32 nfsd4_listxattrs_rsize(const struct svc_rqst *rqstp, 3117 const struct nfsd4_op *op) 3118{ | 3110 return (op_encode_hdr_size + 1 + XDR_QUADLEN(rlen)) * sizeof(__be32); 3111} 3112 3113static u32 nfsd4_setxattr_rsize(const struct svc_rqst *rqstp, 3114 const struct nfsd4_op *op) 3115{ 3116 return (op_encode_hdr_size + op_encode_change_info_maxsz) 3117 * sizeof(__be32); 3118} 3119static u32 nfsd4_listxattrs_rsize(const struct svc_rqst *rqstp, 3120 const struct nfsd4_op *op) 3121{ |
3119 u32 maxcount, rlen; | 3122 u32 rlen = min(op->u.listxattrs.lsxa_maxcount, nfsd4_max_payload(rqstp)); |
3120 | 3123 |
3121 maxcount = svc_max_payload(rqstp); 3122 rlen = min(op->u.listxattrs.lsxa_maxcount, maxcount); 3123 | |
3124 return (op_encode_hdr_size + 4 + XDR_QUADLEN(rlen)) * sizeof(__be32); 3125} 3126 3127static u32 nfsd4_removexattr_rsize(const struct svc_rqst *rqstp, 3128 const struct nfsd4_op *op) 3129{ 3130 return (op_encode_hdr_size + op_encode_change_info_maxsz) 3131 * sizeof(__be32); --- 516 unchanged lines hidden --- | 3124 return (op_encode_hdr_size + 4 + XDR_QUADLEN(rlen)) * sizeof(__be32); 3125} 3126 3127static u32 nfsd4_removexattr_rsize(const struct svc_rqst *rqstp, 3128 const struct nfsd4_op *op) 3129{ 3130 return (op_encode_hdr_size + op_encode_change_info_maxsz) 3131 * sizeof(__be32); --- 516 unchanged lines hidden --- |