Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] Tree-checker unlikely annotations, error code updates
@ 2025-04-04 18:19 David Sterba
  2025-04-04 18:19 ` [PATCH 1/2] btrfs: tree-checker: more unlikely annotations David Sterba
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Sterba @ 2025-04-04 18:19 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

David Sterba (2):
  btrfs: tree-checker: more unlikely annotations
  btrfs: tree-checker: adjust error code for header level check

 fs/btrfs/tree-checker.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.47.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] btrfs: tree-checker: more unlikely annotations
  2025-04-04 18:19 [PATCH 0/2] Tree-checker unlikely annotations, error code updates David Sterba
@ 2025-04-04 18:19 ` David Sterba
  2025-04-04 18:19 ` [PATCH 2/2] btrfs: tree-checker: adjust error code for header level check David Sterba
  2025-04-04 21:31 ` [PATCH 0/2] Tree-checker unlikely annotations, error code updates Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2025-04-04 18:19 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Add more unlikely annotations to branches that lead to EUCLEAN, overall
in the tree checker this helps to reorder instructions for the no-error
case.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/tree-checker.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 43979891f7c8..732e0ca8f447 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -2229,7 +2229,7 @@ int btrfs_verify_level_key(struct extent_buffer *eb,
 	int ret;
 
 	found_level = btrfs_header_level(eb);
-	if (found_level != check->level) {
+	if (unlikely(found_level != check->level)) {
 		WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG),
 		     KERN_ERR "BTRFS: tree level check failed\n");
 		btrfs_err(fs_info,
@@ -2251,7 +2251,7 @@ int btrfs_verify_level_key(struct extent_buffer *eb,
 		return 0;
 
 	/* We have @first_key, so this @eb must have at least one item */
-	if (btrfs_header_nritems(eb) == 0) {
+	if (unlikely(btrfs_header_nritems(eb) == 0)) {
 		btrfs_err(fs_info,
 		"invalid tree nritems, bytenr=%llu nritems=0 expect >0",
 			  eb->start);
@@ -2263,9 +2263,9 @@ int btrfs_verify_level_key(struct extent_buffer *eb,
 		btrfs_node_key_to_cpu(eb, &found_key, 0);
 	else
 		btrfs_item_key_to_cpu(eb, &found_key, 0);
-	ret = btrfs_comp_cpu_keys(&check->first_key, &found_key);
 
-	if (ret) {
+	ret = btrfs_comp_cpu_keys(&check->first_key, &found_key);
+	if (unlikely(ret)) {
 		WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG),
 		     KERN_ERR "BTRFS: tree first key check failed\n");
 		btrfs_err(fs_info,
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] btrfs: tree-checker: adjust error code for header level check
  2025-04-04 18:19 [PATCH 0/2] Tree-checker unlikely annotations, error code updates David Sterba
  2025-04-04 18:19 ` [PATCH 1/2] btrfs: tree-checker: more unlikely annotations David Sterba
@ 2025-04-04 18:19 ` David Sterba
  2025-04-04 21:31 ` [PATCH 0/2] Tree-checker unlikely annotations, error code updates Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2025-04-04 18:19 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The whole tree checker returns EUCLEAN, except the one check in
btrfs_verify_level_key(). This was inherited from the function that was
moved from disk-io.c in 2cac5af16537 ("btrfs: move
btrfs_verify_level_key into tree-checker.c") but this should be unified
with the rest.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/tree-checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 732e0ca8f447..5cd98776a612 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -2235,7 +2235,7 @@ int btrfs_verify_level_key(struct extent_buffer *eb,
 		btrfs_err(fs_info,
 "tree level mismatch detected, bytenr=%llu level expected=%u has=%u",
 			  eb->start, check->level, found_level);
-		return -EIO;
+		return -EUCLEAN;
 	}
 
 	if (!check->has_first_key)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Tree-checker unlikely annotations, error code updates
  2025-04-04 18:19 [PATCH 0/2] Tree-checker unlikely annotations, error code updates David Sterba
  2025-04-04 18:19 ` [PATCH 1/2] btrfs: tree-checker: more unlikely annotations David Sterba
  2025-04-04 18:19 ` [PATCH 2/2] btrfs: tree-checker: adjust error code for header level check David Sterba
@ 2025-04-04 21:31 ` Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2025-04-04 21:31 UTC (permalink / raw)
  To: David Sterba, linux-btrfs



在 2025/4/5 04:49, David Sterba 写道:
> David Sterba (2):
>    btrfs: tree-checker: more unlikely annotations
>    btrfs: tree-checker: adjust error code for header level check
>
>   fs/btrfs/tree-checker.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-04 21:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-04 18:19 [PATCH 0/2] Tree-checker unlikely annotations, error code updates David Sterba
2025-04-04 18:19 ` [PATCH 1/2] btrfs: tree-checker: more unlikely annotations David Sterba
2025-04-04 18:19 ` [PATCH 2/2] btrfs: tree-checker: adjust error code for header level check David Sterba
2025-04-04 21:31 ` [PATCH 0/2] Tree-checker unlikely annotations, error code updates Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox