From 4e3180c76629215d315921436ef19788ed49d2ab Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Fri, 15 May 2015 13:23:08 -0400 Subject: [PATCH] Add ability for drivers to copy data preserving sparseness 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 | 7 ++++++- cinder/volume/drivers/nfs.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index dd3566041..970449695 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -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(): diff --git a/cinder/volume/drivers/nfs.py b/cinder/volume/drivers/nfs.py index dbe77e2b2..9d140aa83 100644 --- a/cinder/volume/drivers/nfs.py +++ b/cinder/volume/drivers/nfs.py @@ -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: -- 2.45.2