geom access method and g_topology_lock
Andriy Gapon
avg at FreeBSD.org
Thu Oct 25 08:36:43 UTC 2012
on 25/10/2012 10:28 Poul-Henning Kamp said the following:
> --------
> In message <5088E0E0.2080307 at 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
More information about the freebsd-geom
mailing list