cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 2094ed57c6e6e765d7e28a0c92f05d2b3cb43fd4 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <2094ed57c6e6e765d7e28a0c92f05d2b3cb43fd4.1389014116.git.minovotn@redhat.com>
0a122b
In-Reply-To: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
0a122b
References: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
0a122b
From: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Date: Mon, 9 Dec 2013 14:09:05 +0100
0a122b
Subject: [PATCH 17/50] iscsi: simplify iscsi_co_discard
0a122b
0a122b
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Message-id: <1386598178-11845-20-git-send-email-pbonzini@redhat.com>
0a122b
Patchwork-id: 56056
0a122b
O-Subject: [RHEL 7.0 qemu-kvm PATCH 19/52] iscsi: simplify iscsi_co_discard
0a122b
Bugzilla: 1007815
0a122b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
0a122b
RH-Acked-by: Fam Zheng <famz@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
From: Peter Lieven <pl@kamp.de>
0a122b
0a122b
now that bdrv_co_discard can handle limits we do not need
0a122b
the request split logic here anymore.
0a122b
0a122b
Reviewed-by: Eric Blake <eblake@redhat.com>
0a122b
Signed-off-by: Peter Lieven <pl@kamp.de>
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
(cherry picked from commit 01a6a238a30b0381846e3e68ba06e232567a7026)
0a122b
---
0a122b
 block/iscsi.c | 67 ++++++++++++++++++++++-------------------------------------
0a122b
 1 file changed, 25 insertions(+), 42 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 block/iscsi.c | 67 ++++++++++++++++++++++-------------------------------------
0a122b
 1 file changed, 25 insertions(+), 42 deletions(-)
0a122b
0a122b
diff --git a/block/iscsi.c b/block/iscsi.c
0a122b
index e5f4670..567a63a 100644
0a122b
--- a/block/iscsi.c
0a122b
+++ b/block/iscsi.c
0a122b
@@ -87,7 +87,6 @@ typedef struct IscsiAIOCB {
0a122b
 #define NOP_INTERVAL 5000
0a122b
 #define MAX_NOP_FAILURES 3
0a122b
 #define ISCSI_CMD_RETRIES 5
0a122b
-#define ISCSI_MAX_UNMAP 131072
0a122b
 
0a122b
 static void
0a122b
 iscsi_bh_cb(void *p)
0a122b
@@ -914,8 +913,6 @@ coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t sector_num,
0a122b
     IscsiLun *iscsilun = bs->opaque;
0a122b
     struct IscsiTask iTask;
0a122b
     struct unmap_list list;
0a122b
-    uint32_t nb_blocks;
0a122b
-    uint32_t max_unmap;
0a122b
 
0a122b
     if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
0a122b
         return -EINVAL;
0a122b
@@ -927,52 +924,38 @@ coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t sector_num,
0a122b
     }
0a122b
 
0a122b
     list.lba = sector_qemu2lun(sector_num, iscsilun);
0a122b
-    nb_blocks = sector_qemu2lun(nb_sectors, iscsilun);
0a122b
+    list.num = sector_qemu2lun(nb_sectors, iscsilun);
0a122b
 
0a122b
-    max_unmap = iscsilun->bl.max_unmap;
0a122b
-    if (max_unmap == 0xffffffff) {
0a122b
-        max_unmap = ISCSI_MAX_UNMAP;
0a122b
-    }
0a122b
-
0a122b
-    while (nb_blocks > 0) {
0a122b
-        iscsi_co_init_iscsitask(iscsilun, &iTask);
0a122b
-        list.num = nb_blocks;
0a122b
-        if (list.num > max_unmap) {
0a122b
-            list.num = max_unmap;
0a122b
-        }
0a122b
+    iscsi_co_init_iscsitask(iscsilun, &iTask);
0a122b
 retry:
0a122b
-        if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1,
0a122b
-                         iscsi_co_generic_cb, &iTask) == NULL) {
0a122b
-            return -EIO;
0a122b
-        }
0a122b
-
0a122b
-        while (!iTask.complete) {
0a122b
-            iscsi_set_events(iscsilun);
0a122b
-            qemu_coroutine_yield();
0a122b
-        }
0a122b
+    if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1,
0a122b
+                     iscsi_co_generic_cb, &iTask) == NULL) {
0a122b
+        return -EIO;
0a122b
+    }
0a122b
 
0a122b
-        if (iTask.task != NULL) {
0a122b
-            scsi_free_scsi_task(iTask.task);
0a122b
-            iTask.task = NULL;
0a122b
-        }
0a122b
+    while (!iTask.complete) {
0a122b
+        iscsi_set_events(iscsilun);
0a122b
+        qemu_coroutine_yield();
0a122b
+    }
0a122b
 
0a122b
-        if (iTask.do_retry) {
0a122b
-            goto retry;
0a122b
-        }
0a122b
+    if (iTask.task != NULL) {
0a122b
+        scsi_free_scsi_task(iTask.task);
0a122b
+        iTask.task = NULL;
0a122b
+    }
0a122b
 
0a122b
-        if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
0a122b
-            /* the target might fail with a check condition if it
0a122b
-               is not happy with the alignment of the UNMAP request
0a122b
-               we silently fail in this case */
0a122b
-            return 0;
0a122b
-        }
0a122b
+    if (iTask.do_retry) {
0a122b
+        goto retry;
0a122b
+    }
0a122b
 
0a122b
-        if (iTask.status != SCSI_STATUS_GOOD) {
0a122b
-            return -EIO;
0a122b
-        }
0a122b
+    if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
0a122b
+        /* the target might fail with a check condition if it
0a122b
+           is not happy with the alignment of the UNMAP request
0a122b
+           we silently fail in this case */
0a122b
+        return 0;
0a122b
+    }
0a122b
 
0a122b
-        list.lba += list.num;
0a122b
-        nb_blocks -= list.num;
0a122b
+    if (iTask.status != SCSI_STATUS_GOOD) {
0a122b
+        return -EIO;
0a122b
     }
0a122b
 
0a122b
     return 0;
0a122b
-- 
0a122b
1.7.11.7
0a122b