Commit abce30b7 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: BCH_EXTENT_ENTRY_TYPES()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 71c9e0ba
...@@ -461,15 +461,19 @@ enum bch_compression_type { ...@@ -461,15 +461,19 @@ enum bch_compression_type {
BCH_COMPRESSION_NR = 5, BCH_COMPRESSION_NR = 5,
}; };
#define BCH_EXTENT_ENTRY_TYPES() \
x(ptr, 0) \
x(crc32, 1) \
x(crc64, 2) \
x(crc128, 3)
#define BCH_EXTENT_ENTRY_MAX 4
enum bch_extent_entry_type { enum bch_extent_entry_type {
BCH_EXTENT_ENTRY_ptr = 0, #define x(f, n) BCH_EXTENT_ENTRY_##f = n,
BCH_EXTENT_ENTRY_crc32 = 1, BCH_EXTENT_ENTRY_TYPES()
BCH_EXTENT_ENTRY_crc64 = 2, #undef x
BCH_EXTENT_ENTRY_crc128 = 3,
}; };
#define BCH_EXTENT_ENTRY_MAX 4
/* Compressed/uncompressed size are stored biased by 1: */ /* Compressed/uncompressed size are stored biased by 1: */
struct bch_extent_crc32 { struct bch_extent_crc32 {
#if defined(__LITTLE_ENDIAN_BITFIELD) #if defined(__LITTLE_ENDIAN_BITFIELD)
...@@ -594,10 +598,10 @@ union bch_extent_entry { ...@@ -594,10 +598,10 @@ union bch_extent_entry {
#else #else
#error edit for your odd byteorder. #error edit for your odd byteorder.
#endif #endif
struct bch_extent_crc32 crc32;
struct bch_extent_crc64 crc64; #define x(f, n) struct bch_extent_##f f;
struct bch_extent_crc128 crc128; BCH_EXTENT_ENTRY_TYPES()
struct bch_extent_ptr ptr; #undef x
}; };
enum { enum {
......
...@@ -162,14 +162,11 @@ extent_entry_type(const union bch_extent_entry *e) ...@@ -162,14 +162,11 @@ extent_entry_type(const union bch_extent_entry *e)
static inline size_t extent_entry_bytes(const union bch_extent_entry *entry) static inline size_t extent_entry_bytes(const union bch_extent_entry *entry)
{ {
switch (extent_entry_type(entry)) { switch (extent_entry_type(entry)) {
case BCH_EXTENT_ENTRY_crc32: #define x(f, n) \
return sizeof(struct bch_extent_crc32); case BCH_EXTENT_ENTRY_##f: \
case BCH_EXTENT_ENTRY_crc64: return sizeof(struct bch_extent_##f);
return sizeof(struct bch_extent_crc64); BCH_EXTENT_ENTRY_TYPES()
case BCH_EXTENT_ENTRY_crc128: #undef x
return sizeof(struct bch_extent_crc128);
case BCH_EXTENT_ENTRY_ptr:
return sizeof(struct bch_extent_ptr);
default: default:
BUG(); BUG();
} }
......
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