Skip to content

Commit

Permalink
block/iscsi: fix deadlock on scsi check condition
Browse files Browse the repository at this point in the history
the retry logic was broken because the complete status
of the task structure was not reset. this resulted in
an infinite loop retrying the command over and over.

CC: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
plieven authored and bonzini committed Feb 22, 2014
1 parent 7ef8cf9 commit 837c390
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion block/iscsi.c
Expand Up @@ -145,12 +145,13 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,

if (iTask->retries-- > 0 && status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_UNIT_ATTENTION) {
error_report("iSCSI CheckCondition: %s", iscsi_get_error(iscsi));
iTask->do_retry = 1;
goto out;
}

if (status != SCSI_STATUS_GOOD) {
error_report("iSCSI: Failure. %s", iscsi_get_error(iscsi));
error_report("iSCSI Failure: %s", iscsi_get_error(iscsi));
}

out:
Expand Down Expand Up @@ -325,6 +326,7 @@ static int coroutine_fn iscsi_co_writev(BlockDriverState *bs,
}

if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}

Expand Down Expand Up @@ -399,6 +401,7 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState *bs,
}

if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}

Expand Down Expand Up @@ -433,6 +436,7 @@ static int coroutine_fn iscsi_co_flush(BlockDriverState *bs)
}

if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}

Expand Down Expand Up @@ -683,6 +687,7 @@ static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs,
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
iTask.complete = 0;
goto retry;
}

Expand Down Expand Up @@ -767,6 +772,7 @@ coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t sector_num,
}

if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}

Expand Down Expand Up @@ -836,6 +842,7 @@ coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num,
}

if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}

Expand Down

0 comments on commit 837c390

Please sign in to comment.