Re: [PATCH NFS 3/3] Replace nfs_block_bits() with roundup_pow_of_two()

From: Rene Scharfe
Date: Tue Jul 26 2005 - 15:48:03 EST


On Tue, Jul 26, 2005 at 01:48:46PM -0400, Trond Myklebust wrote:
> I really don't like the choice of name. If you feel you must change the
> name, then make it something like nfs_blocksize_align(). That describes
> its function, instead of the implementation details.

Yes, rounddown_pow_of_two() belongs in kernel.h next to
roundup_pow_of_two(). And maybe it should get a shorter name.

Anyway, I also don't like "nfs_blocksize_align". So let's simply keep
the old name. Renaming can be done later if really needed.

Rene


[PATCH 3/3] Simplify nfs_block_bits()

Signed-off-by: Rene Scharfe <rene.scharfe@xxxxxxxxxxxxxx>
---

fs/nfs/inode.c | 12 ++----------
1 files changed, 2 insertions(+), 10 deletions(-)

ddad5eadf4c2907842bf9baa2610e0a35ea14137
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -189,16 +189,8 @@ nfs_umount_begin(struct super_block *sb)
static inline unsigned long
nfs_block_bits(unsigned long bsize)
{
- /* make sure blocksize is a power of two */
- if (bsize & (bsize - 1)) {
- unsigned char nrbits;
-
- for (nrbits = 31; nrbits && !(bsize & (1 << nrbits)); nrbits--)
- ;
- bsize = 1 << nrbits;
- }
-
- return bsize;
+ /* round down to the nearest power of two */
+ return bsize ? (1UL << (fls(bsize) - 1)) : 0;
}

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