* [PATCH v2 1/2] btrfs: use true/false for boolean parameters in btrfs_{inc,dec}_ref
2025-11-22 6:00 [PATCH v2 0/2] btrfs: use true/false and simplify boolean parameters in btrfs_{inc,dec}_ref Sun YangKai
@ 2025-11-22 6:00 ` Sun YangKai
2025-11-25 16:46 ` David Sterba
2025-11-22 6:00 ` [PATCH v2 2/2] btrfs: simplify boolean argument for btrfs_{inc,dec}_ref Sun YangKai
2025-11-25 16:44 ` [PATCH v2 0/2] btrfs: use true/false and simplify boolean parameters in btrfs_{inc,dec}_ref David Sterba
2 siblings, 1 reply; 8+ messages in thread
From: Sun YangKai @ 2025-11-22 6:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: Sun YangKai
Replace integer literals 0/1 with true/false when calling
btrfs_inc_ref() and btrfs_dec_ref() to make the code self-documenting
and avoid mixing bool/integer types.
No functional change intended.
Signed-off-by: Sun YangKai <sunk67188@gmail.com>
---
fs/btrfs/ctree.c | 20 ++++++++++----------
fs/btrfs/extent-tree.c | 8 ++++----
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 3c4aea71bbbf..1b15cef86cbc 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -292,11 +292,11 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
}
if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) {
- ret = btrfs_inc_ref(trans, root, cow, 1);
+ ret = btrfs_inc_ref(trans, root, cow, true);
if (unlikely(ret))
btrfs_abort_transaction(trans, ret);
} else {
- ret = btrfs_inc_ref(trans, root, cow, 0);
+ ret = btrfs_inc_ref(trans, root, cow, false);
if (unlikely(ret))
btrfs_abort_transaction(trans, ret);
}
@@ -420,15 +420,15 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
if ((owner == btrfs_root_id(root) ||
btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) &&
!(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)) {
- ret = btrfs_inc_ref(trans, root, buf, 1);
+ ret = btrfs_inc_ref(trans, root, buf, true);
if (ret)
return ret;
if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) {
- ret = btrfs_dec_ref(trans, root, buf, 0);
+ ret = btrfs_dec_ref(trans, root, buf, false);
if (ret)
return ret;
- ret = btrfs_inc_ref(trans, root, cow, 1);
+ ret = btrfs_inc_ref(trans, root, cow, true);
if (ret)
return ret;
}
@@ -439,21 +439,21 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
} else {
if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID)
- ret = btrfs_inc_ref(trans, root, cow, 1);
+ ret = btrfs_inc_ref(trans, root, cow, true);
else
- ret = btrfs_inc_ref(trans, root, cow, 0);
+ ret = btrfs_inc_ref(trans, root, cow, false);
if (ret)
return ret;
}
} else {
if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID)
- ret = btrfs_inc_ref(trans, root, cow, 1);
+ ret = btrfs_inc_ref(trans, root, cow, true);
else
- ret = btrfs_inc_ref(trans, root, cow, 0);
+ ret = btrfs_inc_ref(trans, root, cow, false);
if (ret)
return ret;
- ret = btrfs_dec_ref(trans, root, buf, 1);
+ ret = btrfs_dec_ref(trans, root, buf, true);
if (ret)
return ret;
}
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index b22b0aaa99e4..527310f3aeb3 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5469,12 +5469,12 @@ static noinline int walk_down_proc(struct btrfs_trans_handle *trans,
/* wc->stage == UPDATE_BACKREF */
if (!(wc->flags[level] & flag)) {
ASSERT(path->locks[level]);
- ret = btrfs_inc_ref(trans, root, eb, 1);
+ ret = btrfs_inc_ref(trans, root, eb, true);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
return ret;
}
- ret = btrfs_dec_ref(trans, root, eb, 0);
+ ret = btrfs_dec_ref(trans, root, eb, false);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
return ret;
@@ -5876,13 +5876,13 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
if (wc->refs[level] == 1) {
if (level == 0) {
if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
- ret = btrfs_dec_ref(trans, root, eb, 1);
+ ret = btrfs_dec_ref(trans, root, eb, true);
if (ret) {
btrfs_abort_transaction(trans, ret);
return ret;
}
} else {
- ret = btrfs_dec_ref(trans, root, eb, 0);
+ ret = btrfs_dec_ref(trans, root, eb, false);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
return ret;
--
2.51.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v2 1/2] btrfs: use true/false for boolean parameters in btrfs_{inc,dec}_ref
2025-11-22 6:00 ` [PATCH v2 1/2] btrfs: use true/false for " Sun YangKai
@ 2025-11-25 16:46 ` David Sterba
2025-11-28 4:13 ` Sun Yangkai
0 siblings, 1 reply; 8+ messages in thread
From: David Sterba @ 2025-11-25 16:46 UTC (permalink / raw)
To: Sun YangKai; +Cc: linux-btrfs
On Sat, Nov 22, 2025 at 02:00:43PM +0800, Sun YangKai wrote:
> Replace integer literals 0/1 with true/false when calling
> btrfs_inc_ref() and btrfs_dec_ref() to make the code self-documenting
> and avoid mixing bool/integer types.
>
> No functional change intended.
You don't need to write this sentence to the changelog, in this case
it's obvious it's a simple change, and complicated changes would be
explained in full.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2 1/2] btrfs: use true/false for boolean parameters in btrfs_{inc,dec}_ref
2025-11-25 16:46 ` David Sterba
@ 2025-11-28 4:13 ` Sun Yangkai
0 siblings, 0 replies; 8+ messages in thread
From: Sun Yangkai @ 2025-11-28 4:13 UTC (permalink / raw)
To: dsterba; +Cc: linux-btrfs
Got it. Thanks.
在 2025/11/26 00:46, David Sterba 写道:
> On Sat, Nov 22, 2025 at 02:00:43PM +0800, Sun YangKai wrote:
>> Replace integer literals 0/1 with true/false when calling
>> btrfs_inc_ref() and btrfs_dec_ref() to make the code self-documenting
>> and avoid mixing bool/integer types.
>>
>> No functional change intended.
>
> You don't need to write this sentence to the changelog, in this case
> it's obvious it's a simple change, and complicated changes would be
> explained in full.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] btrfs: simplify boolean argument for btrfs_{inc,dec}_ref
2025-11-22 6:00 [PATCH v2 0/2] btrfs: use true/false and simplify boolean parameters in btrfs_{inc,dec}_ref Sun YangKai
2025-11-22 6:00 ` [PATCH v2 1/2] btrfs: use true/false for " Sun YangKai
@ 2025-11-22 6:00 ` Sun YangKai
2025-11-22 6:51 ` Sun Yangkai
2025-11-25 16:44 ` [PATCH v2 0/2] btrfs: use true/false and simplify boolean parameters in btrfs_{inc,dec}_ref David Sterba
2 siblings, 1 reply; 8+ messages in thread
From: Sun YangKai @ 2025-11-22 6:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: Sun YangKai
Replace open-coded if/else blocks with the boolean directly and introduce
local const bool variables, making the code shorter and easier to read.
No functional change.
Signed-off-by: Sun YangKai <sunk67188@gmail.com>
---
fs/btrfs/ctree.c | 38 ++++++++++++--------------------------
fs/btrfs/extent-tree.c | 17 +++++------------
2 files changed, 17 insertions(+), 38 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 1b15cef86cbc..300fd8c16ad7 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -249,6 +249,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
int ret = 0;
int level;
struct btrfs_disk_key disk_key;
+ const bool is_reloc_root = (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID);
u64 reloc_src_root = 0;
WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
@@ -262,7 +263,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
else
btrfs_node_key(buf, &disk_key, 0);
- if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID)
+ if (is_reloc_root)
reloc_src_root = btrfs_header_owner(buf);
cow = btrfs_alloc_tree_block(trans, root, 0, new_root_objectid,
&disk_key, level, buf->start, 0,
@@ -276,7 +277,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
btrfs_set_header_backref_rev(cow, BTRFS_MIXED_BACKREF_REV);
btrfs_clear_header_flag(cow, BTRFS_HEADER_FLAG_WRITTEN |
BTRFS_HEADER_FLAG_RELOC);
- if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID)
+ if (is_reloc_root)
btrfs_set_header_flag(cow, BTRFS_HEADER_FLAG_RELOC);
else
btrfs_set_header_owner(cow, new_root_objectid);
@@ -291,16 +292,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
return ret;
}
- if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) {
- ret = btrfs_inc_ref(trans, root, cow, true);
- if (unlikely(ret))
- btrfs_abort_transaction(trans, ret);
- } else {
- ret = btrfs_inc_ref(trans, root, cow, false);
- if (unlikely(ret))
- btrfs_abort_transaction(trans, ret);
- }
- if (ret) {
+ ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
+ if (unlikely(ret)) {
+ btrfs_abort_transaction(trans, ret);
btrfs_tree_unlock(cow);
free_extent_buffer(cow);
return ret;
@@ -362,6 +356,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
u64 owner;
u64 flags;
int ret;
+ const bool is_reloc_root = (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID);
/*
* Backrefs update rules:
@@ -397,8 +392,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
}
} else {
refs = 1;
- if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID ||
- btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV)
+ if (is_reloc_root || btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV)
flags = BTRFS_BLOCK_FLAG_FULL_BACKREF;
else
flags = 0;
@@ -417,14 +411,13 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
}
if (refs > 1) {
- if ((owner == btrfs_root_id(root) ||
- btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) &&
+ if ((owner == btrfs_root_id(root) || is_reloc_root) &&
!(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)) {
ret = btrfs_inc_ref(trans, root, buf, true);
if (ret)
return ret;
- if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) {
+ if (is_reloc_root) {
ret = btrfs_dec_ref(trans, root, buf, false);
if (ret)
return ret;
@@ -437,20 +430,13 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
if (ret)
return ret;
} else {
-
- if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID)
- ret = btrfs_inc_ref(trans, root, cow, true);
- else
- ret = btrfs_inc_ref(trans, root, cow, false);
+ ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
if (ret)
return ret;
}
} else {
if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
- if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID)
- ret = btrfs_inc_ref(trans, root, cow, true);
- else
- ret = btrfs_inc_ref(trans, root, cow, false);
+ ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
if (ret)
return ret;
ret = btrfs_dec_ref(trans, root, buf, true);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 527310f3aeb3..f3d33d7a2376 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5875,18 +5875,11 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
if (wc->refs[level] == 1) {
if (level == 0) {
- if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
- ret = btrfs_dec_ref(trans, root, eb, true);
- if (ret) {
- btrfs_abort_transaction(trans, ret);
- return ret;
- }
- } else {
- ret = btrfs_dec_ref(trans, root, eb, false);
- if (unlikely(ret)) {
- btrfs_abort_transaction(trans, ret);
- return ret;
- }
+ const bool full_backref = (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF);
+ ret = btrfs_dec_ref(trans, root, eb, full_backref);
+ if (unlikely(ret)) {
+ btrfs_abort_transaction(trans, ret);
+ return ret;
}
if (btrfs_is_fstree(btrfs_root_id(root))) {
ret = btrfs_qgroup_trace_leaf_items(trans, eb);
--
2.51.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v2 2/2] btrfs: simplify boolean argument for btrfs_{inc,dec}_ref
2025-11-22 6:00 ` [PATCH v2 2/2] btrfs: simplify boolean argument for btrfs_{inc,dec}_ref Sun YangKai
@ 2025-11-22 6:51 ` Sun Yangkai
2025-11-25 16:33 ` David Sterba
0 siblings, 1 reply; 8+ messages in thread
From: Sun Yangkai @ 2025-11-22 6:51 UTC (permalink / raw)
To: linux-btrfs
在 2025/11/22 14:00, Sun YangKai 写道:
> Replace open-coded if/else blocks with the boolean directly and introduce
> local const bool variables, making the code shorter and easier to read.
>
> No functional change.
>
> Signed-off-by: Sun YangKai <sunk67188@gmail.com>
> ---
> fs/btrfs/ctree.c | 38 ++++++++++++--------------------------
> fs/btrfs/extent-tree.c | 17 +++++------------
> 2 files changed, 17 insertions(+), 38 deletions(-)
>
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 1b15cef86cbc..300fd8c16ad7 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -249,6 +249,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
> int ret = 0;
> int level;
> struct btrfs_disk_key disk_key;
> + const bool is_reloc_root = (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID);
> u64 reloc_src_root = 0;
>
> WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
> @@ -262,7 +263,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
> else
> btrfs_node_key(buf, &disk_key, 0);
>
> - if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID)
> + if (is_reloc_root)
> reloc_src_root = btrfs_header_owner(buf);
> cow = btrfs_alloc_tree_block(trans, root, 0, new_root_objectid,
> &disk_key, level, buf->start, 0,
> @@ -276,7 +277,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
> btrfs_set_header_backref_rev(cow, BTRFS_MIXED_BACKREF_REV);
> btrfs_clear_header_flag(cow, BTRFS_HEADER_FLAG_WRITTEN |
> BTRFS_HEADER_FLAG_RELOC);
> - if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID)
> + if (is_reloc_root)
> btrfs_set_header_flag(cow, BTRFS_HEADER_FLAG_RELOC);
> else
> btrfs_set_header_owner(cow, new_root_objectid);
> @@ -291,16 +292,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
> return ret;
> }
>
> - if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) {
> - ret = btrfs_inc_ref(trans, root, cow, true);
> - if (unlikely(ret))
> - btrfs_abort_transaction(trans, ret);
> - } else {
> - ret = btrfs_inc_ref(trans, root, cow, false);
> - if (unlikely(ret))
> - btrfs_abort_transaction(trans, ret);
> - }
> - if (ret) {
> + ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
Now we have something like this:
ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
As suggested by Daniel, it would be helpful to add a comment explaining why we
pass true to @full_backref when dealing with a relocation tree (is_reloc_root).
However, I currently lack the knowledge to provide a clear explanation.
> + if (unlikely(ret)) {
> + btrfs_abort_transaction(trans, ret);
> btrfs_tree_unlock(cow);
> free_extent_buffer(cow);
> return ret;
> @@ -362,6 +356,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
> u64 owner;
> u64 flags;
> int ret;
> + const bool is_reloc_root = (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID);
>
> /*
> * Backrefs update rules:
> @@ -397,8 +392,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
> }
> } else {
> refs = 1;
> - if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID ||
> - btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV)
> + if (is_reloc_root || btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV)
> flags = BTRFS_BLOCK_FLAG_FULL_BACKREF;
> else
> flags = 0;
> @@ -417,14 +411,13 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
> }
>
> if (refs > 1) {
> - if ((owner == btrfs_root_id(root) ||
> - btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) &&
> + if ((owner == btrfs_root_id(root) || is_reloc_root) &&
> !(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)) {
> ret = btrfs_inc_ref(trans, root, buf, true);
> if (ret)
> return ret;
>
> - if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) {
> + if (is_reloc_root) {
> ret = btrfs_dec_ref(trans, root, buf, false);
> if (ret)
> return ret;
> @@ -437,20 +430,13 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
> if (ret)
> return ret;
> } else {
> -
> - if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID)
> - ret = btrfs_inc_ref(trans, root, cow, true);
> - else
> - ret = btrfs_inc_ref(trans, root, cow, false);
> + ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
> if (ret)
> return ret;
> }
> } else {
> if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
> - if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID)
> - ret = btrfs_inc_ref(trans, root, cow, true);
> - else
> - ret = btrfs_inc_ref(trans, root, cow, false);
> + ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
> if (ret)
> return ret;
> ret = btrfs_dec_ref(trans, root, buf, true);
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 527310f3aeb3..f3d33d7a2376 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -5875,18 +5875,11 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
>
> if (wc->refs[level] == 1) {
> if (level == 0) {
> - if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
> - ret = btrfs_dec_ref(trans, root, eb, true);
> - if (ret) {
> - btrfs_abort_transaction(trans, ret);
> - return ret;
> - }
> - } else {
> - ret = btrfs_dec_ref(trans, root, eb, false);
> - if (unlikely(ret)) {
> - btrfs_abort_transaction(trans, ret);
> - return ret;
> - }
> + const bool full_backref = (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF);
> + ret = btrfs_dec_ref(trans, root, eb, full_backref);
> + if (unlikely(ret)) {
> + btrfs_abort_transaction(trans, ret);
> + return ret;
> }
> if (btrfs_is_fstree(btrfs_root_id(root))) {
> ret = btrfs_qgroup_trace_leaf_items(trans, eb);
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2 2/2] btrfs: simplify boolean argument for btrfs_{inc,dec}_ref
2025-11-22 6:51 ` Sun Yangkai
@ 2025-11-25 16:33 ` David Sterba
0 siblings, 0 replies; 8+ messages in thread
From: David Sterba @ 2025-11-25 16:33 UTC (permalink / raw)
To: Sun Yangkai; +Cc: linux-btrfs
On Sat, Nov 22, 2025 at 02:51:08PM +0800, Sun Yangkai wrote:
> > - if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID) {
> > - ret = btrfs_inc_ref(trans, root, cow, true);
> > - if (unlikely(ret))
> > - btrfs_abort_transaction(trans, ret);
> > - } else {
> > - ret = btrfs_inc_ref(trans, root, cow, false);
> > - if (unlikely(ret))
> > - btrfs_abort_transaction(trans, ret);
> > - }
> > - if (ret) {
> > + ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
>
> Now we have something like this:
>
> ret = btrfs_inc_ref(trans, root, cow, is_reloc_root);
>
> As suggested by Daniel, it would be helpful to add a comment explaining why we
> pass true to @full_backref when dealing with a relocation tree (is_reloc_root).
The relocation tree is special in many ways, there was no comment in the
old code and I'm not sure how much explanation we'd need here because
the code dealing with relocation tree is scattered everywhere.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] btrfs: use true/false and simplify boolean parameters in btrfs_{inc,dec}_ref
2025-11-22 6:00 [PATCH v2 0/2] btrfs: use true/false and simplify boolean parameters in btrfs_{inc,dec}_ref Sun YangKai
2025-11-22 6:00 ` [PATCH v2 1/2] btrfs: use true/false for " Sun YangKai
2025-11-22 6:00 ` [PATCH v2 2/2] btrfs: simplify boolean argument for btrfs_{inc,dec}_ref Sun YangKai
@ 2025-11-25 16:44 ` David Sterba
2 siblings, 0 replies; 8+ messages in thread
From: David Sterba @ 2025-11-25 16:44 UTC (permalink / raw)
To: Sun YangKai; +Cc: linux-btrfs
On Sat, Nov 22, 2025 at 02:00:42PM +0800, Sun YangKai wrote:
> This tiny series removes the last 0/1 integer literals passed to
> btrfs_inc_ref() / btrfs_dec_ref() and replaces the open-coded
> if/else blocks with concise boolean expressions.
>
> Patch 1 switches the callsites to the self-documenting true/false
> constants, eliminating the implicit bool <-> int mixing.
>
> Patch 2 folds the remaining if/else ladders into a single line
> using the condition directly, which shrinks the code and makes the
> intent obvious.
>
> No functional change.
>
> [Changelog]
>
> v2:
>
> - Introduce local variable for the conditions in patch 2, suggested by Boris
>
> - Merge the non-zero ret handling blocks in btrfs_copy_root()
>
> Sun YangKai (2):
> btrfs: use true/false for boolean parameters in btrfs_{inc,dec}_ref
> btrfs: simplify boolean argument for btrfs_{inc,dec}_ref
Added to for-next, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread