aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@poochiereds.net>2016-07-10 15:55:58 -0400
committerJ. Bruce Fields <bfields@redhat.com>2016-07-15 15:31:32 -0400
commit8a4c3926889e7bf226e9f0254e7eface1f85f312 (patch)
tree8863285961516c82401234807820d8ad602bdcdd /fs/nfsd/nfs4xdr.c
parent885848186fbc2d1d8fb6d2fdc2156638ae289a46 (diff)
nfsd: allow nfsd to advertise multiple layout types
If the underlying filesystem supports multiple layout types, then there is little reason not to advertise that fact to clients and let them choose what type to use. Turn the ex_layout_type field into a bitfield. For each supported layout type, we set a bit in that field. When the client requests a layout, ensure that the bit for that layout type is set. When the client requests attributes, send back a list of supported types. Signed-off-by: Jeff Layton <jlayton@poochiereds.net> Reviewed-by: Weston Andros Adamson <dros@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 84ef94794496..0aa0236a1429 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2162,22 +2162,20 @@ nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp,
2162} 2162}
2163 2163
2164static inline __be32 2164static inline __be32
2165nfsd4_encode_layout_type(struct xdr_stream *xdr, enum pnfs_layouttype layout_type) 2165nfsd4_encode_layout_types(struct xdr_stream *xdr, u32 layout_types)
2166{ 2166{
2167 __be32 *p; 2167 __be32 *p;
2168 unsigned long i = hweight_long(layout_types);
2168 2169
2169 if (layout_type) { 2170 p = xdr_reserve_space(xdr, 4 + 4 * i);
2170 p = xdr_reserve_space(xdr, 8); 2171 if (!p)
2171 if (!p) 2172 return nfserr_resource;
2172 return nfserr_resource; 2173
2173 *p++ = cpu_to_be32(1); 2174 *p++ = cpu_to_be32(i);
2174 *p++ = cpu_to_be32(layout_type); 2175
2175 } else { 2176 for (i = LAYOUT_NFSV4_1_FILES; i < LAYOUT_TYPE_MAX; ++i)
2176 p = xdr_reserve_space(xdr, 4); 2177 if (layout_types & (1 << i))
2177 if (!p) 2178 *p++ = cpu_to_be32(i);
2178 return nfserr_resource;
2179 *p++ = cpu_to_be32(0);
2180 }
2181 2179
2182 return 0; 2180 return 0;
2183} 2181}
@@ -2752,13 +2750,13 @@ out_acl:
2752 } 2750 }
2753#ifdef CONFIG_NFSD_PNFS 2751#ifdef CONFIG_NFSD_PNFS
2754 if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) { 2752 if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) {
2755 status = nfsd4_encode_layout_type(xdr, exp->ex_layout_type); 2753 status = nfsd4_encode_layout_types(xdr, exp->ex_layout_types);
2756 if (status) 2754 if (status)
2757 goto out; 2755 goto out;
2758 } 2756 }
2759 2757
2760 if (bmval2 & FATTR4_WORD2_LAYOUT_TYPES) { 2758 if (bmval2 & FATTR4_WORD2_LAYOUT_TYPES) {
2761 status = nfsd4_encode_layout_type(xdr, exp->ex_layout_type); 2759 status = nfsd4_encode_layout_types(xdr, exp->ex_layout_types);
2762 if (status) 2760 if (status)
2763 goto out; 2761 goto out;
2764 } 2762 }