]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.15.17/tcmu-release-blocks-for-partially-setup-cmds.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.15.17 / tcmu-release-blocks-for-partially-setup-cmds.patch
1 From foo@baz Mon Apr 9 10:16:32 CEST 2018
2 From: Mike Christie <mchristi@redhat.com>
3 Date: Tue, 28 Nov 2017 12:40:33 -0600
4 Subject: tcmu: release blocks for partially setup cmds
5
6 From: Mike Christie <mchristi@redhat.com>
7
8
9 [ Upstream commit 810b8153c4243d2012a6ec002ddd3bbc9a9ae8c2 ]
10
11 If we cannot setup a cmd because we run out of ring space
12 or global pages release the blocks before sleeping. This
13 prevents a deadlock where dev0 has waiting_blocks set and
14 needs N blocks, but dev1 to devX have each allocated N / X blocks
15 and also hit the global block limit so they went to sleep.
16
17 find_free_blocks is not able to take the sleeping dev's
18 blocks becaause their waiting_blocks is set and even
19 if it was not the block returned by find_last_bit could equal
20 dbi_max. The latter will probably never happen because
21 DATA_BLOCK_BITS is so high but in the next patches
22 DATA_BLOCK_BITS and TCMU_GLOBAL_MAX_BLOCKS will be settable so
23 it might be lower and could happen.
24
25 Signed-off-by: Mike Christie <mchristi@redhat.com>
26 Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
27 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29 ---
30 drivers/target/target_core_user.c | 7 +++++++
31 1 file changed, 7 insertions(+)
32
33 --- a/drivers/target/target_core_user.c
34 +++ b/drivers/target/target_core_user.c
35 @@ -805,6 +805,13 @@ tcmu_queue_cmd_ring(struct tcmu_cmd *tcm
36 int ret;
37 DEFINE_WAIT(__wait);
38
39 + /*
40 + * Don't leave commands partially setup because the unmap
41 + * thread might need the blocks to make forward progress.
42 + */
43 + tcmu_cmd_free_data(tcmu_cmd, tcmu_cmd->dbi_cur);
44 + tcmu_cmd_reset_dbi_cur(tcmu_cmd);
45 +
46 prepare_to_wait(&udev->wait_cmdr, &__wait, TASK_INTERRUPTIBLE);
47
48 pr_debug("sleeping for ring space\n");