diff options
Diffstat (limited to 'libbcachefs/super-io.h')
-rw-r--r-- | libbcachefs/super-io.h | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/libbcachefs/super-io.h b/libbcachefs/super-io.h index d7fecf02..3811de72 100644 --- a/libbcachefs/super-io.h +++ b/libbcachefs/super-io.h @@ -129,7 +129,6 @@ static inline struct bch_member_cpu bch2_mi_to_cpu(struct bch_member *mi) .bucket_size = le16_to_cpu(mi->bucket_size), .group = BCH_MEMBER_GROUP(mi), .state = BCH_MEMBER_STATE(mi), - .tier = BCH_MEMBER_TIER(mi), .replacement = BCH_MEMBER_REPLACEMENT(mi), .discard = BCH_MEMBER_DISCARD(mi), .data_allowed = BCH_MEMBER_DATA_ALLOWED(mi), @@ -204,27 +203,34 @@ struct target { }; }; +#define TARGET_DEV_START 1 +#define TARGET_GROUP_START (256 + TARGET_DEV_START) + static inline u16 dev_to_target(unsigned dev) { - return 1 + dev; + return TARGET_DEV_START + dev; } static inline u16 group_to_target(unsigned group) { - return 1 + U8_MAX + group; + return TARGET_GROUP_START + group; } static inline struct target target_decode(unsigned target) { - if (!target) - return (struct target) { .type = TARGET_NULL }; - - --target; - if (target <= U8_MAX) - return (struct target) { .type = TARGET_DEV, .dev = target }; - - target -= U8_MAX; - return (struct target) { .type = TARGET_GROUP, .group = target }; + if (target >= TARGET_GROUP_START) + return (struct target) { + .type = TARGET_GROUP, + .group = target - TARGET_GROUP_START + }; + + if (target >= TARGET_DEV_START) + return (struct target) { + .type = TARGET_DEV, + .group = target - TARGET_DEV_START + }; + + return (struct target) { .type = TARGET_NULL }; } static inline bool dev_in_target(struct bch_dev *ca, unsigned target) @@ -232,6 +238,8 @@ static inline bool dev_in_target(struct bch_dev *ca, unsigned target) struct target t = target_decode(target); switch (t.type) { + case TARGET_NULL: + return false; case TARGET_DEV: return ca->dev_idx == t.dev; case TARGET_GROUP: @@ -243,4 +251,9 @@ static inline bool dev_in_target(struct bch_dev *ca, unsigned target) const struct bch_devs_mask *bch2_target_to_mask(struct bch_fs *, unsigned); +int __bch2_disk_group_find(struct bch_sb_field_disk_groups *, const char *); + +int bch2_opt_target_parse(struct bch_fs *, const char *, u64 *); +int bch2_opt_target_print(struct bch_fs *, char *, size_t, u64); + #endif /* _BCACHEFS_SUPER_IO_H */ |