From nobody@FreeBSD.org  Mon Dec  7 02:06:06 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 896BE106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  7 Dec 2009 02:06:06 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 78DD88FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  7 Dec 2009 02:06:06 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nB7266oc047793
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 7 Dec 2009 02:06:06 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id nB72653G047792;
	Mon, 7 Dec 2009 02:06:05 GMT
	(envelope-from nobody)
Message-Id: <200912070206.nB72653G047792@www.freebsd.org>
Date: Mon, 7 Dec 2009 02:06:05 GMT
From: Dieter <freebsd@sopwith.solgatos.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: 8.0 no longer provides /dev entries for all disk slices
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         141235
>Category:       kern
>Synopsis:       [geom_part] 8.0 no longer provides /dev entries for all disk slices [regression]
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    ae
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 07 02:10:04 UTC 2009
>Closed-Date:    Wed Jul 27 04:23:58 UTC 2011
>Last-Modified:  Wed Jul 27 04:30:09 UTC 2011
>Originator:     Dieter
>Release:        8.0 RELEASE
>Organization:
>Environment:
GENERIC kernel on 8.0 RELEASE amd64
>Description:
FreeBSD 8.0 RELEASE for amd64 does not provide /dev entries for
disk slices above 4. Slices greater than 4 work fine in 6.x and 7.x

Example, 7.1 amd64:

ls /dev/ad4*
/dev/ad4        /dev/ad4s2      /dev/ad4s2d     /dev/ad4s5      /dev/ad4s5d     /dev/ad4s6
/dev/ad4s1      /dev/ad4s2a     /dev/ad4s2e     /dev/ad4s5a     /dev/ad4s5e     /dev/ad4s7
/dev/ad4s10     /dev/ad4s2b     /dev/ad4s3      /dev/ad4s5b     /dev/ad4s5f     /dev/ad4s8
/dev/ad4s11     /dev/ad4s2c     /dev/ad4s4      /dev/ad4s5c     /dev/ad4s5g     /dev/ad4s9

11 slices and they all work fine.  Some slices are further subdivided
with BSD disklabels, some are not.  They work fine either way.

But 8.0 only provides /dev entries for slices 1-4.  Slices 5 and above
cannot be accessed.

FreeBSD 8 needs to provide /dev entries for all the slices.

>How-To-Repeat:
Setup a disk with more than 4 slices.  Boot 6.x or 7.x and observe that
they all work.  Boot 8.0 and observe that there are no /dev entries
above slice 4.

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Dec 7 07:22:03 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

To submitter: does this happen to be a 'dangerously dedicated' disk? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 
Responsible-Changed-From-To: freebsd-fs->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Feb 5 06:33:28 UTC 2010 
Responsible-Changed-Why:  
On looking at this again, I'm wondering if it might not be a problem 
with the ata rework, instead. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 
State-Changed-From-To: open->feedback 
State-Changed-By: jh 
State-Changed-When: Fri Apr 30 07:42:16 UTC 2010 
State-Changed-Why:  
This is probably related to GEOM_PART_*. Could you confirm that by replacing 
GEOM_PART_* options in your kernel config with GEOM_MBR and GEOM_BSD? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 

From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: bug-followup@FreeBSD.org, freebsd@sopwith.solgatos.com
Cc:  
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk
 slices [regression]
Date: Fri, 30 Apr 2010 12:02:38 +0400

 Hi,
 
 Can you show output of `gpart show` and `kldstat -v | grep part`?
 
 -- 
 WBR, Andrey V. Elsukov

From: dieterbsd@engineer.com
To: bug-followup@freebsd.org, jh@FreeBSD.org
Cc: freebsd@sopwith.solgatos.com, freebsd-bugs@FreeBSD.org
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk slices
 [regression]
Date: Thu, 27 May 2010 18:51:00 -0400

 > This is probably related to GEOM_PART_*. Could you confirm that by=20
 replacing
 > GEOM_PART_* options in your kernel config with GEOM_MBR and GEOM_BSD?
 
 opt_geom.h previously contained:
 
 #define GEOM_LABEL 1
 #define GEOM_PART_EBR 1
 #define GEOM_PART_GPT 1
 #define GEOM_PART_MBR 1
 #define GEOM_PART_EBR_COMPAT 1
 #define GEOM_PART_BSD 1
 
 Added GEOM_MBR and GEOM_BSD to config file.
 (previous config file was stock GENERIC)
 
 opt_geom.h now:
 
 #define GEOM_BSD 1
 #define GEOM_LABEL 1
 #define GEOM_PART_EBR 1
 #define GEOM_PART_GPT 1
 #define GEOM_PART_MBR 1
 #define GEOM_PART_EBR_COMPAT 1
 #define GEOM_PART_BSD 1
 #define GEOM_MBR 1
 
 7.1 kernel works properly:
 
 ls -l /dev/ad4*
 crw-r-----  1 root  operator    0,  85 May 27 19:24 /dev/ad4
 crw-r-----  1 root  operator    0,  89 May 27 19:24 /dev/ad4s1
 crw-r-----  1 root  operator    0,  90 May 27 19:24 /dev/ad4s2
 crw-r-----  1 root  operator    0,  91 May 27 19:24 /dev/ad4s3
 crw-r-----  1 root  operator    0,  98 May 27 19:24 /dev/ad4s3a
 crw-r-----  1 root  operator    0,  99 May 27 19:24 /dev/ad4s3c
 crw-r-----  1 root  operator    0,  92 May 27 19:24 /dev/ad4s4
 crw-r-----  1 root  operator    0, 100 May 27 19:24 /dev/ad4s4a
 crw-r-----  1 root  operator    0, 101 May 27 19:24 /dev/ad4s4b
 crw-r-----  1 root  operator    0, 102 May 27 19:24 /dev/ad4s4c
 
 ls -l /dev/ad20*
 crw-r-----  1 root  operator    0, 120 May 27 19:24 /dev/ad20
 crw-r-----  1 root  operator    0, 163 May 27 19:24 /dev/ad20s1
 crw-r-----  1 root  operator    0, 164 May 27 19:24 /dev/ad20s2
 crw-r-----  1 root  operator    0, 165 May 27 19:24 /dev/ad20s3
 crw-r-----  1 root  operator    0, 166 May 27 19:24 /dev/ad20s4
 crw-r-----  1 root  operator    0, 194 May 27 19:24 /dev/ad20s5        =20
 extended partition
 #
 
 -------------------------
 
 stock 8.0 kernel:
 
 (ada4 in 8.0 is same disk as ad20 in 7.1)
 
 ls -l /dev/ad4*
 crw-r-----  1 root  operator    0, 102 May 27 12:13 /dev/ad4
 crw-r-----  1 root  operator    0, 103 May 27 12:13 /dev/ad4s1
 crw-r-----  1 root  operator    0, 104 May 27 12:13 /dev/ad4s2
 crw-r-----  1 root  operator    0, 105 May 27 12:13 /dev/ad4s3
 crw-r-----  1 root  operator    0, 109 May 27 12:13 /dev/ad4s3a
 crw-r-----  1 root  operator    0, 106 May 27 12:13 /dev/ad4s4
 crw-r-----  1 root  operator    0, 110 May 27 12:13 /dev/ad4s4a
 crw-r-----  1 root  operator    0, 111 May 27 12:13 /dev/ad4s4b
 
 ls -l /dev/ada4*
 crw-r-----  1 root  operator    0, 180 May 27 12:13 /dev/ada4
 crw-r-----  1 root  operator    0, 223 May 27 12:13 /dev/ada4s1
 crw-r-----  1 root  operator    0, 224 May 27 12:13 /dev/ada4s2
 crw-r-----  1 root  operator    0, 225 May 27 12:13 /dev/ada4s3
 crw-r-----  1 root  operator    0, 226 May 27 12:13 /dev/ada4s4
 
 /dev/ada4s5 is missing
 
 ----------
 
 8.0 with GEOM_MBR and GEOM_BSD:
 
 ls -l /dev/ad4*
 crw-r-----  1 root  operator    0, 106 May 27 12:02 /dev/ad4
 crw-r-----  1 root  operator    0, 116 May 27 12:02 /dev/ad4s1
 crw-r-----  1 root  operator    0, 117 May 27 12:02 /dev/ad4s2
 crw-r-----  1 root  operator    0, 118 May 27 12:02 /dev/ad4s3
 crw-r-----  1 root  operator    0, 131 May 27 12:02 /dev/ad4s3a
 crw-r-----  1 root  operator    0, 131 May 27 12:02 /dev/ad4s3a        =20
 dup ?
 crw-r-----  1 root  operator    0, 132 May 27 12:02 /dev/ad4s3c
 crw-r-----  1 root  operator    0, 161 May 27 12:02 /dev/ad4s3ca       =20
 ?
 crw-r-----  1 root  operator    0, 119 May 27 12:02 /dev/ad4s4
 crw-r-----  1 root  operator    0, 134 May 27 12:02 /dev/ad4s4a
 crw-r-----  1 root  operator    0, 135 May 27 12:02 /dev/ad4s4b
 crw-r-----  1 root  operator    0, 136 May 27 12:02 /dev/ad4s4c
 crw-r-----  1 root  operator    0, 166 May 27 12:02 /dev/ad4s4ca       =20
 ?
 crw-r-----  1 root  operator    0, 167 May 27 12:02 /dev/ad4s4cb       =20
 ?
 
 ls -l /dev/ada4* | cat -v
 crw-r-----  1 root  operator    1,  29 May 27 12:02 /dev/ada4
 crw-r-----  1 root  operator    1,  72 May 27 12:02 /dev/ada4s1
 crw-r-----  1 root  operator    1,  72 May 27 12:02 /dev/ada4s1        =20
 dup ?
 crw-r-----  1 root  operator    1,  73 May 27 12:02 /dev/ada4s2
 crw-r-----  1 root  operator    1,  73 May 27 12:02 /dev/ada4s2        =20
 dup ?
 crw-r-----  1 root  operator    1,  74 May 27 12:02 /dev/ada4s3
 crw-r-----  1 root  operator    1,  74 May 27 12:02 /dev/ada4s3        =20
 dup ?
 crw-r-----  1 root  operator    1,  75 May 27 12:02 /dev/ada4s4
 crw-r-----  1 root  operator    1,  75 May 27 12:02 /dev/ada4s4        =20
 dup ?
 crw-r-----  1 root  operator    1, 193 May 27 12:02 /dev/ada4s4s1      =20
 ?
 crw-r-----  1 root  operator    1, 193 May 27 12:02 /dev/ada4s4s1      =20
 ?
 crw-r-----  1 root  operator    1, 192 May 27 12:02 /dev/ada4s5        =20
 extended partition showed up
 
 So the extended partition showed up, but now I have some duplicate /dev=20
 entries
 and some oddball bogus entries.
 
 

From: Jaakko Heinonen <jh@FreeBSD.org>
To: dieterbsd@engineer.com
Cc: bug-followup@freebsd.org, freebsd@sopwith.solgatos.com
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk
 slices [regression]
Date: Fri, 28 May 2010 12:52:02 +0300

 On 2010-05-27, dieterbsd@engineer.com wrote:
 > opt_geom.h previously contained:
 > 
 > #define GEOM_LABEL 1
 > #define GEOM_PART_EBR 1
 > #define GEOM_PART_GPT 1
 > #define GEOM_PART_MBR 1
 > #define GEOM_PART_EBR_COMPAT 1
 > #define GEOM_PART_BSD 1
 > 
 > Added GEOM_MBR and GEOM_BSD to config file.
 > (previous config file was stock GENERIC)
 
 > opt_geom.h now:
 > 
 > #define GEOM_BSD 1
 > #define GEOM_LABEL 1
 > #define GEOM_PART_EBR 1
 > #define GEOM_PART_GPT 1
 > #define GEOM_PART_MBR 1
 > #define GEOM_PART_EBR_COMPAT 1
 > #define GEOM_PART_BSD 1
 > #define GEOM_MBR 1
 
 You should remove GEOM_PART_* entries. I think that the duplicates you
 saw are because you had geom_part still enabled.
 
 > 8.0 with GEOM_MBR and GEOM_BSD:
 [...]
 > So the extended partition showed up, but now I have some duplicate /dev 
 > entries
 > and some oddball bogus entries.
 
 -- 
 Jaakko

From: dieterbsd@engineer.com
To: bug-followup@freebsd.org, jh@FreeBSD.org
Cc: freebsd@sopwith.solgatos.com, freebsd-bugs@FreeBSD.org
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk slices
 [regression]
Date: Fri, 28 May 2010 11:53:49 -0400

 > You should remove GEOM_PART_* entries. I think that the duplicates you
 > saw are because you had geom_part still enabled.
 
 I thought about that.  Having both GEOM_PART_MBR and GEOM_MBR
 seemed suspicious, but GEOM_PART_MBR isn't from the config file:
 
 grep -i geom GENERIC
 options         GEOM_PART_GPT           # GUID Partition Tables.
 options         GEOM_LABEL              # Provides labelization
 
 and then I added GEOM_MBR and GEOM_BSD as suggested.  So I don't
 know where GEOM_PART_MBR comes from or how to get rid of it.
 I am assuming that "make buildkernel" calls config(8) and config
 builds opt_geom.h based on the config file, but it must have some
 other input that I haven't found.
 
 It isn't clear to me what the difference between GEOM_PART_MBR and
 GEOM_MBR is supposed to be (same for GEOM_PART_BSD and GEOM_BSD).
 conf/NOTES doesn't list a GEOM_GPT, only GEOM_PART_GPT.  I assume
 that removing GEOM_PART_GPT would break disks using GUID partition
 tables.
 
 

From: Garrett Cooper <yanefbsd@gmail.com>
To: dieterbsd@engineer.com
Cc: bug-followup@freebsd.org, jh@freebsd.org, freebsd@sopwith.solgatos.com, 
	freebsd-bugs@freebsd.org
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk 
	slices [regression]
Date: Fri, 28 May 2010 10:07:01 -0700

 On Fri, May 28, 2010 at 8:53 AM,  <dieterbsd@engineer.com> wrote:
 >> You should remove GEOM_PART_* entries. I think that the duplicates you
 >> saw are because you had geom_part still enabled.
 >
 > I thought about that. =A0Having both GEOM_PART_MBR and GEOM_MBR
 > seemed suspicious, but GEOM_PART_MBR isn't from the config file:
 >
 > grep -i geom GENERIC
 > options =A0 =A0 =A0 =A0 GEOM_PART_GPT =A0 =A0 =A0 =A0 =A0 # GUID Partitio=
 n Tables.
 > options =A0 =A0 =A0 =A0 GEOM_LABEL =A0 =A0 =A0 =A0 =A0 =A0 =A0# Provides =
 labelization
 >
 > and then I added GEOM_MBR and GEOM_BSD as suggested. =A0So I don't
 > know where GEOM_PART_MBR comes from or how to get rid of it.
 > I am assuming that "make buildkernel" calls config(8) and config
 > builds opt_geom.h based on the config file, but it must have some
 > other input that I haven't found.
 >
 > It isn't clear to me what the difference between GEOM_PART_MBR and
 > GEOM_MBR is supposed to be (same for GEOM_PART_BSD and GEOM_BSD).
 > conf/NOTES doesn't list a GEOM_GPT, only GEOM_PART_GPT. =A0I assume
 > that removing GEOM_PART_GPT would break disks using GUID partition
 > tables.
 
 GEOM_MBR is the legacy way to specify GEOM_PART_MBR IIRC (from .../UPDATING=
 ):
 
 20090320:
         GEOM_PART has become the default partition slicer for storage devic=
 es,
         replacing GEOM_MBR, GEOM_BSD, GEOM_PC98 and GEOM_GPT slicers. It
         introduces some changes:
 
         MSDOS/EBR: the devices created from MSDOS extended partition entrie=
 s
         (EBR) can be named differently than with GEOM_MBR and are now symli=
 nks
         to devices with offset-based names. fstabs may need to be modified.
 
         BSD: the "geometry does not match label" warning is harmless in mos=
 t
         cases but it points to problems in file system misalignment with
         disk geometry. The "c" partition is now implicit, covers the whole
         top-level drive and cannot be (mis)used by users.
 
         General: Kernel dumps are now not allowed to be written to devices
         whose partition types indicate they are meant to be used for file
         systems (or, in case of MSDOS partitions, as something else than
         the "386BSD" type).
 
         Most of these changes date approximately from 200812.
 
 Thanks,
 -Garrett

From: Garrett Cooper <yanefbsd@gmail.com>
To: dieterbsd@engineer.com
Cc: bug-followup@freebsd.org, jh@freebsd.org, freebsd@sopwith.solgatos.com, 
	freebsd-bugs@freebsd.org
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk 
	slices [regression]
Date: Fri, 28 May 2010 10:18:50 -0700

 On Fri, May 28, 2010 at 10:07 AM, Garrett Cooper <yanefbsd@gmail.com> wrote=
 :
 > On Fri, May 28, 2010 at 8:53 AM, =A0<dieterbsd@engineer.com> wrote:
 >>> You should remove GEOM_PART_* entries. I think that the duplicates you
 >>> saw are because you had geom_part still enabled.
 >>
 >> I thought about that. =A0Having both GEOM_PART_MBR and GEOM_MBR
 >> seemed suspicious, but GEOM_PART_MBR isn't from the config file:
 >>
 >> grep -i geom GENERIC
 >> options =A0 =A0 =A0 =A0 GEOM_PART_GPT =A0 =A0 =A0 =A0 =A0 # GUID Partiti=
 on Tables.
 >> options =A0 =A0 =A0 =A0 GEOM_LABEL =A0 =A0 =A0 =A0 =A0 =A0 =A0# Provides=
  labelization
 >>
 >> and then I added GEOM_MBR and GEOM_BSD as suggested. =A0So I don't
 >> know where GEOM_PART_MBR comes from or how to get rid of it.
 >> I am assuming that "make buildkernel" calls config(8) and config
 >> builds opt_geom.h based on the config file, but it must have some
 >> other input that I haven't found.
 >>
 >> It isn't clear to me what the difference between GEOM_PART_MBR and
 >> GEOM_MBR is supposed to be (same for GEOM_PART_BSD and GEOM_BSD).
 >> conf/NOTES doesn't list a GEOM_GPT, only GEOM_PART_GPT. =A0I assume
 >> that removing GEOM_PART_GPT would break disks using GUID partition
 >> tables.
 >
 > GEOM_MBR is the legacy way to specify GEOM_PART_MBR IIRC (from .../UPDATI=
 NG):
 >
 > 20090320:
 > =A0 =A0 =A0 =A0GEOM_PART has become the default partition slicer for stor=
 age devices,
 > =A0 =A0 =A0 =A0replacing GEOM_MBR, GEOM_BSD, GEOM_PC98 and GEOM_GPT slice=
 rs. It
 > =A0 =A0 =A0 =A0introduces some changes:
 >
 > =A0 =A0 =A0 =A0MSDOS/EBR: the devices created from MSDOS extended partiti=
 on entries
 > =A0 =A0 =A0 =A0(EBR) can be named differently than with GEOM_MBR and are =
 now symlinks
 > =A0 =A0 =A0 =A0to devices with offset-based names. fstabs may need to be =
 modified.
 >
 > =A0 =A0 =A0 =A0BSD: the "geometry does not match label" warning is harmle=
 ss in most
 > =A0 =A0 =A0 =A0cases but it points to problems in file system misalignmen=
 t with
 > =A0 =A0 =A0 =A0disk geometry. The "c" partition is now implicit, covers t=
 he whole
 > =A0 =A0 =A0 =A0top-level drive and cannot be (mis)used by users.
 >
 > =A0 =A0 =A0 =A0General: Kernel dumps are now not allowed to be written to=
  devices
 > =A0 =A0 =A0 =A0whose partition types indicate they are meant to be used f=
 or file
 > =A0 =A0 =A0 =A0systems (or, in case of MSDOS partitions, as something els=
 e than
 > =A0 =A0 =A0 =A0the "386BSD" type).
 >
 > =A0 =A0 =A0 =A0Most of these changes date approximately from 200812.
 
 I did a bit more digging and what I discovered wasn't entirely true in
 my first statement; yes, GEOM_MBR is the legacy system from first
 glance compared to GEOM_PART_MBR, but that doesn't tell the entire
 story. The two items (GEOM_PART_MBR and GEOM_MBR) also grossly differ
 with one another.
 
 I'm going to take a look at the code in the meantime and try to better
 digest what's going on (because it would help with work), but just for
 future reference the files that get used [up through 9-CURRENT] are
 located at:
 
 /sys/geom/geom_mbr.c
 /sys/geom/part/g_part_mbr.c
 
 You can of course determine this info from /sys/conf/files.
 HTH,
 -Garrett

From: Jaakko Heinonen <jh@FreeBSD.org>
To: dieterbsd@engineer.com
Cc: bug-followup@freebsd.org, freebsd@sopwith.solgatos.com
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk
 slices [regression]
Date: Sun, 30 May 2010 16:51:40 +0300

 On 2010-05-28, dieterbsd@engineer.com wrote:
 > and then I added GEOM_MBR and GEOM_BSD as suggested.  So I don't
 > know where GEOM_PART_MBR comes from or how to get rid of it.
 
 GEOM_PART_* are in DEFAULTS (sys/amd64/conf/DEFAULTS on amd64).
 
 -- 
 Jaakko

From: dieterbsd@engineer.com
To: bug-followup@freebsd.org, jh@FreeBSD.org
Cc: freebsd@sopwith.solgatos.com, freebsd-bugs@FreeBSD.org
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk slices
 [regression]
Date: Sun, 30 May 2010 16:56:56 -0400

 >> and then I added GEOM_MBR and GEOM_BSD as suggested.  So I don't
 >> know where GEOM_PART_MBR comes from or how to get rid of it.
 >
 > GEOM_PART_* are in DEFAULTS (sys/amd64/conf/DEFAULTS on amd64).
 
 Ah ha!
 
 opt_geom.h now contains:
 
 #define GEOM_BSD 1
 #define GEOM_LABEL 1
 #define GEOM_PART_GPT 1
 #define GEOM_MBR 1
 
 (same as 7.1 had)
 
 Now I have /dev entries for extended partitions, and the
 duplicate and bogus entries are gone.  GUID partitioning
 and partition labels still work.  Yea!
 
 Having some GEOM options in DEFAULTS and some in the config file
 seems prone to error.  I suggest putting them all in the same file.
 Yes, grep can easily find it, but despite many years of experience
 with grep, find, and xargs I somehow managed to miss DEFAULTS.
 I can only blame lack of sleep.
 
 Having both GEOM_MBR and GEOM_PART_MBR is confusing.  If there is a
 good reason to retain both, better documentation might be in order.
 Same for GEOM_BSD and GEOM_PART_BSD.
 
 Thank you.
 
 
State-Changed-From-To: feedback->open 
State-Changed-By: jh 
State-Changed-When: Mon May 31 16:41:23 UTC 2010 
State-Changed-Why:  
Feedback received. 


Responsible-Changed-From-To: freebsd-bugs->freebsd-geom 
Responsible-Changed-By: jh 
Responsible-Changed-When: Mon May 31 16:41:23 UTC 2010 
Responsible-Changed-Why:  
Confirmed to be a geom_part problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 

From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: bug-followup@FreeBSD.org, freebsd@sopwith.solgatos.com, 
 dieterbsd@engineer.com
Cc:  
Subject: Re: kern/141235: [geom_part] 8.0 no longer provides /dev entries
 for all disk slices [regression]
Date: Mon, 31 May 2010 21:11:54 +0400

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enig012887CAF7613F50A2F8F0D2
 Content-Type: text/plain; charset=KOI8-R
 Content-Transfer-Encoding: quoted-printable
 
 Hi,
 
 Did you try to remove both deprecated GEOM_BSD and GEOM_MBR
 from your config?
 Now in 8.0+ you should use GEOM_PART_MBR, GEOM_PART_EBR and
 GEOM_PART_BSD instead. And they all are in DEFAULTS config by
 default.
 
 Your MBR partitions should be served with GEOM_PART_MBR scheme.
 An extended partitions should be served with GEOM_PART_EBR scheme.
 A BSD slices should be served with GEOM_PART_BSD scheme.
 
 --=20
 WBR, Andrey V. Elsukov
 
 
 --------------enig012887CAF7613F50A2F8F0D2
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.14 (FreeBSD)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iQEcBAEBAgAGBQJMA+3fAAoJEAHF6gQQyKF6EWcIAJdFuHyZmmDK1BXAtQluXVnt
 3ZtO9cki7nQBr8yjI0hCtIjIY5+AOEqYB8wUFDGAiZMPTI/5q/iQhqDgr+DGsNQ6
 HXWzr2zM80gYuPXUwJEHSp5ln1zyXfoaGAqidm5y4eUxFF5rpjYwikG+Lz8AOj3A
 bnmYjW4k5cEmrO8aoKmd3pUfsKu4ex0XMwBwnQq9lsYwTe42AEdwLpB4v0ojF/Z5
 5neRUFmJLdGWQsFRiaWT5Vb6niwMRhVfal02BcznE0sz6AqP5YAtBnBBIbJt8ZqC
 3bshq248o6vgK21RX+udPBiBbgT2o3clCDCDmHHQX0vrRzpH1i1IC0tLstMfPOU=
 =5Pr/
 -----END PGP SIGNATURE-----
 
 --------------enig012887CAF7613F50A2F8F0D2--

From: dieterbsd@engineer.com
To: bug-followup@freebsd.org, bu7cher@yandex.ru
Cc: freebsd@sopwith.solgatos.com, freebsd-bugs@FreeBSD.org
Subject: Re: kern/141235: 8.0 no longer provides /dev entries for all disk slices
 [regression]
Date: Thu, 03 Jun 2010 14:30:26 -0400

 > Did you try to remove both deprecated GEOM_BSD and GEOM_MBR
 > from your config?
 > Now in 8.0+ you should use GEOM_PART_MBR, GEOM_PART_EBR and
 > GEOM_PART_BSD instead. And they all are in DEFAULTS config by
 > default.
 >
 > Your MBR partitions should be served with GEOM_PART_MBR scheme.
 > An extended partitions should be served with GEOM_PART_EBR scheme.
 > A BSD slices should be served with GEOM_PART_BSD scheme.
 
 I started with the default GENERIC 8.0-release kernel and it is broken.
 It does not provide /dev entries for MBR extended partitions.
 
 Changing the GEOM_* options to be
 
 #define GEOM_BSD 1
 #define GEOM_LABEL 1
 #define GEOM_PART_GPT 1
 #define GEOM_MBR 1
 
 (which turns out to be the same as they were in 7.1) makes everything=20
 work.
 
 

From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: bug-followup@FreeBSD.org, freebsd@sopwith.solgatos.com, 
 dieterbsd@engineer.com
Cc:  
Subject: Re: kern/141235: [geom_part] 8.0 no longer provides /dev entries
 for all disk slices [regression]
Date: Sat, 05 Jun 2010 12:25:55 +0400

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enig3934C856DDB039C5EC189316
 Content-Type: text/plain; charset=KOI8-R
 Content-Transfer-Encoding: quoted-printable
 
 Hi,
 
 Can you try this patch to g_part_ebr.c to GENERIC kernel and
 report results back?
 http://svn.freebsd.org/viewvc/base?view=3Drevision&revision=3D197608
 
 --=20
 WBR, Andrey V. Elsukov
 
 
 --------------enig3934C856DDB039C5EC189316
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.14 (FreeBSD)
 
 iQEcBAEBAgAGBQJMCgocAAoJEAHF6gQQyKF6KDgH/3M4E4nabTCi/4+mep8uIp8g
 yziDefNPeqa9J1fypFRrtfw74LoJE8ZPviNAbzax9j57crDoLgf6TKtmuAZMf/BO
 44YOZX5lN0j4J+zH+gL9MtNoA3LvM3lzMIvQXCmffVPyfUSNh5/rwecMwiJAWQoB
 7GUWwIlFzgNN982gmiUwhOH2TTdKMyjN6b7ZAkErxkvkoMUsTZU0nHRQlbq7y0Ap
 VjTwB1R3kyz3czLAe4V9PdtajacEuC1e3C9Yh4u240J73RpsWROv91if314n9V8B
 k+MkNGAJY9WXMtbKi2mf6wGXQsyuQqdsytxEVXKSSyMkfoWz19a20+oqeiolN2g=
 =ZXhY
 -----END PGP SIGNATURE-----
 
 --------------enig3934C856DDB039C5EC189316--

From: dieterbsd@engineer.com
To: bu7cher@yandex.ru, bug-followup@FreeBSD.org, freebsd@sopwith.solgatos.com
Cc:  
Subject: Re: kern/141235: [geom_part] 8.0 no longer provides /dev entries for all
 disk slices [regression]
Date: Sun, 06 Jun 2010 20:15:48 -0400

 > Can you try this patch to g_part_ebr.c to GENERIC kernel and
 > report results back?
 
 I reverted the GEOM_* options back to 8.0-release defaults, dropped
 in the new g_part_ebr.c and now I get /dev entries for MBR extended
 partitions.
 
 So the
 
 <       for (index =3D 0; index < DOSPARTOFF - 9; index++)
 ---
 >       for (index =3D 96; index < DOSPARTOFF - 9; index++)
 
 change fixed the problem.
 
 Thanks.
 
 
State-Changed-From-To: open->patched 
State-Changed-By: jh 
State-Changed-When: Mon Jun 7 18:39:22 UTC 2010 
State-Changed-Why:  
Patched in head (r197608). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/141235: commit references a PR
Date: Mon,  7 Jun 2010 20:32:11 +0000 (UTC)

 Author: ae
 Date: Mon Jun  7 20:31:55 2010
 New Revision: 208899
 URL: http://svn.freebsd.org/changeset/base/208899
 
 Log:
   MFC r197608:
   
   The first 96 bytes may not be zeroes. It can contain trivial boot
   code that merely emits an error and waits for a key press before
   rebooting. The error being that extended partitions are not
   bootable. The origin is presumed to be Windows 2000; Windows XP
   does not do this...
   
   For now, ignore the first 96 bytes when checking that the EBR is
   (for the most part) all zeroes.
   
   Tested by:	Mario Lobo <mlobo at digiart.art.br>
   		Dieter <dieterbsd at engineer.com>
   PR:		kern/141235
   Reviewed by:	marcel
   Approved by:	kib (mentor)
   Approved by:	re (bz)
 
 Modified:
   stable/8/sys/geom/part/g_part_ebr.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/dev/xen/xenpci/   (props changed)
   stable/8/sys/geom/sched/   (props changed)
 
 Modified: stable/8/sys/geom/part/g_part_ebr.c
 ==============================================================================
 --- stable/8/sys/geom/part/g_part_ebr.c	Mon Jun  7 18:47:53 2010	(r208898)
 +++ stable/8/sys/geom/part/g_part_ebr.c	Mon Jun  7 20:31:55 2010	(r208899)
 @@ -410,13 +410,13 @@ g_part_ebr_probe(struct g_part_table *ta
  		goto out;
  
  	/*
 -	 * The sector is all zeroes, except for the partition entries
 -	 * and some signatures or disk serial number. Those can be
 -	 * found in the 9 bytes immediately in front of the partition
 -	 * table.
 +	 * The sector is all zeroes, except for the partition entries,
 +	 * pseudo boot code and some signatures or disk serial number.
 +	 * The latter can be found in the 9 bytes immediately in front
 +	 * of the partition table.
  	 */
  	sum = 0;
 -	for (index = 0; index < DOSPARTOFF - 9; index++)
 +	for (index = 96; index < DOSPARTOFF - 9; index++)
  		sum += buf[index];
  	if (sum != 0)
  		goto out;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->suspended 
State-Changed-By: ae 
State-Changed-When: Sat Jul 10 17:09:51 UTC 2010 
State-Changed-Why: Better solution needed.

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 
State-Changed-From-To: suspended->analyzed 
State-Changed-By: ae 
State-Changed-When: Tue Dec 21 10:42:39 UTC 2010 
State-Changed-Why:  
Reopen this PR since I've got several similar reports and 
i have time to work on it. 


Responsible-Changed-From-To: freebsd-geom->ae 
Responsible-Changed-By: ae 
Responsible-Changed-When: Tue Dec 21 10:42:39 UTC 2010 
Responsible-Changed-Why:  
Reopen this PR since I've got several similar reports and 
i have time to work on it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/141235: commit references a PR
Date: Tue, 28 Dec 2010 08:36:50 +0000 (UTC)

 Author: ae
 Date: Tue Dec 28 08:36:44 2010
 New Revision: 216754
 URL: http://svn.freebsd.org/changeset/base/216754
 
 Log:
   Make EBR probe method less strictly to be able detect EBRs with
   small non fatal inconsistency. EBR may contain boot loader and sometimes
   it just has some garbage data. Now this does not prevent FreeBSD to use
   extended partitions. But since we do not support bootcode for EBR we mark
   tables which have non empty boot area as corrupt. This does make them
   readonly and we can not damage this data.
   
   PR:		kern/141235
   MFC after:	1 month
 
 Modified:
   head/sys/geom/part/g_part_ebr.c
 
 Modified: head/sys/geom/part/g_part_ebr.c
 ==============================================================================
 --- head/sys/geom/part/g_part_ebr.c	Tue Dec 28 03:27:20 2010	(r216753)
 +++ head/sys/geom/part/g_part_ebr.c	Tue Dec 28 08:36:44 2010	(r216754)
 @@ -377,7 +377,7 @@ g_part_ebr_probe(struct g_part_table *ta
  	char psn[8];
  	struct g_provider *pp;
  	u_char *buf, *p;
 -	int error, index, res, sum;
 +	int error, index, res;
  	uint16_t magic;
  
  	pp = cp->provider;
 @@ -409,29 +409,11 @@ g_part_ebr_probe(struct g_part_table *ta
  	if (magic != DOSMAGIC)
  		goto out;
  
 -	/*
 -	 * The sector is all zeroes, except for the partition entries,
 -	 * pseudo boot code and some signatures or disk serial number.
 -	 * The latter can be found in the 9 bytes immediately in front
 -	 * of the partition table.
 -	 */
 -	sum = 0;
 -	for (index = 96; index < DOSPARTOFF - 9; index++)
 -		sum += buf[index];
 -	if (sum != 0)
 -		goto out;
 -
 -	for (index = 0; index < NDOSPART; index++) {
 +	for (index = 0; index < 2; index++) {
  		p = buf + DOSPARTOFF + index * DOSPARTSIZE;
  		if (p[0] != 0 && p[0] != 0x80)
  			goto out;
 -		if (index < 2)
 -			continue;
 -		/* The 3rd & 4th entries are always zero. */
 -		if ((le64dec(p+0) + le64dec(p+8)) != 0)
 -			goto out;
  	}
 -
  	res = G_PART_PROBE_PRI_NORM;
  
   out:
 @@ -450,7 +432,7 @@ g_part_ebr_read(struct g_part_table *bas
  	u_char *buf;
  	off_t ofs, msize;
  	u_int lba;
 -	int error, index;
 +	int error, index, sum;
  
  	pp = cp->provider;
  	table = (struct g_part_ebr_table *)basetable;
 @@ -465,6 +447,28 @@ g_part_ebr_read(struct g_part_table *bas
  
  		ebr_entry_decode(buf + DOSPARTOFF + 0 * DOSPARTSIZE, ent + 0);
  		ebr_entry_decode(buf + DOSPARTOFF + 1 * DOSPARTSIZE, ent + 1);
 +
 +		/* The 3rd & 4th entries should be zeroes. */
 +		if (le64dec(buf + DOSPARTOFF + 2 * DOSPARTSIZE) +
 +		    le64dec(buf + DOSPARTOFF + 3 * DOSPARTSIZE) != 0) {
 +			basetable->gpt_corrupt = 1;
 +			printf("GEOM: %s: invalid entries in the EBR ignored.\n",
 +			    pp->name);
 +		}
 +		/* We do not support bootcode for EBR. If bootcode area is
 +		 * not zeroes, then mark this EBR as corrupt to do not break
 +		 * anything for another OS'es.
 +		 */
 +		if (lba == 0) {
 +			sum = 0;
 +			for (index = 0; index < DOSPARTOFF; index++)
 +				sum += buf[index];
 +			if (sum != 0) {
 +				basetable->gpt_corrupt = 1;
 +				printf("GEOM: %s: EBR has non empty bootcode.\n",
 +				    pp->name);
 +			}
 +		}
  		g_free(buf);
  
  		if (ent[0].dp_typ == 0)
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: ae 
State-Changed-When: Tue Dec 28 09:15:24 UTC 2010 
State-Changed-Why:  
Patched in head/. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 

From: Niclas Zeising <zeising@daemonic.se>
To: bug-followup@FreeBSD.org, freebsd@sopwith.solgatos.com
Cc: ae@freebsd.org
Subject: Re: kern/141235: [geom_part] 8.0 no longer provides /dev entries
 for all disk slices [regression]
Date: Tue, 17 May 2011 15:22:21 +0200

 There has been plenty more time than the 1 month MFC timeout. This can
 be merged into 8 and the pr closed.
 Regards!
 -- 
 Niclas

From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: Niclas Zeising <zeising@daemonic.se>
Cc: bug-followup@FreeBSD.org, freebsd@sopwith.solgatos.com
Subject: Re: kern/141235: [geom_part] 8.0 no longer provides /dev entries
 for all disk slices [regression]
Date: Tue, 17 May 2011 18:15:26 +0400

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enig81651B9292840979DEBE0EB1
 Content-Type: text/plain; charset=KOI8-R
 Content-Transfer-Encoding: quoted-printable
 
 On 17.05.2011 17:22, Niclas Zeising wrote:
 > There has been plenty more time than the 1 month MFC timeout. This can
 > be merged into 8 and the pr closed.
 > Regards!
 
 I have work in progress that is related to these changes and i want do
 MFC after it will be commited.
 
 --=20
 WBR, Andrey V. Elsukov
 
 
 --------------enig81651B9292840979DEBE0EB1
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.17 (FreeBSD)
 
 iQEcBAEBAgAGBQJN0oL+AAoJEAHF6gQQyKF6hvAH/iSjG4Eep7XPYdpDHWRTIXvM
 71F1gQcYDohH+OSxvTazZF+KNFA8CjJdV76NfKON0HcrwG3LymQkD5wepvp3lt8l
 WLImF+ekD1/ybbrAA0NNaER1AuJUmrRtEAwinnPcc/c1AcoU8MRwzPaN7z0jGDlm
 vtCvta/Ei9e8u+dHSJ9VhUJjLfVgEbxEpc0j6XPRtu2yAnpnG7BSTXJ4sLliFlZd
 Ukd7NWHBibvC+zdMqKU1cQuqHu8Cw3xrQw4QmAgFjbwMGMZrimb6yqjdez4ddV2X
 u7GAD2j+tZQQcU6afDMAr3fMqY5NAszHUPeZwXg66qDAN1Zv5gXpYotegPcuSEM=
 =m5KO
 -----END PGP SIGNATURE-----
 
 --------------enig81651B9292840979DEBE0EB1--

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/141235: commit references a PR
Date: Mon, 27 Jun 2011 12:43:02 +0000 (UTC)

 Author: ae
 Date: Mon Jun 27 12:42:48 2011
 New Revision: 223594
 URL: http://svn.freebsd.org/changeset/base/223594
 
 Log:
   EBR could contain an early stage of boot code. But we do not support it.
   Remove message about non empty bootcode, we can not break something
   while GEOM_PART_EBR_COMPAT is defined.
   
   But without GEOM_PART_EBR_COMPAT any changes in EBR are allowed and we
   can accidentally wipe the boot code. To do not break anything save
   the first EBR chunk and keep it untouched each time when we are
   changing EBR. Note that we are still not support boot code for EBR.
   
   PR:		kern/141235
   MFC after:	1 month
 
 Modified:
   head/sys/geom/part/g_part_ebr.c
 
 Modified: head/sys/geom/part/g_part_ebr.c
 ==============================================================================
 --- head/sys/geom/part/g_part_ebr.c	Mon Jun 27 12:21:11 2011	(r223593)
 +++ head/sys/geom/part/g_part_ebr.c	Mon Jun 27 12:42:48 2011	(r223594)
 @@ -59,6 +59,9 @@ FEATURE(geom_part_ebr_compat,
  
  struct g_part_ebr_table {
  	struct g_part_table	base;
 +#ifndef GEOM_PART_EBR_COMPAT
 +	u_char		ebr[EBRSIZE];
 +#endif
  };
  
  struct g_part_ebr_entry {
 @@ -459,7 +462,7 @@ g_part_ebr_read(struct g_part_table *bas
  	u_char *buf;
  	off_t ofs, msize;
  	u_int lba;
 -	int error, index, sum;
 +	int error, index;
  
  	pp = cp->provider;
  	table = (struct g_part_ebr_table *)basetable;
 @@ -482,20 +485,11 @@ g_part_ebr_read(struct g_part_table *bas
  			printf("GEOM: %s: invalid entries in the EBR ignored.\n",
  			    pp->name);
  		}
 -		/* We do not support bootcode for EBR. If bootcode area is
 -		 * not zeroes, then mark this EBR as corrupt to do not break
 -		 * anything for another OS'es.
 -		 */
 -		if (lba == 0) {
 -			sum = 0;
 -			for (index = 0; index < DOSPARTOFF; index++)
 -				sum += buf[index];
 -			if (sum != 0) {
 -				basetable->gpt_corrupt = 1;
 -				printf("GEOM: %s: EBR has non empty bootcode.\n",
 -				    pp->name);
 -			}
 -		}
 +#ifndef GEOM_PART_EBR_COMPAT
 +		/* Save the first EBR, it can contain a boot code */
 +		if (lba == 0)
 +			bcopy(buf, table->ebr, sizeof(table->ebr));
 +#endif
  		g_free(buf);
  
  		if (ent[0].dp_typ == 0)
 @@ -583,6 +577,9 @@ g_part_ebr_type(struct g_part_table *bas
  static int
  g_part_ebr_write(struct g_part_table *basetable, struct g_consumer *cp)
  {
 +#ifndef GEOM_PART_EBR_COMPAT
 +	struct g_part_ebr_table *table;
 +#endif
  	struct g_provider *pp;
  	struct g_part_entry *baseentry, *next;
  	struct g_part_ebr_entry *entry;
 @@ -592,6 +589,10 @@ g_part_ebr_write(struct g_part_table *ba
  
  	pp = cp->provider;
  	buf = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO);
 +#ifndef GEOM_PART_EBR_COMPAT
 +	table = (struct g_part_ebr_table *)basetable;
 +	bcopy(table->ebr, buf, DOSPARTOFF);
 +#endif
  	le16enc(buf + DOSMAGICOFFSET, DOSMAGIC);
  
  	baseentry = LIST_FIRST(&basetable->gpt_entry);
 @@ -644,7 +645,10 @@ g_part_ebr_write(struct g_part_table *ba
  
  		error = g_write_data(cp, baseentry->gpe_start * pp->sectorsize,
  		    buf, pp->sectorsize);
 -
 +#ifndef GEOM_PART_EBR_COMPAT
 +		if (baseentry->gpe_start == 0)
 +			bzero(buf, DOSPARTOFF);
 +#endif
  		baseentry = next;
  	} while (!error && baseentry != NULL);
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: ae 
State-Changed-When: Wed Jul 27 04:23:37 UTC 2011 
State-Changed-Why:  
Merged to stable/8. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141235 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/141235: commit references a PR
Date: Wed, 27 Jul 2011 04:23:41 +0000 (UTC)

 Author: ae
 Date: Wed Jul 27 04:23:26 2011
 New Revision: 224465
 URL: http://svn.freebsd.org/changeset/base/224465
 
 Log:
   MFC r216754:
     Make EBR probe method less strictly to be able detect EBRs with
     small non fatal inconsistency. EBR may contain boot loader and sometimes
     it just has some garbage data. Now this does not prevent FreeBSD to use
     extended partitions. But since we do not support bootcode for EBR we mark
     tables which have non empty boot area as corrupt. This does make them
     readonly and we can not damage this data.
   
   MFC r223594:
     EBR could contain an early stage of boot code. But we do not support it.
     Remove message about non empty bootcode, we can not break something
     while GEOM_PART_EBR_COMPAT is defined.
   
     But without GEOM_PART_EBR_COMPAT any changes in EBR are allowed and we
     can accidentally wipe the boot code. To do not break anything save
     the first EBR chunk and keep it untouched each time when we are
     changing EBR. Note that we are still not support boot code for EBR.
   
     PR:		kern/141235
 
 Modified:
   stable/8/sys/geom/part/g_part_ebr.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/geom/label/   (props changed)
 
 Modified: stable/8/sys/geom/part/g_part_ebr.c
 ==============================================================================
 --- stable/8/sys/geom/part/g_part_ebr.c	Wed Jul 27 04:10:32 2011	(r224464)
 +++ stable/8/sys/geom/part/g_part_ebr.c	Wed Jul 27 04:23:26 2011	(r224465)
 @@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$");
  
  struct g_part_ebr_table {
  	struct g_part_table	base;
 +#ifndef GEOM_PART_EBR_COMPAT
 +	u_char		ebr[EBRSIZE];
 +#endif
  };
  
  struct g_part_ebr_entry {
 @@ -395,7 +398,7 @@ g_part_ebr_probe(struct g_part_table *ta
  	char psn[8];
  	struct g_provider *pp;
  	u_char *buf, *p;
 -	int error, index, res, sum;
 +	int error, index, res;
  	uint16_t magic;
  
  	pp = cp->provider;
 @@ -427,29 +430,11 @@ g_part_ebr_probe(struct g_part_table *ta
  	if (magic != DOSMAGIC)
  		goto out;
  
 -	/*
 -	 * The sector is all zeroes, except for the partition entries,
 -	 * pseudo boot code and some signatures or disk serial number.
 -	 * The latter can be found in the 9 bytes immediately in front
 -	 * of the partition table.
 -	 */
 -	sum = 0;
 -	for (index = 96; index < DOSPARTOFF - 9; index++)
 -		sum += buf[index];
 -	if (sum != 0)
 -		goto out;
 -
 -	for (index = 0; index < NDOSPART; index++) {
 +	for (index = 0; index < 2; index++) {
  		p = buf + DOSPARTOFF + index * DOSPARTSIZE;
  		if (p[0] != 0 && p[0] != 0x80)
  			goto out;
 -		if (index < 2)
 -			continue;
 -		/* The 3rd & 4th entries are always zero. */
 -		if ((le64dec(p+0) + le64dec(p+8)) != 0)
 -			goto out;
  	}
 -
  	res = G_PART_PROBE_PRI_NORM;
  
   out:
 @@ -483,6 +468,19 @@ g_part_ebr_read(struct g_part_table *bas
  
  		ebr_entry_decode(buf + DOSPARTOFF + 0 * DOSPARTSIZE, ent + 0);
  		ebr_entry_decode(buf + DOSPARTOFF + 1 * DOSPARTSIZE, ent + 1);
 +
 +		/* The 3rd & 4th entries should be zeroes. */
 +		if (le64dec(buf + DOSPARTOFF + 2 * DOSPARTSIZE) +
 +		    le64dec(buf + DOSPARTOFF + 3 * DOSPARTSIZE) != 0) {
 +			basetable->gpt_corrupt = 1;
 +			printf("GEOM: %s: invalid entries in the EBR ignored.\n",
 +			    pp->name);
 +		}
 +#ifndef GEOM_PART_EBR_COMPAT
 +		/* Save the first EBR, it can contain a boot code */
 +		if (lba == 0)
 +			bcopy(buf, table->ebr, sizeof(table->ebr));
 +#endif
  		g_free(buf);
  
  		if (ent[0].dp_typ == 0)
 @@ -570,6 +568,9 @@ g_part_ebr_type(struct g_part_table *bas
  static int
  g_part_ebr_write(struct g_part_table *basetable, struct g_consumer *cp)
  {
 +#ifndef GEOM_PART_EBR_COMPAT
 +	struct g_part_ebr_table *table;
 +#endif
  	struct g_provider *pp;
  	struct g_part_entry *baseentry, *next;
  	struct g_part_ebr_entry *entry;
 @@ -579,6 +580,10 @@ g_part_ebr_write(struct g_part_table *ba
  
  	pp = cp->provider;
  	buf = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO);
 +#ifndef GEOM_PART_EBR_COMPAT
 +	table = (struct g_part_ebr_table *)basetable;
 +	bcopy(table->ebr, buf, DOSPARTOFF);
 +#endif
  	le16enc(buf + DOSMAGICOFFSET, DOSMAGIC);
  
  	baseentry = LIST_FIRST(&basetable->gpt_entry);
 @@ -631,7 +636,10 @@ g_part_ebr_write(struct g_part_table *ba
  
  		error = g_write_data(cp, baseentry->gpe_start * pp->sectorsize,
  		    buf, pp->sectorsize);
 -
 +#ifndef GEOM_PART_EBR_COMPAT
 +		if (baseentry->gpe_start == 0)
 +			bzero(buf, DOSPARTOFF);
 +#endif
  		baseentry = next;
  	} while (!error && baseentry != NULL);
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
