Kent Overstreet | 2499805 | 2024-05-28 17:13:52 -0400 | [diff] [blame] | 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; |
Thorsten Blum | fa1ab1b | 2024-08-26 12:11:36 +0200 | [diff] [blame] | 8 | __u8 devs[] __counted_by(nr_devs); |
Kent Overstreet | 2499805 | 2024-05-28 17:13:52 -0400 | [diff] [blame] | 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; |
Thorsten Blum | fa1ab1b | 2024-08-26 12:11:36 +0200 | [diff] [blame] | 20 | __u8 devs[] __counted_by(nr_devs); |
Kent Overstreet | 2499805 | 2024-05-28 17:13:52 -0400 | [diff] [blame] | 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 | |
Thorsten Blum | fa1ab1b | 2024-08-26 12:11:36 +0200 | [diff] [blame] | 31 | #define replicas_entry_add_dev(e, d) ({ \ |
| 32 | (e)->nr_devs++; \ |
| 33 | (e)->devs[(e)->nr_devs - 1] = (d); \ |
| 34 | }) |
| 35 | |
Kent Overstreet | 2499805 | 2024-05-28 17:13:52 -0400 | [diff] [blame] | 36 | #endif /* _BCACHEFS_REPLICAS_FORMAT_H */ |