]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes an issue with 'dd' bug from Illumos repo
authorMikhail Khodos <mikhail.khodos@nexenta.com>
Tue, 17 Jun 2014 20:01:26 +0000 (00:01 +0400)
committerMikhail Khodos <mikhail.khodos@nexenta.com>
Wed, 18 Jun 2014 06:11:26 +0000 (10:11 +0400)
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

cinder/tests/test_nexenta.py
cinder/volume/drivers/nexenta/nfs.py

index 2080f5ae2780ad9c88bc448a6ee9183c5bb74916..341a284b5a80b1f0e1695de671353fe14d736ade 100644 (file)
@@ -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)
index d20cbf48f25871e414976713b7d4b35ad5b90ba7..7b92c44e2994a08c1a9cece811075b5386a5a3b8 100644 (file)
@@ -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
             }
         )