linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Coly Li <i@coly.li>
To: linux-ext4@vger.kernel.org
Cc: Alex Tomas <alex@clusterfs.com>, Theodore Tso <tytso@google.com>
Subject: [PATCH 1/5] mballoc: code cleanup in mb_find_buddy()
Date: Sun, 06 Feb 2011 12:53:44 +0800	[thread overview]
Message-ID: <4D4E2958.2010705@coly.li> (raw)

Current code calculate max no matter whether order is zero, it's
unnecessary. This cleanup patch sets max to "1 << (e4b->bd_blkbits
+ 3)" only when order == 0.

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Alex Tomas <alex@clusterfs.com>
Cc: Theodore Tso <tytso@google.com>
---
  fs/ext4/mballoc.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 851f49b..d5b372c 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -427,9 +427,10 @@ static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max)
  	}

  	/* at order 0 we see each particular block */
-	*max = 1 << (e4b->bd_blkbits + 3);
-	if (order == 0)
+	if (order == 0) {
+		*max = 1 << (e4b->bd_blkbits + 3);
  		return EXT4_MB_BITMAP(e4b);
+	}

  	bb = EXT4_MB_BUDDY(e4b) + EXT4_SB(e4b->bd_sb)->s_mb_offsets[order];
  	*max = EXT4_SB(e4b->bd_sb)->s_mb_maxs[order];
-- 
1.7.3.4

             reply	other threads:[~2011-02-06  4:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-06  4:53 Coly Li [this message]
2011-02-24 19:06 ` [PATCH 1/5] mballoc: code cleanup in mb_find_buddy() Ted Ts'o

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=4D4E2958.2010705@coly.li \
    --to=i@coly.li \
    --cc=alex@clusterfs.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@google.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;
as well as URLs for NNTP newsgroup(s).