Date: Sat, 11 Jul 2009 22:15:19 +0400 From: Eygene Ryabinkin <rea-fbsd@codelabs.ru> To: Marcel Moolenaar <xcllnt@mac.com>, freebsd-current@freebsd.org Cc: John Marshall <john.marshall@riverwillow.com.au> Subject: Re: 8.0-BETA1 bsdlabel broken? Message-ID: <TiR5kGIN59NiPk3Q5HjMiImYooQ@MbxgtlHN37ICHkxRO9kSrKasfoA> In-Reply-To: <267A655F-13A6-4D79-A933-3A78854AC5FD@mac.com> References: <v/OAX36A7OnJtyaNY4uYnXPs%2BOI@CWODRlDR5RMqbkBfR0/UzHcfNhE> <EC5F9AF8-2C2D-45DF-A1A2-8481EC73E426@mac.com> <20090710042106.GC31950@rwpc12.mby.riverwillow.net.au> <fX%2BVI6m2svXk4wDqOGQ3HIesgO8@jmKTY7juey8QgiyMw1P6k9Lb4sg> <20090710071023.GB32316@rwpc12.mby.riverwillow.net.au> <20090710112631.GE32316@rwpc12.mby.riverwillow.net.au> <3a142e750907100433y307f9b2bya1dc54953bdf5de2@mail.gmail.com> <0B1F6799-2FAC-4C01-A978-42E247979CAB@mac.com> <1z5niluEh3OBPNSdMbOMyoEwzX4@CWODRlDR5RMqbkBfR0/UzHcfNhE> <267A655F-13A6-4D79-A933-3A78854AC5FD@mac.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--V0207lvV8h4k8FAm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline G'day. Fri, Jul 10, 2009 at 10:15:27AM -0700, Marcel Moolenaar wrote: > There is no need for the verb. bsdlabel should use the same > logic the kernel is using: if the C partition has a non-zero > offset, then the label is absolute and you can subtract that > offset from all partitions to make the label relative. OK, the attached patch should solve the issue in the bsdlabel: it really uses the offset of the 'c' partition to make offsets to be relative. Sat, Jul 11, 2009 at 06:24:14PM +1000, John Marshall wrote: > > Can you send me the output of "gpart show da0" and "gpart show da0s1". > > Could you also send me (or make available for download) a binary dump > > of sectors 0 (the MBR), 63 and 64 (the disklabel in slice 1). > > I have backed out the inclusion of GEOM_BSD in the kernel and no longer > have the WARNING messages appearing in dmesg. Yes, sorry -- it was my fault to advise to include it. Please, try the attached patch -- it should heal bsdlabel and it will show/use the proper offsets everywhere. Works fine for me -- offsets for 7.x and 8.x are the same. Fri, Jul 10, 2009 at 09:33:10AM -0700, Marcel Moolenaar wrote: > Please don't use GEOM_BSD. It's obsolete. I haven't removed > the code out of conservatism, but consider it dead and gone. > > As a special warning: you should not have both GEOM_PART_BSD > and GEOM_BSD. My gut feeling tells me that you have both and > that's why you have the mess you're having. Then I would add a bit stronger warning about the GEOM_BSD into /usr/src/UPDATING -- the current one (from 20090320) is rather mild in respect of the obsoletenness of GEOM_BSD. And since GEOM_PART_* seem to be included by-default, it will produce the mess I had seen when GEOM_BSD is included too. It will be good to embed the checks for incompatible options into config(8). I'll draft the needed patches for config(8). -- Eygene _ ___ _.--. # \`.|\..----...-'` `-._.-'_.-'` # Remember that it is hard / ' ` , __.--' # to read the on-line manual )/' _/ \ `-_, / # while single-stepping the kernel. `-'" `"\_ ,_.-;_.-\_ ', fsc/as # _.-'_./ {_.' ; / # -- FreeBSD Developers handbook {_.-``-' {_/ # --V0207lvV8h4k8FAm Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="obtain-slice-offset-from-disklabel.diff" Content-Transfer-Encoding: quoted-printable =46rom fb4d6d8676700caf861d164003339fb1609e05db Mon Sep 17 00:00:00 2001 =46rom: Eygene Ryabinkin <rea-fbsd@codelabs.ru> Date: Sat, 11 Jul 2009 14:53:11 +0400 Subject: [PATCH] bsdlabel: obtain slice offset from the disklabel itself Don't use offset from MBR that is obtained by the geom(4): not any system has MBR and so on ;)) Partition 'c' holds offset, so it is used -- this corresponds to the current kernel behaviour. Signed-off-by: Eygene Ryabinkin <rea-fbsd@codelabs.ru> --- sbin/bsdlabel/bsdlabel.c | 28 ++++++++-------------------- 1 files changed, 8 insertions(+), 20 deletions(-) diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c index 1cb9995..5aa97df 100644 --- a/sbin/bsdlabel/bsdlabel.c +++ b/sbin/bsdlabel/bsdlabel.c @@ -118,7 +118,6 @@ static int installboot; /* non-zero if we should instal= l a boot program */ static int allfields; /* present all fields in edit */ static char const *xxboot; /* primary boot */ =20 -static off_t mbroffset; #ifndef LABELSECTOR #define LABELSECTOR -1 #endif @@ -388,6 +387,7 @@ writelabel(void) struct gctl_req *grq; char const *errstr; struct disklabel *lp =3D &lab; + off_t sliceoffset; =20 if (disable_write) { warnx("write to disk label supressed - label was as follows:"); @@ -401,9 +401,10 @@ writelabel(void) lp->d_checksum =3D dkcksum(lp); if (installboot) readboot(); + sliceoffset =3D lab.d_partitions[RAW_PART].p_offset; for (i =3D 0; i < lab.d_npartitions; i++) if (lab.d_partitions[i].p_size) - lab.d_partitions[i].p_offset +=3D mbroffset; + lab.d_partitions[i].p_offset +=3D sliceoffset; bsd_disklabel_le_enc(bootarea + labeloffset + labelsoffset * secsize, lp); if (alphacksum) { @@ -481,8 +482,7 @@ readlabel(int flag) { int f, i; int error; - struct gctl_req *grq; - char const *errstr; + off_t sliceoffset; =20 f =3D open(specname, O_RDONLY); if (f < 0) @@ -510,22 +510,10 @@ readlabel(int flag) =20 if (is_file) return(0); - grq =3D gctl_get_handle(); - gctl_ro_param(grq, "verb", -1, "read mbroffset"); - gctl_ro_param(grq, "class", -1, "BSD"); - gctl_ro_param(grq, "geom", -1, pname); - gctl_rw_param(grq, "mbroffset", sizeof(mbroffset), &mbroffset); - errstr =3D gctl_issue(grq); - if (errstr !=3D NULL) { - mbroffset =3D 0; - gctl_free(grq); - return (error); - } - mbroffset /=3D lab.d_secsize; - if (lab.d_partitions[RAW_PART].p_offset =3D=3D mbroffset) - for (i =3D 0; i < lab.d_npartitions; i++) - if (lab.d_partitions[i].p_size) - lab.d_partitions[i].p_offset -=3D mbroffset; + sliceoffset =3D lab.d_partitions[RAW_PART].p_offset; + for (i =3D 0; i < lab.d_npartitions; i++) + if (lab.d_partitions[i].p_size) + lab.d_partitions[i].p_offset -=3D sliceoffset; return (error); } =20 --=20 1.6.3.1 --V0207lvV8h4k8FAm--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?TiR5kGIN59NiPk3Q5HjMiImYooQ>