blob: b7eff904acdb7170b6fc1191f101ddb4079ce8cd [file] [log] [blame]
Kent Overstreet24998052024-05-28 17:13:52 -04001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _BCACHEFS_REPLICAS_FORMAT_H
3#define _BCACHEFS_REPLICAS_FORMAT_H
4
5struct bch_replicas_entry_v0 {
6 __u8 data_type;
7 __u8 nr_devs;
Thorsten Blumfa1ab1b2024-08-26 12:11:36 +02008 __u8 devs[] __counted_by(nr_devs);
Kent Overstreet24998052024-05-28 17:13:52 -04009} __packed;
10
11struct bch_sb_field_replicas_v0 {
12 struct bch_sb_field field;
13 struct bch_replicas_entry_v0 entries[];
14} __packed __aligned(8);
15
16struct bch_replicas_entry_v1 {
17 __u8 data_type;
18 __u8 nr_devs;
19 __u8 nr_required;
Thorsten Blumfa1ab1b2024-08-26 12:11:36 +020020 __u8 devs[] __counted_by(nr_devs);
Kent Overstreet24998052024-05-28 17:13:52 -040021} __packed;
22
23struct 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
Thorsten Blumfa1ab1b2024-08-26 12:11:36 +020031#define replicas_entry_add_dev(e, d) ({ \
32 (e)->nr_devs++; \
33 (e)->devs[(e)->nr_devs - 1] = (d); \
34})
35
Kent Overstreet24998052024-05-28 17:13:52 -040036#endif /* _BCACHEFS_REPLICAS_FORMAT_H */