Change in vdsm[master]: sp: Add resize PV verb

frolland at redhat.com frolland at redhat.com
Tue Mar 31 08:11:02 UTC 2015


Hello Fred Rolland,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/39382

to review the following change.

Change subject: sp: Add resize PV verb
......................................................................

sp: Add resize PV verb

This command calls pvresize on a device and returns the PV size.
The pvresize command is called only with the device path as parameter.

This command will extend the PV after a LUN was resized on the storage
server. It should be called after invoking Refresh Device verb,
otherwise the PV size will not increase.
This is a SPM operation.

The input parameters are : storage domain UUID, storage pool UUID and
device GUID.

Example outputs:

    $ vdsClient -s 0 resizePV d24ebee6-ec30-4270-88a2-a8f38a5a804a
        5966cee6-ee28-454c-96bc-e318bed1291a 360014057fac79f7f7dc4c15b29405f4e
        size = '36104568832'

    $ vdsClient -s 0 resizePV
      Error using command: Wrong number of arguments provided, expecting 3
      (3 required) got 0

      resizePV
          <sdUUID> <spUUID> <GUID>
          Resize PV in Storage Domain - update the PV size

Change-Id: I57e0fe4fad3e41cd6346b49623869c6d26afaa92
Bug-Url:https://bugzilla.redhat.com/609689
Signed-off-by: Fred Rolland <frolland at redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/rpc/Bridge.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/storage/blockSD.py
M vdsm/storage/hsm.py
M vdsm/storage/lvm.py
M vdsm/storage/sd.py
M vdsm/storage/sp.py
M vdsm/storage/storage_exception.py
11 files changed, 113 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/39382/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index 47cf383..a9120d9 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -799,6 +799,18 @@
             return dom['status']['code'], dom['status']['message']
         return 0, ''
 
+    def resizePV(self, args):
+        validateArgTypes(args, [str, str, str], requiredArgsNumber=3)
+        sdUUID = args[0]
+        spUUID = args[1]
+        guid = args[2]
+        res = self.s.resizePV(sdUUID, spUUID, guid)
+        if res['status']['code']:
+            return res['status']['code'], res['status']['message']
+        del res['status']
+        printDict(res, self.pretty)
+        return 0, ''
+
     def discoverST(self, args):
         portal = args[0].split(":")
         ip = portal[0]
@@ -2251,6 +2263,10 @@
                                  'Extend the Storage Domain by adding devices'
                                  ' devlist (list of dev GUIDs)'
                                  )),
+        'resizePV': (serv.resizePV,
+                     ('<sdUUID> <spUUID> <GUID>',
+                      'Resize PV in Storage Domain - update the PV size'
+                      )),
         'discoverST': (serv.discoverST,
                        ('ip[:port] [[username password] [auth=]]',
                         'Discover the available iSCSI targetnames on a '
diff --git a/vdsm/API.py b/vdsm/API.py
index a53d42c..1084cb1 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1013,6 +1013,9 @@
         return self._irs.extendStorageDomain(self._UUID, storagepoolID,
                                              devlist, force)
 
+    def resizePV(self, storagepoolID, guid):
+        return self._irs.resizePV(self._UUID, storagepoolID, guid)
+
     def format(self, autoDetach):
         return self._irs.formatStorageDomain(self._UUID, autoDetach)
 
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 1483736..2ad9563 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -632,6 +632,10 @@
         domain = API.StorageDomain(sdUUID)
         return domain.extend(spUUID, devlist, force)
 
+    def resizePV(self, sdUUID, spUUID, guid, options=None):
+        domain = API.StorageDomain(sdUUID)
+        return domain.resizePV(spUUID, guid)
+
     def domainFormat(self, sdUUID,
                      autoDetach=False, options=None):
         domain = API.StorageDomain(sdUUID)
@@ -1050,6 +1054,7 @@
                 (self.domainDetach, 'detachStorageDomain'),
                 (self.domainDetachForced, 'forcedDetachStorageDomain'),
                 (self.domainExtend, 'extendStorageDomain'),
+                (self.resizePV, 'resizePV'),
                 (self.domainFormat, 'formatStorageDomain'),
                 (self.domainGetFileStats, 'getFileStats'),
                 (self.domainGetImages, 'getImagesList'),
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index 15a2b1e..4a28b19 100644
--- a/vdsm/rpc/Bridge.py
+++ b/vdsm/rpc/Bridge.py
@@ -436,6 +436,7 @@
     'StorageDomain_getInfo': {'ret': 'info'},
     'StorageDomain_getStats': {'ret': 'stats'},
     'StorageDomain_getVolumes': {'ret': 'uuidlist'},
+    'StorageDomain_resizePV': {'ret': 'size'},
     'StoragePool_connectStorageServer': {'ret': 'statuslist'},
     'StoragePool_disconnectStorageServer': {'ret': 'statuslist'},
     'StoragePool_fence': {'ret': 'spm_st'},
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index fd3952d..3482686 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -5087,6 +5087,27 @@
           'devlist': ['str'], '*force': 'bool'}}
 
 ##
+# @StorageDomain.resizePV:
+#
+# Resize PV and return the size after resize.
+#
+# @storagedomainID:  The UUID of the Storage Domain
+#
+# @storagepoolID:    The UUID of the Storage Pool
+#
+# @guid:  A block device GUID
+#
+# Returns:
+# The size in bytes of the device after resize
+#
+# Since: 4.17.0
+##
+{'command': {'class': 'StorageDomain', 'name': 'resizePV'},
+ 'data': {'storagedomainID': 'UUID', 'storagepoolID': 'UUID',
+          'guid': ['UUID']},
+  'returns': 'str'}
+
+##
 # @StorageDomain.format:
 #
 # Format a storage domain and erase all of its data.
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index caaef6b..3f74512 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -711,6 +711,9 @@
             newsize = self.metaSize(self.sdUUID)
             lvm.extendLV(self.sdUUID, sd.METADATA, newsize)
 
+    def resizePV(selfself, guid):
+        lvm.resizePV(guid)
+
     def getVolumeMetadataSlot(self, vol_name, slotSize):
         if self.getVersion() in VERS_METADATA_LV:
             return self.getVolumeMetadataOffsetFromPvMapping(vol_name)
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index d5ba6e8..6efce4c 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -761,6 +761,34 @@
                        in guids)
         pool.extendSD(sdUUID, dmDevs, force)
 
+    @public
+    def resizePV(self, sdUUID, spUUID, guid, options=None):
+        """
+        Calls pvresize with specified pv guid
+        and returns the size after the resize
+
+        :param sdUUID: The UUID of the storage domain that owns the VG.
+        :type sdUUID: UUID
+        :param spUUID: The UUID of the storage pool that owns the VG.
+        :type spUUID: UUID
+        :param guid: PV UUID to resize.
+        :type guid: UUID
+        :param options: unused
+        :returns: dictionary with one item :size
+        :rtype: dict
+        """
+        vars.task.setDefaultException(
+            se.StorageDomainActionError(
+                "sdUUID=%s, PV=%s" % (sdUUID, guid)))
+
+        vars.task.getSharedLock(STORAGE, sdUUID)
+        # We need to let the domain to resize the PV
+        pool = self.getPool(spUUID)
+        pool.resizePV(sdUUID, guid)
+
+        pv = lvm.getPV(guid)
+        return dict(size=str(pv.size))
+
     def _deatchStorageDomainFromOldPools(self, sdUUID):
         # We are called with blank pool uuid, to avoid changing exiting
         # API which we want to drop in next version anyway.
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 50702f4..fba946e 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -905,6 +905,30 @@
         return lv
 
 
+def resizePV(guid):
+    """
+    In case the LUN was increased on storage server, in order to see the
+    changes it is needed to resize the PV after the multipath devices have
+    been resized
+
+    This method calls pvresize without only the PV name as parameter
+
+    Raises se.CouldNotResizePhysicalVolume if pvresize fails
+
+    """
+    log.debug("Resizing PV %r", guid)
+    cmd = ["pvresize"]
+    cmd.append(_fqpvname(guid))
+    rc, out, err = _lvminfo.cmd(cmd)
+    if rc != 0:
+        log.error("pvresize failed with rc=%s", rc)
+        log.error("%s, %s", out, err)
+        raise se.CouldNotResizePhysicalVolume("Error pvresize PV %s: %s"
+                                              (guid, str(err)))
+    invalidateCache()
+    log.debug("Resizing PV %r finished", guid)
+
+
 #
 # Public Volume Group interface
 #
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index a771abf..865cb39 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -794,6 +794,9 @@
     def extend(self, devlist, force):
         pass
 
+    def resizePV(self, guid):
+        pass
+
     def isMaster(self):
         return self.getMetaParam(DMDK_ROLE).capitalize() == MASTER_DOMAIN
 
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 34a8fbf..8574bac 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -1946,6 +1946,10 @@
         self.validatePoolSD(sdUUID)
         sdCache.produce(sdUUID).extend(devlist, force)
 
+    def resizePV(self, sdUUID, guid):
+        self.validatePoolSD(sdUUID)
+        sdCache.produce(sdUUID).resizePV(guid)
+
     def setSDDescription(self, sd, description):
         self.validatePoolSD(sd.sdUUID)
         sd.setDescription(descr=description)
diff --git a/vdsm/storage/storage_exception.py b/vdsm/storage/storage_exception.py
index 1cfc8e4..8a78584 100644
--- a/vdsm/storage/storage_exception.py
+++ b/vdsm/storage/storage_exception.py
@@ -1514,6 +1514,11 @@
                  issue and how to resolve it"""
 
 
+class CouldNotResizePhysicalVolume(StorageException):
+    code = 615
+    message = "Could not resize pv"
+
+
 #################################################
 #  SPM/HSM Exceptions
 #################################################


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I57e0fe4fad3e41cd6346b49623869c6d26afaa92
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Freddy Rolland <frolland at redhat.com>
Gerrit-Reviewer: Fred Rolland <frolland at redhat.com>


More information about the vdsm-patches mailing list