Skip to content

Commit 23b2cb7

Browse files
committed
btrfs-progs: qgroup: add debugging prints to verifier
CodeQL points out commented code, which is a macro to enable debugging. To make this more useful compile it unconditionally and provide under the debugging log level. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent a2f6387 commit 23b2cb7

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

check/qgroup-verify.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void qgroup_set_item_count_ptr(u64 *item_count_ptr)
4545
qgroup_item_count = item_count_ptr;
4646
}
4747

48-
/*#define QGROUP_VERIFY_DEBUG*/
4948
static unsigned long tot_extents_scanned = 0;
5049

5150
static struct qgroup_count *find_count(u64 qgroupid);
@@ -157,15 +156,14 @@ struct ref {
157156
struct rb_node bytenr_node;
158157
};
159158

160-
#ifdef QGROUP_VERIFY_DEBUG
161159
static void print_ref(struct ref *ref)
162160
{
163161
printf("bytenr: %llu\t\tnum_bytes: %llu\t\t parent: %llu\t\t"
164162
"root: %llu\n", ref->bytenr, ref->num_bytes,
165163
ref->parent, ref->root);
166164
}
167165

168-
static void print_all_refs(void)
166+
static void __maybe_unused print_all_refs(void)
169167
{
170168
unsigned long count = 0;
171169
struct ref *ref;
@@ -184,7 +182,6 @@ static void print_all_refs(void)
184182
printf("%lu extents scanned with %lu refs in total.\n",
185183
tot_extents_scanned, count);
186184
}
187-
#endif
188185

189186
/*
190187
* Store by bytenr in rbtree
@@ -490,14 +487,12 @@ static int account_one_extent(struct ulist *roots, u64 bytenr, u64 num_bytes)
490487
count->info.exclusive_compressed += num_bytes;
491488
}
492489
}
493-
#ifdef QGROUP_VERIFY_DEBUG
494-
printf("account (%llu, %llu), qgroup %llu/%llu, rfer %llu,"
490+
pr_verbose(LOG_DEBUG, "account (%llu, %llu), qgroup %u/%llu, rfer %llu,"
495491
" excl %llu, refs %llu, roots %llu\n", bytenr, num_bytes,
496492
btrfs_qgroup_level(count->qgroupid),
497493
btrfs_qgroup_subvolid(count->qgroupid),
498494
count->info.referenced, count->info.exclusive, nr_refs,
499495
nr_roots);
500-
#endif
501496
}
502497

503498
inc_qgroup_seq(roots->nnodes);
@@ -636,7 +631,6 @@ static void free_tree_blocks(void)
636631
tree_blocks = NULL;
637632
}
638633

639-
#ifdef QGROUP_VERIFY_DEBUG
640634
static void print_tree_block(u64 bytenr, struct tree_block *block)
641635
{
642636
struct ref *ref;
@@ -656,7 +650,7 @@ static void print_tree_block(u64 bytenr, struct tree_block *block)
656650
printf("\n");
657651
}
658652

659-
static void print_all_tree_blocks(void)
653+
static void __maybe_unused print_all_tree_blocks(void)
660654
{
661655
struct ulist_iterator uiter;
662656
struct ulist_node *unode;
@@ -670,7 +664,6 @@ static void print_all_tree_blocks(void)
670664
while ((unode = ulist_next(tree_blocks, &uiter)))
671665
print_tree_block(unode_bytenr(unode), unode_tree_block(unode));
672666
}
673-
#endif
674667

675668
static int add_refs_for_leaf_items(struct extent_buffer *eb, u64 ref_parent)
676669
{

0 commit comments

Comments
 (0)