]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.44/pnfs-fix-race-in-pnfs_wait_on_layoutreturn.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.44 / pnfs-fix-race-in-pnfs_wait_on_layoutreturn.patch
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
5
6 From: Trond Myklebust <trond.myklebust@primarydata.com>
7
8 commit ee284e35d8c71bf5d4d807eaff6f67a17134b359 upstream.
9
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.
12
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>
16
17 ---
18 fs/nfs/pnfs.c | 8 +++-----
19 1 file changed, 3 insertions(+), 5 deletions(-)
20
21 --- a/fs/nfs/pnfs.c
22 +++ b/fs/nfs/pnfs.c
23 @@ -1185,13 +1185,11 @@ bool pnfs_wait_on_layoutreturn(struct in
24 * i_lock */
25 spin_lock(&ino->i_lock);
26 lo = nfsi->layout;
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);
30 sleep = true;
31 + }
32 spin_unlock(&ino->i_lock);
33 -
34 - if (sleep)
35 - rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);
36 -
37 return sleep;
38 }
39