2014-05-14 08:46:46 |
Zhou Yu |
description |
The copy volume function (cinder/volume/utils:copy_volume()) which is used for clear volume can set iflag and oflag to direct.
The problem is when this is used for volume clear and the clear method specifies use of the 'zero' option (/dev/zero) setting iflag direct is not a valid option for that input file and results in an erro:
[root@openstack home]# dd if=/dev/zero of=/home/test iflag=direct bs=1M count=100
dd: opening `/dev/zero': Invalid argument
But, oflag is vaild argument.
[root@openstack home]# dd if=/dev/zero of=/home/test oflag=direct bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.367249 s, 286 MB/s
currently,the code is :
# Use O_DIRECT to avoid thrashing the system buffer cache
extra_flags = ['iflag=direct', 'oflag=direct']
# Check whether O_DIRECT is supported
try:
execute('dd', 'count=0', 'if=%s' % srcstr, 'of=%s' % deststr,
*extra_flags, run_as_root=True)
except processutils.ProcessExecutionError:
extra_flags = []
I think we should test dd iflag=direct and oflag=direct separately, like this:
# Use O_DIRECT to avoid thrashing the system buffer cache
extra_flags = []
# Check whether O_DIRECT is supported
for flag in ['iflag=direct', 'oflag=direct']:
try:
execute('dd', 'count=0', 'if=%s' % srcstr, 'of=%s' % destdev,
*extra_flags, run_as_root=True)
extra_flags .append(flag)
except processutils.ProcessExecutionError:
pass |
The copy volume function (cinder/volume/utils:copy_volume()) which is used for clear volume can set iflag and oflag to direct.
The problem is when this is used for volume clear and the clear method specifies use of the 'zero' option (/dev/zero) setting iflag direct is not a valid option for that input file and results in an erro:
[root@openstack home]# dd if=/dev/zero of=/home/test iflag=direct bs=1M count=100
dd: opening `/dev/zero': Invalid argument
But, oflag is vaild argument.
[root@openstack home]# dd if=/dev/zero of=/home/test oflag=direct bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.367249 s, 286 MB/s
currently,the code is :
# Use O_DIRECT to avoid thrashing the system buffer cache
extra_flags = ['iflag=direct', 'oflag=direct']
# Check whether O_DIRECT is supported
try:
execute('dd', 'count=0', 'if=%s' % srcstr, 'of=%s' % deststr,
*extra_flags, run_as_root=True)
except processutils.ProcessExecutionError:
extra_flags = []
I think we should test dd iflag=direct and oflag=direct separately, like this:
# Use O_DIRECT to avoid thrashing the system buffer cache
extra_flags = []
# Check whether O_DIRECT is supported
for flag in ['iflag=direct', 'oflag=direct']:
try:
execute('dd', 'count=0', 'if=%s' % srcstr, 'of=%s' % destdev, flag
*extra_flags, run_as_root=True)
extra_flags .append(flag)
except processutils.ProcessExecutionError:
pass |
|