]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.69/nfsv4-fix-locking-in-pnfs_generic_recover_commit_reqs.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / nfsv4-fix-locking-in-pnfs_generic_recover_commit_reqs.patch
1 From d0fbb1d8a194c0ec0180c1d073ad709e45503a43 Mon Sep 17 00:00:00 2001
2 From: Trond Myklebust <trondmy@gmail.com>
3 Date: Tue, 14 Aug 2018 17:25:37 -0400
4 Subject: NFSv4: Fix locking in pnfs_generic_recover_commit_reqs
5
6 From: Trond Myklebust <trondmy@gmail.com>
7
8 commit d0fbb1d8a194c0ec0180c1d073ad709e45503a43 upstream.
9
10 The use of the inode->i_lock was converted to a mutex, but we forgot
11 to remove the old inode unlock/lock() pair that allowed the layout
12 segment to be put inside the loop.
13
14 Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
15 Fixes: e824f99adaaf1 ("NFSv4: Use a mutex to protect the per-inode commit...")
16 Cc: stable@vger.kernel.org # v4.14+
17 Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
18 Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21 ---
22 fs/nfs/pnfs_nfs.c | 16 +++++++---------
23 1 file changed, 7 insertions(+), 9 deletions(-)
24
25 --- a/fs/nfs/pnfs_nfs.c
26 +++ b/fs/nfs/pnfs_nfs.c
27 @@ -61,7 +61,7 @@ EXPORT_SYMBOL_GPL(pnfs_generic_commit_re
28
29 /* The generic layer is about to remove the req from the commit list.
30 * If this will make the bucket empty, it will need to put the lseg reference.
31 - * Note this must be called holding i_lock
32 + * Note this must be called holding nfsi->commit_mutex
33 */
34 void
35 pnfs_generic_clear_request_commit(struct nfs_page *req,
36 @@ -149,9 +149,7 @@ restart:
37 if (list_empty(&b->written)) {
38 freeme = b->wlseg;
39 b->wlseg = NULL;
40 - spin_unlock(&cinfo->inode->i_lock);
41 pnfs_put_lseg(freeme);
42 - spin_lock(&cinfo->inode->i_lock);
43 goto restart;
44 }
45 }
46 @@ -167,7 +165,7 @@ static void pnfs_generic_retry_commit(st
47 LIST_HEAD(pages);
48 int i;
49
50 - spin_lock(&cinfo->inode->i_lock);
51 + mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
52 for (i = idx; i < fl_cinfo->nbuckets; i++) {
53 bucket = &fl_cinfo->buckets[i];
54 if (list_empty(&bucket->committing))
55 @@ -177,12 +175,12 @@ static void pnfs_generic_retry_commit(st
56 list_for_each(pos, &bucket->committing)
57 cinfo->ds->ncommitting--;
58 list_splice_init(&bucket->committing, &pages);
59 - spin_unlock(&cinfo->inode->i_lock);
60 + mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
61 nfs_retry_commit(&pages, freeme, cinfo, i);
62 pnfs_put_lseg(freeme);
63 - spin_lock(&cinfo->inode->i_lock);
64 + mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
65 }
66 - spin_unlock(&cinfo->inode->i_lock);
67 + mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
68 }
69
70 static unsigned int
71 @@ -222,13 +220,13 @@ void pnfs_fetch_commit_bucket_list(struc
72 struct list_head *pos;
73
74 bucket = &cinfo->ds->buckets[data->ds_commit_index];
75 - spin_lock(&cinfo->inode->i_lock);
76 + mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
77 list_for_each(pos, &bucket->committing)
78 cinfo->ds->ncommitting--;
79 list_splice_init(&bucket->committing, pages);
80 data->lseg = bucket->clseg;
81 bucket->clseg = NULL;
82 - spin_unlock(&cinfo->inode->i_lock);
83 + mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
84
85 }
86