Skip to content

Commit 8b04013

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
pNFS/flexfiles: Fix list corruption if the mirror count changes
If the mirror count changes in the new layout we pick up inside ff_layout_pg_init_write(), then we can end up adding the request to the wrong mirror and corrupting the mirror->pg_list. Fixes: d600ad1 ("NFS41: pop some layoutget errors to application") Cc: [email protected] Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 4659ed7 commit 8b04013

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,8 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
907907
goto out_mds;
908908

909909
/* Use a direct mapping of ds_idx to pgio mirror_idx */
910-
if (WARN_ON_ONCE(pgio->pg_mirror_count !=
911-
FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg)))
912-
goto out_mds;
910+
if (pgio->pg_mirror_count != FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg))
911+
goto out_eagain;
913912

914913
for (i = 0; i < pgio->pg_mirror_count; i++) {
915914
mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i);
@@ -931,7 +930,10 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
931930
(NFS_MOUNT_SOFT|NFS_MOUNT_SOFTERR))
932931
pgio->pg_maxretrans = io_maxretrans;
933932
return;
934-
933+
out_eagain:
934+
pnfs_generic_pg_cleanup(pgio);
935+
pgio->pg_error = -EAGAIN;
936+
return;
935937
out_mds:
936938
trace_pnfs_mds_fallback_pg_init_write(pgio->pg_inode,
937939
0, NFS4_MAX_UINT64, IOMODE_RW,
@@ -941,6 +943,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
941943
pgio->pg_lseg = NULL;
942944
pgio->pg_maxretrans = 0;
943945
nfs_pageio_reset_write_mds(pgio);
946+
pgio->pg_error = -EAGAIN;
944947
}
945948

946949
static unsigned int

0 commit comments

Comments
 (0)