Message ID | 3575cc74f0d9f63647e92082979fa8cfd3901e90.1606938211.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Cleanup error handling in relocation | expand |
On 2020/12/3 上午3:51, Josef Bacik wrote: > 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. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Qu Wenruo <wqu@suse.com> THanks, Qu > --- > fs/btrfs/disk-io.c | 2 +- > fs/btrfs/print-tree.c | 10 +++++----- > fs/btrfs/print-tree.h | 2 +- > 3 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index 46dd9e0b077e..c73d172aa1f7 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -1458,7 +1458,7 @@ void btrfs_check_leaked_roots(struct btrfs_fs_info *fs_info) > root = list_first_entry(&fs_info->allocated_roots, > struct btrfs_root, leak_list); > btrfs_err(fs_info, "leaked root %s refcount %d", > - btrfs_root_name(root->root_key.objectid, buf), > + btrfs_root_name(&root->root_key, buf), > refcount_read(&root->refs)); > while (refcount_read(&root->refs) > 1) > btrfs_put_root(root); > diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c > index fe5e0026129d..b8137dbf6a3a 100644 > --- a/fs/btrfs/print-tree.c > +++ b/fs/btrfs/print-tree.c > @@ -26,22 +26,22 @@ static const struct root_name_map root_map[] = { > { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }, > }; > > -const char *btrfs_root_name(u64 objectid, char *buf) > +const char *btrfs_root_name(struct btrfs_key *key, char *buf) > { > int i; > > - if (objectid == BTRFS_TREE_RELOC_OBJECTID) { > + if (key->objectid == BTRFS_TREE_RELOC_OBJECTID) { > snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, > - "TREE_RELOC offset=%llu", objectid); > + "TREE_RELOC offset=%llu", key->offset); > return buf; > } > > for (i = 0; i < ARRAY_SIZE(root_map); i++) { > - if (root_map[i].id == objectid) > + if (root_map[i].id == key->objectid) > return root_map[i].name; > } > > - snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, "%llu", objectid); > + snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, "%llu", key->objectid); > return buf; > } > > diff --git a/fs/btrfs/print-tree.h b/fs/btrfs/print-tree.h > index 78b99385a503..802628dd1a6e 100644 > --- a/fs/btrfs/print-tree.h > +++ b/fs/btrfs/print-tree.h > @@ -11,6 +11,6 @@ > > void btrfs_print_leaf(struct extent_buffer *l); > void btrfs_print_tree(struct extent_buffer *c, bool follow); > -const char *btrfs_root_name(u64 objectid, char *buf); > +const char *btrfs_root_name(struct btrfs_key *key, char *buf); > > #endif >
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 46dd9e0b077e..c73d172aa1f7 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1458,7 +1458,7 @@ void btrfs_check_leaked_roots(struct btrfs_fs_info *fs_info) root = list_first_entry(&fs_info->allocated_roots, struct btrfs_root, leak_list); btrfs_err(fs_info, "leaked root %s refcount %d", - btrfs_root_name(root->root_key.objectid, buf), + btrfs_root_name(&root->root_key, buf), refcount_read(&root->refs)); while (refcount_read(&root->refs) > 1) btrfs_put_root(root); diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c index fe5e0026129d..b8137dbf6a3a 100644 --- a/fs/btrfs/print-tree.c +++ b/fs/btrfs/print-tree.c @@ -26,22 +26,22 @@ static const struct root_name_map root_map[] = { { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }, }; -const char *btrfs_root_name(u64 objectid, char *buf) +const char *btrfs_root_name(struct btrfs_key *key, char *buf) { int i; - if (objectid == BTRFS_TREE_RELOC_OBJECTID) { + if (key->objectid == BTRFS_TREE_RELOC_OBJECTID) { snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, - "TREE_RELOC offset=%llu", objectid); + "TREE_RELOC offset=%llu", key->offset); return buf; } for (i = 0; i < ARRAY_SIZE(root_map); i++) { - if (root_map[i].id == objectid) + if (root_map[i].id == key->objectid) return root_map[i].name; } - snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, "%llu", objectid); + snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, "%llu", key->objectid); return buf; } diff --git a/fs/btrfs/print-tree.h b/fs/btrfs/print-tree.h index 78b99385a503..802628dd1a6e 100644 --- a/fs/btrfs/print-tree.h +++ b/fs/btrfs/print-tree.h @@ -11,6 +11,6 @@ void btrfs_print_leaf(struct extent_buffer *l); void btrfs_print_tree(struct extent_buffer *c, bool follow); -const char *btrfs_root_name(u64 objectid, char *buf); +const char *btrfs_root_name(struct btrfs_key *key, char *buf); #endif
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. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/print-tree.c | 10 +++++----- fs/btrfs/print-tree.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)