From: Mikhail Khodos Date: Tue, 17 Jun 2014 20:01:26 +0000 (+0400) Subject: Fixes an issue with 'dd' bug from Illumos repo X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=46f3b9912af501aed5a2d914183110303f1c9cc5;p=openstack-build%2Fcinder-build.git Fixes an issue with 'dd' bug from Illumos repo The Illumos version of 'dd' never stops in case of count=0. Thus 'truncate' should be used for creating a sparsed file. Change-Id: I7a1840e2c43a27c648e5f65c2a87286311a34516 --- diff --git a/cinder/tests/test_nexenta.py b/cinder/tests/test_nexenta.py index 2080f5ae2..341a284b5 100644 --- a/cinder/tests/test_nexenta.py +++ b/cinder/tests/test_nexenta.py @@ -555,9 +555,7 @@ class TestNexentaNfsDriver(test.TestCase): 'stack/share/volume-1', self.TEST_SHARE_OPTS) self.nms_mock.appliance.execute( - 'dd if=/dev/zero of=/volumes/stack/share/volume-1/volume bs=1M ' - 'count=0 seek=1024' - ) + 'truncate --size 1G /volumes/stack/share/volume-1/volume') self.nms_mock.appliance.execute('chmod ugo+rw ' '/volumes/stack/share/volume-1/volume') @@ -581,8 +579,7 @@ class TestNexentaNfsDriver(test.TestCase): volume) def test_create_sparsed_file(self): - self.nms_mock.appliance.execute('dd if=/dev/zero of=/tmp/path bs=1M ' - 'count=0 seek=1024') + self.nms_mock.appliance.execute('truncate --size 1G /tmp/path') self.mox.ReplayAll() self.drv._create_sparsed_file(self.nms_mock, '/tmp/path', 1) diff --git a/cinder/volume/drivers/nexenta/nfs.py b/cinder/volume/drivers/nexenta/nfs.py index d20cbf48f..7b92c44e2 100644 --- a/cinder/volume/drivers/nexenta/nfs.py +++ b/cinder/volume/drivers/nexenta/nfs.py @@ -277,14 +277,10 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921 :param path: path to new file :param size: size of file """ - block_size_mb = 1 - block_count = size * units.GiB / (block_size_mb * units.MiB) - nms.appliance.execute( - 'dd if=/dev/zero of=%(path)s bs=%(bs)dM count=0 seek=%(count)d' % { + 'truncate --size %(size)dG %(path)s' % { 'path': path, - 'bs': block_size_mb, - 'count': block_count + 'size': size } )