Skip to content

Commit 3d716a7

Browse files
fdmananakdave
authored andcommitted
btrfs: use the key format macros when printing keys
Change all locations that print a key to use the new macros to print them in order to ensure a consistent style and avoid repetitive code. Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 400b2fb commit 3d716a7

File tree

11 files changed

+64
-79
lines changed

11 files changed

+64
-79
lines changed

fs/btrfs/backref.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,9 @@ static int resolve_indirect_ref(struct btrfs_backref_walk_ctx *ctx,
666666
ret = btrfs_search_old_slot(root, &search_key, path, ctx->time_seq);
667667

668668
btrfs_debug(ctx->fs_info,
669-
"search slot in root %llu (level %d, ref count %d) returned %d for key (%llu %u %llu)",
670-
ref->root_id, level, ref->count, ret,
671-
ref->key_for_search.objectid, ref->key_for_search.type,
672-
ref->key_for_search.offset);
669+
"search slot in root %llu (level %d, ref count %d) returned %d for key " BTRFS_KEY_FMT,
670+
ref->root_id, level, ref->count, ret,
671+
BTRFS_KEY_FMT_VALUE(&ref->key_for_search));
673672
if (ret < 0)
674673
goto out;
675674

@@ -3323,9 +3322,9 @@ static int handle_indirect_tree_backref(struct btrfs_trans_handle *trans,
33233322
eb = path->nodes[level];
33243323
if (btrfs_node_blockptr(eb, path->slots[level]) != cur->bytenr) {
33253324
btrfs_err(fs_info,
3326-
"couldn't find block (%llu) (level %d) in tree (%llu) with key (%llu %u %llu)",
3325+
"couldn't find block (%llu) (level %d) in tree (%llu) with key " BTRFS_KEY_FMT,
33273326
cur->bytenr, level - 1, btrfs_root_id(root),
3328-
tree_key->objectid, tree_key->type, tree_key->offset);
3327+
BTRFS_KEY_FMT_VALUE(tree_key));
33293328
btrfs_put_root(root);
33303329
ret = -ENOENT;
33313330
goto out;

fs/btrfs/ctree.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,12 +2599,11 @@ void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans,
25992599
if (unlikely(btrfs_comp_keys(&disk_key, new_key) >= 0)) {
26002600
btrfs_print_leaf(eb);
26012601
btrfs_crit(fs_info,
2602-
"slot %u key (%llu %u %llu) new key (%llu %u %llu)",
2602+
"slot %u key " BTRFS_KEY_FMT " new key " BTRFS_KEY_FMT,
26032603
slot, btrfs_disk_key_objectid(&disk_key),
26042604
btrfs_disk_key_type(&disk_key),
26052605
btrfs_disk_key_offset(&disk_key),
2606-
new_key->objectid, new_key->type,
2607-
new_key->offset);
2606+
BTRFS_KEY_FMT_VALUE(new_key));
26082607
BUG();
26092608
}
26102609
}
@@ -2613,12 +2612,11 @@ void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans,
26132612
if (unlikely(btrfs_comp_keys(&disk_key, new_key) <= 0)) {
26142613
btrfs_print_leaf(eb);
26152614
btrfs_crit(fs_info,
2616-
"slot %u key (%llu %u %llu) new key (%llu %u %llu)",
2615+
"slot %u key " BTRFS_KEY_FMT " new key " BTRFS_KEY_FMT,
26172616
slot, btrfs_disk_key_objectid(&disk_key),
26182617
btrfs_disk_key_type(&disk_key),
26192618
btrfs_disk_key_offset(&disk_key),
2620-
new_key->objectid, new_key->type,
2621-
new_key->offset);
2619+
BTRFS_KEY_FMT_VALUE(new_key));
26222620
BUG();
26232621
}
26242622
}
@@ -2677,10 +2675,9 @@ static bool check_sibling_keys(const struct extent_buffer *left,
26772675
btrfs_crit(left->fs_info, "right extent buffer:");
26782676
btrfs_print_tree(right, false);
26792677
btrfs_crit(left->fs_info,
2680-
"bad key order, sibling blocks, left last (%llu %u %llu) right first (%llu %u %llu)",
2681-
left_last.objectid, left_last.type,
2682-
left_last.offset, right_first.objectid,
2683-
right_first.type, right_first.offset);
2678+
"bad key order, sibling blocks, left last " BTRFS_KEY_FMT " right first " BTRFS_KEY_FMT,
2679+
BTRFS_KEY_FMT_VALUE(&left_last),
2680+
BTRFS_KEY_FMT_VALUE(&right_first));
26842681
return true;
26852682
}
26862683
return false;

fs/btrfs/extent-tree.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
164164
if (unlikely(num_refs == 0)) {
165165
ret = -EUCLEAN;
166166
btrfs_err(fs_info,
167-
"unexpected zero reference count for extent item (%llu %u %llu)",
168-
key.objectid, key.type, key.offset);
167+
"unexpected zero reference count for extent item " BTRFS_KEY_FMT,
168+
BTRFS_KEY_FMT_VALUE(&key));
169169
btrfs_abort_transaction(trans, ret);
170170
return ret;
171171
}
@@ -597,8 +597,8 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans,
597597
num_refs = btrfs_shared_data_ref_count(leaf, ref2);
598598
} else {
599599
btrfs_err(trans->fs_info,
600-
"unrecognized backref key (%llu %u %llu)",
601-
key.objectid, key.type, key.offset);
600+
"unrecognized backref key " BTRFS_KEY_FMT,
601+
BTRFS_KEY_FMT_VALUE(&key));
602602
btrfs_abort_transaction(trans, -EUCLEAN);
603603
return -EUCLEAN;
604604
}
@@ -3326,9 +3326,9 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
33263326
if (iref) {
33273327
if (unlikely(path->slots[0] != extent_slot)) {
33283328
abort_and_dump(trans, path,
3329-
"invalid iref, extent item key (%llu %u %llu) slot %u doesn't have wanted iref",
3330-
key.objectid, key.type,
3331-
key.offset, path->slots[0]);
3329+
"invalid iref, extent item key " BTRFS_KEY_FMT " slot %u doesn't have wanted iref",
3330+
BTRFS_KEY_FMT_VALUE(&key),
3331+
path->slots[0]);
33323332
ret = -EUCLEAN;
33333333
goto out;
33343334
}

fs/btrfs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5642,9 +5642,9 @@ static int btrfs_inode_by_name(struct btrfs_inode *dir, struct dentry *dentry,
56425642
location->type != BTRFS_ROOT_ITEM_KEY)) {
56435643
ret = -EUCLEAN;
56445644
btrfs_warn(root->fs_info,
5645-
"%s gets something invalid in DIR_ITEM (name %s, directory ino %llu, location(%llu %u %llu))",
5645+
"%s gets something invalid in DIR_ITEM (name %s, directory ino %llu, location " BTRFS_KEY_FMT ")",
56465646
__func__, fname.disk_name.name, btrfs_ino(dir),
5647-
location->objectid, location->type, location->offset);
5647+
BTRFS_KEY_FMT_VALUE(location));
56485648
}
56495649
if (!ret)
56505650
*type = btrfs_dir_ftype(path->nodes[0], di);

fs/btrfs/print-tree.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static void print_extent_item(const struct extent_buffer *eb, int slot, int type
131131
struct btrfs_tree_block_info *info;
132132
info = (struct btrfs_tree_block_info *)(ei + 1);
133133
btrfs_tree_block_key(eb, info, &key);
134-
pr_info("\t\ttree block key (%llu %u %llu) level %d\n",
134+
pr_info("\t\ttree block key " BTRFS_KEY_FMT " level %d\n",
135135
btrfs_disk_key_objectid(&key), key.type,
136136
btrfs_disk_key_offset(&key),
137137
btrfs_tree_block_level(eb, info));
@@ -277,9 +277,8 @@ static void print_dir_item(const struct extent_buffer *eb, int i)
277277
struct btrfs_key location;
278278

279279
btrfs_dir_item_key_to_cpu(eb, di, &location);
280-
pr_info("\t\tlocation key (%llu %u %llu) type %d\n",
281-
location.objectid, location.type, location.offset,
282-
btrfs_dir_ftype(eb, di));
280+
pr_info("\t\tlocation key " BTRFS_KEY_FMT " type %d\n",
281+
BTRFS_KEY_FMT_VALUE(&location), btrfs_dir_ftype(eb, di));
283282
pr_info("\t\ttransid %llu data_len %u name_len %u\n",
284283
btrfs_dir_transid(eb, di), data_len, name_len);
285284
di = (struct btrfs_dir_item *)((char *)di + len);
@@ -598,10 +597,9 @@ void btrfs_print_tree(const struct extent_buffer *c, bool follow)
598597
print_eb_refs_lock(c);
599598
for (i = 0; i < nr; i++) {
600599
btrfs_node_key_to_cpu(c, &key, i);
601-
pr_info("\tkey %d (%llu %u %llu) block %llu gen %llu\n",
602-
i, key.objectid, key.type, key.offset,
603-
btrfs_node_blockptr(c, i),
604-
btrfs_node_ptr_generation(c, i));
600+
pr_info("\tkey %d " BTRFS_KEY_FMT " block %llu gen %llu\n",
601+
i, BTRFS_KEY_FMT_VALUE(&key), btrfs_node_blockptr(c, i),
602+
btrfs_node_ptr_generation(c, i));
605603
}
606604
if (!follow)
607605
return;

fs/btrfs/qgroup.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,10 +3710,8 @@ static int qgroup_rescan_leaf(struct btrfs_trans_handle *trans,
37103710
path, 1, 0);
37113711

37123712
btrfs_debug(fs_info,
3713-
"current progress key (%llu %u %llu), search_slot ret %d",
3714-
fs_info->qgroup_rescan_progress.objectid,
3715-
fs_info->qgroup_rescan_progress.type,
3716-
fs_info->qgroup_rescan_progress.offset, ret);
3713+
"current progress key " BTRFS_KEY_FMT ", search_slot ret %d",
3714+
BTRFS_KEY_FMT_VALUE(&fs_info->qgroup_rescan_progress), ret);
37173715

37183716
if (ret) {
37193717
/*

fs/btrfs/relocation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,8 @@ static struct btrfs_root *create_reloc_root(struct btrfs_trans_handle *trans,
615615

616616
btrfs_disk_key_to_cpu(&cpu_key, &root->root_item.drop_progress);
617617
btrfs_err(fs_info,
618-
"cannot relocate partially dropped subvolume %llu, drop progress key (%llu %u %llu)",
619-
objectid, cpu_key.objectid, cpu_key.type, cpu_key.offset);
618+
"cannot relocate partially dropped subvolume %llu, drop progress key " BTRFS_KEY_FMT,
619+
objectid, BTRFS_KEY_FMT_VALUE(&cpu_key));
620620
ret = -EUCLEAN;
621621
goto fail;
622622
}

fs/btrfs/root-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
147147

148148
if (unlikely(ret > 0)) {
149149
btrfs_crit(fs_info,
150-
"unable to find root key (%llu %u %llu) in tree %llu",
151-
key->objectid, key->type, key->offset, btrfs_root_id(root));
150+
"unable to find root key " BTRFS_KEY_FMT " in tree %llu",
151+
BTRFS_KEY_FMT_VALUE(key), btrfs_root_id(root));
152152
ret = -EUCLEAN;
153153
btrfs_abort_transaction(trans, ret);
154154
return ret;

fs/btrfs/send.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,8 @@ static int iterate_inode_ref(struct btrfs_root *root, struct btrfs_path *path,
10531053
}
10541054
if (unlikely(start < p->buf)) {
10551055
btrfs_err(root->fs_info,
1056-
"send: path ref buffer underflow for key (%llu %u %llu)",
1057-
found_key->objectid,
1058-
found_key->type,
1059-
found_key->offset);
1056+
"send: path ref buffer underflow for key " BTRFS_KEY_FMT,
1057+
BTRFS_KEY_FMT_VALUE(found_key));
10601058
ret = -EINVAL;
10611059
goto out;
10621060
}
@@ -7234,8 +7232,8 @@ static int search_key_again(const struct send_ctx *sctx,
72347232
if (unlikely(ret > 0)) {
72357233
btrfs_print_tree(path->nodes[path->lowest_level], false);
72367234
btrfs_err(root->fs_info,
7237-
"send: key (%llu %u %llu) not found in %s root %llu, lowest_level %d, slot %d",
7238-
key->objectid, key->type, key->offset,
7235+
"send: key " BTRFS_KEY_FMT" not found in %s root %llu, lowest_level %d, slot %d",
7236+
BTRFS_KEY_FMT_VALUE(key),
72397237
(root == sctx->parent_root ? "parent" : "send"),
72407238
btrfs_root_id(root), path->lowest_level,
72417239
path->slots[path->lowest_level]);

fs/btrfs/tree-checker.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,10 +1618,9 @@ static int check_extent_item(struct extent_buffer *leaf,
16181618

16191619
if (unlikely(prev_end > key->objectid)) {
16201620
extent_err(leaf, slot,
1621-
"previous extent [%llu %u %llu] overlaps current extent [%llu %u %llu]",
1622-
prev_key->objectid, prev_key->type,
1623-
prev_key->offset, key->objectid, key->type,
1624-
key->offset);
1621+
"previous extent " BTRFS_KEY_FMT " overlaps current extent " BTRFS_KEY_FMT,
1622+
BTRFS_KEY_FMT_VALUE(prev_key),
1623+
BTRFS_KEY_FMT_VALUE(key));
16251624
return -EUCLEAN;
16261625
}
16271626
}
@@ -2060,10 +2059,9 @@ enum btrfs_tree_block_status __btrfs_check_leaf(struct extent_buffer *leaf)
20602059
/* Make sure the keys are in the right order */
20612060
if (unlikely(btrfs_comp_cpu_keys(&prev_key, &key) >= 0)) {
20622061
generic_err(leaf, slot,
2063-
"bad key order, prev (%llu %u %llu) current (%llu %u %llu)",
2064-
prev_key.objectid, prev_key.type,
2065-
prev_key.offset, key.objectid, key.type,
2066-
key.offset);
2062+
"bad key order, prev " BTRFS_KEY_FMT " current " BTRFS_KEY_FMT,
2063+
BTRFS_KEY_FMT_VALUE(&prev_key),
2064+
BTRFS_KEY_FMT_VALUE(&key));
20672065
return BTRFS_TREE_BLOCK_BAD_KEY_ORDER;
20682066
}
20692067

@@ -2181,10 +2179,9 @@ enum btrfs_tree_block_status __btrfs_check_node(struct extent_buffer *node)
21812179

21822180
if (unlikely(btrfs_comp_cpu_keys(&key, &next_key) >= 0)) {
21832181
generic_err(node, slot,
2184-
"bad key order, current (%llu %u %llu) next (%llu %u %llu)",
2185-
key.objectid, key.type, key.offset,
2186-
next_key.objectid, next_key.type,
2187-
next_key.offset);
2182+
"bad key order, current " BTRFS_KEY_FMT " next " BTRFS_KEY_FMT,
2183+
BTRFS_KEY_FMT_VALUE(&key),
2184+
BTRFS_KEY_FMT_VALUE(&next_key));
21882185
return BTRFS_TREE_BLOCK_BAD_KEY_ORDER;
21892186
}
21902187
}

0 commit comments

Comments
 (0)