aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorCheng Renquan <crquan@gmail.com>2009-01-08 16:31:08 -0500
committerNeilBrown <neilb@suse.de>2009-01-08 16:31:08 -0500
commitcd2ac9321c26dc7a76455cd2a4df89123fa2b73e (patch)
tree8163a2cc791282cf32fafed19a60f357882d6169 /drivers/md/md.c
parent159ec1fc060ab22b157a62364045f5e98749c4d3 (diff)
md: need another print_sb for mdp_superblock_1
md_print_devices is called in two code path: MD_BUG(...), and md_ioctl with PRINT_RAID_DEBUG. it will dump out all in use md devices information; However, it wrongly processed two types of superblock in one: The header file <linux/raid/md_p.h> has defined two types of superblock, struct mdp_superblock_s (typedefed with mdp_super_t) according to md with metadata 0.90, and struct mdp_superblock_1 according to md with metadata 1.0 and later, These two types of superblock are very different, The md_print_devices code processed them both in mdp_super_t, that would lead to wrong informaton dump like: [ 6742.345877] [ 6742.345887] md: ********************************** [ 6742.345890] md: * <COMPLETE RAID STATE PRINTOUT> * [ 6742.345892] md: ********************************** [ 6742.345896] md1: <ram7><ram6><ram5><ram4> [ 6742.345907] md: rdev ram7, SZ:00065472 F:0 S:1 DN:3 [ 6742.345909] md: rdev superblock: [ 6742.345914] md: SB: (V:0.90.0) ID:<42ef13c7.598c059a.5f9f1645.801e9ee6> CT:4919856d [ 6742.345918] md: L5 S00065472 ND:4 RD:4 md1 LO:2 CS:65536 [ 6742.345922] md: UT:4919856d ST:1 AD:4 WD:4 FD:0 SD:0 CSUM:b7992907 E:00000001 [ 6742.345924] D 0: DISK<N:0,(1,8),R:0,S:6> [ 6742.345930] D 1: DISK<N:1,(1,10),R:1,S:6> [ 6742.345933] D 2: DISK<N:2,(1,12),R:2,S:6> [ 6742.345937] D 3: DISK<N:3,(1,14),R:3,S:6> [ 6742.345942] md: THIS: DISK<N:3,(1,14),R:3,S:6> ... [ 6742.346058] md0: <ram3><ram2><ram1><ram0> [ 6742.346067] md: rdev ram3, SZ:00065472 F:0 S:1 DN:3 [ 6742.346070] md: rdev superblock: [ 6742.346073] md: SB: (V:1.0.0) ID:<369aad81.00000000.00000000.00000000> CT:9a322a9c [ 6742.346077] md: L-1507699579 S976570180 ND:48 RD:0 md0 LO:65536 CS:196610 [ 6742.346081] md: UT:00000018 ST:0 AD:131048 WD:0 FD:8 SD:0 CSUM:00000000 E:00000000 [ 6742.346084] D 0: DISK<N:-1,(-1,-1),R:-1,S:-1> [ 6742.346089] D 1: DISK<N:-1,(-1,-1),R:-1,S:-1> [ 6742.346092] D 2: DISK<N:-1,(-1,-1),R:-1,S:-1> [ 6742.346096] D 3: DISK<N:-1,(-1,-1),R:-1,S:-1> [ 6742.346102] md: THIS: DISK<N:0,(0,0),R:0,S:0> ... [ 6742.346219] md: ********************************** [ 6742.346221] Here md1 is metadata 0.90.0, and md0 is metadata 1.2 After some more code to distinguish these two types of superblock, in this patch, it will generate dump information like: [ 7906.755790] [ 7906.755799] md: ********************************** [ 7906.755802] md: * <COMPLETE RAID STATE PRINTOUT> * [ 7906.755804] md: ********************************** [ 7906.755808] md1: <ram7><ram6><ram5><ram4> [ 7906.755819] md: rdev ram7, SZ:00065472 F:0 S:1 DN:3 [ 7906.755821] md: rdev superblock (MJ:0): [ 7906.755826] md: SB: (V:0.90.0) ID:<3fca7a0d.a612bfed.5f9f1645.801e9ee6> CT:491989f3 [ 7906.755830] md: L5 S00065472 ND:4 RD:4 md1 LO:2 CS:65536 [ 7906.755834] md: UT:491989f3 ST:1 AD:4 WD:4 FD:0 SD:0 CSUM:00fb52ad E:00000001 [ 7906.755836] D 0: DISK<N:0,(1,8),R:0,S:6> [ 7906.755842] D 1: DISK<N:1,(1,10),R:1,S:6> [ 7906.755845] D 2: DISK<N:2,(1,12),R:2,S:6> [ 7906.755849] D 3: DISK<N:3,(1,14),R:3,S:6> [ 7906.755855] md: THIS: DISK<N:3,(1,14),R:3,S:6> ... [ 7906.755972] md0: <ram3><ram2><ram1><ram0> [ 7906.755981] md: rdev ram3, SZ:00065472 F:0 S:1 DN:3 [ 7906.755984] md: rdev superblock (MJ:1): [ 7906.755989] md: SB: (V:1) (F:0) Array-ID:<5fbcf158:55aa:5fbe:9a79:1e939880dcbd> [ 7906.755990] md: Name: "DG5:0" CT:1226410480 [ 7906.755998] md: L5 SZ130944 RD:4 LO:2 CS:128 DO:24 DS:131048 SO:8 RO:0 [ 7906.755999] md: Dev:00000003 UUID: 9194d744:87f7:a448:85f2:7497b84ce30a [ 7906.756001] md: (F:0) UT:1226410480 Events:0 ResyncOffset:-1 CSUM:0dbcd829 [ 7906.756003] md: (MaxDev:384) ... [ 7906.756113] md: ********************************** [ 7906.756116] this md0 (metadata 1.2) information dumping is exactly according to struct mdp_superblock_1. Signed-off-by: Cheng Renquan <crquan@gmail.com> Cc: Neil Brown <neilb@suse.de> Cc: Dan Williams <dan.j.williams@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c66
1 files changed, 60 insertions, 6 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 58be665bb46b..1f770c16d435 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1588,7 +1588,7 @@ static void print_desc(mdp_disk_t *desc)
1588 desc->major,desc->minor,desc->raid_disk,desc->state); 1588 desc->major,desc->minor,desc->raid_disk,desc->state);
1589} 1589}
1590 1590
1591static void print_sb(mdp_super_t *sb) 1591static void print_sb_90(mdp_super_t *sb)
1592{ 1592{
1593 int i; 1593 int i;
1594 1594
@@ -1619,10 +1619,57 @@ static void print_sb(mdp_super_t *sb)
1619 } 1619 }
1620 printk(KERN_INFO "md: THIS: "); 1620 printk(KERN_INFO "md: THIS: ");
1621 print_desc(&sb->this_disk); 1621 print_desc(&sb->this_disk);
1622
1623} 1622}
1624 1623
1625static void print_rdev(mdk_rdev_t *rdev) 1624static void print_sb_1(struct mdp_superblock_1 *sb)
1625{
1626 __u8 *uuid;
1627
1628 uuid = sb->set_uuid;
1629 printk(KERN_INFO "md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x"
1630 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n"
1631 KERN_INFO "md: Name: \"%s\" CT:%llu\n",
1632 le32_to_cpu(sb->major_version),
1633 le32_to_cpu(sb->feature_map),
1634 uuid[0], uuid[1], uuid[2], uuid[3],
1635 uuid[4], uuid[5], uuid[6], uuid[7],
1636 uuid[8], uuid[9], uuid[10], uuid[11],
1637 uuid[12], uuid[13], uuid[14], uuid[15],
1638 sb->set_name,
1639 (unsigned long long)le64_to_cpu(sb->ctime)
1640 & MD_SUPERBLOCK_1_TIME_SEC_MASK);
1641
1642 uuid = sb->device_uuid;
1643 printk(KERN_INFO "md: L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu"
1644 " RO:%llu\n"
1645 KERN_INFO "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x"
1646 ":%02x%02x%02x%02x%02x%02x\n"
1647 KERN_INFO "md: (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n"
1648 KERN_INFO "md: (MaxDev:%u) \n",
1649 le32_to_cpu(sb->level),
1650 (unsigned long long)le64_to_cpu(sb->size),
1651 le32_to_cpu(sb->raid_disks),
1652 le32_to_cpu(sb->layout),
1653 le32_to_cpu(sb->chunksize),
1654 (unsigned long long)le64_to_cpu(sb->data_offset),
1655 (unsigned long long)le64_to_cpu(sb->data_size),
1656 (unsigned long long)le64_to_cpu(sb->super_offset),
1657 (unsigned long long)le64_to_cpu(sb->recovery_offset),
1658 le32_to_cpu(sb->dev_number),
1659 uuid[0], uuid[1], uuid[2], uuid[3],
1660 uuid[4], uuid[5], uuid[6], uuid[7],
1661 uuid[8], uuid[9], uuid[10], uuid[11],
1662 uuid[12], uuid[13], uuid[14], uuid[15],
1663 sb->devflags,
1664 (unsigned long long)le64_to_cpu(sb->utime) & MD_SUPERBLOCK_1_TIME_SEC_MASK,
1665 (unsigned long long)le64_to_cpu(sb->events),
1666 (unsigned long long)le64_to_cpu(sb->resync_offset),
1667 le32_to_cpu(sb->sb_csum),
1668 le32_to_cpu(sb->max_dev)
1669 );
1670}
1671
1672static void print_rdev(mdk_rdev_t *rdev, int major_version)
1626{ 1673{
1627 char b[BDEVNAME_SIZE]; 1674 char b[BDEVNAME_SIZE];
1628 printk(KERN_INFO "md: rdev %s, SZ:%08llu F:%d S:%d DN:%u\n", 1675 printk(KERN_INFO "md: rdev %s, SZ:%08llu F:%d S:%d DN:%u\n",
@@ -1630,8 +1677,15 @@ static void print_rdev(mdk_rdev_t *rdev)
1630 test_bit(Faulty, &rdev->flags), test_bit(In_sync, &rdev->flags), 1677 test_bit(Faulty, &rdev->flags), test_bit(In_sync, &rdev->flags),
1631 rdev->desc_nr); 1678 rdev->desc_nr);
1632 if (rdev->sb_loaded) { 1679 if (rdev->sb_loaded) {
1633 printk(KERN_INFO "md: rdev superblock:\n"); 1680 printk(KERN_INFO "md: rdev superblock (MJ:%d):\n", major_version);
1634 print_sb((mdp_super_t*)page_address(rdev->sb_page)); 1681 switch (major_version) {
1682 case 0:
1683 print_sb_90((mdp_super_t*)page_address(rdev->sb_page));
1684 break;
1685 case 1:
1686 print_sb_1((struct mdp_superblock_1 *)page_address(rdev->sb_page));
1687 break;
1688 }
1635 } else 1689 } else
1636 printk(KERN_INFO "md: no rdev superblock!\n"); 1690 printk(KERN_INFO "md: no rdev superblock!\n");
1637} 1691}
@@ -1658,7 +1712,7 @@ static void md_print_devices(void)
1658 printk("\n"); 1712 printk("\n");
1659 1713
1660 list_for_each_entry(rdev, &mddev->disks, same_set) 1714 list_for_each_entry(rdev, &mddev->disks, same_set)
1661 print_rdev(rdev); 1715 print_rdev(rdev, mddev->major_version);
1662 } 1716 }
1663 printk("md: **********************************\n"); 1717 printk("md: **********************************\n");
1664 printk("\n"); 1718 printk("\n");