Thread (5 messages) 5 messages, 3 authors, 2021-12-14

Re: [PATCH] btrfs: Refactor unlock_up

From: David Sterba <hidden>
Date: 2021-12-14 16:22:12

On Tue, Dec 14, 2021 at 03:39:39PM +0200, Nikolay Borisov wrote:
quoted hunk ↗ jump to hunk
The purpose of this function is to unlock all nodes in a btrfs path
which are above 'lowest_unlock' and whose slot used is different than 0.
As such it used slightly awkward structure of 'if' as well as somewhat
cryptic "no_skip" control variable which denotes whether we should
check the current level of skipiability or no.

This patch does the following (cosmetic) refactorings:

* Renames 'no_skip' to 'check_skip' and makes it a boolean. This
variable controls whether we are below the lowest_unlock/skip_level
levels.

* Consolidates the 2 conditions which warrant checking whether the
current level should be skipped under 1 common if (check_skip) branch,
this increase indentation level but is not critical.

* Consolidates the 'skip_level < i && i >= lowest_unlock' and
'i >= lowest_unlock && i > skip_level' condition into a common branch
since those are identical.

* Eliminates the local extent_buffer variable as in this case it doesn't
bring anything to function readability.

Signed-off-by: Nikolay Borisov <redacted>
---
 fs/btrfs/ctree.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 62066c034363..ab2ea0b2863c 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1348,33 +1348,34 @@ static noinline void unlock_up(struct btrfs_path *path, int level,
 {
 	int i;
 	int skip_level = level;
-	int no_skips = 0;
-	struct extent_buffer *t;
+	int check_skip = true;
this should be bool, right
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help