From owner-freebsd-current@FreeBSD.ORG Sat Jul 11 18:15:25 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D47E1065670 for ; Sat, 11 Jul 2009 18:15:25 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id E429F8FC19 for ; Sat, 11 Jul 2009 18:15:24 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) DomainKey-Signature: a=rsa-sha1; q=dns; c=simple; s=one; d=codelabs.ru; h=Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:Sender; b=nsAgiMTHD2GiP04PEO4lxdGmx5qFWzynyJ2/ovNaOza+A6MzOa9MQz70eKoobeyHm27/c3GhCBOp2yBvtDt4fg3i+1HcaQVPlCHqLWPlJs7LVlX6XeKvOLcryln8cRrHupwf3m0OhYNoqav5jTHjGNgCwyXnCgZW3SOdxksLz30=; Received: from amnesiac.at.no.dns (ppp85-141-163-216.pppoe.mtu-net.ru [85.141.163.216]) by 0.mx.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1MPh6X-000Ex6-6Z; Sat, 11 Jul 2009 22:15:21 +0400 Date: Sat, 11 Jul 2009 22:15:19 +0400 From: Eygene Ryabinkin To: Marcel Moolenaar , freebsd-current@freebsd.org Message-ID: References: <20090710042106.GC31950@rwpc12.mby.riverwillow.net.au> <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> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="V0207lvV8h4k8FAm" Content-Disposition: inline In-Reply-To: <267A655F-13A6-4D79-A933-3A78854AC5FD@mac.com> Sender: rea-fbsd@codelabs.ru Cc: John Marshall Subject: Re: 8.0-BETA1 bsdlabel broken? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rea-fbsd@codelabs.ru List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jul 2009 18:15:25 -0000 --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 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 --- 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--