public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Alasdair G Kergon <agk@redhat.com>
Cc: kevcorry@us.ibm.com, linux-kernel@vger.kernel.org,
	dm-devel@redhat.com, torvalds@osdl.org, agk@redhat.com,
	jim.houston@comcast.net
Subject: Re: [PATCH] 1/1: Device-Mapper: Remove 1024 devices limitation
Date: Tue, 6 Jul 2004 15:20:00 -0700	[thread overview]
Message-ID: <20040706152000.6d83c3a3.akpm@osdl.org> (raw)
In-Reply-To: <20040706213552.GA30237@agk.surrey.redhat.com>

Alasdair G Kergon <agk@redhat.com> wrote:
>
> > 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.

ah, OK.  The original idr.c code had a (weird) feature in which each time
you add a new element, idr_add_new() returns a generation counter in the
top bits of the returned index.  So when doing a lookup the idr code would
mask the counter bits off the index before using it.

This was so that if someone did a quick add/remove/add, the second `add'
would return the same index, with a different counter in te top eight bits.

When you do another lookup you can compare the counter which you imbedded
in the object with the counter in the index which you used for the lookup. 
If they're different, you know that someone has deleted the object you were
looking for.

It was, IMO, sorry, a complete crock and was all thrown away a month or so
ago.

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

The comment is stale - I'll remove it.

  parent reply	other threads:[~2004-07-06 22:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-01 15:35 [PATCH] 1/1: Device-Mapper: Remove 1024 devices limitation Kevin Corry
2004-07-01 21:38 ` Andrew Morton
2004-07-02  2:54   ` Kevin Corry
2004-07-02  3:30     ` Andrew Morton
2004-07-02 17:33       ` Kevin Corry
2004-07-02 19:42         ` Andrew Morton
2004-07-06 18:23           ` Kevin Corry
2004-07-06 21:23             ` Andrew Morton
2004-07-06 21:35               ` Alasdair G Kergon
2004-07-06 22:04                 ` Alasdair G Kergon
2004-07-06 22:20                 ` Andrew Morton [this message]
2004-07-06 22:07               ` Jim Houston
2004-07-06 22:28                 ` Andrew Morton
2004-07-06 23:00                   ` Jim Houston
2004-07-06 23:16                     ` Andrew Morton
2004-07-07 10:58                       ` Jim Houston
2004-07-07 11:10                         ` Andrew Morton
2004-07-12 14:49                           ` Kevin Corry
2004-07-12 18:14                             ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040706152000.6d83c3a3.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=jim.houston@comcast.net \
    --cc=kevcorry@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox