From: Andrew Morton <akpm@linux-foundation.org>
To: Jeff Layton <jlayton@redhat.com>
Cc: hch@infradead.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] make iunique use a do/while loop rather than its obscure goto loop
Date: Fri, 13 Apr 2007 12:55:12 -0700 [thread overview]
Message-ID: <20070413125512.af11f013.akpm@linux-foundation.org> (raw)
In-Reply-To: <461FD536.80903@redhat.com>
On Fri, 13 Apr 2007 15:08:38 -0400
Jeff Layton <jlayton@redhat.com> wrote:
> >
> > ino_t iunique(struct super_block *sb, ino_t max_reserved)
> > {
> > static ino_t counter;
> > struct inode *inode;
> > struct hlist_head * head;
> > ino_t res;
> >
> > spin_lock(&inode_lock);
> > do {
> > if (counter <= max_reserved)
> > counter = max_reserved + 1;
> > res = counter++;
> > head = inode_hashtable + hash(sb, res);
> > inode = find_inode_fast(sb, head, res);
> > } while (inode != NULL);
> > spin_unlock(&inode_lock);
> >
> > return res;
> > }
> >
> > The counter-vs-max_reserved test can be moved outside the loop, can't it?
> >
>
> No. If the counter wraps while we're looping, then we'll need to skip
> past the "reserved" inode numbers. So we need to check this on every
> loop iteration.
oh.
(wonders why alpha and s390 use unsigned int for ino_t while everyone
else uses unsigned long)
> We could potentially put that in an "unlikely" if you
> think that would be better.
Doubt if it'd make much difference.
> > Shouldn't counter be per-sb?
>
> I doubt it really matters too much, but it could potentially be more
> efficient to do that, especially after a wraparound on the counter. It
> might be reasonable to make new_inode use a per-sb counter as well. Do
> you think it's worth respinning?
Well, that'd be a separate patch. Sometime, if you're keen.
If that function is ever a performance problem, it'll be an awful
performance problem and we'd need to so something smarter than
a linear search - an idr tree, for example.
next prev parent reply other threads:[~2007-04-13 19:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-11 21:58 [PATCH] make iunique use a do/while loop rather than its obscure goto loop Jeffrey Layton
2007-04-13 18:42 ` Andrew Morton
2007-04-13 19:08 ` Jeff Layton
2007-04-13 19:55 ` Andrew Morton [this message]
2007-06-23 8:08 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2007-01-30 15:45 Jeffrey Layton
2007-01-31 8:16 ` Christoph Hellwig
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=20070413125512.af11f013.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.