]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - 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
CommitLineData
72fc6108
GKH
1From foo@baz Mon Apr 9 10:16:32 CEST 2018
2From: Mike Christie <mchristi@redhat.com>
3Date: Tue, 28 Nov 2017 12:40:33 -0600
4Subject: tcmu: release blocks for partially setup cmds
5
6From: Mike Christie <mchristi@redhat.com>
7
8
9[ Upstream commit 810b8153c4243d2012a6ec002ddd3bbc9a9ae8c2 ]
10
11If we cannot setup a cmd because we run out of ring space
12or global pages release the blocks before sleeping. This
13prevents a deadlock where dev0 has waiting_blocks set and
14needs N blocks, but dev1 to devX have each allocated N / X blocks
15and also hit the global block limit so they went to sleep.
16
17find_free_blocks is not able to take the sleeping dev's
18blocks becaause their waiting_blocks is set and even
19if it was not the block returned by find_last_bit could equal
20dbi_max. The latter will probably never happen because
21DATA_BLOCK_BITS is so high but in the next patches
22DATA_BLOCK_BITS and TCMU_GLOBAL_MAX_BLOCKS will be settable so
23it might be lower and could happen.
24
25Signed-off-by: Mike Christie <mchristi@redhat.com>
26Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
27Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
28Signed-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");