]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: use the key format macros when printing keys
authorFilipe Manana <fdmanana@suse.com>
Wed, 15 Oct 2025 12:16:26 +0000 (13:16 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:03:02 +0000 (22:03 +0100)
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 <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/backref.c
fs/btrfs/ctree.c
fs/btrfs/extent-tree.c
fs/btrfs/inode.c
fs/btrfs/print-tree.c
fs/btrfs/qgroup.c
fs/btrfs/relocation.c
fs/btrfs/root-tree.c
fs/btrfs/send.c
fs/btrfs/tree-checker.c
fs/btrfs/tree-log.c

index 2ab550a1e715a746a10b7b65848fc3cdad6e9c59..e050d0938dc45f13a1dd44a7ba59dbd76ddd82e9 100644 (file)
@@ -666,10 +666,9 @@ static int resolve_indirect_ref(struct btrfs_backref_walk_ctx *ctx,
                ret = btrfs_search_old_slot(root, &search_key, path, ctx->time_seq);
 
        btrfs_debug(ctx->fs_info,
-               "search slot in root %llu (level %d, ref count %d) returned %d for key (%llu %u %llu)",
-                ref->root_id, level, ref->count, ret,
-                ref->key_for_search.objectid, ref->key_for_search.type,
-                ref->key_for_search.offset);
+"search slot in root %llu (level %d, ref count %d) returned %d for key " BTRFS_KEY_FMT,
+                   ref->root_id, level, ref->count, ret,
+                   BTRFS_KEY_FMT_VALUE(&ref->key_for_search));
        if (ret < 0)
                goto out;
 
@@ -3323,9 +3322,9 @@ static int handle_indirect_tree_backref(struct btrfs_trans_handle *trans,
        eb = path->nodes[level];
        if (btrfs_node_blockptr(eb, path->slots[level]) != cur->bytenr) {
                btrfs_err(fs_info,
-"couldn't find block (%llu) (level %d) in tree (%llu) with key (%llu %u %llu)",
+"couldn't find block (%llu) (level %d) in tree (%llu) with key " BTRFS_KEY_FMT,
                          cur->bytenr, level - 1, btrfs_root_id(root),
-                         tree_key->objectid, tree_key->type, tree_key->offset);
+                         BTRFS_KEY_FMT_VALUE(tree_key));
                btrfs_put_root(root);
                ret = -ENOENT;
                goto out;
index 561658aca018b4b94f1c6ef97490a729b8899f01..3be1b66aea357d5530735efd000e14a897a08d94 100644 (file)
@@ -2599,12 +2599,11 @@ void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans,
                if (unlikely(btrfs_comp_keys(&disk_key, new_key) >= 0)) {
                        btrfs_print_leaf(eb);
                        btrfs_crit(fs_info,
-               "slot %u key (%llu %u %llu) new key (%llu %u %llu)",
+               "slot %u key " BTRFS_KEY_FMT " new key " BTRFS_KEY_FMT,
                                   slot, btrfs_disk_key_objectid(&disk_key),
                                   btrfs_disk_key_type(&disk_key),
                                   btrfs_disk_key_offset(&disk_key),
-                                  new_key->objectid, new_key->type,
-                                  new_key->offset);
+                                  BTRFS_KEY_FMT_VALUE(new_key));
                        BUG();
                }
        }
@@ -2613,12 +2612,11 @@ void btrfs_set_item_key_safe(struct btrfs_trans_handle *trans,
                if (unlikely(btrfs_comp_keys(&disk_key, new_key) <= 0)) {
                        btrfs_print_leaf(eb);
                        btrfs_crit(fs_info,
-               "slot %u key (%llu %u %llu) new key (%llu %u %llu)",
+               "slot %u key " BTRFS_KEY_FMT " new key " BTRFS_KEY_FMT,
                                   slot, btrfs_disk_key_objectid(&disk_key),
                                   btrfs_disk_key_type(&disk_key),
                                   btrfs_disk_key_offset(&disk_key),
-                                  new_key->objectid, new_key->type,
-                                  new_key->offset);
+                                  BTRFS_KEY_FMT_VALUE(new_key));
                        BUG();
                }
        }
@@ -2677,10 +2675,9 @@ static bool check_sibling_keys(const struct extent_buffer *left,
                btrfs_crit(left->fs_info, "right extent buffer:");
                btrfs_print_tree(right, false);
                btrfs_crit(left->fs_info,
-"bad key order, sibling blocks, left last (%llu %u %llu) right first (%llu %u %llu)",
-                          left_last.objectid, left_last.type,
-                          left_last.offset, right_first.objectid,
-                          right_first.type, right_first.offset);
+"bad key order, sibling blocks, left last " BTRFS_KEY_FMT " right first " BTRFS_KEY_FMT,
+                          BTRFS_KEY_FMT_VALUE(&left_last),
+                          BTRFS_KEY_FMT_VALUE(&right_first));
                return true;
        }
        return false;
index d1e75da97f587b4e6dd1d3b1ccac931e05f9193b..ae2c3dc9957e6be43fdaa95bdbebdabc3b00f4f5 100644 (file)
@@ -164,8 +164,8 @@ search_again:
                if (unlikely(num_refs == 0)) {
                        ret = -EUCLEAN;
                        btrfs_err(fs_info,
-               "unexpected zero reference count for extent item (%llu %u %llu)",
-                                 key.objectid, key.type, key.offset);
+               "unexpected zero reference count for extent item " BTRFS_KEY_FMT,
+                                 BTRFS_KEY_FMT_VALUE(&key));
                        btrfs_abort_transaction(trans, ret);
                        return ret;
                }
@@ -597,8 +597,8 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans,
                num_refs = btrfs_shared_data_ref_count(leaf, ref2);
        } else {
                btrfs_err(trans->fs_info,
-                         "unrecognized backref key (%llu %u %llu)",
-                         key.objectid, key.type, key.offset);
+                         "unrecognized backref key " BTRFS_KEY_FMT,
+                         BTRFS_KEY_FMT_VALUE(&key));
                btrfs_abort_transaction(trans, -EUCLEAN);
                return -EUCLEAN;
        }
@@ -3326,9 +3326,9 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
                        if (iref) {
                                if (unlikely(path->slots[0] != extent_slot)) {
                                        abort_and_dump(trans, path,
-"invalid iref, extent item key (%llu %u %llu) slot %u doesn't have wanted iref",
-                                                      key.objectid, key.type,
-                                                      key.offset, path->slots[0]);
+"invalid iref, extent item key " BTRFS_KEY_FMT " slot %u doesn't have wanted iref",
+                                                      BTRFS_KEY_FMT_VALUE(&key),
+                                                      path->slots[0]);
                                        ret = -EUCLEAN;
                                        goto out;
                                }
index 81cb8a86324dbea6c76e28f49c142130243dbe12..41b1d7819b8612885daea14b1e581b08a337dcdc 100644 (file)
@@ -5644,9 +5644,9 @@ static int btrfs_inode_by_name(struct btrfs_inode *dir, struct dentry *dentry,
                     location->type != BTRFS_ROOT_ITEM_KEY)) {
                ret = -EUCLEAN;
                btrfs_warn(root->fs_info,
-"%s gets something invalid in DIR_ITEM (name %s, directory ino %llu, location(%llu %u %llu))",
+"%s gets something invalid in DIR_ITEM (name %s, directory ino %llu, location " BTRFS_KEY_FMT ")",
                           __func__, fname.disk_name.name, btrfs_ino(dir),
-                          location->objectid, location->type, location->offset);
+                          BTRFS_KEY_FMT_VALUE(location));
        }
        if (!ret)
                *type = btrfs_dir_ftype(path->nodes[0], di);
index d16f2960d55d239be65debaefd2b3c4cb8eef6d2..f189bf09ce6aabf96559e0b7da7483f3e258374a 100644 (file)
@@ -131,7 +131,7 @@ static void print_extent_item(const struct extent_buffer *eb, int slot, int type
                struct btrfs_tree_block_info *info;
                info = (struct btrfs_tree_block_info *)(ei + 1);
                btrfs_tree_block_key(eb, info, &key);
-               pr_info("\t\ttree block key (%llu %u %llu) level %d\n",
+               pr_info("\t\ttree block key " BTRFS_KEY_FMT " level %d\n",
                       btrfs_disk_key_objectid(&key), key.type,
                       btrfs_disk_key_offset(&key),
                       btrfs_tree_block_level(eb, info));
@@ -277,9 +277,8 @@ static void print_dir_item(const struct extent_buffer *eb, int i)
                struct btrfs_key location;
 
                btrfs_dir_item_key_to_cpu(eb, di, &location);
-               pr_info("\t\tlocation key (%llu %u %llu) type %d\n",
-                       location.objectid, location.type, location.offset,
-                       btrfs_dir_ftype(eb, di));
+               pr_info("\t\tlocation key " BTRFS_KEY_FMT " type %d\n",
+                       BTRFS_KEY_FMT_VALUE(&location), btrfs_dir_ftype(eb, di));
                pr_info("\t\ttransid %llu data_len %u name_len %u\n",
                        btrfs_dir_transid(eb, di), data_len, name_len);
                di = (struct btrfs_dir_item *)((char *)di + len);
@@ -598,10 +597,9 @@ void btrfs_print_tree(const struct extent_buffer *c, bool follow)
        print_eb_refs_lock(c);
        for (i = 0; i < nr; i++) {
                btrfs_node_key_to_cpu(c, &key, i);
-               pr_info("\tkey %d (%llu %u %llu) block %llu gen %llu\n",
-                      i, key.objectid, key.type, key.offset,
-                      btrfs_node_blockptr(c, i),
-                      btrfs_node_ptr_generation(c, i));
+               pr_info("\tkey %d " BTRFS_KEY_FMT " block %llu gen %llu\n",
+                       i, BTRFS_KEY_FMT_VALUE(&key), btrfs_node_blockptr(c, i),
+                       btrfs_node_ptr_generation(c, i));
        }
        if (!follow)
                return;
index 31ad8580322a6e7909e9cf8a5b427afcf915131a..6e3871ba18455ff5b53e9fd555cc7685ca9f5806 100644 (file)
@@ -3712,10 +3712,8 @@ static int qgroup_rescan_leaf(struct btrfs_trans_handle *trans,
                                         path, 1, 0);
 
        btrfs_debug(fs_info,
-               "current progress key (%llu %u %llu), search_slot ret %d",
-               fs_info->qgroup_rescan_progress.objectid,
-               fs_info->qgroup_rescan_progress.type,
-               fs_info->qgroup_rescan_progress.offset, ret);
+                   "current progress key " BTRFS_KEY_FMT ", search_slot ret %d",
+                   BTRFS_KEY_FMT_VALUE(&fs_info->qgroup_rescan_progress), ret);
 
        if (ret) {
                /*
index 748290758459b2f7373f6d6111968af360ae8d83..96539e8b7b4b17bf3134ea01494c273e1386ee13 100644 (file)
@@ -615,8 +615,8 @@ static struct btrfs_root *create_reloc_root(struct btrfs_trans_handle *trans,
 
                        btrfs_disk_key_to_cpu(&cpu_key, &root->root_item.drop_progress);
                        btrfs_err(fs_info,
-       "cannot relocate partially dropped subvolume %llu, drop progress key (%llu %u %llu)",
-                                 objectid, cpu_key.objectid, cpu_key.type, cpu_key.offset);
+       "cannot relocate partially dropped subvolume %llu, drop progress key " BTRFS_KEY_FMT,
+                                 objectid, BTRFS_KEY_FMT_VALUE(&cpu_key));
                        ret = -EUCLEAN;
                        goto fail;
                }
index d07eab70f759d990ac9e8ddbfa9aff1dabd98c01..6a7e297ab0a7a147a8e54231435df42eff8dbcc4 100644 (file)
@@ -147,8 +147,8 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
 
        if (unlikely(ret > 0)) {
                btrfs_crit(fs_info,
-                       "unable to find root key (%llu %u %llu) in tree %llu",
-                       key->objectid, key->type, key->offset, btrfs_root_id(root));
+                          "unable to find root key " BTRFS_KEY_FMT " in tree %llu",
+                          BTRFS_KEY_FMT_VALUE(key), btrfs_root_id(root));
                ret = -EUCLEAN;
                btrfs_abort_transaction(trans, ret);
                return ret;
index 96a030d28e0910cd66a43f2ddc81a783eae4c972..caeaa50f2f446c936405ed00fe14d29e502981f2 100644 (file)
@@ -1053,10 +1053,8 @@ static int iterate_inode_ref(struct btrfs_root *root, struct btrfs_path *path,
                                }
                                if (unlikely(start < p->buf)) {
                                        btrfs_err(root->fs_info,
-                       "send: path ref buffer underflow for key (%llu %u %llu)",
-                                                 found_key->objectid,
-                                                 found_key->type,
-                                                 found_key->offset);
+                         "send: path ref buffer underflow for key " BTRFS_KEY_FMT,
+                                                 BTRFS_KEY_FMT_VALUE(found_key));
                                        ret = -EINVAL;
                                        goto out;
                                }
@@ -7274,8 +7272,8 @@ static int search_key_again(const struct send_ctx *sctx,
        if (unlikely(ret > 0)) {
                btrfs_print_tree(path->nodes[path->lowest_level], false);
                btrfs_err(root->fs_info,
-"send: key (%llu %u %llu) not found in %s root %llu, lowest_level %d, slot %d",
-                         key->objectid, key->type, key->offset,
+"send: key " BTRFS_KEY_FMT" not found in %s root %llu, lowest_level %d, slot %d",
+                         BTRFS_KEY_FMT_VALUE(key),
                          (root == sctx->parent_root ? "parent" : "send"),
                          btrfs_root_id(root), path->lowest_level,
                          path->slots[path->lowest_level]);
index c10b4c242acfc98a40e496ae61812b9bf5a4f751..5684750ca7a64a44e5bc637dcd83b6e51894f371 100644 (file)
@@ -1618,10 +1618,9 @@ static int check_extent_item(struct extent_buffer *leaf,
 
                if (unlikely(prev_end > key->objectid)) {
                        extent_err(leaf, slot,
-       "previous extent [%llu %u %llu] overlaps current extent [%llu %u %llu]",
-                                  prev_key->objectid, prev_key->type,
-                                  prev_key->offset, key->objectid, key->type,
-                                  key->offset);
+       "previous extent " BTRFS_KEY_FMT " overlaps current extent " BTRFS_KEY_FMT,
+                                  BTRFS_KEY_FMT_VALUE(prev_key),
+                                  BTRFS_KEY_FMT_VALUE(key));
                        return -EUCLEAN;
                }
        }
@@ -2060,10 +2059,9 @@ enum btrfs_tree_block_status __btrfs_check_leaf(struct extent_buffer *leaf)
                /* Make sure the keys are in the right order */
                if (unlikely(btrfs_comp_cpu_keys(&prev_key, &key) >= 0)) {
                        generic_err(leaf, slot,
-       "bad key order, prev (%llu %u %llu) current (%llu %u %llu)",
-                               prev_key.objectid, prev_key.type,
-                               prev_key.offset, key.objectid, key.type,
-                               key.offset);
+       "bad key order, prev " BTRFS_KEY_FMT " current " BTRFS_KEY_FMT,
+                                   BTRFS_KEY_FMT_VALUE(&prev_key),
+                                   BTRFS_KEY_FMT_VALUE(&key));
                        return BTRFS_TREE_BLOCK_BAD_KEY_ORDER;
                }
 
@@ -2181,10 +2179,9 @@ enum btrfs_tree_block_status __btrfs_check_node(struct extent_buffer *node)
 
                if (unlikely(btrfs_comp_cpu_keys(&key, &next_key) >= 0)) {
                        generic_err(node, slot,
-       "bad key order, current (%llu %u %llu) next (%llu %u %llu)",
-                               key.objectid, key.type, key.offset,
-                               next_key.objectid, next_key.type,
-                               next_key.offset);
+       "bad key order, current " BTRFS_KEY_FMT " next " BTRFS_KEY_FMT,
+                                   BTRFS_KEY_FMT_VALUE(&key),
+                                   BTRFS_KEY_FMT_VALUE(&next_key));
                        return BTRFS_TREE_BLOCK_BAD_KEY_ORDER;
                }
        }
index f7e5fe3adff2263aae7465502807e425abad7567..030d0fef97bdbce13d74876c9400e342efb0dda7 100644 (file)
@@ -198,9 +198,9 @@ static void do_abort_log_replay(struct walk_control *wc, const char *function,
 
        if (wc->log_leaf) {
                btrfs_crit(fs_info,
-         "log tree (for root %llu) leaf currently being processed (slot %d key %llu %u %llu):",
+"log tree (for root %llu) leaf currently being processed (slot %d key " BTRFS_KEY_FMT "):",
                           btrfs_root_id(wc->root), wc->log_slot,
-                          wc->log_key.objectid, wc->log_key.type, wc->log_key.offset);
+                          BTRFS_KEY_FMT_VALUE(&wc->log_key));
                btrfs_print_leaf(wc->log_leaf);
        }
 
@@ -510,9 +510,9 @@ static int overwrite_item(struct walk_control *wc)
        ret = btrfs_search_slot(NULL, root, &wc->log_key, wc->subvol_path, 0, 0);
        if (ret < 0) {
                btrfs_abort_log_replay(wc, ret,
-               "failed to search subvolume tree for key (%llu %u %llu) root %llu",
-                                      wc->log_key.objectid, wc->log_key.type,
-                                      wc->log_key.offset, btrfs_root_id(root));
+               "failed to search subvolume tree for key " BTRFS_KEY_FMT " root %llu",
+                                      BTRFS_KEY_FMT_VALUE(&wc->log_key),
+                                      btrfs_root_id(root));
                return ret;
        }
 
@@ -618,9 +618,8 @@ insert:
                        btrfs_extend_item(trans, wc->subvol_path, item_size - found_size);
        } else if (ret) {
                btrfs_abort_log_replay(wc, ret,
-                                      "failed to insert item for key (%llu %u %llu)",
-                                      wc->log_key.objectid, wc->log_key.type,
-                                      wc->log_key.offset);
+                                      "failed to insert item for key " BTRFS_KEY_FMT,
+                                      BTRFS_KEY_FMT_VALUE(&wc->log_key));
                return ret;
        }
        dst_ptr = btrfs_item_ptr_offset(dst_eb, dst_slot);
@@ -829,9 +828,9 @@ static noinline int replay_one_extent(struct walk_control *wc)
                                      &wc->log_key, sizeof(*item));
        if (ret) {
                btrfs_abort_log_replay(wc, ret,
-                      "failed to insert item with key (%llu %u %llu) root %llu",
-                                      wc->log_key.objectid, wc->log_key.type,
-                                      wc->log_key.offset, btrfs_root_id(root));
+                      "failed to insert item with key " BTRFS_KEY_FMT " root %llu",
+                                      BTRFS_KEY_FMT_VALUE(&wc->log_key),
+                                      btrfs_root_id(root));
                goto out;
        }
        dest_offset = btrfs_item_ptr_offset(wc->subvol_path->nodes[0],
@@ -1348,9 +1347,9 @@ again:
        ret = btrfs_search_slot(NULL, root, &search_key, wc->subvol_path, 0, 0);
        if (ret < 0) {
                btrfs_abort_log_replay(wc, ret,
-              "failed to search subvolume tree for key (%llu %u %llu) root %llu",
-                                      search_key.objectid, search_key.type,
-                                      search_key.offset, btrfs_root_id(root));
+              "failed to search subvolume tree for key " BTRFS_KEY_FMT " root %llu",
+                                      BTRFS_KEY_FMT_VALUE(&search_key),
+                                      btrfs_root_id(root));
                return ret;
        } else if (ret == 0) {
                /*
@@ -1483,9 +1482,9 @@ again:
        }
        if (ret < 0) {
                btrfs_abort_log_replay(wc, ret,
-              "failed to search subvolume tree for key (%llu %u %llu) root %llu",
-                                      wc->log_key.objectid, wc->log_key.type,
-                                      wc->log_key.offset, btrfs_root_id(root));
+              "failed to search subvolume tree for key " BTRFS_KEY_FMT " root %llu",
+                                      BTRFS_KEY_FMT_VALUE(&wc->log_key),
+                                      btrfs_root_id(root));
                goto out;
        }
 
@@ -2700,10 +2699,9 @@ static noinline int replay_dir_deletes(struct walk_control *wc,
                                                wc->subvol_path, 0, 0);
                        if (ret < 0) {
                                btrfs_abort_log_replay(wc, ret,
-                              "failed to search root %llu for key (%llu %u %llu)",
+                              "failed to search root %llu for key " BTRFS_KEY_FMT,
                                                       btrfs_root_id(root),
-                                                      dir_key.objectid, dir_key.type,
-                                                      dir_key.offset);
+                                                      BTRFS_KEY_FMT_VALUE(&dir_key));
                                goto out;
                        }