Skip to content

Commit 016c22e

Browse files
author
Kent Overstreet
committed
bcachefs: split out sb-members_format.h
Signed-off-by: Kent Overstreet <[email protected]>
1 parent f1d4fed commit 016c22e

File tree

2 files changed

+111
-101
lines changed

2 files changed

+111
-101
lines changed

fs/bcachefs/bcachefs_format.h

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ struct bch_sb_field {
513513
#include "snapshot_format.h"
514514
#include "subvolume_format.h"
515515
#include "sb-counters_format.h"
516+
#include "sb-members_format.h"
516517

517518
enum bch_sb_field_type {
518519
#define x(f, nr) BCH_SB_FIELD_##f = nr,
@@ -545,106 +546,6 @@ struct bch_sb_field_journal_v2 {
545546
} d[];
546547
};
547548

548-
/* BCH_SB_FIELD_members_v1: */
549-
550-
#define BCH_MIN_NR_NBUCKETS (1 << 6)
551-
552-
#define BCH_IOPS_MEASUREMENTS() \
553-
x(seqread, 0) \
554-
x(seqwrite, 1) \
555-
x(randread, 2) \
556-
x(randwrite, 3)
557-
558-
enum bch_iops_measurement {
559-
#define x(t, n) BCH_IOPS_##t = n,
560-
BCH_IOPS_MEASUREMENTS()
561-
#undef x
562-
BCH_IOPS_NR
563-
};
564-
565-
#define BCH_MEMBER_ERROR_TYPES() \
566-
x(read, 0) \
567-
x(write, 1) \
568-
x(checksum, 2)
569-
570-
enum bch_member_error_type {
571-
#define x(t, n) BCH_MEMBER_ERROR_##t = n,
572-
BCH_MEMBER_ERROR_TYPES()
573-
#undef x
574-
BCH_MEMBER_ERROR_NR
575-
};
576-
577-
struct bch_member {
578-
__uuid_t uuid;
579-
__le64 nbuckets; /* device size */
580-
__le16 first_bucket; /* index of first bucket used */
581-
__le16 bucket_size; /* sectors */
582-
__u8 btree_bitmap_shift;
583-
__u8 pad[3];
584-
__le64 last_mount; /* time_t */
585-
586-
__le64 flags;
587-
__le32 iops[4];
588-
__le64 errors[BCH_MEMBER_ERROR_NR];
589-
__le64 errors_at_reset[BCH_MEMBER_ERROR_NR];
590-
__le64 errors_reset_time;
591-
__le64 seq;
592-
__le64 btree_allocated_bitmap;
593-
/*
594-
* On recovery from a clean shutdown we don't normally read the journal,
595-
* but we still want to resume writing from where we left off so we
596-
* don't overwrite more than is necessary, for list journal debugging:
597-
*/
598-
__le32 last_journal_bucket;
599-
__le32 last_journal_bucket_offset;
600-
};
601-
602-
/*
603-
* This limit comes from the bucket_gens array - it's a single allocation, and
604-
* kernel allocation are limited to INT_MAX
605-
*/
606-
#define BCH_MEMBER_NBUCKETS_MAX (INT_MAX - 64)
607-
608-
#define BCH_MEMBER_V1_BYTES 56
609-
610-
LE64_BITMASK(BCH_MEMBER_STATE, struct bch_member, flags, 0, 4)
611-
/* 4-14 unused, was TIER, HAS_(META)DATA, REPLACEMENT */
612-
LE64_BITMASK(BCH_MEMBER_DISCARD, struct bch_member, flags, 14, 15)
613-
LE64_BITMASK(BCH_MEMBER_DATA_ALLOWED, struct bch_member, flags, 15, 20)
614-
LE64_BITMASK(BCH_MEMBER_GROUP, struct bch_member, flags, 20, 28)
615-
LE64_BITMASK(BCH_MEMBER_DURABILITY, struct bch_member, flags, 28, 30)
616-
LE64_BITMASK(BCH_MEMBER_FREESPACE_INITIALIZED,
617-
struct bch_member, flags, 30, 31)
618-
619-
#if 0
620-
LE64_BITMASK(BCH_MEMBER_NR_READ_ERRORS, struct bch_member, flags[1], 0, 20);
621-
LE64_BITMASK(BCH_MEMBER_NR_WRITE_ERRORS,struct bch_member, flags[1], 20, 40);
622-
#endif
623-
624-
#define BCH_MEMBER_STATES() \
625-
x(rw, 0) \
626-
x(ro, 1) \
627-
x(failed, 2) \
628-
x(spare, 3)
629-
630-
enum bch_member_state {
631-
#define x(t, n) BCH_MEMBER_STATE_##t = n,
632-
BCH_MEMBER_STATES()
633-
#undef x
634-
BCH_MEMBER_STATE_NR
635-
};
636-
637-
struct bch_sb_field_members_v1 {
638-
struct bch_sb_field field;
639-
struct bch_member _members[]; //Members are now variable size
640-
};
641-
642-
struct bch_sb_field_members_v2 {
643-
struct bch_sb_field field;
644-
__le16 member_bytes; //size of single member entry
645-
u8 pad[6];
646-
struct bch_member _members[];
647-
};
648549

649550
/* BCH_SB_FIELD_crypt: */
650551

@@ -909,7 +810,6 @@ unsigned bcachefs_metadata_required_upgrade_below = bcachefs_metadata_version_re
909810
#define bcachefs_metadata_version_current (bcachefs_metadata_version_max - 1)
910811

911812
#define BCH_SB_SECTOR 8
912-
#define BCH_SB_MEMBERS_MAX 64 /* XXX kill */
913813

914814
#define BCH_SB_LAYOUT_SIZE_BITS_MAX 16 /* 32 MB */
915815

fs/bcachefs/sb-members_format.h

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _BCACHEFS_SB_MEMBERS_FORMAT_H
3+
#define _BCACHEFS_SB_MEMBERS_FORMAT_H
4+
5+
/*
6+
* We refer to members with bitmasks in various places - but we need to get rid
7+
* of this limit:
8+
*/
9+
#define BCH_SB_MEMBERS_MAX 64
10+
11+
#define BCH_MIN_NR_NBUCKETS (1 << 6)
12+
13+
#define BCH_IOPS_MEASUREMENTS() \
14+
x(seqread, 0) \
15+
x(seqwrite, 1) \
16+
x(randread, 2) \
17+
x(randwrite, 3)
18+
19+
enum bch_iops_measurement {
20+
#define x(t, n) BCH_IOPS_##t = n,
21+
BCH_IOPS_MEASUREMENTS()
22+
#undef x
23+
BCH_IOPS_NR
24+
};
25+
26+
#define BCH_MEMBER_ERROR_TYPES() \
27+
x(read, 0) \
28+
x(write, 1) \
29+
x(checksum, 2)
30+
31+
enum bch_member_error_type {
32+
#define x(t, n) BCH_MEMBER_ERROR_##t = n,
33+
BCH_MEMBER_ERROR_TYPES()
34+
#undef x
35+
BCH_MEMBER_ERROR_NR
36+
};
37+
38+
struct bch_member {
39+
__uuid_t uuid;
40+
__le64 nbuckets; /* device size */
41+
__le16 first_bucket; /* index of first bucket used */
42+
__le16 bucket_size; /* sectors */
43+
__u8 btree_bitmap_shift;
44+
__u8 pad[3];
45+
__le64 last_mount; /* time_t */
46+
47+
__le64 flags;
48+
__le32 iops[4];
49+
__le64 errors[BCH_MEMBER_ERROR_NR];
50+
__le64 errors_at_reset[BCH_MEMBER_ERROR_NR];
51+
__le64 errors_reset_time;
52+
__le64 seq;
53+
__le64 btree_allocated_bitmap;
54+
/*
55+
* On recovery from a clean shutdown we don't normally read the journal,
56+
* but we still want to resume writing from where we left off so we
57+
* don't overwrite more than is necessary, for list journal debugging:
58+
*/
59+
__le32 last_journal_bucket;
60+
__le32 last_journal_bucket_offset;
61+
};
62+
63+
/*
64+
* This limit comes from the bucket_gens array - it's a single allocation, and
65+
* kernel allocation are limited to INT_MAX
66+
*/
67+
#define BCH_MEMBER_NBUCKETS_MAX (INT_MAX - 64)
68+
69+
#define BCH_MEMBER_V1_BYTES 56
70+
71+
LE64_BITMASK(BCH_MEMBER_STATE, struct bch_member, flags, 0, 4)
72+
/* 4-14 unused, was TIER, HAS_(META)DATA, REPLACEMENT */
73+
LE64_BITMASK(BCH_MEMBER_DISCARD, struct bch_member, flags, 14, 15)
74+
LE64_BITMASK(BCH_MEMBER_DATA_ALLOWED, struct bch_member, flags, 15, 20)
75+
LE64_BITMASK(BCH_MEMBER_GROUP, struct bch_member, flags, 20, 28)
76+
LE64_BITMASK(BCH_MEMBER_DURABILITY, struct bch_member, flags, 28, 30)
77+
LE64_BITMASK(BCH_MEMBER_FREESPACE_INITIALIZED,
78+
struct bch_member, flags, 30, 31)
79+
80+
#if 0
81+
LE64_BITMASK(BCH_MEMBER_NR_READ_ERRORS, struct bch_member, flags[1], 0, 20);
82+
LE64_BITMASK(BCH_MEMBER_NR_WRITE_ERRORS,struct bch_member, flags[1], 20, 40);
83+
#endif
84+
85+
#define BCH_MEMBER_STATES() \
86+
x(rw, 0) \
87+
x(ro, 1) \
88+
x(failed, 2) \
89+
x(spare, 3)
90+
91+
enum bch_member_state {
92+
#define x(t, n) BCH_MEMBER_STATE_##t = n,
93+
BCH_MEMBER_STATES()
94+
#undef x
95+
BCH_MEMBER_STATE_NR
96+
};
97+
98+
struct bch_sb_field_members_v1 {
99+
struct bch_sb_field field;
100+
struct bch_member _members[]; //Members are now variable size
101+
};
102+
103+
struct bch_sb_field_members_v2 {
104+
struct bch_sb_field field;
105+
__le16 member_bytes; //size of single member entry
106+
u8 pad[6];
107+
struct bch_member _members[];
108+
};
109+
110+
#endif /* _BCACHEFS_SB_MEMBERS_FORMAT_H */

0 commit comments

Comments
 (0)