Shahar Havivi has uploaded a new change for review.

Change subject: Remove sparsify from vdsm
......................................................................

Remove sparsify from vdsm

We are changing the sparsify image to in place sparsify image,
e.g. no need for a new image in order to sparsify the image.

Next patch will present the new spasify method.

Change-Id: I2d2b86035b6cc6ec74a403c3379d0b384fb6f23e
Signed-off-by: Shahar Havivi <shah...@redhat.com>
---
M client/vdsClient.py
M lib/api/vdsmapi-schema.json
M lib/vdsm/Makefile.am
M lib/vdsm/rpc/bindingxmlrpc.py
D lib/vdsm/virtsparsify.py
M tests/Makefile.am
M tests/crossImportsTests.py.in
D tests/sparsifyTests.py
M vdsm.spec.in
M vdsm/API.py
M vdsm/storage/hsm.py
M vdsm/storage/image.py
M vdsm/storage/sp.py
M vdsm/storage/storage_exception.py
14 files changed, 0 insertions(+), 287 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/54426/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index ca4fe2c..957020b 100755
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1409,16 +1409,6 @@
             return image['status']['code'], image['status']['message']
         return 0, image['uuid']
 
-    def sparsifyImage(self, args):
-        (spUUID, tmpSdUUID, tmpImgUUID, tmpVolUUID, dstSdUUID, dstImgUUID,
-         dstVolUUID) = args
-        status = self.s.sparsifyImage(spUUID, tmpSdUUID, tmpImgUUID,
-                                      tmpVolUUID, dstSdUUID, dstImgUUID,
-                                      dstVolUUID)
-        if status['status']['code']:
-            return status['status']['code'], status['status']['message']
-        return 0, status['uuid']
-
     def cloneImageStructure(self, args):
         spUUID, sdUUID, imgUUID, dstSdUUID = args
         image = self.s.cloneImageStructure(spUUID, sdUUID, imgUUID, dstSdUUID)
diff --git a/lib/api/vdsmapi-schema.json b/lib/api/vdsmapi-schema.json
index 0fc210d..a9f43ef 100644
--- a/lib/api/vdsmapi-schema.json
+++ b/lib/api/vdsmapi-schema.json
@@ -5092,33 +5092,6 @@
  'returns': 'UUID'}
 
 ##
-# @Image.sparsify:
-#
-# Create a copy of a sparse volume to a destination volume within the same
-# Storage Pool with free space removed from the source volume.
-#
-# @imageID:          The UUID of the Image
-#
-# @storagepoolID:    The UUID of the Storage Pool associated with the Image
-#
-# @storagedomainID:  The UUID of the Storage Domain associated with the Image
-#
-# @tmpVolUUID:       The UUID of the snapshot volume
-#
-# @dstSdUUID:        The UUID of the destination storage domain
-#
-# @dstImgUUID:       The UUID of the destination image
-#
-# @dstVolUUID:       The UUID of the destination volume
-#
-# Since: 4.17.0
-##
-{'command': {'class': 'Image', 'name': 'sparsify'},
- 'data': {'imageID': 'UUID', 'storagepoolID': 'UUID',
-          'storagedomainID': 'UUID', 'tmpVolUUID': 'UUID', 'dstSdUUID': 'UUID',
-          'dstImgUUID': 'UUID', 'dstVolUUID': 'UUID'}}
-
-##
 # @Image.cloneStructure:
 #
 # Clone an image structure from a source domain to a destination domain
diff --git a/lib/vdsm/Makefile.am b/lib/vdsm/Makefile.am
index 69eb968..fb63dd3 100644
--- a/lib/vdsm/Makefile.am
+++ b/lib/vdsm/Makefile.am
@@ -63,7 +63,6 @@
        utils.py \
        v2v.py \
        vdscli.py \
-       virtsparsify.py \
        xmlrpc.py \
        $(NULL)
 
diff --git a/lib/vdsm/rpc/bindingxmlrpc.py b/lib/vdsm/rpc/bindingxmlrpc.py
index 5ead04d..7184fb9 100644
--- a/lib/vdsm/rpc/bindingxmlrpc.py
+++ b/lib/vdsm/rpc/bindingxmlrpc.py
@@ -742,11 +742,6 @@
         image = API.Image(imgUUID, spUUID, srcDomUUID)
         return image.move(dstDomUUID, op, postZero, force)
 
-    def imageSparsify(self, spUUID, sdUUID, imgUUID, tmpVolUUID, dstSdUUID,
-                      dstImgUUID, dstVolUUID):
-        image = API.Image(imgUUID, spUUID, sdUUID)
-        return image.sparsify(tmpVolUUID, dstSdUUID, dstImgUUID, dstVolUUID)
-
     def imageCloneStructure(self, spUUID, sdUUID, imgUUID, dstSdUUID):
         image = API.Image(imgUUID, spUUID, sdUUID)
         return image.cloneStructure(dstSdUUID)
@@ -1138,7 +1133,6 @@
                 (self.imageDeleteVolumes, 'deleteVolume'),
                 (self.imageMergeSnapshots, 'mergeSnapshots'),
                 (self.imageMove, 'moveImage'),
-                (self.imageSparsify, 'sparsifyImage'),
                 (self.imageCloneStructure, 'cloneImageStructure'),
                 (self.imageSyncData, 'syncImageData'),
                 (self.imageUpload, 'uploadImage'),
diff --git a/lib/vdsm/virtsparsify.py b/lib/vdsm/virtsparsify.py
deleted file mode 100644
index 44ed778..0000000
--- a/lib/vdsm/virtsparsify.py
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Copyright 2014 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# Refer to the README and COPYING files for full details of the license
-#
-
-from __future__ import absolute_import
-import signal
-
-from . import cmdutils
-from . import commands
-from . import utils
-
-# Fedora, EL6
-_VIRTSPARSIFY = utils.CommandPath("virt-sparsify",
-                                  "/usr/bin/virt-sparsify",)
-
-
-def sparsify(src_vol, tmp_vol, dst_vol, src_format=None, dst_format=None):
-    """
-    Sparsify the 'src_vol' volume (src_format) to 'dst_vol' volume (dst_format)
-    using libguestfs virt-sparsify
-
-    src_vol: path of base volume
-    tmp_vol: path of temporary volume created with src_vol as backing volume
-    dst_vol: path of destination volume
-    src_format: format of base volume ('raw' or `qcow2')
-    src_format: format of destination volume ('raw' or `qcow2')
-    """
-    cmd = [_VIRTSPARSIFY.cmd, '--tmp', 'prebuilt:' + tmp_vol]
-
-    if src_format:
-        cmd.extend(("--format", src_format))
-
-    if dst_format:
-        cmd.extend(("--convert", dst_format))
-
-    cmd.extend((src_vol, dst_vol))
-
-    rc, out, err = commands.execCmd(cmd, deathSignal=signal.SIGKILL)
-
-    if rc != 0:
-        raise cmdutils.Error(cmd, rc, out, err)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cc71074..903ed17 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -108,7 +108,6 @@
        sdm_indirection_tests.py \
        securableTests.py \
        sourceroutingTests.py \
-       sparsifyTests.py \
        sslTests.py \
        stompAdapterTests.py \
        stompAsyncClientTests.py \
diff --git a/tests/crossImportsTests.py.in b/tests/crossImportsTests.py.in
index 225f81a..87555e7 100644
--- a/tests/crossImportsTests.py.in
+++ b/tests/crossImportsTests.py.in
@@ -51,7 +51,6 @@
             # some random samples. Some names must include 'p', 'y', 'c'
             Mod("response.py", "response"),
             Mod("cmdutils.py", "cmdutils"),
-            Mod("virtsparsify.py", "virtsparsify"),
             Mod("pthread.py", "pthread"),
             Mod("constants.py", "constants"),
             Mod("compat.py", "compat"),
diff --git a/tests/sparsifyTests.py b/tests/sparsifyTests.py
deleted file mode 100644
index f99b0c8..0000000
--- a/tests/sparsifyTests.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright 2015 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-#
-# Refer to the README and COPYING files for full details of the license
-#
-
-from vdsm import cmdutils
-from vdsm import virtsparsify
-
-from monkeypatch import MonkeyPatch
-from testlib import VdsmTestCase as TestCaseBase
-
-
-FAKE_VOLUME = '/we/dont/care/about/this/path'
-
-
-class FakeCommand(object):
-    # as per manpage, false ignores any argument
-    cmd = '/bin/false'
-
-
-class VirtSparsifyTests(TestCaseBase):
-
-    @MonkeyPatch(virtsparsify, '_VIRTSPARSIFY', FakeCommand())
-    def test_raise_error_on_failure(self):
-
-        self.assertRaises(cmdutils.Error,
-                          virtsparsify.sparsify,
-                          FAKE_VOLUME, FAKE_VOLUME, FAKE_VOLUME)
diff --git a/vdsm.spec.in b/vdsm.spec.in
index b1873b8..5f9125f 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1165,7 +1165,6 @@
 %{python_sitelib}/%{vdsm_name}/utils.py*
 %{python_sitelib}/%{vdsm_name}/v2v.py*
 %{python_sitelib}/%{vdsm_name}/vdscli.py*
-%{python_sitelib}/%{vdsm_name}/virtsparsify.py*
 %{python_sitelib}/%{vdsm_name}/xmlrpc.py*
 %{python_sitelib}/%{vdsm_name}/tool/__init__.py*
 %{python_sitelib}/%{vdsm_name}/tool/configfile.py*
diff --git a/vdsm/API.py b/vdsm/API.py
index ab3ff05..185a46c 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -936,11 +936,6 @@
                                    self._UUID, vmUUID, operation, postZero,
                                    force)
 
-    def sparsify(self, tmpVolUUID, dstSdUUID, dstImgUUID, dstVolUUID):
-        return self._irs.sparsifyImage(self._spUUID, self._sdUUID, self._UUID,
-                                       tmpVolUUID, dstSdUUID, dstImgUUID,
-                                       dstVolUUID)
-
     def cloneStructure(self, dstSdUUID):
         return self._irs.cloneImageStructure(self._spUUID, self._sdUUID,
                                              self._UUID, dstSdUUID)
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 019fb8c..53b9f93 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1629,25 +1629,6 @@
             misc.parseBool(force))
 
     @public
-    def sparsifyImage(self, spUUID, tmpSdUUID, tmpImgUUID, tmpVolUUID,
-                      dstSdUUID, dstImgUUID, dstVolUUID):
-        """
-        Reduce sparse image size by converting free space on image to free
-        space on storage domain using virt-sparsify.
-        """
-
-        pool = self.getPool(spUUID)
-
-        sdUUIDs = sorted(set((tmpSdUUID, dstSdUUID)))
-
-        for dom in sdUUIDs:
-            vars.task.getSharedLock(STORAGE, dom)
-
-        self._spmSchedule(spUUID, "sparsifyImage", pool.sparsifyImage,
-                          tmpSdUUID, tmpImgUUID, tmpVolUUID, dstSdUUID,
-                          dstImgUUID, dstVolUUID)
-
-    @public
     def cloneImageStructure(self, spUUID, sdUUID, imgUUID, dstSdUUID):
         """
         Clone an image structure (volume chain) to a destination domain within
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index a5c088d..d0e46fc 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -26,7 +26,6 @@
 
 import volume
 from vdsm import qemuimg
-from vdsm import virtsparsify
 from vdsm.config import config
 from sdc import sdCache
 import sd
@@ -581,74 +580,6 @@
         self.log.info("%s task on image %s was successfully finished",
                       OP_TYPES[op], imgUUID)
         return True
-
-    def _getSparsifyVolume(self, sdUUID, imgUUID, volUUID):
-        # FIXME:
-        # sdCache.produce.produceVolume gives volumes that return getVolumePath
-        # with a colon (:) for NFS servers. So, we're using volClass().
-        # https://bugzilla.redhat.com/1128942
-        # If, and when the bug gets solved, use
-        # sdCache.produce(...).produceVolume(...) to create the volumes.
-        volClass = sdCache.produce(sdUUID).getVolumeClass()
-        return volClass(self.repoPath, sdUUID, imgUUID, volUUID)
-
-    def sparsify(self, tmpSdUUID, tmpImgUUID, tmpVolUUID, dstSdUUID,
-                 dstImgUUID, dstVolUUID):
-        """
-        Reduce sparse image size by converting free space on image to free
-        space on storage domain using virt-sparsify.
-        """
-        self.log.info("tmpSdUUID=%s, tmpImgUUID=%s, tmpVolUUID=%s, "
-                      "dstSdUUID=%s, dstImgUUID=%s, dstVolUUID=%s", tmpSdUUID,
-                      tmpImgUUID, tmpVolUUID, dstSdUUID, dstImgUUID,
-                      dstVolUUID)
-
-        tmpVolume = self._getSparsifyVolume(tmpSdUUID, tmpImgUUID, tmpVolUUID)
-        dstVolume = self._getSparsifyVolume(dstSdUUID, dstImgUUID, dstVolUUID)
-
-        if not dstVolume.isSparse():
-            raise se.VolumeNotSparse()
-
-        srcVolume = self._getSparsifyVolume(tmpSdUUID, tmpImgUUID,
-                                            tmpVolume.getParent())
-
-        tmpVolume.prepare()
-        try:
-            dstVolume.prepare()
-            try:
-                # By definition "sparsification" is implemented writing a file
-                # with zeroes as large as the entire file-system. So at least
-                # tmpVolume needs to be as large as the virtual disk size for
-                # the worst case.
-                # TODO: Some extra space may be needed for QCOW2 headers
-                tmpVolume.extend(tmpVolume.getSize())
-                # For the dstVolume we may think of an optimization where the
-                # extension is as large as the source (and at the end we
-                # shrinkToOptimalSize).
-                # TODO: Extend the dstVolume only as much as the actual size of
-                # srcVolume
-                # TODO: Some extra space may be needed for QCOW2 headers
-                dstVolume.extend(tmpVolume.getSize())
-
-                srcFormat = volume.fmt2str(srcVolume.getFormat())
-                dstFormat = volume.fmt2str(dstVolume.getFormat())
-
-                virtsparsify.sparsify(srcVolume.getVolumePath(),
-                                      tmpVolume.getVolumePath(),
-                                      dstVolume.getVolumePath(),
-                                      src_format=srcFormat,
-                                      dst_format=dstFormat)
-            except Exception:
-                self.log.exception('Unexpected error sparsifying %s',
-                                   tmpVolUUID)
-                raise se.CannotSparsifyVolume(tmpVolUUID)
-            finally:
-                dstVolume.teardown(sdUUID=dstSdUUID, volUUID=dstVolUUID)
-        finally:
-            tmpVolume.teardown(sdUUID=tmpSdUUID, volUUID=tmpVolUUID)
-
-        tmpVolume.shrinkToOptimalSize()
-        dstVolume.shrinkToOptimalSize()
 
     def cloneStructure(self, sdUUID, imgUUID, dstSdUUID):
         self._createTargetImage(sdCache.produce(dstSdUUID), sdUUID, imgUUID)
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 5c1a42f..696f42b 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -1618,48 +1618,6 @@
             image.Image(self.poolPath).move(srcDomUUID, dstDomUUID, imgUUID,
                                             vmUUID, op, postZero, force)
 
-    def sparsifyImage(self, tmpSdUUID, tmpImgUUID, tmpVolUUID, dstSdUUID,
-                      dstImgUUID, dstVolUUID):
-        """
-        Reduce sparse image size by converting free space on image to free
-        space on host using virt-sparsify.
-
-        :param tmpSdUUID: The UUID of the storage domain where the temporary
-                            snapshot of source volume exists.
-        :type tmpSdUUID: UUUID
-        :param tmpImgUUID: The UUID of the temporary snapshot image.
-        :type tmpImgUUID: UUID
-        :param tmpVolUUID: The UUID of the temporary snapshot volume that needs
-                            to be sparsified.
-        :type tmpVolUUID: UUID
-        :param dstSdUUID: The UUID of the storage domain where the destination
-                            image exists.
-        :type dstSdUUID: UUUID
-        :param dstImgUUID: The UUID of the destination image to which the
-                            destination volume belongs.
-        :type dstImgUUID: UUID
-        :param dstVolUUID: The UUID of the destination volume for the
-                            sparsified volume.
-        :type dstVolUUID: UUID
-        """
-        srcNamespace = sd.getNamespace(tmpSdUUID, IMAGE_NAMESPACE)
-        dstNamespace = sd.getNamespace(dstSdUUID, IMAGE_NAMESPACE)
-
-        # virt-sparsify writes to temporary volume when using --tmp:prebuilt,
-        # so we acquire exclusive lock for the temporary image.
-        # Destination image is where the sparsified volume gets written to, so
-        # we acquire exclusive lock for the destination image too.
-        # Since source volume is only a parent of temporary volume, we don't
-        # need to acquire any lock for it.
-        with nested(
-            rmanager.acquireResource(srcNamespace, tmpImgUUID,
-                                     rm.LockType.exclusive),
-            rmanager.acquireResource(dstNamespace, dstImgUUID,
-                                     rm.LockType.exclusive)):
-            image.Image(self.poolPath).sparsify(
-                tmpSdUUID, tmpImgUUID, tmpVolUUID, dstSdUUID, dstImgUUID,
-                dstVolUUID)
-
     def cloneImageStructure(self, sdUUID, imgUUID, dstSdUUID):
         """
         Clone an image structure from a source domain to a destination domain
diff --git a/vdsm/storage/storage_exception.py 
b/vdsm/storage/storage_exception.py
index b01b6f5..6c8209e 100644
--- a/vdsm/storage/storage_exception.py
+++ b/vdsm/storage/storage_exception.py
@@ -334,11 +334,6 @@
     message = "Volume type is not sparse"
 
 
-class CannotSparsifyVolume(StorageException):
-    code = 234
-    message = "Cannot sparsify volume"
-
-
 #################################################
 #  Images Exceptions
 #################################################


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d2b86035b6cc6ec74a403c3379d0b384fb6f23e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <shav...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to