fs/unionfs/: Use __roundup_pow_of_two instead of custom rounding code
authorJosef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
Thu, 1 Feb 2007 17:14:03 +0000 (12:14 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 12 Jan 2009 23:20:17 +0000 (18:20 -0500)
Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
fs/unionfs/rdstate.c
fs/unionfs/union.h

index 16ce1bf26fa2de2dae192abc16348d2f41497a60..e2402852996273ddf7ff72b05370a4227eefa1c4 100644 (file)
@@ -115,19 +115,12 @@ struct unionfs_dir_state *alloc_rdstate(struct inode *inode, int bindex)
 {
        int i = 0;
        int hashsize;
-       int mallocsize = sizeof(struct unionfs_dir_state);
+       unsigned long mallocsize = sizeof(struct unionfs_dir_state);
        struct unionfs_dir_state *rdstate;
 
        hashsize = guesstimate_hash_size(inode);
        mallocsize += hashsize * sizeof(struct list_head);
-       /* Round it up to the next highest power of two. */
-       mallocsize--;
-       mallocsize |= mallocsize >> 1;
-       mallocsize |= mallocsize >> 2;
-       mallocsize |= mallocsize >> 4;
-       mallocsize |= mallocsize >> 8;
-       mallocsize |= mallocsize >> 16;
-       mallocsize++;
+       mallocsize = __roundup_pow_of_two(mallocsize);
 
        /* This should give us about 500 entries anyway. */
        if (mallocsize > PAGE_SIZE)
index 8e9a1cc56487487cf3266b9837a9bc4a046ecfc8..fc87b032d4aed3b3229a70c07edac47de79c8eae 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/xattr.h>
 #include <linux/fs_stack.h>
 #include <linux/magic.h>
+#include <linux/log2.h>
 
 #include <asm/mman.h>
 #include <asm/system.h>