pNFS: Fix a deadlock between read resends and layoutreturn

We must not call nfs_pageio_init_read() on a new nfs_pageio_descriptor
while holding a reference to a layout segment, as that can deadlock
pnfs_update_layout().

Fixes: d67ae825a5 ("pnfs/flexfiles: Add the FlexFile Layout Driver")
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: stable@vger.kernel.org # v4.0+
This commit is contained in:
Trond Myklebust
2016-11-27 15:12:39 -05:00
parent 9a837856cf
commit 54e4a0dfa2
2 changed files with 8 additions and 0 deletions

View File

@ -2286,6 +2286,10 @@ void pnfs_read_resend_pnfs(struct nfs_pgio_header *hdr)
struct nfs_pageio_descriptor pgio;
if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) {
/* Prevent deadlocks with layoutreturn! */
pnfs_put_lseg(hdr->lseg);
hdr->lseg = NULL;
nfs_pageio_init_read(&pgio, hdr->inode, false,
hdr->completion_ops);
hdr->task.tk_status = nfs_pageio_resend(&pgio, hdr);