[11/18] btrfs: Simplify btrfs_search_slot() for performance
diff mbox

Message ID 4BAB5853.9030402@cn.fujitsu.com
State New, archived
Headers show

Commit Message

Miao Xie March 25, 2010, 12:34 p.m. UTC
None

Patch
diff mbox

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);
 
 		/*