From: David Chinner <dgc@sgi.com>
To: Andi Kleen <ak@suse.de>
Cc: xfs@oss.sgi.com, cattelan@thebarn.com
Subject: Re: [PATCH] Replace XFS bit functions with Linux functions
Date: Tue, 2 Oct 2007 22:59:23 +1000 [thread overview]
Message-ID: <20071002125923.GH995458@sgi.com> (raw)
In-Reply-To: <200710021010.58284.ak@suse.de>
On Tue, Oct 02, 2007 at 10:10:58AM +0200, Andi Kleen wrote:
> XFS had some own functions to find high and low bits.
>
> This patch replaces them with a call to the respective Linux functions.
> The semantics of the Linux functions differ a little, but i checked
> all call sites that they can deal with that. I think all callers
> are ok; but i added a few more asserts for the 0 case (where Linux
> and old XFS differ) just to make it easy to detect mistakes.
>
> Index: linux-2.6.23-rc8-misc/fs/xfs/xfs_iget.c
> ===================================================================
> --- linux-2.6.23-rc8-misc.orig/fs/xfs/xfs_iget.c
> +++ linux-2.6.23-rc8-misc/fs/xfs/xfs_iget.c
> @@ -55,8 +55,7 @@ xfs_ihash_init(xfs_mount_t *mp)
> if (!mp->m_ihsize) {
> icount = mp->m_maxicount ? mp->m_maxicount :
> (mp->m_sb.sb_dblocks << mp->m_sb.sb_inopblog);
> - mp->m_ihsize = 1 << max_t(uint, 8,
> - (xfs_highbit64(icount) + 1) / 2);
> + mp->m_ihsize = 1 << max_t(uint, 8, fls64(icount) / 2);
> mp->m_ihsize = min_t(uint, mp->m_ihsize,
> (64 * NBPP) / sizeof(xfs_ihash_t));
> }
This is well out of date with where the XFS tree is now.
You might want to rebase this on the XFS CVS code or the master
branch of the XFS git tree...
So the conversion is:
xfs_highbit64 -> fls64() - 1
xfs_lowbit64(v) -> find_first_bit(&v, 64)
xfs_highbit32 -> fls - 1
xfs_lowbit32(v) -> find_first_bit(&v, 32)
and touching lots of places where the xfs functions are used.
One thing that is notable here is that the XFS code returns
-1 if no bits are set. fls/fls64 return 0 in the same case, so
the magic "- 1" will make them behave the same. however, it
appears that find_first_bit() will return the number of bits
searched. That might leave us with som nasty, non-obvious error
cases....
Also, I don't really like the fact it requires sprinkling magic "-
1" adjustments to the return value of the replacement functions. If
that is the way the functions work and relate to the XFS bitmaps,
then that *should* be hidden away in a macro/static inline so it
doesn't get screwed up in future.
Hence I'd prefer to keep the xfs wrappers whilst replacing the guts of
them with the more efficient generic code. I'm not too concerned,
though, but Russell might want to comment here...
Cheers,
Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
next prev parent reply other threads:[~2007-10-02 12:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-02 8:10 [PATCH] Replace XFS bit functions with Linux functions Andi Kleen
2007-10-02 9:55 ` Christoph Hellwig
2007-10-02 10:11 ` Andi Kleen
2007-10-02 12:59 ` David Chinner [this message]
2007-10-02 13:35 ` Andi Kleen
2007-10-02 16:37 ` Russell Cattelan
2007-10-03 17:58 ` Andi Kleen
2007-10-03 18:20 ` Russell Cattelan
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=20071002125923.GH995458@sgi.com \
--to=dgc@sgi.com \
--cc=ak@suse.de \
--cc=cattelan@thebarn.com \
--cc=xfs@oss.sgi.com \
/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