New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at:
http://gerrit.usersys.redhat.com/832
commit acf5fcd8c69b561161dadca39d1e18df77891160
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Thu Aug 18 16:23:51 2011 +0300
BZ#726400 - Remove lvm operations from StoragePool.__rebuild().
Change-Id: I712d57d3d16aba5e394ed42f247b14cf86c44b2d
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 11d337c..09ff28c 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -19,6 +19,7 @@ import codecs
import constants
import storage_mailbox
import blockSD
+import fileSD
import sd
import misc
from misc import Event
@@ -508,6 +509,7 @@ class StoragePool:
def __masterMigrate(self, sdUUID, msdUUID, masterVersion):
curmsd = SDF.produce(sdUUID)
newmsd = SDF.produce(msdUUID)
+ self._refreshDomainLinks(newmsd)
curmsd.invalidateMetadata()
newmsd.upgrade(curmsd.getVersion())
@@ -861,24 +863,29 @@ class StoragePool:
if msdUUID in domUUIDs:
domUUIDs.remove(msdUUID)
- for domUUID in domUUIDs:
- try:
- d = SDF.produce(domUUID)
- except se.StorageDomainDoesNotExist:
- # We should not rebuild a non-master active domain
- # if it is disconnected. Log the error and continue
- self.log.error("pool %s metadata contains an unknown domain
%s", self.spUUID, domUUID, exc_info=True)
- continue
-
- try:
- self._refreshDomainLinks(d)
- except (se.StorageException, OSError):
- self.log.error("Can't refresh domain links",
exc_info=True)
- continue
- # Remove domain from potential cleanup
+ #TODO: Consider to remove this whole block. UGLY!
+ #We want to avoid lookups (vgs) of unknown block domains.
+ #domUUIDs includes all the domains, file or block.
+ #fileSDs includes local and NFS domains.
+ block_mountpoint = os.path.join(sd.StorageDomain.storage_repository,
+ sd.DOMAIN_MNT_POINT, sd.BLOCKSD_DIR)
+ domDirs = {} # {domUUID: domaindir}
+ for domUUID, domaindir in fileSD.scanDomains(): #[(fileDomUUID, file_domaindir)]
+ domDirs[domUUID] = domaindir
+ #domDirs contains only fileDomUUID: file_domainPath pairs until now.
+ #Add the block domains
+ blockDomUUIDs = [domUUID for domUUID in domUUIDs if domUUID not in
domDirs.iterkeys()]
+ for domUUID in blockDomUUIDs:
+ domaindir = os.path.join(block_mountpoint, domUUID)
+ domDirs[domUUID] = domaindir
+ # create domain special volumes folder
+ domMD = os.path.join(domaindir, sd.DOMAIN_META_DATA)
+ fileUtils.createdir(domMD)
+ #Link all the domains to the pool
+ for domUUID, domaindir in domDirs.iteritems():
linkName = os.path.join(self.poolPath, domUUID)
- if linkName in oldLinks:
- oldLinks.remove(linkName)
+ self._linkStorageDomain(domainDir, linkName)
+
# Always try to build master links
try:
self._refreshDomainLinks(msd)
@@ -890,13 +897,14 @@ class StoragePool:
# Cleanup old trash from the pool
for oldie in oldLinks:
- try:
- os.remove(oldie)
- except OSError as e:
- if e.errno != errno.ENOENT:
- self.log.warn("Could not clean all trash from the pool dom `%s`
(%s)", oldie, e)
- except Exception as e:
- self.log.warn("Could not clean all trash from the pool dom `%s`
(%s)", oldie, e)
+ if oldie not in domUUIDs:
+ try:
+ os.remove(oldie)
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ self.log.warn("Could not clean all trash from the pool dom
`%s` (%s)", oldie, e)
+ except Exception as e:
+ self.log.warn("Could not clean all trash from the pool dom
`%s` (%s)", oldie, e)
def refresh(self, msdUUID=None, masterVersion=None):