From: Miao Xie <miaox@cn.fujitsu.com>
To: Chris Mason <chris.mason@oracle.com>
Cc: Linux Btrfs <linux-btrfs@vger.kernel.org>
Subject: [PATCH 11/18] btrfs: Simplify btrfs_search_slot() for performance
Date: Thu, 25 Mar 2010 20:34:27 +0800 [thread overview]
Message-ID: <4BAB5853.9030402@cn.fujitsu.com> (raw)
From: Zhao Lei <zhaolei@cn.fujitsu.com>
This patch include following modify:
1: It isn't necessary to use following type of goto statement:
if (cow) {
if (!should_cow_block(trans, root, b))
goto cow_done;
...
}
cow_done:
...
2: Updating of p->nodes[level] is only necessary on cow.
we move these code into if (cow) {} block.
3: Updating of level and p->locks[level] is only necessary when
level is changed, so we avoid no-use operation in old code.
4: Add a unlikely() for rare case.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
fs/btrfs/ctree.c | 34 ++++++++++++++++------------------
1 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index c4bc570..4f258ba 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1724,15 +1724,12 @@ again:
if (!p->skip_locking)
p->locks[level] = 1;
- if (cow) {
- /*
- * if we don't really need to cow this block
- * then we don't want to set the path blocking,
- * so we test it here
- */
- if (!should_cow_block(trans, root, b))
- goto cow_done;
-
+ /*
+ * if we don't really need to cow this block
+ * then we don't want to set the path blocking,
+ * so we test it here
+ */
+ if (cow && should_cow_block(trans, root, b)) {
btrfs_set_path_blocking(p);
err = btrfs_cow_block(trans, root, b,
@@ -1743,17 +1740,18 @@ again:
ret = err;
goto done;
}
- }
-cow_done:
- BUG_ON(!cow && ins_len);
- if (level != btrfs_header_level(b))
- WARN_ON(1);
- level = btrfs_header_level(b);
- p->nodes[level] = b;
- if (!p->skip_locking)
- p->locks[level] = 1;
+ if (unlikely(level != btrfs_header_level(b))) {
+ WARN_ON(1);
+ level = btrfs_header_level(b);
+ if (!p->skip_locking)
+ p->locks[level] = 1;
+ }
+ p->nodes[level] = b;
+ }
+
+ BUG_ON(!cow && ins_len);
btrfs_clear_path_blocking(p, NULL);
/*
--
1.6.5.2
reply other threads:[~2010-03-25 12:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4BAB5853.9030402@cn.fujitsu.com \
--to=miaox@cn.fujitsu.com \
--cc=chris.mason@oracle.com \
--cc=linux-btrfs@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.