Re: [PATCH] 1/1: Device-Mapper: Remove 1024 devices limitation

From: Alasdair G Kergon
Date: Tue Jul 06 2004 - 16:37:12 EST


On Tue, Jul 06, 2004 at 02:23:35PM -0700, Andrew Morton wrote:
> Kevin Corry <kevcorry@xxxxxxxxxx> wrote:

> > It seems (based on some comments in lib/idr.c) that

> Confused. idr_find() returns the thing it found, or NULL.

Yes, but the comments imply that the thing it found might in some
circumstances not be the thing you asked it to look for (if there've
been deletions) and it's the caller's responsibility to verify
what's returned.

> To which comments do you refer?

lib/idr.c:30

* What you need to do is, since we don't keep the counter as part of
* id / ptr pair, to keep a copy of it in the pointed to structure
* (or else where) so that when you ask for a ptr you can varify that
* the returned ptr is correct by comparing the id it contains with the one
* you asked for. In other words, we only did half the reuse protection.
* Since the code depends on your code doing this check, we ignore high
* order bits in the id, not just the count, but bits that would, if used,
* index outside of the allocated ids. In other words, if the largest id
* currently allocated is 32 a look up will only look at the low 5 bits of
* the id. Since you will want to keep this id in the structure anyway
* (if for no other reason than to be able to eliminate the id when the
* structure is found in some other way) this seems reasonable. If you
* really think otherwise, the code to check these bits here, it is just
* disabled with a #if 0.

Alasdair
--
agk@xxxxxxxxxx
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/