Commit 59a0fcdb authored by David Sterba's avatar David Sterba

btrfs: inline checksum name and driver definitions

There's an unnecessary indirection in the checksum definition table,
pointer and the string itself. The strings are short and the overall
size of one entry is now 24 bytes.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 11c67b1a
...@@ -31,8 +31,8 @@ static void del_ptr(struct btrfs_root *root, struct btrfs_path *path, ...@@ -31,8 +31,8 @@ static void del_ptr(struct btrfs_root *root, struct btrfs_path *path,
static const struct btrfs_csums { static const struct btrfs_csums {
u16 size; u16 size;
const char *name; const char name[10];
const char *driver; const char driver[12];
} btrfs_csums[] = { } btrfs_csums[] = {
[BTRFS_CSUM_TYPE_CRC32] = { .size = 4, .name = "crc32c" }, [BTRFS_CSUM_TYPE_CRC32] = { .size = 4, .name = "crc32c" },
[BTRFS_CSUM_TYPE_XXHASH] = { .size = 8, .name = "xxhash64" }, [BTRFS_CSUM_TYPE_XXHASH] = { .size = 8, .name = "xxhash64" },
...@@ -63,7 +63,8 @@ const char *btrfs_super_csum_name(u16 csum_type) ...@@ -63,7 +63,8 @@ const char *btrfs_super_csum_name(u16 csum_type)
const char *btrfs_super_csum_driver(u16 csum_type) const char *btrfs_super_csum_driver(u16 csum_type)
{ {
/* csum type is validated at mount time */ /* csum type is validated at mount time */
return btrfs_csums[csum_type].driver ?: return btrfs_csums[csum_type].driver[0] ?
btrfs_csums[csum_type].driver :
btrfs_csums[csum_type].name; btrfs_csums[csum_type].name;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment