Skip to content

Commit b9326d7

Browse files
committed
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>
1 parent 4a0abaf commit b9326d7

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

fs/btrfs/btrfs_inode.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,6 @@ static inline void btrfs_set_inode_mapping_order(struct btrfs_inode *inode)
543543
#endif
544544
}
545545

546-
/* Array of bytes with variable length, hexadecimal format 0x1234 */
547-
#define CSUM_FMT "0x%*phN"
548-
#define CSUM_FMT_VALUE(size, bytes) size, bytes
549-
550546
void btrfs_calculate_block_csum(struct btrfs_fs_info *fs_info, phys_addr_t paddr,
551547
u8 *dest);
552548
int btrfs_check_block_csum(struct btrfs_fs_info *fs_info, phys_addr_t paddr, u8 *csum,

fs/btrfs/disk-io.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,10 @@ int btrfs_validate_extent_buffer(struct extent_buffer *eb,
399399

400400
if (memcmp(result, header_csum, csum_size) != 0) {
401401
btrfs_warn_rl(fs_info,
402-
"checksum verify failed on logical %llu mirror %u wanted " CSUM_FMT " found " CSUM_FMT " level %d%s",
402+
"checksum verify failed on logical %llu mirror %u wanted " BTRFS_CSUM_FMT " found " BTRFS_CSUM_FMT " level %d%s",
403403
eb->start, eb->read_mirror,
404-
CSUM_FMT_VALUE(csum_size, header_csum),
405-
CSUM_FMT_VALUE(csum_size, result),
404+
BTRFS_CSUM_FMT_VALUE(csum_size, header_csum),
405+
BTRFS_CSUM_FMT_VALUE(csum_size, result),
406406
btrfs_header_level(eb),
407407
ignore_csum ? ", ignored" : "");
408408
if (unlikely(!ignore_csum)) {

fs/btrfs/fs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ struct btrfs_space_info;
7474
#define BTRFS_SUPER_INFO_SIZE 4096
7575
static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);
7676

77+
/* Array of bytes with variable length, hexadecimal format 0x1234 */
78+
#define BTRFS_CSUM_FMT "0x%*phN"
79+
#define BTRFS_CSUM_FMT_VALUE(size, bytes) size, bytes
80+
7781
#define BTRFS_KEY_FMT "(%llu %u %llu)"
7882
#define BTRFS_KEY_FMT_VALUE(key) (key)->objectid, (key)->type, (key)->offset
7983

fs/btrfs/inode.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,21 +234,21 @@ static void print_data_reloc_error(const struct btrfs_inode *inode, u64 file_off
234234
if (logical == U64_MAX) {
235235
btrfs_warn_rl(fs_info, "has data reloc tree but no running relocation");
236236
btrfs_warn_rl(fs_info,
237-
"csum failed root %lld ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
237+
"csum failed root %lld ino %llu off %llu csum " BTRFS_CSUM_FMT " expected csum " BTRFS_CSUM_FMT " mirror %d",
238238
btrfs_root_id(inode->root), btrfs_ino(inode), file_off,
239-
CSUM_FMT_VALUE(csum_size, csum),
240-
CSUM_FMT_VALUE(csum_size, csum_expected),
239+
BTRFS_CSUM_FMT_VALUE(csum_size, csum),
240+
BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
241241
mirror_num);
242242
return;
243243
}
244244

245245
logical += file_off;
246246
btrfs_warn_rl(fs_info,
247-
"csum failed root %lld ino %llu off %llu logical %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
247+
"csum failed root %lld ino %llu off %llu logical %llu csum " BTRFS_CSUM_FMT " expected csum " BTRFS_CSUM_FMT " mirror %d",
248248
btrfs_root_id(inode->root),
249249
btrfs_ino(inode), file_off, logical,
250-
CSUM_FMT_VALUE(csum_size, csum),
251-
CSUM_FMT_VALUE(csum_size, csum_expected),
250+
BTRFS_CSUM_FMT_VALUE(csum_size, csum),
251+
BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
252252
mirror_num);
253253

254254
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,
319319
/* Output without objectid, which is more meaningful */
320320
if (btrfs_root_id(root) >= BTRFS_LAST_FREE_OBJECTID) {
321321
btrfs_warn_rl(root->fs_info,
322-
"csum failed root %lld ino %lld off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
322+
"csum failed root %lld ino %lld off %llu csum " BTRFS_CSUM_FMT " expected csum " BTRFS_CSUM_FMT " mirror %d",
323323
btrfs_root_id(root), btrfs_ino(inode),
324324
logical_start,
325-
CSUM_FMT_VALUE(csum_size, csum),
326-
CSUM_FMT_VALUE(csum_size, csum_expected),
325+
BTRFS_CSUM_FMT_VALUE(csum_size, csum),
326+
BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
327327
mirror_num);
328328
} else {
329329
btrfs_warn_rl(root->fs_info,
330-
"csum failed root %llu ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d",
330+
"csum failed root %llu ino %llu off %llu csum " BTRFS_CSUM_FMT " expected csum " BTRFS_CSUM_FMT " mirror %d",
331331
btrfs_root_id(root), btrfs_ino(inode),
332332
logical_start,
333-
CSUM_FMT_VALUE(csum_size, csum),
334-
CSUM_FMT_VALUE(csum_size, csum_expected),
333+
BTRFS_CSUM_FMT_VALUE(csum_size, csum),
334+
BTRFS_CSUM_FMT_VALUE(csum_size, csum_expected),
335335
mirror_num);
336336
}
337337
}

fs/btrfs/scrub.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,10 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
775775
scrub_bitmap_set_meta_error(stripe, sector_nr, sectors_per_tree);
776776
scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree);
777777
btrfs_warn_rl(fs_info,
778-
"scrub: tree block %llu mirror %u has bad csum, has " CSUM_FMT " want " CSUM_FMT,
778+
"scrub: tree block %llu mirror %u has bad csum, has " BTRFS_CSUM_FMT " want " BTRFS_CSUM_FMT,
779779
logical, stripe->mirror_num,
780-
CSUM_FMT_VALUE(fs_info->csum_size, on_disk_csum),
781-
CSUM_FMT_VALUE(fs_info->csum_size, calculated_csum));
780+
BTRFS_CSUM_FMT_VALUE(fs_info->csum_size, on_disk_csum),
781+
BTRFS_CSUM_FMT_VALUE(fs_info->csum_size, calculated_csum));
782782
return;
783783
}
784784
if (stripe->sectors[sector_nr].generation !=

0 commit comments

Comments
 (0)