Skip to contentSkip to conversation

RAID10 overwrites partition tables

DISCUSSION Felix Bellaby 2 participants 2 messages Nov 26, 2004 – Nov 27, 2004 MD RAID

lore
Share & tools
lore
#0 lore raw

mdadm --level 10 does not seem to respect disk partition boundaries.

Whilst trying to construct a small RAID10 array on a workstation, I naturally attempted to set the array up over partitions to leave somewhere for grub to access the kernel. Using partitions also assists with booting Fedora 3 as it relies on RAID autodetection and partition labels in its standard initial ram disk.

However, the RAID10 seems to overwrite some of the partition tables.

For example, configuring a RAID10 array over 3 partitions as follows:

       mdadm --create /dev/md0 --level 10 --raid-devices 3 \
               /dev/sda1 /dev/sdb1 /dev/sdc1

seems to overwrite the partition tables for the disks in the same way as configuring RAID10 over the complete disks:

mdadm --create /dev/md0 --level 10 --raid-devices 3 \
/dev/sda /dev/sdb /dev/sdc

A more detailed example:

       echo ',,fd' | sfdisk /dev/sda
       echo ',,fd' | sfdisk /dev/sdb
       echo ',,fd' | sfdisk /dev/sdc

mdadm --create /dev/md0 --level 10 --raid-devices 3 \
/dev/sda1 /dev/sdb1 /dev/sdc1

mke2fs /dev/md0

sfdisk -d /dev/sda
sfdisk -d /dev/sdb
sfdisk -d /dev/sdc

One of the partition tables in the above example will be replaced with the start of the second chunk of the ext2 fs, just as one would expect with an array configured over /dev/sda, dev/sdb and /dev/sdc.

The problem appears consistently on my test system (minimal Fedora 3 on an NForce3 system using the sata_nv.ko device driver). I have had the same results with a separate, identical system, and when using various custom 2.6.9 kernels. However, the problems do not appear with RAID5.

The code in raid10.c is probably to blame. A cursory examination suggests that raid10.c accesses the configured devices using very similar code to raid1.c (where the problem might go unnoticed) but rather differently from raid5.c.

Felix

Signature · 4 lines
Whatever you Wanadoo:
http://www.wanadoo.co.uk/time/

This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm
#1 lore raw
Quoted 1 line · On Friday November 26, [email protected] wrote:

mdadm --level 10 does not seem to respect disk partition boundaries.

Hmmm, yes, thanks.

I think the following should fix the bug. It only affects 'resync' not normal IO or recovery (after a drive has failed).

(I only tested it on whole-drives....)

Please let me know if it helps.

NeilBrown

----------- Diffstat output ------------

 ./drivers/md/raid10.c |    1 +
 1 files changed, 1 insertion(+)
drivers/md/raid10.c renamed from drivers/md/raid10.c~current~ +1 -0
diff ./drivers/md/raid10.c~current~ ./drivers/md/raid10.c
@@ -1150,6 +1150,7 @@ static void sync_request_write(mddev_t *
 		md_sync_acct(conf->mirrors[d].rdev->bdev, tbio->bi_size >> 9);
 
 		tbio->bi_sector += conf->mirrors[d].rdev->data_offset;
+		tbio->bi_bdev = conf->mirrors[d].rdev->bdev;
 		generic_make_request(tbio);
 	}