From owner-freebsd-geom@FreeBSD.ORG Thu Oct 25 08:36:43 2012 Return-Path: Delivered-To: freebsd-geom@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 64677F1D for ; Thu, 25 Oct 2012 08:36:43 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id AA7828FC12 for ; Thu, 25 Oct 2012 08:36:42 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id LAA05260; Thu, 25 Oct 2012 11:36:39 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1TRIvf-000JfA-0r; Thu, 25 Oct 2012 11:36:39 +0300 Message-ID: <5088FA15.30205@FreeBSD.org> Date: Thu, 25 Oct 2012 11:36:37 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:16.0) Gecko/20121013 Thunderbird/16.0.1 MIME-Version: 1.0 To: Poul-Henning Kamp Subject: Re: geom access method and g_topology_lock References: <5088E0E0.2080307@FreeBSD.org> <28185.1351150111@critter.freebsd.dk> In-Reply-To: <28185.1351150111@critter.freebsd.dk> X-Enigmail-Version: 1.4.5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-geom@FreeBSD.org X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2012 08:36:43 -0000 on 25/10/2012 10:28 Poul-Henning Kamp said the following: > -------- > In message <5088E0E0.2080307@FreeBSD.org>, Andriy Gapon writes: Unfortunately the questions got stripped :-) >> The problem is that the following innocent-looking code may become not quite so >> innocent: >> >> g_topology_assert(); >> g_access(cp, -1, 0, -1); >> /* a lot might have happened between these two lines */ >> g_detach(cp); >> g_destroy_consumer(cp); > > > It really depends what "a lot" actually is. > > It is perfectly legal and acceptable for a consumer to be attached to a provider > without holding an access count. > > But lacking an access count, there are obviously things you cannot do to that > provider. To be less cryptic: there is a piece of code that tries to re-use the consumer in certain situations. Basically, in addition to the above snippet there is a different snippet in a different function (oversimplified version): g_topology_assert(); LIST_FOREACH(cp, &gp->consumer, consumer) { if (cp->provider == pp) break; } if (cp != NULL) g_access(cp, 1, 0, 1) Both pieces look sane and non-racy (because of g_topology_assert) until we allow g_access (some geom access method, rather) to drop the topology lock. Hence my original questions. I would also accept that such a re-use of a consumer is a bad idea on its own. -- Andriy Gapon