From nobody@FreeBSD.org  Thu Nov 24 23:17:36 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 6111916AF38
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 24 Nov 2005 23:17:16 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id F117445381
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 24 Nov 2005 21:01:42 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id jAOL1gNl089226
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 24 Nov 2005 21:01:42 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id jAOL1gE0089225;
	Thu, 24 Nov 2005 21:01:42 GMT
	(envelope-from nobody)
Message-Id: <200511242101.jAOL1gE0089225@www.freebsd.org>
Date: Thu, 24 Nov 2005 21:01:42 GMT
From: Marcin Simonides <marcin@studio4plus.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: VIA 6420 SATA RAID0 array size is that of a single disk
X-Send-Pr-Version: www-2.3

>Number:         89511
>Category:       kern
>Synopsis:       [ata] [patch] VIA 6420 SATA RAID0 array size is that of a single disk
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 24 23:20:09 GMT 2005
>Closed-Date:    Wed Jan 04 21:38:23 GMT 2006
>Last-Modified:  Wed Jan 04 21:38:23 GMT 2006
>Originator:     Marcin Simonides
>Release:        6.0-STABLE
>Organization:
>Environment:
FreeBSD simon 6.0-STABLE FreeBSD 6.0-STABLE #2: Thu Nov 10 17:51:18 CET 2005
cinek@simon:/usr/obj/usr/src/sys/CUSTOM  i386

>Description:
Size of RAID 0 array is set to the size of one of disks that comprise the
array instead of the sum of disks:

atapci0: <VIA 6420 SATA150 controller> port 0xec00-0xec07,0xe800-0xe803,0xe400-0xe407,0xe000-0xe003,0xdc00-0xdc0f,0xd800-0xd8ff irq 20 at device 15.0 on pci0
[...]
ad0: 29314MB <IBM DTLA-307030 TX4OA60A> at ata0-master UDMA100
ad4: 76319MB <WDC WD800JD-00HKA0 13.03G13> at ata2-master SATA150
ad6: 76319MB <WDC WD800JD-00HKA0 13.03G13> at ata3-master SATA150
ar0: 76319MB <VIA Tech V-RAID RAID0 (stripe 16 KB)> status: READY
ar0: disk0 READY using ad4 at ata2-master
ar0: disk1 READY using ad6 at ata3-master 

The size of ar0 should be 152638MB.
Partitions starting beyond the first half of array are inaccessible.
>How-To-Repeat:
Just create a RAID 0 array in BIOS, the size reported by FreeBSD for
respective ar device will be equal to the size of a single disk.
>Fix:
Go to src/sys/dev/ata/ata-raid.c and in function ata_raid_via_read_meta()
change one line, here's a diff:

--- ata-raid.c.orig     Thu Nov 24 21:57:31 2005
+++ ata-raid.c  Thu Nov 24 21:58:03 2005
@@ -3022,7 +3022,7 @@
        case VIA_T_RAID0:
            raid->type = AR_T_RAID0;
            raid->width = meta->stripe_layout & VIA_L_MASK;
-           raid->total_sectors = meta->total_sectors;
+           raid->total_sectors = meta->total_sectors * raid->width;
            break;
 
        case VIA_T_RAID1:

to multiply the number of total_sectors by the number of disks (I guess
that's what raid->width stands for).  Recompile and install the new kernel
(but keep the old :).

It has worked for me for a week now (data has been copied to and from a
FAT slice near the end of array, both with FreeBSD and Windows), but I'm
no expert, perhaps this "fix" may break something.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Nov 25 00:35:42 GMT 2005 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89511 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Wed Jan 4 21:37:43 UTC 2006 
State-Changed-Why:  
A slightly different fix has been committed to -current, MFC to follow. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89511 
>Unformatted:
