All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: akpm@linux-foundation.org, "Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>
Subject: [PATCH 1/3] fs/unionfs/: Use __roundup_pow_of_two instead of custom rounding code
Date: Mon, 12 Feb 2007 13:30:50 -0500	[thread overview]
Message-ID: <11713050522466-git-send-email-jsipek@cs.sunysb.edu> (raw)
In-Reply-To: <11713050521708-git-send-email-jsipek@cs.sunysb.edu>

Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
 fs/unionfs/rdstate.c |   11 ++---------
 fs/unionfs/union.h   |    1 +
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/fs/unionfs/rdstate.c b/fs/unionfs/rdstate.c
index 16ce1bf..e240285 100644
--- a/fs/unionfs/rdstate.c
+++ b/fs/unionfs/rdstate.c
@@ -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)
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 8e9a1cc..fc87b03 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -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>
-- 
1.5.0.rc3.g5057


  reply	other threads:[~2007-02-12 18:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-12 18:30 [GIT PULL -mm] Unionfs updates/cleanups Josef 'Jeff' Sipek
2007-02-12 18:30 ` Josef 'Jeff' Sipek [this message]
2007-02-12 18:30 ` [PATCH 2/3] fs/: Move eCryptfs & Unionfs config options into a sub-menu Josef 'Jeff' Sipek
2007-02-12 18:30 ` [PATCH 3/3] Unionfs: Documentation update Josef 'Jeff' Sipek

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=11713050522466-git-send-email-jsipek@cs.sunysb.edu \
    --to=jsipek@cs.sunysb.edu \
    --cc=akpm@linux-foundation.org \
    --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.