[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 12/41] iscsi: simplify iscsi_co_discard
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 12/41] iscsi: simplify iscsi_co_discard |
Date: |
Fri, 29 Nov 2013 17:45:27 +0100 |
From: Peter Lieven <address@hidden>
now that bdrv_co_discard can handle limits we do not need
the request split logic here anymore.
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Peter Lieven <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/iscsi.c | 67 ++++++++++++++++++++++-------------------------------------
1 file changed, 25 insertions(+), 42 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index 1cafa78..f91134e 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -87,7 +87,6 @@ typedef struct IscsiAIOCB {
#define NOP_INTERVAL 5000
#define MAX_NOP_FAILURES 3
#define ISCSI_CMD_RETRIES 5
-#define ISCSI_MAX_UNMAP 131072
static void
iscsi_bh_cb(void *p)
@@ -912,8 +911,6 @@ coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t
sector_num,
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
struct unmap_list list;
- uint32_t nb_blocks;
- uint32_t max_unmap;
if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
return -EINVAL;
@@ -925,52 +922,38 @@ coroutine_fn iscsi_co_discard(BlockDriverState *bs,
int64_t sector_num,
}
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;
- if (max_unmap == 0xffffffff) {
- max_unmap = ISCSI_MAX_UNMAP;
- }
-
- while (nb_blocks > 0) {
- iscsi_co_init_iscsitask(iscsilun, &iTask);
- list.num = nb_blocks;
- if (list.num > max_unmap) {
- list.num = max_unmap;
- }
+ iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
- if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1,
- iscsi_co_generic_cb, &iTask) == NULL) {
- return -EIO;
- }
-
- while (!iTask.complete) {
- iscsi_set_events(iscsilun);
- qemu_coroutine_yield();
- }
+ if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1,
+ iscsi_co_generic_cb, &iTask) == NULL) {
+ return -EIO;
+ }
- if (iTask.task != NULL) {
- scsi_free_scsi_task(iTask.task);
- iTask.task = NULL;
- }
+ while (!iTask.complete) {
+ iscsi_set_events(iscsilun);
+ qemu_coroutine_yield();
+ }
- if (iTask.do_retry) {
- goto retry;
- }
+ if (iTask.task != NULL) {
+ scsi_free_scsi_task(iTask.task);
+ iTask.task = NULL;
+ }
- if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
- /* 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.do_retry) {
+ goto retry;
+ }
- if (iTask.status != SCSI_STATUS_GOOD) {
- return -EIO;
- }
+ if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
+ /* 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;
+ }
- list.lba += list.num;
- nb_blocks -= list.num;
+ if (iTask.status != SCSI_STATUS_GOOD) {
+ return -EIO;
}
return 0;
--
1.8.1.4
- [Qemu-devel] [PULL 02/41] block: add flags to bdrv_*_write_zeroes, (continued)
- [Qemu-devel] [PULL 02/41] block: add flags to bdrv_*_write_zeroes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 01/41] block: make BdrvRequestFlags public, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 03/41] block: introduce BDRV_REQ_MAY_UNMAP request flag, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 07/41] block: add BlockLimits structure to BlockDriverState, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 06/41] block/iscsi: add .bdrv_get_info, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 05/41] block: add wrappers for logical block provisioning information, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 08/41] block/raw: copy BlockLimits on raw_open, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 09/41] block: honour BlockLimits in bdrv_co_do_write_zeroes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 10/41] block: honour BlockLimits in bdrv_co_discard, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 11/41] iscsi: set limits in BlockDriverState, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 12/41] iscsi: simplify iscsi_co_discard,
Kevin Wolf <=
- [Qemu-devel] [PULL 13/41] iscsi: add bdrv_co_write_zeroes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 14/41] block: introduce bdrv_make_zero, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 15/41] block/get_block_status: fix BDRV_BLOCK_ZERO for unallocated blocks, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 16/41] qemu-img: add support for fully allocated images, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 17/41] qemu-img: conditionally zero out target on convert, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 18/41] util/error: Save errno from clobbering, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 19/41] Test coroutine execution order, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 20/41] sheepdog: implement .bdrv_get_allocated_file_size, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 21/41] block/stream: Don't stream unbacked devices, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 22/41] block: per caller dirty bitmap, Kevin Wolf, 2013/11/29