]> err.no Git - linux-2.6/commitdiff
[PATCH] md: use ffz instead of find_first_set to convert multiplier to shift
authorPaul Clements <paul.clements@steeleye.com>
Tue, 3 Oct 2006 08:16:01 +0000 (01:16 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 3 Oct 2006 15:04:18 +0000 (08:04 -0700)
find_first_set doesn't find the least-significant bit on bigendian machines,
so it is really wrong to use it.

ffs is closer, but takes an 'int' and we have a 'unsigned long'.  So use
ffz(~X) to convert a chunksize into a chunkshift.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/md/bitmap.c

index 0a44298fb3535bc2b5f7efae268387c065c130d1..8e67634e79a0d1f16d033e9e7ecdf3bcdd416f56 100644 (file)
@@ -1444,8 +1444,7 @@ int bitmap_create(mddev_t *mddev)
        if (err)
                goto error;
 
-       bitmap->chunkshift = find_first_bit(&bitmap->chunksize,
-                                       sizeof(bitmap->chunksize));
+       bitmap->chunkshift = ffz(~bitmap->chunksize);
 
        /* now that chunksize and chunkshift are set, we can use these macros */
        chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) /