[2/3] btrfs: ctree: Reduce one indent level for btrfs_search_old_slot()
diff mbox series

Message ID 20190910074019.23158-3-wqu@suse.com
State New
Headers show
Series
  • Small code style cleanup for ctree.c
Related show

Commit Message

Qu WenRuo Sept. 10, 2019, 7:40 a.m. UTC
Pretty much the same refactor for btrfs_search_slot().

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/ctree.c | 68 +++++++++++++++++++++++-------------------------
 1 file changed, 33 insertions(+), 35 deletions(-)

Comments

Anand Jain Sept. 10, 2019, 7:58 a.m. UTC | #1
Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks.
David Sterba Sept. 23, 2019, 4:32 p.m. UTC | #2
On Tue, Sep 10, 2019 at 03:40:18PM +0800, Qu Wenruo wrote:
> Pretty much the same refactor for btrfs_search_slot().

Please write something more sensible than that next time, this changelog
makes sense for a short period of time when the patches are in the
mailing list and the context is obvious, but once the patch is merged
the reference to "same thing as in some funrction" does not help.

Patch
diff mbox series

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 1e29183cdf62..3be8b32c0d37 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2983,6 +2983,7 @@  int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key,
 	p->locks[level] = BTRFS_READ_LOCK;
 
 	while (b) {
+		int dec = 0;
 		level = btrfs_header_level(b);
 		p->nodes[level] = b;
 
@@ -3003,48 +3004,45 @@  int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key,
 		if (ret < 0)
 			goto done;
 
-		if (level != 0) {
-			int dec = 0;
-			if (ret && slot > 0) {
-				dec = 1;
-				slot -= 1;
-			}
+		if (level == 0) {
 			p->slots[level] = slot;
 			unlock_up(p, level, lowest_unlock, 0, NULL);
+			goto done;
+		}
+		if (ret && slot > 0) {
+			dec = 1;
+			slot -= 1;
+		}
+		p->slots[level] = slot;
+		unlock_up(p, level, lowest_unlock, 0, NULL);
 
-			if (level == lowest_level) {
-				if (dec)
-					p->slots[level]++;
-				goto done;
-			}
+		if (level == lowest_level) {
+			if (dec)
+				p->slots[level]++;
+			goto done;
+		}
 
-			err = read_block_for_search(root, p, &b, level,
-						    slot, key);
-			if (err == -EAGAIN)
-				goto again;
-			if (err) {
-				ret = err;
-				goto done;
-			}
+		err = read_block_for_search(root, p, &b, level, slot, key);
+		if (err == -EAGAIN)
+			goto again;
+		if (err) {
+			ret = err;
+			goto done;
+		}
 
-			level = btrfs_header_level(b);
-			err = btrfs_tree_read_lock_atomic(b);
-			if (!err) {
-				btrfs_set_path_blocking(p);
-				btrfs_tree_read_lock(b);
-			}
-			b = tree_mod_log_rewind(fs_info, p, b, time_seq);
-			if (!b) {
-				ret = -ENOMEM;
-				goto done;
-			}
-			p->locks[level] = BTRFS_READ_LOCK;
-			p->nodes[level] = b;
-		} else {
-			p->slots[level] = slot;
-			unlock_up(p, level, lowest_unlock, 0, NULL);
+		level = btrfs_header_level(b);
+		err = btrfs_tree_read_lock_atomic(b);
+		if (!err) {
+			btrfs_set_path_blocking(p);
+			btrfs_tree_read_lock(b);
+		}
+		b = tree_mod_log_rewind(fs_info, p, b, time_seq);
+		if (!b) {
+			ret = -ENOMEM;
 			goto done;
 		}
+		p->locks[level] = BTRFS_READ_LOCK;
+		p->nodes[level] = b;
 	}
 	ret = 1;
 done: