]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tcmu: release blocks for partially setup cmds
authorMike Christie <mchristi@redhat.com>
Tue, 28 Nov 2017 18:40:33 +0000 (12:40 -0600)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 12 Jan 2018 23:07:14 +0000 (15:07 -0800)
If we cannot setup a cmd because we run out of ring space
or global pages release the blocks before sleeping. This
prevents a deadlock where dev0 has waiting_blocks set and
needs N blocks, but dev1 to devX have each allocated N / X blocks
and also hit the global block limit so they went to sleep.

find_free_blocks is not able to take the sleeping dev's
blocks becaause their waiting_blocks is set and even
if it was not the block returned by find_last_bit could equal
dbi_max. The latter will probably never happen because
DATA_BLOCK_BITS is so high but in the next patches
DATA_BLOCK_BITS and TCMU_GLOBAL_MAX_BLOCKS will be settable so
it might be lower and could happen.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_user.c

index 43583a792439ed8544e60bd689696c3e47986ce2..c7541f090453d7327908eeafdcccdd8bac949046 100644 (file)
@@ -807,6 +807,13 @@ tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
                int ret;
                DEFINE_WAIT(__wait);
 
+               /*
+                * Don't leave commands partially setup because the unmap
+                * thread might need the blocks to make forward progress.
+                */
+               tcmu_cmd_free_data(tcmu_cmd, tcmu_cmd->dbi_cur);
+               tcmu_cmd_reset_dbi_cur(tcmu_cmd);
+
                prepare_to_wait(&udev->wait_cmdr, &__wait, TASK_INTERRUPTIBLE);
 
                pr_debug("sleeping for ring space\n");