Nir Soffer has uploaded a new change for review.

Change subject: scsi: Scan only the required domain type
......................................................................

scsi: Scan only the required domain type

We used to perform both iSCSI and FCP rescan when creating or editing a
storage domain, connecting to storage server, getting vg and storage
domain list and more.

The unneeded rescan is typically fast, but if a storage server or device
is not accessible, a SCSI rescan may block for couple of minutes,
leading to unwanted blocking of unrelated storage threads. This is
particularly bad when you are interested only in one domain type, but
the host get stuck scanning the other type.

To improve storage domain isolation, we use the specified storage type
to perform a rescan only of the relevant type. If storage type was not
specified, we scan both ISCSI and FCP keeping the old behavior.

Change-Id: Ic32cd683020e94df016dd77b19ae3eb7317c5554
Signed-off-by: Nir Soffer <nsof...@redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/storage/multipath.py
M vdsm/storage/sdc.py
3 files changed, 25 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/24/45824/1

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 1b8c064..541b699 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1984,15 +1984,16 @@
         return dict(devList=devices)
 
     def _getDeviceList(self, storageType=None, guids=(), checkStatus=True):
-        sdCache.refreshStorage()
-        typeFilter = lambda dev: True
-        if storageType:
-            if sd.storageType(storageType) == sd.type2name(sd.ISCSI_DOMAIN):
-                typeFilter = \
-                    lambda dev: multipath.devIsiSCSI(dev.get("devtype"))
-            elif sd.storageType(storageType) == sd.type2name(sd.FCP_DOMAIN):
-                typeFilter = \
-                    lambda dev: multipath.devIsFCP(dev.get("devtype"))
+        domType = sd.storageType(storageType) if storageType else None
+
+        sdCache.refreshStorage(domType)
+
+        if domType == sd.ISCSI_DOMAIN:
+            typeFilter = lambda dev: multipath.devIsiSCSI(dev.get("devtype"))
+        elif domType == sd.FCP_DOMAIN:
+            typeFilter = lambda dev: multipath.devIsFCP(dev.get("devtype"))
+        else:
+            typeFilter = lambda dev: True
 
         devices = []
         pvs = {}
@@ -2470,7 +2471,7 @@
                 # while the VDSM was not connected, we need to
                 # call refreshStorage.
                 if domType in (sd.FCP_DOMAIN, sd.ISCSI_DOMAIN):
-                    sdCache.refreshStorage()
+                    sdCache.refreshStorage(domType)
                 try:
                     doms = self.__prefetchDomains(domType, conObj)
                 except:
@@ -2864,7 +2865,8 @@
         """
         vars.task.setDefaultException(
             se.StorageDomainActionError("spUUID: %s" % spUUID))
-        sdCache.refreshStorage()
+        domType = sd.storageType(storageType) if storageType else None
+        sdCache.refreshStorage(domType)
         if spUUID and spUUID != volume.BLANK_UUID:
             domList = self.getPool(spUUID).getDomains()
             domains = domList.keys()
@@ -2925,7 +2927,8 @@
         :rtype: dict
         """
         vars.task.setDefaultException(se.VolumeGroupActionError())
-        sdCache.refreshStorage()
+        domType = sd.storageType(storageType) if storageType else None
+        sdCache.refreshStorage(domType)
         # getSharedLock(connectionsResource...)
         vglist = []
         vgs = self.__getVGsInfo()
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index ad81d2d..32deb98 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -39,6 +39,7 @@
 import misc
 import iscsi
 import devicemapper
+import sd
 
 DEV_ISCSI = "iSCSI"
 DEV_FCP = "FCP"
@@ -61,7 +62,7 @@
     """ multipath operation failed """
 
 
-def rescan():
+def rescan(domType=None):
     """
     Forces multipath daemon to rescan the list of available devices and
     refresh the mapping table. New devices can be found under /dev/mapper
@@ -70,8 +71,12 @@
     """
 
     # First rescan iSCSI and FCP connections
-    iscsi.rescan()
-    hba.rescan()
+
+    if domType in (None, sd.ISCSI_DOMAIN):
+        iscsi.rescan()
+
+    if domType in (None, sd.FCP_DOMAIN):
+        hba.rescan()
 
     # Now let multipath daemon pick up new devices
     misc.execCmd([constants.EXT_MULTIPATH], sudo=True)
diff --git a/vdsm/storage/sdc.py b/vdsm/storage/sdc.py
index ecb9708..273c5c0 100644
--- a/vdsm/storage/sdc.py
+++ b/vdsm/storage/sdc.py
@@ -77,10 +77,10 @@
             self.__staleStatus = self.STORAGE_STALE
 
     @misc.samplingmethod
-    def refreshStorage(self):
+    def refreshStorage(self, domType=None):
         self.__staleStatus = self.STORAGE_REFRESHING
 
-        multipath.rescan()
+        multipath.rescan(domType)
         multipath.resize_devices()
         lvm.invalidateCache()
 


-- 
To view, visit https://gerrit.ovirt.org/45824
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic32cd683020e94df016dd77b19ae3eb7317c5554
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsof...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to