Merge "Handling Invalid argument iflag=direct in dd"
This commit is contained in:
commit
073f6bbb6b
@ -445,6 +445,20 @@ class OdirectSupportTestCase(test.TestCase):
|
||||
mock_exec.assert_called_once_with('dd', 'count=0', 'if=/dev/abc',
|
||||
'of=/dev/def', 'iflag=direct',
|
||||
run_as_root=True)
|
||||
mock_exec.reset_mock()
|
||||
|
||||
output = volume_utils.check_for_odirect_support('/dev/zero',
|
||||
'/dev/def',
|
||||
'iflag=direct')
|
||||
self.assertFalse(output)
|
||||
mock_exec.reset_mock()
|
||||
|
||||
output = volume_utils.check_for_odirect_support('/dev/zero',
|
||||
'/dev/def')
|
||||
self.assertTrue(output)
|
||||
mock_exec.assert_called_once_with('dd', 'count=0', 'if=/dev/zero',
|
||||
'of=/dev/def', 'oflag=direct',
|
||||
run_as_root=True)
|
||||
|
||||
@mock.patch('cinder.utils.execute',
|
||||
side_effect=processutils.ProcessExecutionError)
|
||||
@ -454,6 +468,13 @@ class OdirectSupportTestCase(test.TestCase):
|
||||
mock_exec.assert_called_once_with('dd', 'count=0', 'if=/dev/abc',
|
||||
'of=/dev/def', 'oflag=direct',
|
||||
run_as_root=True)
|
||||
mock_exec.reset_mock()
|
||||
output = volume_utils.check_for_odirect_support('/dev/zero',
|
||||
'/dev/def')
|
||||
self.assertFalse(output)
|
||||
mock_exec.assert_called_once_with('dd', 'count=0', 'if=/dev/zero',
|
||||
'of=/dev/def', 'oflag=direct',
|
||||
run_as_root=True)
|
||||
|
||||
|
||||
class ClearVolumeTestCase(test.TestCase):
|
||||
|
@ -299,9 +299,15 @@ def check_for_odirect_support(src, dest, flag='oflag=direct'):
|
||||
|
||||
# Check whether O_DIRECT is supported
|
||||
try:
|
||||
utils.execute('dd', 'count=0', 'if=%s' % src, 'of=%s' % dest,
|
||||
flag, run_as_root=True)
|
||||
return True
|
||||
# iflag=direct and if=/dev/zero combination does not work
|
||||
# error: dd: failed to open '/dev/zero': Invalid argument
|
||||
if (src == '/dev/zero' and flag == 'iflag=direct'):
|
||||
return False
|
||||
else:
|
||||
utils.execute('dd', 'count=0', 'if=%s' % src,
|
||||
'of=%s' % dest,
|
||||
flag, run_as_root=True)
|
||||
return True
|
||||
except processutils.ProcessExecutionError:
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user