summaryrefslogtreecommitdiff
path: root/libbcachefs/bcachefs_format.h
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/bcachefs_format.h')
-rw-r--r--libbcachefs/bcachefs_format.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/libbcachefs/bcachefs_format.h b/libbcachefs/bcachefs_format.h
index 6d8397bc..efda901e 100644
--- a/libbcachefs/bcachefs_format.h
+++ b/libbcachefs/bcachefs_format.h
@@ -73,6 +73,7 @@
#include <asm/types.h>
#include <asm/byteorder.h>
+#include <linux/kernel.h>
#include <linux/uuid.h>
#define LE_BITMASK(_bits, name, type, field, offset, end) \
@@ -802,11 +803,6 @@ struct bch_xattr {
/* Bucket/allocation information: */
-enum {
- BCH_ALLOC_FIELD_READ_TIME = 0,
- BCH_ALLOC_FIELD_WRITE_TIME = 1,
-};
-
struct bch_alloc {
struct bch_val v;
__u8 fields;
@@ -814,6 +810,32 @@ struct bch_alloc {
__u8 data[];
} __attribute__((packed, aligned(8)));
+#define BCH_ALLOC_FIELDS() \
+ x(read_time, 2) \
+ x(write_time, 2) \
+ x(data_type, 1) \
+ x(dirty_sectors, 2) \
+ x(cached_sectors, 2)
+
+enum {
+#define x(name, bytes) BCH_ALLOC_FIELD_##name,
+ BCH_ALLOC_FIELDS()
+#undef x
+ BCH_ALLOC_FIELD_NR
+};
+
+static const unsigned BCH_ALLOC_FIELD_BYTES[] = {
+#define x(name, bytes) [BCH_ALLOC_FIELD_##name] = bytes,
+ BCH_ALLOC_FIELDS()
+#undef x
+};
+
+#define x(name, bytes) + bytes
+static const unsigned BKEY_ALLOC_VAL_U64s_MAX =
+ DIV_ROUND_UP(offsetof(struct bch_alloc, data)
+ BCH_ALLOC_FIELDS(), sizeof(u64));
+#undef x
+
/* Quotas: */
enum quota_types {