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