]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add ability for drivers to copy data preserving sparseness
authorEric Harney <eharney@redhat.com>
Fri, 15 May 2015 17:23:08 +0000 (13:23 -0400)
committerEric Harney <eharney@redhat.com>
Fri, 15 May 2015 18:08:34 +0000 (14:08 -0400)
Drivers can set self._sparse_copy_volume_data to opt in
to copying data in a way that preserves sparseness.

This is likely to be desired elsewhere, but currently this
patch only enables it for the NFS driver and provides a
method for other drivers to opt in, in case there are
unexpected issues in some drivers.

On the NFS driver, this prevents volume migration from
changing a volume file from sparse to fully allocated.

Change-Id: Ib74b2fb4015b805d33de42dfe60c8a97cc970b84
Closes-Bug: #1455595

cinder/volume/driver.py
cinder/volume/drivers/nfs.py

index dd3566041c6c0594921d4f71f191c7fa03168c73..9704496956430ec7ec3ce9ea2e9a7f35bbd7819e 100644 (file)
@@ -299,6 +299,10 @@ class BaseVD(object):
         # set True by manager after successful check_for_setup
         self._initialized = False
 
+        # Copy volume data in a sparse fashion.
+        #  (overload in drivers where this is desired)
+        self._sparse_copy_volume_data = False
+
     def _is_non_recoverable(self, err, non_recoverable_list):
         for item in non_recoverable_list:
             if item in err:
@@ -528,7 +532,8 @@ class BaseVD(object):
                 dest_attach_info['device']['path'],
                 size_in_mb,
                 self.configuration.volume_dd_blocksize,
-                throttle=self._throttle)
+                throttle=self._throttle,
+                sparse=self._sparse_copy_volume_data)
             copy_error = False
         except Exception:
             with excutils.save_and_reraise_exception():
index dbe77e2b246741b8a3c1ee6d9b97fae52e311359..9d140aa834be8cb11983877e99f6e7c800c81236 100644 (file)
@@ -108,6 +108,8 @@ class NfsDriver(remotefs.RemoteFSDriver):
             nfs_mount_point_base=self.base,
             nfs_mount_options=opts)
 
+        self._sparse_copy_volume_data = True
+
     def set_execute(self, execute):
         super(NfsDriver, self).set_execute(execute)
         if self._remotefsclient: