kernel/nataraid: Fix a panic upon booting with a degraded Intel RAID.
authorSascha Wildner <saw@online.de>
Thu, 20 Feb 2014 20:44:03 +0000 (21:44 +0100)
committerSascha Wildner <saw@online.de>
Thu, 20 Feb 2014 20:44:03 +0000 (21:44 +0100)
disk_idx has upper bits set in this case which we need to mask.

Taken-from:             FreeBSD's r205074
Reported-and-tested-by: Aaron Bieber <deftly@gmail.com>
sys/dev/disk/nata/ata-raid.c

index 33fc7e2..d469d4d 100644 (file)
@@ -2243,22 +2243,24 @@ ata_raid_intel_read_meta(device_t dev, struct ar_softc **raidp)
 
            /* clear out any old info */
            for (disk = 0; disk < raid->total_disks; disk++) {
+               u_int disk_idx = map->disk_idx[disk] & 0xffff;
+
                raid->disks[disk].dev = NULL;
-               bcopy(meta->disk[map->disk_idx[disk]].serial,
+               bcopy(meta->disk[disk_idx].serial,
                      raid->disks[disk].serial,
                      sizeof(raid->disks[disk].serial));
                raid->disks[disk].sectors =
-                   meta->disk[map->disk_idx[disk]].sectors;
+                   meta->disk[disk_idx].sectors;
                raid->disks[disk].flags = 0;
-               if (meta->disk[map->disk_idx[disk]].flags & INTEL_F_ONLINE)
+               if (meta->disk[disk_idx].flags & INTEL_F_ONLINE)
                    raid->disks[disk].flags |= AR_DF_ONLINE;
-               if (meta->disk[map->disk_idx[disk]].flags & INTEL_F_ASSIGNED)
+               if (meta->disk[disk_idx].flags & INTEL_F_ASSIGNED)
                    raid->disks[disk].flags |= AR_DF_ASSIGNED;
-               if (meta->disk[map->disk_idx[disk]].flags & INTEL_F_SPARE) {
+               if (meta->disk[disk_idx].flags & INTEL_F_SPARE) {
                    raid->disks[disk].flags &= ~(AR_DF_ONLINE | AR_DF_ASSIGNED);
                    raid->disks[disk].flags |= AR_DF_SPARE;
                }
-               if (meta->disk[map->disk_idx[disk]].flags & INTEL_F_DOWN)
+               if (meta->disk[disk_idx].flags & INTEL_F_DOWN)
                    raid->disks[disk].flags &= ~AR_DF_ONLINE;
            }
        }