From owner-freebsd-fs@FreeBSD.ORG Wed Feb 8 07:31:52 2012 Return-Path: Delivered-To: freebsd-fs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E2E1106564A; Wed, 8 Feb 2012 07:31:52 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mail.kirov.so-ups.ru (mail.kirov.so-ups.ru [178.74.170.1]) by mx1.freebsd.org (Postfix) with ESMTP id 1BA108FC17; Wed, 8 Feb 2012 07:31:51 +0000 (UTC) Received: from kas30pipe.localhost (localhost.kirov.so-ups.ru [127.0.0.1]) by mail.kirov.so-ups.ru (Postfix) with SMTP id 2EE42B8071; Wed, 8 Feb 2012 11:31:50 +0400 (MSK) Received: from kirov.so-ups.ru (unknown [172.21.81.1]) by mail.kirov.so-ups.ru (Postfix) with ESMTP id 29329B8070; Wed, 8 Feb 2012 11:31:50 +0400 (MSK) Received: by ns.kirov.so-ups.ru (Postfix, from userid 1010) id 244BCB8F6C; Wed, 8 Feb 2012 11:31:50 +0400 (MSK) Received: from [127.0.0.1] (elsukov.kirov.oduur.so [10.118.3.52]) by ns.kirov.so-ups.ru (Postfix) with ESMTP id CD54FB8F45; Wed, 8 Feb 2012 11:31:49 +0400 (MSK) Message-ID: <4F3224E5.10406@FreeBSD.org> Date: Wed, 08 Feb 2012 11:31:49 +0400 From: "Andrey V. Elsukov" User-Agent: Mozilla Thunderbird 1.5 (FreeBSD/20051231) MIME-Version: 1.0 To: Yar Tikhiy References: <201202072310.q17NAD0h052230@freefall.freebsd.org> In-Reply-To: <201202072310.q17NAD0h052230@freefall.freebsd.org> X-Enigmail-Version: 1.3.4 Content-Type: multipart/mixed; boundary="------------030908090907000300080105" X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0284], KAS30/Release X-SpamTest-Info: Not protected Cc: freebsd-fs@FreeBSD.org, Marcel Moolenaar , Pawel Jakub Dawidek Subject: Re: bin/145309: bsdlabel: Editing disk label invalidates the whole device X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Feb 2012 07:31:52 -0000 This is a multi-part message in MIME format. --------------030908090907000300080105 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit On 08.02.2012 3:10, Yar Tikhiy wrote: > > When you are in single user mode your root filesystem is mounted read-onl= > y. > > When you run bsdlabel it opens geom provider for writing and this trigger= > s spoiling for it. > > When bsdlabel closes provider GEOM_PART destroys it and creates again. > > But VFS code seems loses it. > > Sorry but do you think it's intended behavior or not? It doesn't look > so to me and, IMMSMR, it wasn't there before. Please correct me if > I'm wrong. GEOM_BSD class uses g_slice interface to implement partitions. It grabs an extra exclusive access bit when provider is opened first time. This grants him protection from spoiling. GEOM_PART class does this only when provider is opened for writing. We can try to change this behavior or just don't use bsdlabel :) Changes may lead to unexpected problems. If you want to test you can try attached patch (untested). -- WBR, Andrey V. Elsukov --------------030908090907000300080105 Content-Type: text/plain; name="g_part.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="g_part.c.diff" Index: head/sys/geom/part/g_part.c =================================================================== --- head/sys/geom/part/g_part.c (revision 231127) +++ head/sys/geom/part/g_part.c (working copy) @@ -1948,8 +1948,13 @@ g_part_access(struct g_provider *pp, int dr, int d cp = LIST_FIRST(&pp->geom->consumer); - /* We always gain write-exclusive access. */ - return (g_access(cp, dr, dw, dw + de)); + /* On first open, grab an extra "exclusive" bit */ + if (cp->acr == 0 && cp->acw == 0 && cp->ace == 0) + de++; + /* ... and let go of it on last close */ + if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1) + de--; + return (g_access(cp, dr, dw, de)); } static void --------------030908090907000300080105--