From patchwork Tue Sep 17 13:48:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 275465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DD6D02C00AA for ; Tue, 17 Sep 2013 23:53:01 +1000 (EST) Received: from localhost ([::1]:41293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLvi8-0000Ny-1Z for incoming@patchwork.ozlabs.org; Tue, 17 Sep 2013 09:53:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLvgi-000750-OJ for qemu-devel@nongnu.org; Tue, 17 Sep 2013 09:51:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLvga-0001ut-Pp for qemu-devel@nongnu.org; Tue, 17 Sep 2013 09:51:32 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:50142 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLvga-0001uW-Ah for qemu-devel@nongnu.org; Tue, 17 Sep 2013 09:51:24 -0400 Received: (qmail 23419 invoked by uid 89); 17 Sep 2013 13:51:23 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.97.8/17868. hbedv: 8.2.12.120/7.11.102.228. spamassassin: 3.3.1. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 4.011007 secs); 17 Sep 2013 13:51:23 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 17 Sep 2013 13:51:19 -0000 X-GL_Whitelist: yes Received: from lieven-pc.kamp-intra.net (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 379DE206B0; Tue, 17 Sep 2013 15:49:15 +0200 (CEST) Received: by lieven-pc.kamp-intra.net (Postfix, from userid 1000) id B167E5FA22; Tue, 17 Sep 2013 15:49:15 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org Date: Tue, 17 Sep 2013 15:48:45 +0200 Message-Id: <1379425736-11326-10-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1379425736-11326-1-git-send-email-pl@kamp.de> References: <1379425736-11326-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, ronniesahlberg@gmail.com, Peter Lieven , stefanha@redhat.com, anthony@codemonkey.ws, pbonzini@redhat.com Subject: [Qemu-devel] [PATCHv2 09/20] iscsi: simplify iscsi_co_discard X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org now that bdrv_co_discard can handle limits we do not need the request split logic here anymore. Signed-off-by: Peter Lieven Reviewed-by: Eric Blake --- block/iscsi.c | 67 +++++++++++++++++++++------------------------------------ 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 68f99d3..aabcddb 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) @@ -908,8 +907,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; @@ -921,52 +918,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;