|
|
ae23c9 |
From 0729a3f3d2313e3429c27004ba91bce8644e4765 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
Date: Fri, 29 Jun 2018 06:11:47 +0200
|
|
|
ae23c9 |
Subject: [PATCH 173/268] iscsi: Create and use iscsi_co_wait_for_task
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180629061153.12687-8-famz@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 81160
|
|
|
ae23c9 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH v2 07/13] iscsi: Create and use iscsi_co_wait_for_task
|
|
|
ae23c9 |
Bugzilla: 1482537
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
This loop is repeated a growing number times. Make a helper.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
Message-id: 20180601092648.24614-8-famz@redhat.com
|
|
|
ae23c9 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 66e75c03b2247bda6dcaa883b700291bc0f7f0ef)
|
|
|
ae23c9 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block/iscsi.c | 54 +++++++++++++++++-------------------------------------
|
|
|
ae23c9 |
1 file changed, 17 insertions(+), 37 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block/iscsi.c b/block/iscsi.c
|
|
|
ae23c9 |
index a1a0044..338f3dd 100644
|
|
|
ae23c9 |
--- a/block/iscsi.c
|
|
|
ae23c9 |
+++ b/block/iscsi.c
|
|
|
ae23c9 |
@@ -557,6 +557,17 @@ static inline bool iscsi_allocmap_is_valid(IscsiLun *iscsilun,
|
|
|
ae23c9 |
offset / iscsilun->cluster_size) == size);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+static void coroutine_fn iscsi_co_wait_for_task(IscsiTask *iTask,
|
|
|
ae23c9 |
+ IscsiLun *iscsilun)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ while (!iTask->complete) {
|
|
|
ae23c9 |
+ iscsi_set_events(iscsilun);
|
|
|
ae23c9 |
+ qemu_mutex_unlock(&iscsilun->mutex);
|
|
|
ae23c9 |
+ qemu_coroutine_yield();
|
|
|
ae23c9 |
+ qemu_mutex_lock(&iscsilun->mutex);
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
static int coroutine_fn
|
|
|
ae23c9 |
iscsi_co_writev_flags(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|
|
ae23c9 |
QEMUIOVector *iov, int flags)
|
|
|
ae23c9 |
@@ -618,12 +629,7 @@ retry:
|
|
|
ae23c9 |
scsi_task_set_iov_out(iTask.task, (struct scsi_iovec *) iov->iov,
|
|
|
ae23c9 |
iov->niov);
|
|
|
ae23c9 |
#endif
|
|
|
ae23c9 |
- while (!iTask.complete) {
|
|
|
ae23c9 |
- iscsi_set_events(iscsilun);
|
|
|
ae23c9 |
- qemu_mutex_unlock(&iscsilun->mutex);
|
|
|
ae23c9 |
- qemu_coroutine_yield();
|
|
|
ae23c9 |
- qemu_mutex_lock(&iscsilun->mutex);
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
+ iscsi_co_wait_for_task(&iTask, iscsilun);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (iTask.task != NULL) {
|
|
|
ae23c9 |
scsi_free_scsi_task(iTask.task);
|
|
|
ae23c9 |
@@ -694,13 +700,7 @@ retry:
|
|
|
ae23c9 |
ret = -ENOMEM;
|
|
|
ae23c9 |
goto out_unlock;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
- while (!iTask.complete) {
|
|
|
ae23c9 |
- iscsi_set_events(iscsilun);
|
|
|
ae23c9 |
- qemu_mutex_unlock(&iscsilun->mutex);
|
|
|
ae23c9 |
- qemu_coroutine_yield();
|
|
|
ae23c9 |
- qemu_mutex_lock(&iscsilun->mutex);
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
+ iscsi_co_wait_for_task(&iTask, iscsilun);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (iTask.do_retry) {
|
|
|
ae23c9 |
if (iTask.task != NULL) {
|
|
|
ae23c9 |
@@ -864,13 +864,8 @@ retry:
|
|
|
ae23c9 |
#if LIBISCSI_API_VERSION < (20160603)
|
|
|
ae23c9 |
scsi_task_set_iov_in(iTask.task, (struct scsi_iovec *) iov->iov, iov->niov);
|
|
|
ae23c9 |
#endif
|
|
|
ae23c9 |
- while (!iTask.complete) {
|
|
|
ae23c9 |
- iscsi_set_events(iscsilun);
|
|
|
ae23c9 |
- qemu_mutex_unlock(&iscsilun->mutex);
|
|
|
ae23c9 |
- qemu_coroutine_yield();
|
|
|
ae23c9 |
- qemu_mutex_lock(&iscsilun->mutex);
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ iscsi_co_wait_for_task(&iTask, iscsilun);
|
|
|
ae23c9 |
if (iTask.task != NULL) {
|
|
|
ae23c9 |
scsi_free_scsi_task(iTask.task);
|
|
|
ae23c9 |
iTask.task = NULL;
|
|
|
ae23c9 |
@@ -907,12 +902,7 @@ retry:
|
|
|
ae23c9 |
return -ENOMEM;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- while (!iTask.complete) {
|
|
|
ae23c9 |
- iscsi_set_events(iscsilun);
|
|
|
ae23c9 |
- qemu_mutex_unlock(&iscsilun->mutex);
|
|
|
ae23c9 |
- qemu_coroutine_yield();
|
|
|
ae23c9 |
- qemu_mutex_lock(&iscsilun->mutex);
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
+ iscsi_co_wait_for_task(&iTask, iscsilun);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (iTask.task != NULL) {
|
|
|
ae23c9 |
scsi_free_scsi_task(iTask.task);
|
|
|
ae23c9 |
@@ -1144,12 +1134,7 @@ retry:
|
|
|
ae23c9 |
goto out_unlock;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- while (!iTask.complete) {
|
|
|
ae23c9 |
- iscsi_set_events(iscsilun);
|
|
|
ae23c9 |
- qemu_mutex_unlock(&iscsilun->mutex);
|
|
|
ae23c9 |
- qemu_coroutine_yield();
|
|
|
ae23c9 |
- qemu_mutex_lock(&iscsilun->mutex);
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
+ iscsi_co_wait_for_task(&iTask, iscsilun);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (iTask.task != NULL) {
|
|
|
ae23c9 |
scsi_free_scsi_task(iTask.task);
|
|
|
ae23c9 |
@@ -1245,12 +1230,7 @@ retry:
|
|
|
ae23c9 |
return -ENOMEM;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- while (!iTask.complete) {
|
|
|
ae23c9 |
- iscsi_set_events(iscsilun);
|
|
|
ae23c9 |
- qemu_mutex_unlock(&iscsilun->mutex);
|
|
|
ae23c9 |
- qemu_coroutine_yield();
|
|
|
ae23c9 |
- qemu_mutex_lock(&iscsilun->mutex);
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
+ iscsi_co_wait_for_task(&iTask, iscsilun);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (iTask.status == SCSI_STATUS_CHECK_CONDITION &&
|
|
|
ae23c9 |
iTask.task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|