]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: move and rename CSUM_FMT definition
authorDavid Sterba <dsterba@suse.com>
Wed, 15 Oct 2025 16:48:37 +0000 (18:48 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:42:23 +0000 (22:42 +0100)
Move the CSUM_FMT* definitions to fs.h where is be the BTRFS_KEY_FMT
and add the prefix for consistency.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/btrfs_inode.h
fs/btrfs/disk-io.c
fs/btrfs/fs.h
fs/btrfs/inode.c
fs/btrfs/scrub.c

index a66ca5531b5c57726e71555bd3607121c8ffd64f..af38d47fc131953ed068a8d12d51d7d77b2a5713 100644 (file)
@@ -543,10 +543,6 @@ static inline void btrfs_set_inode_mapping_order(struct btrfs_inode *inode)
 #endif
 }
 
-/* Array of bytes with variable length, hexadecimal format 0x1234 */
-#define CSUM_FMT                               "0x%*phN"
-#define CSUM_FMT_VALUE(size, bytes)            size, bytes
-
 void btrfs_calculate_block_csum(struct btrfs_fs_info *fs_info, phys_addr_t paddr,
                                u8 *dest);
 int btrfs_check_block_csum(struct btrfs_fs_info *fs_info, phys_addr_t paddr, u8 *csum,
index 6a1fa3b08b3f22ad0b066402cfda65d8f6fac661..4764108b03381a726a841bd9ff40125b1401f38e 100644 (file)
@@ -399,10 +399,10 @@ int btrfs_validate_extent_buffer(struct extent_buffer *eb,
 
        if (memcmp(result, header_csum, csum_size) != 0) {
                btrfs_warn_rl(fs_info,
-"checksum verify failed on logical %llu mirror %u wanted " CSUM_FMT " found " CSUM_FMT " level %d%s",
+"checksum verify failed on logical %llu mirror %u wanted " BTRFS_CSUM_FMT " found " BTRFS_CSUM_FMT " level %d%s",
                              eb->start, eb->read_mirror,
-                             CSUM_FMT_VALUE(csum_size, header_csum),
-                             CSUM_FMT_VALUE(csum_size, result),
+                             BTRFS_CSUM_FMT_VALUE(csum_size, header_csum),
+                             BTRFS_CSUM_FMT_VALUE(csum_size, result),
                              btrfs_header_level(eb),
                              ignore_csum ? ", ignored" : "");
                if (unlikely(!ignore_csum)) {
index e7cd4490736f2a71991cfb557f54533c80b487d7..0f7e1ef278917bac32b7c1929c95710ed4e54d8a 100644 (file)
@@ -74,6 +74,10 @@ struct btrfs_space_info;
 #define BTRFS_SUPER_INFO_SIZE                  4096
 static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);
 
+/* Array of bytes with variable length, hexadecimal format 0x1234 */
+#define BTRFS_CSUM_FMT                         "0x%*phN"
+#define BTRFS_CSUM_FMT_VALUE(size, bytes)      size, bytes
+
 #define BTRFS_KEY_FMT                  "(%llu %u %llu)"
 #define BTRFS_KEY_FMT_VALUE(key)       (key)->objectid, (key)->type, (key)->offset
 
index 8737914e8552c1e020518a0c3c5fcbdca008df23..5929cc5fc01f85dbc39f645a6e40f6fef443f2a6 100644 (file)
@@ -234,21 +234,21 @@ static void print_data_reloc_error(const struct btrfs_inode *inode, u64 file_off
        if (logical == U64_MAX) {
                btrfs_warn_rl(fs_info, "has data reloc tree but no running relocation");
                btrfs_warn_rl(fs_info,
-"csum failed root %lld ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
+"csum failed root %lld ino %llu off %llu csum " BTRFS_CSUM_FMT " expected csum " BTRFS_CSUM_FMT " mirror %d",
                        btrfs_root_id(inode->root), btrfs_ino(inode), file_off,
-                       CSUM_FMT_VALUE(csum_size, csum),
-                       CSUM_FMT_VALUE(csum_size, csum_expected),
+                       BTRFS_CSUM_FMT_VALUE(csum_size, csum),
+                       BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
                        mirror_num);
                return;
        }
 
        logical += file_off;
        btrfs_warn_rl(fs_info,
-"csum failed root %lld ino %llu off %llu logical %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
+"csum failed root %lld ino %llu off %llu logical %llu csum " BTRFS_CSUM_FMT " expected csum " BTRFS_CSUM_FMT " mirror %d",
                        btrfs_root_id(inode->root),
                        btrfs_ino(inode), file_off, logical,
-                       CSUM_FMT_VALUE(csum_size, csum),
-                       CSUM_FMT_VALUE(csum_size, csum_expected),
+                       BTRFS_CSUM_FMT_VALUE(csum_size, csum),
+                       BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
                        mirror_num);
 
        ret = extent_from_logical(fs_info, logical, &path, &found_key, &flags);
@@ -319,19 +319,19 @@ static void __cold btrfs_print_data_csum_error(struct btrfs_inode *inode,
        /* Output without objectid, which is more meaningful */
        if (btrfs_root_id(root) >= BTRFS_LAST_FREE_OBJECTID) {
                btrfs_warn_rl(root->fs_info,
-"csum failed root %lld ino %lld off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
+"csum failed root %lld ino %lld off %llu csum " BTRFS_CSUM_FMT " expected csum " BTRFS_CSUM_FMT " mirror %d",
                        btrfs_root_id(root), btrfs_ino(inode),
                        logical_start,
-                       CSUM_FMT_VALUE(csum_size, csum),
-                       CSUM_FMT_VALUE(csum_size, csum_expected),
+                       BTRFS_CSUM_FMT_VALUE(csum_size, csum),
+                       BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
                        mirror_num);
        } else {
                btrfs_warn_rl(root->fs_info,
-"csum failed root %llu ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
+"csum failed root %llu ino %llu off %llu csum " BTRFS_CSUM_FMT " expected csum " BTRFS_CSUM_FMT " mirror %d",
                        btrfs_root_id(root), btrfs_ino(inode),
                        logical_start,
-                       CSUM_FMT_VALUE(csum_size, csum),
-                       CSUM_FMT_VALUE(csum_size, csum_expected),
+                       BTRFS_CSUM_FMT_VALUE(csum_size, csum),
+                       BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
                        mirror_num);
        }
 }
index 3029ef683fb990c8323a5bb0d2258c1cba432756..ab259815a899cadf2fb0b8a5f67fc86e4d81e4af 100644 (file)
@@ -775,10 +775,10 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
                scrub_bitmap_set_meta_error(stripe, sector_nr, sectors_per_tree);
                scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree);
                btrfs_warn_rl(fs_info,
-"scrub: tree block %llu mirror %u has bad csum, has " CSUM_FMT " want " CSUM_FMT,
+"scrub: tree block %llu mirror %u has bad csum, has " BTRFS_CSUM_FMT " want " BTRFS_CSUM_FMT,
                              logical, stripe->mirror_num,
-                             CSUM_FMT_VALUE(fs_info->csum_size, on_disk_csum),
-                             CSUM_FMT_VALUE(fs_info->csum_size, calculated_csum));
+                             BTRFS_CSUM_FMT_VALUE(fs_info->csum_size, on_disk_csum),
+                             BTRFS_CSUM_FMT_VALUE(fs_info->csum_size, calculated_csum));
                return;
        }
        if (stripe->sectors[sector_nr].generation !=