Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Oct 2012 11:36:37 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        freebsd-geom@FreeBSD.org
Subject:   Re: geom access method and g_topology_lock
Message-ID:  <5088FA15.30205@FreeBSD.org>
In-Reply-To: <28185.1351150111@critter.freebsd.dk>
References:  <5088E0E0.2080307@FreeBSD.org> <28185.1351150111@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5088FA15.30205>