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 /* 12 * Sentinal value - indicates a device that does not exist 13 */ 14 #define BCH_SB_MEMBER_INVALID 255 15 16 #define BCH_MIN_NR_NBUCKETS (1 << 6) 17 18 #define BCH_IOPS_MEASUREMENTS() \ 19 x(seqread, 0) \ 20 x(seqwrite, 1) \ 21 x(randread, 2) \ 22 x(randwrite, 3) 23 24 enum bch_iops_measurement { 25 #define x(t, n) BCH_IOPS_##t = n, 26 BCH_IOPS_MEASUREMENTS() 27 #undef x 28 BCH_IOPS_NR 29 }; 30 31 #define BCH_MEMBER_ERROR_TYPES() \ 32 x(read, 0) \ 33 x(write, 1) \ 34 x(checksum, 2) 35 36 enum bch_member_error_type { 37 #define x(t, n) BCH_MEMBER_ERROR_##t = n, 38 BCH_MEMBER_ERROR_TYPES() 39 #undef x 40 BCH_MEMBER_ERROR_NR 41 }; 42 43 struct bch_member { 44 __uuid_t uuid; 45 __le64 nbuckets; /* device size */ 46 __le16 first_bucket; /* index of first bucket used */ 47 __le16 bucket_size; /* sectors */ 48 __u8 btree_bitmap_shift; 49 __u8 pad[3]; 50 __le64 last_mount; /* time_t */ 51 52 __le64 flags; 53 __le32 iops[4]; 54 __le64 errors[BCH_MEMBER_ERROR_NR]; 55 __le64 errors_at_reset[BCH_MEMBER_ERROR_NR]; 56 __le64 errors_reset_time; 57 __le64 seq; 58 __le64 btree_allocated_bitmap; 59 /* 60 * On recovery from a clean shutdown we don't normally read the journal, 61 * but we still want to resume writing from where we left off so we 62 * don't overwrite more than is necessary, for list journal debugging: 63 */ 64 __le32 last_journal_bucket; 65 __le32 last_journal_bucket_offset; 66 }; 67 68 /* 69 * btree_allocated_bitmap can represent sector addresses of a u64: it itself has 70 * 64 elements, so 64 - ilog2(64) 71 */ 72 #define BCH_MI_BTREE_BITMAP_SHIFT_MAX 58 73 74 /* 75 * This limit comes from the bucket_gens array - it's a single allocation, and 76 * kernel allocation are limited to INT_MAX 77 */ 78 #define BCH_MEMBER_NBUCKETS_MAX (INT_MAX - 64) 79 80 #define BCH_MEMBER_V1_BYTES 56 81 82 LE64_BITMASK(BCH_MEMBER_STATE, struct bch_member, flags, 0, 4) 83 /* 4-14 unused, was TIER, HAS_(META)DATA, REPLACEMENT */ 84 LE64_BITMASK(BCH_MEMBER_DISCARD, struct bch_member, flags, 14, 15) 85 LE64_BITMASK(BCH_MEMBER_DATA_ALLOWED, struct bch_member, flags, 15, 20) 86 LE64_BITMASK(BCH_MEMBER_GROUP, struct bch_member, flags, 20, 28) 87 LE64_BITMASK(BCH_MEMBER_DURABILITY, struct bch_member, flags, 28, 30) 88 LE64_BITMASK(BCH_MEMBER_FREESPACE_INITIALIZED, 89 struct bch_member, flags, 30, 31) 90 91 #if 0 92 LE64_BITMASK(BCH_MEMBER_NR_READ_ERRORS, struct bch_member, flags[1], 0, 20); 93 LE64_BITMASK(BCH_MEMBER_NR_WRITE_ERRORS,struct bch_member, flags[1], 20, 40); 94 #endif 95 96 #define BCH_MEMBER_STATES() \ 97 x(rw, 0) \ 98 x(ro, 1) \ 99 x(failed, 2) \ 100 x(spare, 3) 101 102 enum bch_member_state { 103 #define x(t, n) BCH_MEMBER_STATE_##t = n, 104 BCH_MEMBER_STATES() 105 #undef x 106 BCH_MEMBER_STATE_NR 107 }; 108 109 struct bch_sb_field_members_v1 { 110 struct bch_sb_field field; 111 struct bch_member _members[]; //Members are now variable size 112 }; 113 114 struct bch_sb_field_members_v2 { 115 struct bch_sb_field field; 116 __le16 member_bytes; //size of single member entry 117 u8 pad[6]; 118 struct bch_member _members[]; 119 }; 120 121 #endif /* _BCACHEFS_SB_MEMBERS_FORMAT_H */ 122