0a7476
From 95c8eb63a3078bfd4a568b02898be2be91e3cd95 Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <95c8eb63a3078bfd4a568b02898be2be91e3cd95@dist-git>
bba56f
From: John Ferlan <jferlan@redhat.com>
bba56f
Date: Tue, 12 Mar 2019 13:55:59 -0400
bba56f
Subject: [PATCH] storage: Fetch a unique key for vHBA/NPIV LUNs
bba56f
MIME-Version: 1.0
bba56f
Content-Type: text/plain; charset=UTF-8
bba56f
Content-Transfer-Encoding: 8bit
bba56f
bba56f
https://bugzilla.redhat.com/show_bug.cgi?id=1687715 (7.6.z)
bba56f
https://bugzilla.redhat.com/show_bug.cgi?id=1657468 (7.7.0)
bba56f
bba56f
Commit be1bb6c95 changed the way volumes were stored from a forward
bba56f
linked list to a hash table. In doing so, it required that each vol
bba56f
object would have 3 unique values as keys into tables - key, name,
bba56f
and path. Due to how vHBA/NPIV LUNs are created/used this resulted
bba56f
in a failure to utilize all the LUN's found during processing.
bba56f
bba56f
During virStorageBackendSCSINewLun processing fetch the key (or
bba56f
serial value) for NPIV LUN's using virStorageFileGetNPIVKey which
bba56f
will formulate a more unique key based on the serial value and
bba56f
the port for the LUN.
bba56f
bba56f
Signed-off-by: John Ferlan <jferlan@redhat.com>
bba56f
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
bba56f
Reviewed-by: Ján Tomko <jtomko@redhat.com>
bba56f
(cherry picked from commit 850cfd75beb7872b20439eccda0bcf7b68cab525)
bba56f
Message-Id: <20190312175559.13583-5-jferlan@redhat.com>
bba56f
Reviewed-by: Ján Tomko <jtomko@redhat.com>
bba56f
---
bba56f
 src/storage/storage_util.c | 13 ++++++++++---
bba56f
 1 file changed, 10 insertions(+), 3 deletions(-)
bba56f
bba56f
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
bba56f
index d1659c0c8d..19e6e0544b 100644
bba56f
--- a/src/storage/storage_util.c
bba56f
+++ b/src/storage/storage_util.c
bba56f
@@ -3694,12 +3694,16 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
bba56f
 
bba56f
 
bba56f
 static char *
bba56f
-virStorageBackendSCSISerial(const char *dev)
bba56f
+virStorageBackendSCSISerial(const char *dev,
bba56f
+                            bool isNPIV)
bba56f
 {
bba56f
     int rc;
bba56f
     char *serial = NULL;
bba56f
 
bba56f
-    rc = virStorageFileGetSCSIKey(dev, &serial, true);
bba56f
+    if (isNPIV)
bba56f
+        rc = virStorageFileGetNPIVKey(dev, &serial);
bba56f
+    else
bba56f
+        rc = virStorageFileGetSCSIKey(dev, &serial, true);
bba56f
     if (rc == 0 && serial)
bba56f
         return serial;
bba56f
 
bba56f
@@ -3796,7 +3800,10 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
bba56f
                                                  VIR_STORAGE_VOL_READ_NOERROR)) < 0)
bba56f
         goto cleanup;
bba56f
 
bba56f
-    if (!(vol->key = virStorageBackendSCSISerial(vol->target.path)))
bba56f
+    vol->key = virStorageBackendSCSISerial(vol->target.path,
bba56f
+                                           (def->source.adapter.type ==
bba56f
+                                            VIR_STORAGE_ADAPTER_TYPE_FC_HOST));
bba56f
+    if (!vol->key)
bba56f
         goto cleanup;
bba56f
 
bba56f
     def->capacity += vol->target.capacity;
bba56f
-- 
bba56f
2.21.0
bba56f