Skip to content

Commit 8a4c392

Browse files
jtlaytonJ. Bruce Fields
authored andcommitted
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>
1 parent 8858481 commit 8a4c392

5 files changed

Lines changed: 22 additions & 24 deletions

File tree

‎fs/nfsd/export.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
706706
new->ex_fslocs.locations = NULL;
707707
new->ex_fslocs.locations_count = 0;
708708
new->ex_fslocs.migrated = 0;
709-
new->ex_layout_type = 0;
709+
new->ex_layout_types = 0;
710710
new->ex_uuid = NULL;
711711
new->cd = item->cd;
712712
}
@@ -731,7 +731,7 @@ static void export_update(struct cache_head *cnew, struct cache_head *citem)
731731
item->ex_fslocs.locations_count = 0;
732732
new->ex_fslocs.migrated = item->ex_fslocs.migrated;
733733
item->ex_fslocs.migrated = 0;
734-
new->ex_layout_type = item->ex_layout_type;
734+
new->ex_layout_types = item->ex_layout_types;
735735
new->ex_nflavors = item->ex_nflavors;
736736
for (i = 0; i < MAX_SECINFO_LIST; i++) {
737737
new->ex_flavors[i] = item->ex_flavors[i];

‎fs/nfsd/export.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct svc_export {
5757
struct nfsd4_fs_locations ex_fslocs;
5858
uint32_t ex_nflavors;
5959
struct exp_flavor_info ex_flavors[MAX_SECINFO_LIST];
60-
enum pnfs_layouttype ex_layout_type;
60+
u32 ex_layout_types;
6161
struct nfsd4_deviceid_map *ex_devid_map;
6262
struct cache_detail *cd;
6363
};

‎fs/nfsd/nfs4layouts.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,21 @@ void nfsd4_setup_layout_type(struct svc_export *exp)
139139
* otherwise advertise the block layout.
140140
*/
141141
#ifdef CONFIG_NFSD_FLEXFILELAYOUT
142-
exp->ex_layout_type = LAYOUT_FLEX_FILES;
142+
exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
143143
#endif
144144
#ifdef CONFIG_NFSD_BLOCKLAYOUT
145145
/* overwrite flex file layout selection if needed */
146146
if (sb->s_export_op->get_uuid &&
147147
sb->s_export_op->map_blocks &&
148148
sb->s_export_op->commit_blocks)
149-
exp->ex_layout_type = LAYOUT_BLOCK_VOLUME;
149+
exp->ex_layout_types |= 1 << LAYOUT_BLOCK_VOLUME;
150150
#endif
151151
#ifdef CONFIG_NFSD_SCSILAYOUT
152152
/* overwrite block layout selection if needed */
153153
if (sb->s_export_op->map_blocks &&
154154
sb->s_export_op->commit_blocks &&
155155
sb->s_bdev && sb->s_bdev->bd_disk->fops->pr_ops)
156-
exp->ex_layout_type = LAYOUT_SCSI;
156+
exp->ex_layout_types |= 1 << LAYOUT_SCSI;
157157
#endif
158158
}
159159

‎fs/nfsd/nfs4proc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,12 +1219,12 @@ nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
12191219
static const struct nfsd4_layout_ops *
12201220
nfsd4_layout_verify(struct svc_export *exp, unsigned int layout_type)
12211221
{
1222-
if (!exp->ex_layout_type) {
1222+
if (!exp->ex_layout_types) {
12231223
dprintk("%s: export does not support pNFS\n", __func__);
12241224
return NULL;
12251225
}
12261226

1227-
if (exp->ex_layout_type != layout_type) {
1227+
if (!(exp->ex_layout_types & (1 << layout_type))) {
12281228
dprintk("%s: layout type %d not supported\n",
12291229
__func__, layout_type);
12301230
return NULL;

‎fs/nfsd/nfs4xdr.c‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,22 +2162,20 @@ nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp,
21622162
}
21632163

21642164
static inline __be32
2165-
nfsd4_encode_layout_type(struct xdr_stream *xdr, enum pnfs_layouttype layout_type)
2165+
nfsd4_encode_layout_types(struct xdr_stream *xdr, u32 layout_types)
21662166
{
2167-
__be32 *p;
2167+
__be32 *p;
2168+
unsigned long i = hweight_long(layout_types);
21682169

2169-
if (layout_type) {
2170-
p = xdr_reserve_space(xdr, 8);
2171-
if (!p)
2172-
return nfserr_resource;
2173-
*p++ = cpu_to_be32(1);
2174-
*p++ = cpu_to_be32(layout_type);
2175-
} else {
2176-
p = xdr_reserve_space(xdr, 4);
2177-
if (!p)
2178-
return nfserr_resource;
2179-
*p++ = cpu_to_be32(0);
2180-
}
2170+
p = xdr_reserve_space(xdr, 4 + 4 * i);
2171+
if (!p)
2172+
return nfserr_resource;
2173+
2174+
*p++ = cpu_to_be32(i);
2175+
2176+
for (i = LAYOUT_NFSV4_1_FILES; i < LAYOUT_TYPE_MAX; ++i)
2177+
if (layout_types & (1 << i))
2178+
*p++ = cpu_to_be32(i);
21812179

21822180
return 0;
21832181
}
@@ -2752,13 +2750,13 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
27522750
}
27532751
#ifdef CONFIG_NFSD_PNFS
27542752
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);
27562754
if (status)
27572755
goto out;
27582756
}
27592757

27602758
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);
27622760
if (status)
27632761
goto out;
27642762
}

0 commit comments

Comments
 (0)