cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-iscsi-check-WRITE-SAME-support-differently-dep.patch.patch.patch

0a122b
From 615429e3068cb4a3e57ee60d52f318aa6ca06f6d Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <615429e3068cb4a3e57ee60d52f318aa6ca06f6d.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:22 +0100
0a122b
Subject: [PATCH 34/50] block/iscsi: check WRITE SAME support differently
0a122b
 depending on MAY_UNMAP
0a122b
0a122b
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Message-id: <1386598178-11845-37-git-send-email-pbonzini@redhat.com>
0a122b
Patchwork-id: 56073
0a122b
O-Subject: [RHEL 7.0 qemu-kvm PATCH 36/52] block/iscsi: check WRITE SAME support differently depending on MAY_UNMAP
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
The current check is right for MAY_UNMAP=1.  For MAY_UNMAP=0, just
0a122b
try and fall back to regular writes as soon as a WRITE SAME command
0a122b
fails.
0a122b
0a122b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Reviewed-by: Peter Lieven <pl@kamp.de>
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
(cherry picked from commit fa6252b0565526ec2347e248172f91771e0d9f47)
0a122b
---
0a122b
 block/iscsi.c | 19 +++++++++++++++++--
0a122b
 1 file changed, 17 insertions(+), 2 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 block/iscsi.c | 19 +++++++++++++++++--
0a122b
 1 file changed, 17 insertions(+), 2 deletions(-)
0a122b
0a122b
diff --git a/block/iscsi.c b/block/iscsi.c
0a122b
index 7ae61f9..8b82fe7 100644
0a122b
--- a/block/iscsi.c
0a122b
+++ b/block/iscsi.c
0a122b
@@ -55,6 +55,7 @@ typedef struct IscsiLun {
0a122b
     QEMUTimer *nop_timer;
0a122b
     uint8_t lbpme;
0a122b
     uint8_t lbprz;
0a122b
+    uint8_t has_write_same;
0a122b
     struct scsi_inquiry_logical_block_provisioning lbp;
0a122b
     struct scsi_inquiry_block_limits bl;
0a122b
     unsigned char *zeroblock;
0a122b
@@ -978,8 +979,13 @@ coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num,
0a122b
         return -EINVAL;
0a122b
     }
0a122b
 
0a122b
-    if (!iscsilun->lbp.lbpws) {
0a122b
-        /* WRITE SAME is not supported by the target */
0a122b
+    if (!(flags & BDRV_REQ_MAY_UNMAP) && !iscsilun->has_write_same) {
0a122b
+        /* WRITE SAME without UNMAP is not supported by the target */
0a122b
+        return -ENOTSUP;
0a122b
+    }
0a122b
+
0a122b
+    if ((flags & BDRV_REQ_MAY_UNMAP) && !iscsilun->lbp.lbpws) {
0a122b
+        /* WRITE SAME with UNMAP is not supported by the target */
0a122b
         return -ENOTSUP;
0a122b
     }
0a122b
 
0a122b
@@ -1014,6 +1020,14 @@ retry:
0a122b
     }
0a122b
 
0a122b
     if (iTask.status != SCSI_STATUS_GOOD) {
0a122b
+        if (iTask.status == SCSI_STATUS_CHECK_CONDITION &&
0a122b
+            iTask.task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
0a122b
+            iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
0a122b
+            /* WRITE SAME is not supported by the target */
0a122b
+            iscsilun->has_write_same = false;
0a122b
+            return -ENOTSUP;
0a122b
+        }
0a122b
+
0a122b
         return -EIO;
0a122b
     }
0a122b
 
0a122b
@@ -1377,6 +1391,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
0a122b
     }
0a122b
 
0a122b
     iscsilun->type = inq->periperal_device_type;
0a122b
+    iscsilun->has_write_same = true;
0a122b
 
0a122b
     if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
0a122b
         goto out;
0a122b
-- 
0a122b
1.7.11.7
0a122b