aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorKinglong Mee <kinglongmee@gmail.com>2015-07-30 09:52:44 -0400
committerJ. Bruce Fields <bfields@redhat.com>2015-08-31 16:12:39 -0400
commit6896f15aabde505b35888039af93d1d182a0108a (patch)
treeb851c03b11766c3eb378d212eb52f1db74a34add /fs/nfsd
parent0a2050d744037158de773be5c6f1fc468a551bae (diff)
nfsd: Fix an FS_LAYOUT_TYPES/LAYOUT_TYPES encode bug
Currently we'll respond correctly to a request for either FS_LAYOUT_TYPES or LAYOUT_TYPES, but not to a request for both attributes simultaneously. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4xdr.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 1aa0dc38ed58..ea05dfb13249 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2140,6 +2140,27 @@ nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp,
2140 return nfsd4_encode_user(xdr, rqstp, ace->who_uid); 2140 return nfsd4_encode_user(xdr, rqstp, ace->who_uid);
2141} 2141}
2142 2142
2143static inline __be32
2144nfsd4_encode_layout_type(struct xdr_stream *xdr, enum pnfs_layouttype layout_type)
2145{
2146 __be32 *p;
2147
2148 if (layout_type) {
2149 p = xdr_reserve_space(xdr, 8);
2150 if (!p)
2151 return nfserr_resource;
2152 *p++ = cpu_to_be32(1);
2153 *p++ = cpu_to_be32(layout_type);
2154 } else {
2155 p = xdr_reserve_space(xdr, 4);
2156 if (!p)
2157 return nfserr_resource;
2158 *p++ = cpu_to_be32(0);
2159 }
2160
2161 return 0;
2162}
2163
2143#define WORD0_ABSENT_FS_ATTRS (FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_FSID | \ 2164#define WORD0_ABSENT_FS_ATTRS (FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_FSID | \
2144 FATTR4_WORD0_RDATTR_ERROR) 2165 FATTR4_WORD0_RDATTR_ERROR)
2145#define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID 2166#define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID
@@ -2695,20 +2716,16 @@ out_acl:
2695 p = xdr_encode_hyper(p, ino); 2716 p = xdr_encode_hyper(p, ino);
2696 } 2717 }
2697#ifdef CONFIG_NFSD_PNFS 2718#ifdef CONFIG_NFSD_PNFS
2698 if ((bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) || 2719 if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) {
2699 (bmval2 & FATTR4_WORD2_LAYOUT_TYPES)) { 2720 status = nfsd4_encode_layout_type(xdr, exp->ex_layout_type);
2700 if (exp->ex_layout_type) { 2721 if (status)
2701 p = xdr_reserve_space(xdr, 8); 2722 goto out;
2702 if (!p) 2723 }
2703 goto out_resource; 2724
2704 *p++ = cpu_to_be32(1); 2725 if (bmval2 & FATTR4_WORD2_LAYOUT_TYPES) {
2705 *p++ = cpu_to_be32(exp->ex_layout_type); 2726 status = nfsd4_encode_layout_type(xdr, exp->ex_layout_type);
2706 } else { 2727 if (status)
2707 p = xdr_reserve_space(xdr, 4); 2728 goto out;
2708 if (!p)
2709 goto out_resource;
2710 *p++ = cpu_to_be32(0);
2711 }
2712 } 2729 }
2713 2730
2714 if (bmval2 & FATTR4_WORD2_LAYOUT_BLKSIZE) { 2731 if (bmval2 & FATTR4_WORD2_LAYOUT_BLKSIZE) {