Bug 490121 - dmraid command fails in liveCD
Summary: dmraid command fails in liveCD
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dmraid
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Hans de Goede
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 489068 (view as bug list)
Depends On:
Blocks: 496835
TreeView+ depends on / blocked
 
Reported: 2009-03-13 12:51 UTC by Joel Andres Granados
Modified: 2009-04-22 13:59 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 496835 (view as bug list)
Environment:
Last Closed: 2009-04-20 19:04:08 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Get last 16 characters from serial number when this is > than MAX_RAID_SERIAL_LEN (683 bytes, patch)
2009-03-14 21:27 UTC, Alberto Patino
no flags Details | Diff
PATCH adding support for longer disk serial numbers (2.85 KB, patch)
2009-04-10 12:59 UTC, Hans de Goede
no flags Details | Diff

Description Joel Andres Granados 2009-03-13 12:51:20 UTC
A report to anaconda resulted in a user finding an issue with dmraid in liveCD.  look at https://bugzilla.redhat.com/show_bug.cgi?id=470543#c27.  The reporter provided a patch.

Anaconda has a tracker bug used to track all the dmraid related issues and this bug is getting duped so we can have one point of entrance for dmraid issues.  Im opening a new bug for dmraid in case this has not been reported and the patch is relevant.

Comment 1 Alberto Patino 2009-03-14 21:20:59 UTC
Summary:

dmraid uses ioctl() function to get disk info (so do hdparm command), isw raid metadata contains also disk serial numbers. dmraid validates serial number obtained from ioctl() against serial data obtained from raid medatata. However, for my particular hardware configuration serial number from ioctl() is "090114FC3D00NJG3ZDYD" and serial number from isw metadata is "14FC3D00NJG3ZDYD"
This causes error:

sh-4.0# dmraid -s
ERROR: isw: Could not find disk /dev/sdb in the metadata
ERROR: isw: Could not find disk /dev/sda in the metadata

Detail:

I have run F10 Live CD, and I have also installed dmraid src rpm from rawhide
repo, after debugging the program dmraid I have narrowed my particular problem
(Dell Precision M6400):

[root@localhost ~]# hdparm -i /dev/sda

/dev/sda:

 Model=Hitachi HTS723225L9A362                 , FwRev=FCDOC30F,  SerialNo=090114FC3D00NJG3ZDYD
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=DualPortCache, BuffSize=15058kB, MaxMultSect=16, MultSect=?0?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=488397168
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
 AdvancedPM=yes: mode=0x80 (128) WriteCache=enabled
 Drive conforms to: unknown:  ATA/ATAPI-2,3,4,5,6,7

ioctl function returns serial number for di struct with this:
(gdb) p *di
$16 = {list = {next = 0x63f900, prev = 0x63f900}, path = 0x63f8e0 "/dev/sda",
serial = 0x63f930 "090114FC3D00NJG3ZDYD", sectors = 488397168}

and isw disk metadata info has this:

(gdb) p *isw
$25 = {sig = "Intel Raid ISM Cfg Sig. 1.0.00\000", check_sum = 4095911876,
mpb_size = 480, family_num = 3938914151, generation_num = 196, 
  error_log_size = 4080, attributes = 2147483648, num_disks = 2 '\002',
num_raid_devs = 1 '\001', error_log_pos = 2 '\002', fill = "", cache_size = 0, 
  orig_family_num = 3938914151, filler = {94, 0 <repeats 36 times>}, disk =
{{serial = "14FC3D00NJG3ZDYD", totalBlocks = 488397168, scsiId = 0, 
      status = 314, owner_cfg_num = 0, filler = {0, 0, 0, 0}}}}

(gdb) p isw->disk[0]
$26 = {serial = "14FC3D00NJG3ZDYD", totalBlocks = 488397168, scsiId = 0, status
= 314, owner_cfg_num = 0, filler = {0, 0, 0, 0}}

(gdb) p isw->disk[1]
$27 = {serial = "14FC3D00NJG3ZJ6D", totalBlocks = 488397168, scsiId = 262144,
status = 314, owner_cfg_num = 0, filler = {0, 0, 0, 0}}

The function _get_disk try to match serial number from di->serial
("090114FC3D00NJG3ZDYD") with serial number frow isw->disk[0].serial
("14FC3D00NJG3ZDYD"), but seriial number from ioctl has a 4 byte prefix that
causes the problem 

Patch: (Also attached)

--- lib/format/ataraid/isw.old	2009-03-10 23:05:09.000000000 -0400
+++ lib/format/ataraid/isw.c	2009-03-10 23:19:45.000000000 -0400
@@ -84,12 +84,18 @@
 static struct isw_disk *
 _get_disk(struct isw *isw, struct dev_info *di)
 {
+	size_t serial_len, serial_off;
+
 	if (di->serial) {
 		int i = isw->num_disks;
 		struct isw_disk *disk = isw->disk;
 
 		while (i--) {
-			if (!strncmp(di->serial, (const char *) disk[i].serial,
+			serial_off = ((serial_len=strlen(di->serial)) > MAX_RAID_SERIAL_LEN) ?
+						serial_len - MAX_RAID_SERIAL_LEN : 0;
+
+
+			if (!strncmp(di->serial+serial_off, (const char *) disk[i].serial,
 				     MAX_RAID_SERIAL_LEN))
 				return disk + i;
 		}

Comment 2 Alberto Patino 2009-03-14 21:27:46 UTC
Created attachment 335230 [details]
Get last 16 characters from serial number when this is > than MAX_RAID_SERIAL_LEN

Similar to the patch to remove white spaces from serial number this is needed when serial number is > 16 characters wide.

Comment 3 Hans de Goede 2009-04-10 12:59:18 UTC
Created attachment 339090 [details]
PATCH adding support for longer disk serial numbers

Here is a patch properly fixing this, this code is partially based on:
http://git.kernel.org/?p=linux/kernel/git/djbw/mdadm.git;a=blob_plain;f=super-intel.c;h=dd15673c153801bbb743b9fa4051867a254cc714

Thanks for the initial patch! And can you please test if this patch fixes things for you as well ?

Heinz, could you please review this patch ?

Comment 4 Alberto Patino 2009-04-13 03:22:12 UTC
Hi Hans,

Thanks for the right patch, I tested this with rawhide dmraid-1.0.0.rc15-6.fc11.src.rpm and it's fine, also tested with serial number < MAX_RAID_SERIAL_LEN

[root@hawking ~]# /usr/local/sbin/dmraid -s
*** Group superset isw_djdijbebfb
--> Active Subset
name   : isw_djdijbebfb_ARRAY
size   : 976783360
stride : 256
type   : stripe
status : ok
subsets: 0
devs   : 2
spares : 0

Hope Heinz could test it and add it to Fedora 11. I had to build my own DVD/CD set to include dmraid patched by me and install Fedora 11 Beta on my Dell laptop.

Comment 5 Hans de Goede 2009-04-20 19:04:08 UTC
This is fixed (with the patch I attached) in dmraid-1.0.0.rc15-7.fc11, which
will be in the next rawhide (and F-11 final).

Thanks for testing!

Comment 6 Hans de Goede 2009-04-22 13:59:06 UTC
*** Bug 489068 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.