1 From ee284e35d8c71bf5d4d807eaff6f67a17134b359 Mon Sep 17 00:00:00 2001
2 From: Trond Myklebust <trond.myklebust@primarydata.com>
3 Date: Fri, 18 Nov 2016 15:21:30 -0500
4 Subject: pNFS: Fix race in pnfs_wait_on_layoutreturn
6 From: Trond Myklebust <trond.myklebust@primarydata.com>
8 commit ee284e35d8c71bf5d4d807eaff6f67a17134b359 upstream.
10 We must put the task to sleep while holding the inode->i_lock in order
11 to ensure atomicity with the test for NFS_LAYOUT_RETURN.
13 Fixes: 500d701f336b ("NFS41: make close wait for layoutreturn")
14 Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 fs/nfs/pnfs.c | 8 +++-----
19 1 file changed, 3 insertions(+), 5 deletions(-)
23 @@ -1185,13 +1185,11 @@ bool pnfs_wait_on_layoutreturn(struct in
25 spin_lock(&ino->i_lock);
27 - if (lo && test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
28 + if (lo && test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) {
29 + rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);
32 spin_unlock(&ino->i_lock);
35 - rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);