Skip to content

Commit d455179

Browse files
author
Kent Overstreet
committed
bcachefs: alloc_background_format.h
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 72e0801 commit d455179

File tree

2 files changed

+94
-93
lines changed

2 files changed

+94
-93
lines changed

fs/bcachefs/alloc_background_format.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _BCACHEFS_ALLOC_BACKGROUND_FORMAT_H
3+
#define _BCACHEFS_ALLOC_BACKGROUND_FORMAT_H
4+
5+
struct bch_alloc {
6+
struct bch_val v;
7+
__u8 fields;
8+
__u8 gen;
9+
__u8 data[];
10+
} __packed __aligned(8);
11+
12+
#define BCH_ALLOC_FIELDS_V1() \
13+
x(read_time, 16) \
14+
x(write_time, 16) \
15+
x(data_type, 8) \
16+
x(dirty_sectors, 16) \
17+
x(cached_sectors, 16) \
18+
x(oldest_gen, 8) \
19+
x(stripe, 32) \
20+
x(stripe_redundancy, 8)
21+
22+
enum {
23+
#define x(name, _bits) BCH_ALLOC_FIELD_V1_##name,
24+
BCH_ALLOC_FIELDS_V1()
25+
#undef x
26+
};
27+
28+
struct bch_alloc_v2 {
29+
struct bch_val v;
30+
__u8 nr_fields;
31+
__u8 gen;
32+
__u8 oldest_gen;
33+
__u8 data_type;
34+
__u8 data[];
35+
} __packed __aligned(8);
36+
37+
#define BCH_ALLOC_FIELDS_V2() \
38+
x(read_time, 64) \
39+
x(write_time, 64) \
40+
x(dirty_sectors, 32) \
41+
x(cached_sectors, 32) \
42+
x(stripe, 32) \
43+
x(stripe_redundancy, 8)
44+
45+
struct bch_alloc_v3 {
46+
struct bch_val v;
47+
__le64 journal_seq;
48+
__le32 flags;
49+
__u8 nr_fields;
50+
__u8 gen;
51+
__u8 oldest_gen;
52+
__u8 data_type;
53+
__u8 data[];
54+
} __packed __aligned(8);
55+
56+
LE32_BITMASK(BCH_ALLOC_V3_NEED_DISCARD,struct bch_alloc_v3, flags, 0, 1)
57+
LE32_BITMASK(BCH_ALLOC_V3_NEED_INC_GEN,struct bch_alloc_v3, flags, 1, 2)
58+
59+
struct bch_alloc_v4 {
60+
struct bch_val v;
61+
__u64 journal_seq;
62+
__u32 flags;
63+
__u8 gen;
64+
__u8 oldest_gen;
65+
__u8 data_type;
66+
__u8 stripe_redundancy;
67+
__u32 dirty_sectors;
68+
__u32 cached_sectors;
69+
__u64 io_time[2];
70+
__u32 stripe;
71+
__u32 nr_external_backpointers;
72+
__u64 fragmentation_lru;
73+
} __packed __aligned(8);
74+
75+
#define BCH_ALLOC_V4_U64s_V0 6
76+
#define BCH_ALLOC_V4_U64s (sizeof(struct bch_alloc_v4) / sizeof(__u64))
77+
78+
BITMASK(BCH_ALLOC_V4_NEED_DISCARD, struct bch_alloc_v4, flags, 0, 1)
79+
BITMASK(BCH_ALLOC_V4_NEED_INC_GEN, struct bch_alloc_v4, flags, 1, 2)
80+
BITMASK(BCH_ALLOC_V4_BACKPOINTERS_START,struct bch_alloc_v4, flags, 2, 8)
81+
BITMASK(BCH_ALLOC_V4_NR_BACKPOINTERS, struct bch_alloc_v4, flags, 8, 14)
82+
83+
#define KEY_TYPE_BUCKET_GENS_BITS 8
84+
#define KEY_TYPE_BUCKET_GENS_NR (1U << KEY_TYPE_BUCKET_GENS_BITS)
85+
#define KEY_TYPE_BUCKET_GENS_MASK (KEY_TYPE_BUCKET_GENS_NR - 1)
86+
87+
struct bch_bucket_gens {
88+
struct bch_val v;
89+
u8 gens[KEY_TYPE_BUCKET_GENS_NR];
90+
} __packed __aligned(8);
91+
92+
#endif /* _BCACHEFS_ALLOC_BACKGROUND_FORMAT_H */

fs/bcachefs/bcachefs_format.h

Lines changed: 2 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -710,89 +710,6 @@ struct bch_reservation {
710710
#define BKEY_BTREE_PTR_U64s_MAX \
711711
(BKEY_U64s + BKEY_BTREE_PTR_VAL_U64s_MAX)
712712

713-
714-
/* Bucket/allocation information: */
715-
716-
struct bch_alloc {
717-
struct bch_val v;
718-
__u8 fields;
719-
__u8 gen;
720-
__u8 data[];
721-
} __packed __aligned(8);
722-
723-
#define BCH_ALLOC_FIELDS_V1() \
724-
x(read_time, 16) \
725-
x(write_time, 16) \
726-
x(data_type, 8) \
727-
x(dirty_sectors, 16) \
728-
x(cached_sectors, 16) \
729-
x(oldest_gen, 8) \
730-
x(stripe, 32) \
731-
x(stripe_redundancy, 8)
732-
733-
enum {
734-
#define x(name, _bits) BCH_ALLOC_FIELD_V1_##name,
735-
BCH_ALLOC_FIELDS_V1()
736-
#undef x
737-
};
738-
739-
struct bch_alloc_v2 {
740-
struct bch_val v;
741-
__u8 nr_fields;
742-
__u8 gen;
743-
__u8 oldest_gen;
744-
__u8 data_type;
745-
__u8 data[];
746-
} __packed __aligned(8);
747-
748-
#define BCH_ALLOC_FIELDS_V2() \
749-
x(read_time, 64) \
750-
x(write_time, 64) \
751-
x(dirty_sectors, 32) \
752-
x(cached_sectors, 32) \
753-
x(stripe, 32) \
754-
x(stripe_redundancy, 8)
755-
756-
struct bch_alloc_v3 {
757-
struct bch_val v;
758-
__le64 journal_seq;
759-
__le32 flags;
760-
__u8 nr_fields;
761-
__u8 gen;
762-
__u8 oldest_gen;
763-
__u8 data_type;
764-
__u8 data[];
765-
} __packed __aligned(8);
766-
767-
LE32_BITMASK(BCH_ALLOC_V3_NEED_DISCARD,struct bch_alloc_v3, flags, 0, 1)
768-
LE32_BITMASK(BCH_ALLOC_V3_NEED_INC_GEN,struct bch_alloc_v3, flags, 1, 2)
769-
770-
struct bch_alloc_v4 {
771-
struct bch_val v;
772-
__u64 journal_seq;
773-
__u32 flags;
774-
__u8 gen;
775-
__u8 oldest_gen;
776-
__u8 data_type;
777-
__u8 stripe_redundancy;
778-
__u32 dirty_sectors;
779-
__u32 cached_sectors;
780-
__u64 io_time[2];
781-
__u32 stripe;
782-
__u32 nr_external_backpointers;
783-
__u64 fragmentation_lru;
784-
} __packed __aligned(8);
785-
786-
#define BCH_ALLOC_V4_U64s_V0 6
787-
#define BCH_ALLOC_V4_U64s (sizeof(struct bch_alloc_v4) / sizeof(__u64))
788-
789-
BITMASK(BCH_ALLOC_V4_NEED_DISCARD, struct bch_alloc_v4, flags, 0, 1)
790-
BITMASK(BCH_ALLOC_V4_NEED_INC_GEN, struct bch_alloc_v4, flags, 1, 2)
791-
BITMASK(BCH_ALLOC_V4_BACKPOINTERS_START,struct bch_alloc_v4, flags, 2, 8)
792-
BITMASK(BCH_ALLOC_V4_NR_BACKPOINTERS, struct bch_alloc_v4, flags, 8, 14)
793-
794-
#define BCH_ALLOC_V4_NR_BACKPOINTERS_MAX 40
795-
796713
struct bch_backpointer {
797714
struct bch_val v;
798715
__u8 btree_id;
@@ -803,15 +720,6 @@ struct bch_backpointer {
803720
struct bpos pos;
804721
} __packed __aligned(8);
805722

806-
#define KEY_TYPE_BUCKET_GENS_BITS 8
807-
#define KEY_TYPE_BUCKET_GENS_NR (1U << KEY_TYPE_BUCKET_GENS_BITS)
808-
#define KEY_TYPE_BUCKET_GENS_MASK (KEY_TYPE_BUCKET_GENS_NR - 1)
809-
810-
struct bch_bucket_gens {
811-
struct bch_val v;
812-
u8 gens[KEY_TYPE_BUCKET_GENS_NR];
813-
} __packed __aligned(8);
814-
815723
/* Erasure coding */
816724

817725
struct bch_stripe {
@@ -991,8 +899,9 @@ struct bch_sb_field {
991899
x(ext, 13) \
992900
x(downgrade, 14)
993901

994-
#include "dirent_format.h"
902+
#include "alloc_background_format.h"
995903
#include "inode_format.h"
904+
#include "dirent_format.h"
996905
#include "xattr_format.h"
997906
#include "quota_format.h"
998907
#include "sb-counters_format.h"

0 commit comments

Comments
 (0)