brintos

brintos / linux-shallow public Read only

0
0
Text · 3.1 KiB · 2adf122 Raw
122 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef _BCACHEFS_SB_MEMBERS_FORMAT_H3#define _BCACHEFS_SB_MEMBERS_FORMAT_H4 5/*6 * We refer to members with bitmasks in various places - but we need to get rid7 * of this limit:8 */9#define BCH_SB_MEMBERS_MAX		6410 11/*12 * Sentinal value - indicates a device that does not exist13 */14#define BCH_SB_MEMBER_INVALID		25515 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 24enum bch_iops_measurement {25#define x(t, n) BCH_IOPS_##t = n,26	BCH_IOPS_MEASUREMENTS()27#undef x28	BCH_IOPS_NR29};30 31#define BCH_MEMBER_ERROR_TYPES()		\32	x(read,		0)			\33	x(write,	1)			\34	x(checksum,	2)35 36enum bch_member_error_type {37#define x(t, n) BCH_MEMBER_ERROR_##t = n,38	BCH_MEMBER_ERROR_TYPES()39#undef x40	BCH_MEMBER_ERROR_NR41};42 43struct 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 we62	 * 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 has70 * 64 elements, so 64 - ilog2(64)71 */72#define BCH_MI_BTREE_BITMAP_SHIFT_MAX	5873 74/*75 * This limit comes from the bucket_gens array - it's a single allocation, and76 * kernel allocation are limited to INT_MAX77 */78#define BCH_MEMBER_NBUCKETS_MAX	(INT_MAX - 64)79 80#define BCH_MEMBER_V1_BYTES	5681 82LE64_BITMASK(BCH_MEMBER_STATE,		struct bch_member, flags,  0,  4)83/* 4-14 unused, was TIER, HAS_(META)DATA, REPLACEMENT */84LE64_BITMASK(BCH_MEMBER_DISCARD,	struct bch_member, flags, 14, 15)85LE64_BITMASK(BCH_MEMBER_DATA_ALLOWED,	struct bch_member, flags, 15, 20)86LE64_BITMASK(BCH_MEMBER_GROUP,		struct bch_member, flags, 20, 28)87LE64_BITMASK(BCH_MEMBER_DURABILITY,	struct bch_member, flags, 28, 30)88LE64_BITMASK(BCH_MEMBER_FREESPACE_INITIALIZED,89					struct bch_member, flags, 30, 31)90 91#if 092LE64_BITMASK(BCH_MEMBER_NR_READ_ERRORS,	struct bch_member, flags[1], 0,  20);93LE64_BITMASK(BCH_MEMBER_NR_WRITE_ERRORS,struct bch_member, flags[1], 20, 40);94#endif95 96#define BCH_MEMBER_STATES()			\97	x(rw,		0)			\98	x(ro,		1)			\99	x(failed,	2)			\100	x(spare,	3)101 102enum bch_member_state {103#define x(t, n) BCH_MEMBER_STATE_##t = n,104	BCH_MEMBER_STATES()105#undef x106	BCH_MEMBER_STATE_NR107};108 109struct bch_sb_field_members_v1 {110	struct bch_sb_field	field;111	struct bch_member	_members[]; //Members are now variable size112};113 114struct bch_sb_field_members_v2 {115	struct bch_sb_field	field;116	__le16			member_bytes; //size of single member entry117	u8			pad[6];118	struct bch_member	_members[];119};120 121#endif /* _BCACHEFS_SB_MEMBERS_FORMAT_H */122