mirror of https://github.com/xqemu/xqemu.git
iscsi: simplify iscsi_co_discard
now that bdrv_co_discard can handle limits we do not need the request split logic here anymore. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Peter Lieven <pl@kamp.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
ba6c59191f
commit
01a6a238a3
|
@ -87,7 +87,6 @@ typedef struct IscsiAIOCB {
|
||||||
#define NOP_INTERVAL 5000
|
#define NOP_INTERVAL 5000
|
||||||
#define MAX_NOP_FAILURES 3
|
#define MAX_NOP_FAILURES 3
|
||||||
#define ISCSI_CMD_RETRIES 5
|
#define ISCSI_CMD_RETRIES 5
|
||||||
#define ISCSI_MAX_UNMAP 131072
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iscsi_bh_cb(void *p)
|
iscsi_bh_cb(void *p)
|
||||||
|
@ -912,8 +911,6 @@ coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t sector_num,
|
||||||
IscsiLun *iscsilun = bs->opaque;
|
IscsiLun *iscsilun = bs->opaque;
|
||||||
struct IscsiTask iTask;
|
struct IscsiTask iTask;
|
||||||
struct unmap_list list;
|
struct unmap_list list;
|
||||||
uint32_t nb_blocks;
|
|
||||||
uint32_t max_unmap;
|
|
||||||
|
|
||||||
if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
|
if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -925,52 +922,38 @@ coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t sector_num,
|
||||||
}
|
}
|
||||||
|
|
||||||
list.lba = sector_qemu2lun(sector_num, iscsilun);
|
list.lba = sector_qemu2lun(sector_num, iscsilun);
|
||||||
nb_blocks = sector_qemu2lun(nb_sectors, iscsilun);
|
list.num = sector_qemu2lun(nb_sectors, iscsilun);
|
||||||
|
|
||||||
max_unmap = iscsilun->bl.max_unmap;
|
iscsi_co_init_iscsitask(iscsilun, &iTask);
|
||||||
if (max_unmap == 0xffffffff) {
|
retry:
|
||||||
max_unmap = ISCSI_MAX_UNMAP;
|
if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1,
|
||||||
|
iscsi_co_generic_cb, &iTask) == NULL) {
|
||||||
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (nb_blocks > 0) {
|
while (!iTask.complete) {
|
||||||
iscsi_co_init_iscsitask(iscsilun, &iTask);
|
iscsi_set_events(iscsilun);
|
||||||
list.num = nb_blocks;
|
qemu_coroutine_yield();
|
||||||
if (list.num > max_unmap) {
|
}
|
||||||
list.num = max_unmap;
|
|
||||||
}
|
|
||||||
retry:
|
|
||||||
if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1,
|
|
||||||
iscsi_co_generic_cb, &iTask) == NULL) {
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!iTask.complete) {
|
if (iTask.task != NULL) {
|
||||||
iscsi_set_events(iscsilun);
|
scsi_free_scsi_task(iTask.task);
|
||||||
qemu_coroutine_yield();
|
iTask.task = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iTask.task != NULL) {
|
if (iTask.do_retry) {
|
||||||
scsi_free_scsi_task(iTask.task);
|
goto retry;
|
||||||
iTask.task = NULL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (iTask.do_retry) {
|
if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
|
||||||
goto retry;
|
/* the target might fail with a check condition if it
|
||||||
}
|
is not happy with the alignment of the UNMAP request
|
||||||
|
we silently fail in this case */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
|
if (iTask.status != SCSI_STATUS_GOOD) {
|
||||||
/* the target might fail with a check condition if it
|
return -EIO;
|
||||||
is not happy with the alignment of the UNMAP request
|
|
||||||
we silently fail in this case */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iTask.status != SCSI_STATUS_GOOD) {
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
list.lba += list.num;
|
|
||||||
nb_blocks -= list.num;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue