From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 20 13:40:22 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0B691065671 for ; Thu, 20 Mar 2008 13:40:22 +0000 (UTC) (envelope-from stef-list@memberwebs.com) Received: from mx.npubs.com (mail.writemehere.com [209.66.100.224]) by mx1.freebsd.org (Postfix) with ESMTP id C5D498FC17 for ; Thu, 20 Mar 2008 13:40:22 +0000 (UTC) (envelope-from stef-list@memberwebs.com) Received: from mx.npubs.com (avhost [209.66.100.194]) by mx.npubs.com (Postfix) with ESMTP id 2DBCA94C8A9 for ; Thu, 20 Mar 2008 13:16:39 +0000 (UTC) Received: from northstar-srv2 (unknown [172.27.2.11]) by mx.npubs.com (Postfix) with ESMTP id 7E66B94C853 for ; Thu, 20 Mar 2008 13:16:38 +0000 (UTC) From: Stef Walter User-Agent: Thunderbird 2.0.0.12 (X11/20080227) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: multipart/mixed; boundary="------------030601000406070402070900" Message-Id: <20080320131638.7E66B94C853@mx.npubs.com> X-Virus-Scanned: ClamAV using ClamSMTP Date: Thu, 20 Mar 2008 13:16:39 +0000 (UTC) X-Mailman-Approved-At: Thu, 20 Mar 2008 13:52:32 +0000 Subject: Vital Patches for ataraid with Intel Matrix RAID (ICH7) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: stef@memberwebs.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Mar 2008 13:40:23 -0000 This is a multi-part message in MIME format. --------------030601000406070402070900 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Here's some vital patches for the ataraid driver when using Intel Matrix RAID (often found built into mainboards these days). These are problems that will bite at the worst time: When a disk goes out in your RAID. A combined patch is attached which applies to FreeBSD 6 and 7, and the various specific problem reports and issues are outlined below. Cheers, Stef Walter Fix an early boot panic if you reboot with all drives present when your RAID is marked DEGRADED. This can happen if a drive has an unreadable block and the drive gets detached from the RAID. Rebooting at this point will panic. Yoichi created a patch for this over a year ago. http://www.freebsd.org/cgi/query-pr.cgi?pr=102211 Don't duplicate the RAID amoeba style if you boot with a drive present that was detached from a RAID. This can happen if you manage to get past the above panic problem. You'll end up with two devices like ar0 and ar1. This can be a major mess if ar1 was already contained active file systems. http://www.freebsd.org/cgi/query-pr.cgi?pr=121899 If you reboot after adding a spare, or during the rebuilding process, the RAID will become magically READY by itself. Not cool. http://www.freebsd.org/cgi/query-pr.cgi?pr=102210 --------------030601000406070402070900 Content-Type: text/x-patch; name="intel-matrix-raid.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="intel-matrix-raid.patch" --- sys/dev/ata/ata-raid.c.orig 2008-03-19 11:20:15.000000000 +0000 +++ sys/dev/ata/ata-raid.c 2008-03-19 21:53:37.000000000 +0000 @@ -848,10 +848,17 @@ rdp->status &= ~AR_S_READY; } + /* + * Note that when the array breaks so comes up broken we + * force a write of the array config to the remaining + * drives so that the generation will be incremented past + * those of the missing or failed drives (in all cases). + */ if (rdp->status != status) { if (!(rdp->status & AR_S_READY)) { printf("ar%d: FAILURE - %s array broken\n", rdp->lun, ata_raid_type(rdp)); + writeback = 1; } else if (rdp->status & AR_S_DEGRADED) { if (rdp->type & (AR_T_RAID1 | AR_T_RAID01)) @@ -860,6 +867,7 @@ printf("ar%d: WARNING - parity", rdp->lun); printf(" protection lost. %s array in DEGRADED mode\n", ata_raid_type(rdp)); + writeback = 1; } } mtx_unlock(&rdp->lock); @@ -2157,22 +2165,23 @@ /* clear out any old info */ for (disk = 0; disk < raid->total_disks; disk++) { + u_int32_t 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) { - raid->disks[disk].flags &= ~(AR_DF_ONLINE | AR_DF_ASSIGNED); - raid->disks[disk].flags |= AR_DF_SPARE; + if (meta->disk[disk_idx].flags & INTEL_F_SPARE) { + raid->disks[disk].flags &= ~AR_DF_ONLINE; + raid->disks[disk].flags |= (AR_DF_SPARE | AR_DF_ASSIGNED); } - 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; } } @@ -2183,7 +2192,7 @@ if (!strncmp(raid->disks[disk].serial, atadev->param.serial, sizeof(raid->disks[disk].serial))) { raid->disks[disk].dev = parent; - raid->disks[disk].flags |= (AR_DF_PRESENT | AR_DF_ONLINE); + raid->disks[disk].flags |= AR_DF_PRESENT; ars->raid[raid->volume] = raid; ars->disk_number[raid->volume] = disk; retval = 1; @@ -2233,11 +2242,16 @@ } rdp->generation++; - microtime(×tamp); + + /* Generate a new config_id if none exists */ + if (!rdp->magic_0) { + microtime(×tamp); + rdp->magic_0 = timestamp.tv_sec ^ timestamp.tv_usec; + } bcopy(INTEL_MAGIC, meta->intel_id, sizeof(meta->intel_id)); bcopy(INTEL_VERSION_1100, meta->version, sizeof(meta->version)); - meta->config_id = timestamp.tv_sec; + meta->config_id = rdp->magic_0; meta->generation = rdp->generation; meta->total_disks = rdp->total_disks; meta->total_volumes = 1; /* XXX SOS */ --------------030601000406070402070900--