Federico Simoncelli has uploaded a new change for review.

Change subject: sp: fix pool membership check in attachSD
......................................................................

sp: fix pool membership check in attachSD

A race between attachStorageDomain and connectStoragePool using
StoragePoolMemoryBackend could lead to the new domain not being
attached (on storage).

The race happens in StoragePool.attachSD:

        domains = self.getDomains()
        if sdUUID in domains:
            return True

if the domain map has been already updated by connectStoragePool
the domain is deemed attached and the remaining operations are
skipped.

In this patch:
- use only validateAttachedDomain in detachSD (validatePoolSD is
  redundant)
- make attachSD symmetric to detachSD using validateAttachedDomain
  to check if the domain is already attached

Change-Id: I4169ddcb4da29c8b806b5788080c16349b642197
Signed-off-by: Federico Simoncelli <[email protected]>
---
M vdsm/storage/sp.py
1 file changed, 15 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/23446/1

diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 0610804..4801ca4 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -859,18 +859,26 @@
         """
         self.log.info("sdUUID=%s spUUID=%s", sdUUID, self.spUUID)
 
-        domains = self.getDomains()
-        if sdUUID in domains:
-            return True
-
-        if len(domains) >= self._backend.getMaximumSupportedDomains():
-            raise se.TooManyDomainsInStoragePoolError()
-
         try:
             dom = sdCache.produce(sdUUID)
         except se.StorageDomainDoesNotExist:
             sdCache.invalidateStorage()
             dom = sdCache.produce(sdUUID)
+
+        try:
+            self.validateAttachedDomain(dom)
+        except (se.StorageDomainNotMemberOfPool, se.StorageDomainNotInPool):
+            pass  # domain is not attached to this pool yet
+        else:
+            log.warning('domain %s is already attached to pool %s',
+                        sdUUID, self.spUUID)
+            return
+
+        domains = self.getDomains()
+
+        if len(domains) >= self._backend.getMaximumSupportedDomains():
+            raise se.TooManyDomainsInStoragePoolError()
+
         dom.acquireHostId(self.id)
 
         try:
@@ -933,7 +941,6 @@
         dom = sdCache.produce(sdUUID)
 
         # Avoid detach domains if not owned by pool
-        self.validatePoolSD(sdUUID)
         self.validateAttachedDomain(dom)
 
         if sdUUID == self.masterDomain.sdUUID:


-- 
To view, visit http://gerrit.ovirt.org/23446
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4169ddcb4da29c8b806b5788080c16349b642197
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to