Skip to content

Commit 400b2fb

Browse files
fdmananakdave
authored andcommitted
btrfs: add macros to facilitate printing of keys
There's a lot of places where we need to print a key, and it's tiresome to type the format specifier, typically "(%llu %u %llu)", as well as passing 3 arguments to a prink family function (key->objectid, key->type, key->offset). So add a couple macros for this just like we have for csum values in btrfs_inode.h (CSUM_FMT and CSUM_FMT_VALUE). This also ensures that we consistently print a key in the same format, always as "(%llu %llu %llu)", which is the most common format we use, but we have a few variations such as "[%llu %llu %llu]" for no good reason. This patch introduces the macros while the next one makes use of it. This is to ease backports of future patches, since then we can backport this patch which is simple and short and then backport those future patches, as the next patch in the series that makes use of these new macros is quite large and may have some dependencies. Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 3a9a1b9 commit 400b2fb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/btrfs/fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ 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+
#define BTRFS_KEY_FMT "(%llu %u %llu)"
78+
#define BTRFS_KEY_FMT_VALUE(key) (key)->objectid, (key)->type, (key)->offset
79+
7780
/*
7881
* Number of metadata items necessary for an unlink operation:
7982
*

0 commit comments

Comments
 (0)