btrfs: move and rename CSUM_FMT definition

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>
pull/1354/merge
David Sterba 2025-10-15 18:48:37 +02:00
parent a320476ca8
commit 4decf577fb
5 changed files with 22 additions and 22 deletions

View File

@ -543,10 +543,6 @@ static inline void btrfs_set_inode_mapping_order(struct btrfs_inode *inode)
#endif #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, void btrfs_calculate_block_csum(struct btrfs_fs_info *fs_info, phys_addr_t paddr,
u8 *dest); u8 *dest);
int btrfs_check_block_csum(struct btrfs_fs_info *fs_info, phys_addr_t paddr, u8 *csum, int btrfs_check_block_csum(struct btrfs_fs_info *fs_info, phys_addr_t paddr, u8 *csum,

View File

@ -399,10 +399,10 @@ int btrfs_validate_extent_buffer(struct extent_buffer *eb,
if (memcmp(result, header_csum, csum_size) != 0) { if (memcmp(result, header_csum, csum_size) != 0) {
btrfs_warn_rl(fs_info, 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, eb->start, eb->read_mirror,
CSUM_FMT_VALUE(csum_size, header_csum), BTRFS_CSUM_FMT_VALUE(csum_size, header_csum),
CSUM_FMT_VALUE(csum_size, result), BTRFS_CSUM_FMT_VALUE(csum_size, result),
btrfs_header_level(eb), btrfs_header_level(eb),
ignore_csum ? ", ignored" : ""); ignore_csum ? ", ignored" : "");
if (unlikely(!ignore_csum)) { if (unlikely(!ignore_csum)) {

View File

@ -74,6 +74,10 @@ struct btrfs_space_info;
#define BTRFS_SUPER_INFO_SIZE 4096 #define BTRFS_SUPER_INFO_SIZE 4096
static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); 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 "(%llu %u %llu)"
#define BTRFS_KEY_FMT_VALUE(key) (key)->objectid, (key)->type, (key)->offset #define BTRFS_KEY_FMT_VALUE(key) (key)->objectid, (key)->type, (key)->offset

View File

@ -234,21 +234,21 @@ static void print_data_reloc_error(const struct btrfs_inode *inode, u64 file_off
if (logical == U64_MAX) { if (logical == U64_MAX) {
btrfs_warn_rl(fs_info, "has data reloc tree but no running relocation"); btrfs_warn_rl(fs_info, "has data reloc tree but no running relocation");
btrfs_warn_rl(fs_info, 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, btrfs_root_id(inode->root), btrfs_ino(inode), file_off,
CSUM_FMT_VALUE(csum_size, csum), BTRFS_CSUM_FMT_VALUE(csum_size, csum),
CSUM_FMT_VALUE(csum_size, csum_expected), BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
mirror_num); mirror_num);
return; return;
} }
logical += file_off; logical += file_off;
btrfs_warn_rl(fs_info, 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_root_id(inode->root),
btrfs_ino(inode), file_off, logical, btrfs_ino(inode), file_off, logical,
CSUM_FMT_VALUE(csum_size, csum), BTRFS_CSUM_FMT_VALUE(csum_size, csum),
CSUM_FMT_VALUE(csum_size, csum_expected), BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
mirror_num); mirror_num);
ret = extent_from_logical(fs_info, logical, &path, &found_key, &flags); 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 */ /* Output without objectid, which is more meaningful */
if (btrfs_root_id(root) >= BTRFS_LAST_FREE_OBJECTID) { if (btrfs_root_id(root) >= BTRFS_LAST_FREE_OBJECTID) {
btrfs_warn_rl(root->fs_info, 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), btrfs_root_id(root), btrfs_ino(inode),
logical_start, logical_start,
CSUM_FMT_VALUE(csum_size, csum), BTRFS_CSUM_FMT_VALUE(csum_size, csum),
CSUM_FMT_VALUE(csum_size, csum_expected), BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
mirror_num); mirror_num);
} else { } else {
btrfs_warn_rl(root->fs_info, 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), btrfs_root_id(root), btrfs_ino(inode),
logical_start, logical_start,
CSUM_FMT_VALUE(csum_size, csum), BTRFS_CSUM_FMT_VALUE(csum_size, csum),
CSUM_FMT_VALUE(csum_size, csum_expected), BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
mirror_num); mirror_num);
} }
} }

View 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_meta_error(stripe, sector_nr, sectors_per_tree);
scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree); scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree);
btrfs_warn_rl(fs_info, 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, logical, stripe->mirror_num,
CSUM_FMT_VALUE(fs_info->csum_size, on_disk_csum), BTRFS_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, calculated_csum));
return; return;
} }
if (stripe->sectors[sector_nr].generation != if (stripe->sectors[sector_nr].generation !=