mirror of https://github.com/xemu-project/xemu.git
block/iscsi: use a bh to schedule co reentrance
this fixes a potential segfault and performance regression.
If the coroutine is reentered directly in the iscsi_co_generic_cb
iscsi_process_{read,write} are interrupted and reentered any
time later. One the one hand this could happen after an iscsi_close
where the iscsi context is already gone (segfault). On the
other hand this limits the number of processed callbacks
in each aio_dispatch to one (potential performance regression).
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 8b9dfe9098
)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
parent
9692bad34d
commit
02e1c55ddd
|
@ -65,6 +65,7 @@ typedef struct IscsiTask {
|
||||||
int do_retry;
|
int do_retry;
|
||||||
struct scsi_task *task;
|
struct scsi_task *task;
|
||||||
Coroutine *co;
|
Coroutine *co;
|
||||||
|
QEMUBH *bh;
|
||||||
} IscsiTask;
|
} IscsiTask;
|
||||||
|
|
||||||
typedef struct IscsiAIOCB {
|
typedef struct IscsiAIOCB {
|
||||||
|
@ -121,6 +122,13 @@ iscsi_schedule_bh(IscsiAIOCB *acb)
|
||||||
qemu_bh_schedule(acb->bh);
|
qemu_bh_schedule(acb->bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void iscsi_co_generic_bh_cb(void *opaque)
|
||||||
|
{
|
||||||
|
struct IscsiTask *iTask = opaque;
|
||||||
|
qemu_bh_delete(iTask->bh);
|
||||||
|
qemu_coroutine_enter(iTask->co, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
|
iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
|
||||||
void *command_data, void *opaque)
|
void *command_data, void *opaque)
|
||||||
|
@ -145,7 +153,8 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (iTask->co) {
|
if (iTask->co) {
|
||||||
qemu_coroutine_enter(iTask->co, NULL);
|
iTask->bh = qemu_bh_new(iscsi_co_generic_bh_cb, iTask);
|
||||||
|
qemu_bh_schedule(iTask->bh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue