1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_REPLICAS_FORMAT_H 3 #define _BCACHEFS_REPLICAS_FORMAT_H 4 5 struct bch_replicas_entry_v0 { 6 __u8 data_type; 7 __u8 nr_devs; 8 __u8 devs[] __counted_by(nr_devs); 9 } __packed; 10 11 struct bch_sb_field_replicas_v0 { 12 struct bch_sb_field field; 13 struct bch_replicas_entry_v0 entries[]; 14 } __packed __aligned(8); 15 16 struct bch_replicas_entry_v1 { 17 __u8 data_type; 18 __u8 nr_devs; 19 __u8 nr_required; 20 __u8 devs[] __counted_by(nr_devs); 21 } __packed; 22 23 struct bch_sb_field_replicas { 24 struct bch_sb_field field; 25 struct bch_replicas_entry_v1 entries[]; 26 } __packed __aligned(8); 27 28 #define replicas_entry_bytes(_i) \ 29 (offsetof(typeof(*(_i)), devs) + (_i)->nr_devs) 30 31 #define replicas_entry_add_dev(e, d) ({ \ 32 (e)->nr_devs++; \ 33 (e)->devs[(e)->nr_devs - 1] = (d); \ 34 }) 35 36 #endif /* _BCACHEFS_REPLICAS_FORMAT_H */ 37