Skip to content

Commit dbba7a3

Browse files
josefbacikgregkh
authored andcommitted
btrfs: print the actual offset in btrfs_root_name
[ Upstream commit 7100873 ] We're supposed to print the root_key.offset in btrfs_root_name in the case of a reloc root, not the objectid. Fix this helper to take the key so we have access to the offset when we need it. Fixes: 457f186 ("btrfs: pretty print leaked root name") Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1f54a26 commit dbba7a3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

fs/btrfs/disk-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ void btrfs_check_leaked_roots(struct btrfs_fs_info *fs_info)
14821482
root = list_first_entry(&fs_info->allocated_roots,
14831483
struct btrfs_root, leak_list);
14841484
btrfs_err(fs_info, "leaked root %s refcount %d",
1485-
btrfs_root_name(root->root_key.objectid, buf),
1485+
btrfs_root_name(&root->root_key, buf),
14861486
refcount_read(&root->refs));
14871487
while (refcount_read(&root->refs) > 1)
14881488
btrfs_put_root(root);

fs/btrfs/print-tree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ static const struct root_name_map root_map[] = {
2626
{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" },
2727
};
2828

29-
const char *btrfs_root_name(u64 objectid, char *buf)
29+
const char *btrfs_root_name(const struct btrfs_key *key, char *buf)
3030
{
3131
int i;
3232

33-
if (objectid == BTRFS_TREE_RELOC_OBJECTID) {
33+
if (key->objectid == BTRFS_TREE_RELOC_OBJECTID) {
3434
snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN,
35-
"TREE_RELOC offset=%llu", objectid);
35+
"TREE_RELOC offset=%llu", key->offset);
3636
return buf;
3737
}
3838

3939
for (i = 0; i < ARRAY_SIZE(root_map); i++) {
40-
if (root_map[i].id == objectid)
40+
if (root_map[i].id == key->objectid)
4141
return root_map[i].name;
4242
}
4343

44-
snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, "%llu", objectid);
44+
snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, "%llu", key->objectid);
4545
return buf;
4646
}
4747

fs/btrfs/print-tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
void btrfs_print_leaf(struct extent_buffer *l);
1313
void btrfs_print_tree(struct extent_buffer *c, bool follow);
14-
const char *btrfs_root_name(u64 objectid, char *buf);
14+
const char *btrfs_root_name(const struct btrfs_key *key, char *buf);
1515

1616
#endif

0 commit comments

Comments
 (0)