]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.97/cifs-fix-possible-hang-during-async-mtu-reads-and-writes.patch
Linux 4.14.97
[thirdparty/kernel/stable-queue.git] / releases / 4.14.97 / cifs-fix-possible-hang-during-async-mtu-reads-and-writes.patch
1 From acc58d0bab55a50e02c25f00bd6a210ee121595f Mon Sep 17 00:00:00 2001
2 From: Pavel Shilovsky <pshilov@microsoft.com>
3 Date: Thu, 17 Jan 2019 08:21:24 -0800
4 Subject: CIFS: Fix possible hang during async MTU reads and writes
5
6 From: Pavel Shilovsky <pshilov@microsoft.com>
7
8 commit acc58d0bab55a50e02c25f00bd6a210ee121595f upstream.
9
10 When doing MTU i/o we need to leave some credits for
11 possible reopen requests and other operations happening
12 in parallel. Currently we leave 1 credit which is not
13 enough even for reopen only: we need at least 2 credits
14 if durable handle reconnect fails. Also there may be
15 other operations at the same time including compounding
16 ones which require 3 credits at a time each. Fix this
17 by leaving 8 credits which is big enough to cover most
18 scenarios.
19
20 Was able to reproduce this when server was configured
21 to give out fewer credits than usual.
22
23 The proper fix would be to reconnect a file handle first
24 and then obtain credits for an MTU request but this leads
25 to bigger code changes and should happen in other patches.
26
27 Cc: <stable@vger.kernel.org>
28 Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
29 Signed-off-by: Steve French <stfrench@microsoft.com>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31
32 ---
33 fs/cifs/smb2ops.c | 6 +++---
34 1 file changed, 3 insertions(+), 3 deletions(-)
35
36 --- a/fs/cifs/smb2ops.c
37 +++ b/fs/cifs/smb2ops.c
38 @@ -153,14 +153,14 @@ smb2_wait_mtu_credits(struct TCP_Server_
39
40 scredits = server->credits;
41 /* can deadlock with reopen */
42 - if (scredits == 1) {
43 + if (scredits <= 8) {
44 *num = SMB2_MAX_BUFFER_SIZE;
45 *credits = 0;
46 break;
47 }
48
49 - /* leave one credit for a possible reopen */
50 - scredits--;
51 + /* leave some credits for reopen and other ops */
52 + scredits -= 8;
53 *num = min_t(unsigned int, size,
54 scredits * SMB2_MAX_BUFFER_SIZE);
55