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: d600ad1f2b ("NFS41: pop some layoutget errors to application")
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Trond Myklebust 2020-06-22 15:04:15 -04:00 коммит произвёл Anna Schumaker
Родитель 4659ed7cc8
Коммит 8b04013737
1 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -907,9 +907,8 @@ retry:
goto out_mds; goto out_mds;
/* Use a direct mapping of ds_idx to pgio mirror_idx */ /* Use a direct mapping of ds_idx to pgio mirror_idx */
if (WARN_ON_ONCE(pgio->pg_mirror_count != if (pgio->pg_mirror_count != FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg))
FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg))) goto out_eagain;
goto out_mds;
for (i = 0; i < pgio->pg_mirror_count; i++) { for (i = 0; i < pgio->pg_mirror_count; i++) {
mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i); mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i);
@ -931,7 +930,10 @@ retry:
(NFS_MOUNT_SOFT|NFS_MOUNT_SOFTERR)) (NFS_MOUNT_SOFT|NFS_MOUNT_SOFTERR))
pgio->pg_maxretrans = io_maxretrans; pgio->pg_maxretrans = io_maxretrans;
return; return;
out_eagain:
pnfs_generic_pg_cleanup(pgio);
pgio->pg_error = -EAGAIN;
return;
out_mds: out_mds:
trace_pnfs_mds_fallback_pg_init_write(pgio->pg_inode, trace_pnfs_mds_fallback_pg_init_write(pgio->pg_inode,
0, NFS4_MAX_UINT64, IOMODE_RW, 0, NFS4_MAX_UINT64, IOMODE_RW,
@ -941,6 +943,7 @@ out_mds:
pgio->pg_lseg = NULL; pgio->pg_lseg = NULL;
pgio->pg_maxretrans = 0; pgio->pg_maxretrans = 0;
nfs_pageio_reset_write_mds(pgio); nfs_pageio_reset_write_mds(pgio);
pgio->pg_error = -EAGAIN;
} }
static unsigned int static unsigned int