dd iflag/oflag set invalid argument

Bug #1318748 reported by Zhou Yu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Zhou Yu

Bug 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, flag
                              *extra_flags, run_as_root=True)
              extra_flags .append(flag)
    except processutils.ProcessExecutionError:
                pass

Zhou Yu (vitas-yuzhou)
Changed in cinder:
assignee: nobody → Zhou Yu (vitas-yuzhou)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/93461

Zhou Yu (vitas-yuzhou)
Changed in cinder:
status: New → In Progress
Zhou Yu (vitas-yuzhou)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/93461
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=2448ffd53bd224564b8fca17e4cbbace2e039597
Submitter: Jenkins
Branch: master

commit 2448ffd53bd224564b8fca17e4cbbace2e039597
Author: vitas.yuzhou <email address hidden>
Date: Tue May 13 02:57:48 2014 +0800

    Check whether O_DIRECT is supported to iflag and oflag separately

    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, but oflag direct is a valid
    option for output file, so we should check iflag and oflag separately.

    Change-Id: I4b627e95b68d56e3011cddc577c62fad0c384dba
    Close-Bug: 1318748

Zhou Yu (vitas-yuzhou)
Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
Thierry Carrez (ttx) wrote :

Do not set to FixReleased until it made it to a milestone.

Changed in cinder:
status: Fix Released → Fix Committed
Thierry Carrez (ttx)
Changed in cinder:
milestone: none → juno-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: juno-1 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.