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

Alasdair G Kergon agk at redhat.com
Tue Jul 6 21:35:52 UTC 2004

On Tue, Jul 06, 2004 at 02:23:35PM -0700, Andrew Morton wrote:
> Kevin Corry <kevcorry at us.ibm.com> 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?


 * 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.

agk at redhat.com

More information about the dm-devel mailing list