mirror of https://github.com/xemu-project/xemu.git
block/iscsi: Use lock guard macros
Replace manual lock()/unlock() calls with lock guard macros (QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/iscsi. Signed-off-by: Gan Qixin <ganqixin@huawei.com> Message-Id: <20201203075055.127773-5-ganqixin@huawei.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
3af613ebdb
commit
c208b0ef96
|
@ -322,11 +322,10 @@ iscsi_aio_cancel(BlockAIOCB *blockacb)
|
||||||
IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
|
IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
|
||||||
IscsiLun *iscsilun = acb->iscsilun;
|
IscsiLun *iscsilun = acb->iscsilun;
|
||||||
|
|
||||||
qemu_mutex_lock(&iscsilun->mutex);
|
WITH_QEMU_LOCK_GUARD(&iscsilun->mutex) {
|
||||||
|
|
||||||
/* If it was cancelled or completed already, our work is done here */
|
/* If it was cancelled or completed already, our work is done here */
|
||||||
if (acb->cancelled || acb->status != -EINPROGRESS) {
|
if (acb->cancelled || acb->status != -EINPROGRESS) {
|
||||||
qemu_mutex_unlock(&iscsilun->mutex);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,8 +338,7 @@ iscsi_aio_cancel(BlockAIOCB *blockacb)
|
||||||
iscsi_abort_task_cb, acb) < 0) {
|
iscsi_abort_task_cb, acb) < 0) {
|
||||||
qemu_aio_unref(acb); /* since iscsi_abort_task_cb() won't be called */
|
qemu_aio_unref(acb); /* since iscsi_abort_task_cb() won't be called */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
qemu_mutex_unlock(&iscsilun->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const AIOCBInfo iscsi_aiocb_info = {
|
static const AIOCBInfo iscsi_aiocb_info = {
|
||||||
|
@ -375,8 +373,7 @@ static void iscsi_timed_check_events(void *opaque)
|
||||||
{
|
{
|
||||||
IscsiLun *iscsilun = opaque;
|
IscsiLun *iscsilun = opaque;
|
||||||
|
|
||||||
qemu_mutex_lock(&iscsilun->mutex);
|
WITH_QEMU_LOCK_GUARD(&iscsilun->mutex) {
|
||||||
|
|
||||||
/* check for timed out requests */
|
/* check for timed out requests */
|
||||||
iscsi_service(iscsilun->iscsi, 0);
|
iscsi_service(iscsilun->iscsi, 0);
|
||||||
|
|
||||||
|
@ -385,11 +382,12 @@ static void iscsi_timed_check_events(void *opaque)
|
||||||
iscsi_reconnect(iscsilun->iscsi);
|
iscsi_reconnect(iscsilun->iscsi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* newer versions of libiscsi may return zero events. Ensure we are able
|
/*
|
||||||
* to return to service once this situation changes. */
|
* newer versions of libiscsi may return zero events. Ensure we are
|
||||||
|
* able to return to service once this situation changes.
|
||||||
|
*/
|
||||||
iscsi_set_events(iscsilun);
|
iscsi_set_events(iscsilun);
|
||||||
|
}
|
||||||
qemu_mutex_unlock(&iscsilun->mutex);
|
|
||||||
|
|
||||||
timer_mod(iscsilun->event_timer,
|
timer_mod(iscsilun->event_timer,
|
||||||
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL);
|
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + EVENT_INTERVAL);
|
||||||
|
|
Loading…
Reference in New Issue