Bug 249067

Summary: dosfslabel fails to read/write label on device-mapper device
Product: Red Hat Enterprise Linux 5 Reporter: Jun'ichi NOMURA <junichi.nomura>
Component: dosfstoolsAssignee: Stepan Kasal <kasal>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: 5.3CC: daniel, dkovalsk, i-kitayama, kueda, lvm-team, m-ikeda, rvokal, syeghiay
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 483085 (view as bug list) Environment:
Last Closed: 2010-01-06 08:55:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 228988    
Attachments:
Description Flags
a patch for mkdosfs
none
reproducer shell script none

Description Jun'ichi NOMURA 2007-07-20 18:17:28 UTC
Description of problem:
  dosfslabel fails to read/write label on device-mapper device

Version-Release number of selected component:
  dosfstools-2.11-6.2.el5
  device-mapper-multipath-0.4.7-10.el5
  dmraid-1.0.0.rc13-2.el5

How reproducible:
  Always

Steps to Reproduce:
  1. Create DM device (multipath, dmraid, etc.)
  2. Execute dosfslabel to write a label on it

Actual results:
  # dosfslabel /dev/mapper/200301384044c0009p1 a
  Invalid disk format in boot sector.
  # dosfslabel /dev/mapper/200301384044c0009p1 
  Invalid disk format in boot sector.

Expected results:
  # dosfslabel /dev/mapper/200301384044c0009p1 a
  # dosfslabel /dev/mapper/200301384044c0009p1 
  a          

Additional Info:
  The same operation works on loop device.
    # losetup /dev/loop0 loopfile
    # mkdosfs /dev/loop0
    mkdosfs 2.11 (12 Mar 2005)
    Loop device does not match a floppy size, using default hd params
    # dosfslabel /dev/loop0 a
    # dosfslabel /dev/loop0
    a

  The problem is caused by the following reasons:
    1. dosfslabel checks the FAT superblock to see if the 'secs_track'
       and 'heads' values are non-zero (and they are actually zero),
    2. 'secs_track' and 'heads' are set by mkdosfs, the values came
       from the result of HDIO_GETGEO ioctl or the default ones if the ioctl
       fails (ioctl returns successful but all-zero result),
    3. unless user-space program specifically sets the geometry with
       dm_task_set_geometry() library call, device-mapper device returns
       all-zero geometry for HDIO_GETGEO ioctl (and neither multipath-tools,
       kpartx nor dmraid calls dm_task_set_geometry())

  Possible fix:
    a) Modify multipath-tools, kpartx and dmraid to set the geometry
       on the DM device
    b) Modify device-mapper to return -ENOTTY if the geometry isn't set
    c) Modify mkdosfs to use the default value if the returned geometry
       is all-zero
    d) Modify dosfslabel to ignore 'secs_track' and 'heads' being zero
 
  a) will be the most productive as it could solve other possible issues
  regarding the geometry and HDIO_GETGEO. But it will take time.

  Others are workaround.
  Attached is a patch to do c).

Comment 1 Jun'ichi NOMURA 2007-07-20 18:17:28 UTC
Created attachment 159671 [details]
a patch for mkdosfs

Comment 2 Jun'ichi NOMURA 2007-07-20 18:20:20 UTC
Created attachment 159672 [details]
reproducer shell script

Test script to do dosfslabel on DM device (on top of loop dev).

# sh dosfslabel-fail.sh 
1+0 records in
1+0 records out
1 byte (1 B) copied, 0.000104256 seconds, 9.6 kB/s
mkdosfs 2.11 (12 Mar 2005)
Invalid disk format in boot sector.
Invalid disk format in boot sector.
Invalid disk format in boot sector.
FAIL

Comment 3 RHEL Program Management 2007-12-03 20:44:18 UTC
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release.  This request will
be reviewed for a future Red Hat Enterprise Linux release.

Comment 9 Daniel Baumann 2009-12-24 09:07:57 UTC
Hi,

I could not reproduce this, it works fine with 3.0.6.

Regards,
Daniel

Comment 10 errata-xmlrpc 2010-01-06 08:55:13 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2010-0007.html