1 #ifndef _BCACHEFS_DISK_GROUPS_H
2 #define _BCACHEFS_DISK_GROUPS_H
4 extern const struct bch_sb_field_ops bch_sb_field_ops_disk_groups;
6 static inline unsigned disk_groups_nr(struct bch_sb_field_disk_groups *groups)
9 ? (vstruct_end(&groups->field) -
10 (void *) &groups->entries[0]) / sizeof(struct bch_disk_group)
26 #define TARGET_DEV_START 1
27 #define TARGET_GROUP_START (256 + TARGET_DEV_START)
29 static inline u16 dev_to_target(unsigned dev)
31 return TARGET_DEV_START + dev;
34 static inline u16 group_to_target(unsigned group)
36 return TARGET_GROUP_START + group;
39 static inline struct target target_decode(unsigned target)
41 if (target >= TARGET_GROUP_START)
42 return (struct target) {
44 .group = target - TARGET_GROUP_START
47 if (target >= TARGET_DEV_START)
48 return (struct target) {
50 .group = target - TARGET_DEV_START
53 return (struct target) { .type = TARGET_NULL };
56 const struct bch_devs_mask *bch2_target_to_mask(struct bch_fs *, unsigned);
58 static inline struct bch_devs_mask target_rw_devs(struct bch_fs *c,
59 enum bch_data_type data_type,
62 struct bch_devs_mask devs = c->rw_devs[data_type];
63 const struct bch_devs_mask *t = bch2_target_to_mask(c, target);
66 bitmap_and(devs.d, devs.d, t->d, BCH_SB_MEMBERS_MAX);
70 bool bch2_dev_in_target(struct bch_fs *, unsigned, unsigned);
72 int bch2_disk_path_find(struct bch_sb_handle *, const char *);
73 int bch2_disk_path_find_or_create(struct bch_sb_handle *, const char *);
74 void bch2_disk_path_to_text(struct printbuf *, struct bch_sb_handle *,
77 int bch2_opt_target_parse(struct bch_fs *, const char *, u64 *);
78 void bch2_opt_target_to_text(struct printbuf *, struct bch_fs *, u64);
80 int bch2_sb_disk_groups_to_cpu(struct bch_fs *);
82 int bch2_dev_group_set(struct bch_fs *, struct bch_dev *, const char *);
84 const char *bch2_sb_validate_disk_groups(struct bch_sb *,
85 struct bch_sb_field *);
87 #endif /* _BCACHEFS_DISK_GROUPS_H */