diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2016-11-27 15:12:39 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-09 02:32:25 -0500 |
commit | ba15defe1807ff546ab4d14beb2f9602789c0170 (patch) | |
tree | 20288e15fc4b004dbc1a116fe2f1ebc70923be13 /fs | |
parent | e523ce8c99f9bbd530fda7d46c35409fee88a50f (diff) |
pNFS: Fix a deadlock between read resends and layoutreturn
commit 54e4a0dfa25d9365c4e80a639e80d9213eb6edbe upstream.
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: d67ae825a59d6 ("pnfs/flexfiles: Add the FlexFile Layout Driver")
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/flexfilelayout/flexfilelayout.c | 4 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 98ace127bf86..a5c38889e7ae 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
@@ -28,6 +28,9 @@ | |||
28 | 28 | ||
29 | static struct group_info *ff_zero_group; | 29 | static struct group_info *ff_zero_group; |
30 | 30 | ||
31 | static void ff_layout_read_record_layoutstats_done(struct rpc_task *task, | ||
32 | struct nfs_pgio_header *hdr); | ||
33 | |||
31 | static struct pnfs_layout_hdr * | 34 | static struct pnfs_layout_hdr * |
32 | ff_layout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags) | 35 | ff_layout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags) |
33 | { | 36 | { |
@@ -1293,6 +1296,7 @@ static int ff_layout_read_done_cb(struct rpc_task *task, | |||
1293 | hdr->pgio_mirror_idx + 1, | 1296 | hdr->pgio_mirror_idx + 1, |
1294 | &hdr->pgio_mirror_idx)) | 1297 | &hdr->pgio_mirror_idx)) |
1295 | goto out_eagain; | 1298 | goto out_eagain; |
1299 | ff_layout_read_record_layoutstats_done(task, hdr); | ||
1296 | pnfs_read_resend_pnfs(hdr); | 1300 | pnfs_read_resend_pnfs(hdr); |
1297 | return task->tk_status; | 1301 | return task->tk_status; |
1298 | case -NFS4ERR_RESET_TO_MDS: | 1302 | case -NFS4ERR_RESET_TO_MDS: |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index a106f709c1a7..31b107e196fd 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -2293,6 +2293,10 @@ void pnfs_read_resend_pnfs(struct nfs_pgio_header *hdr) | |||
2293 | struct nfs_pageio_descriptor pgio; | 2293 | struct nfs_pageio_descriptor pgio; |
2294 | 2294 | ||
2295 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { | 2295 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
2296 | /* Prevent deadlocks with layoutreturn! */ | ||
2297 | pnfs_put_lseg(hdr->lseg); | ||
2298 | hdr->lseg = NULL; | ||
2299 | |||
2296 | nfs_pageio_init_read(&pgio, hdr->inode, false, | 2300 | nfs_pageio_init_read(&pgio, hdr->inode, false, |
2297 | hdr->completion_ops); | 2301 | hdr->completion_ops); |
2298 | hdr->task.tk_status = nfs_pageio_resend(&pgio, hdr); | 2302 | hdr->task.tk_status = nfs_pageio_resend(&pgio, hdr); |