X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libbcachefs%2Fec.h;h=885ae5d5165587e4f72312401edcf1b67dcff964;hb=54b6beabf05b6cf62092f98f0c06395e4242b064;hp=d112aea9ec5632f0339532fd39c3e2407fceedc2;hpb=0206d42daf4c4bd3bbcfa15a2bef34319524db49;p=bcachefs-tools-debian diff --git a/libbcachefs/ec.h b/libbcachefs/ec.h index d112aea..885ae5d 100644 --- a/libbcachefs/ec.h +++ b/libbcachefs/ec.h @@ -6,8 +6,10 @@ #include "buckets_types.h" #include "extents_types.h" +enum bkey_invalid_flags; + int bch2_stripe_invalid(const struct bch_fs *, struct bkey_s_c, - unsigned, struct printbuf *); + enum bkey_invalid_flags, struct printbuf *); void bch2_stripe_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); @@ -17,6 +19,7 @@ void bch2_stripe_to_text(struct printbuf *, struct bch_fs *, .swab = bch2_ptr_swab, \ .trans_trigger = bch2_trans_mark_stripe, \ .atomic_trigger = bch2_mark_stripe, \ + .min_val_size = 8, \ }) static inline unsigned stripe_csums_per_device(const struct bch_stripe *s) @@ -135,14 +138,17 @@ struct ec_stripe_buf { void *data[BCH_BKEY_PTRS_MAX]; - union { - struct bkey_i_stripe key; - u64 pad[255]; - }; + __BKEY_PADDED(key, 255); }; struct ec_stripe_head; +enum ec_stripe_ref { + STRIPE_REF_io, + STRIPE_REF_stripe, + STRIPE_REF_NR +}; + struct ec_stripe_new { struct bch_fs *c; struct ec_stripe_head *h; @@ -154,8 +160,7 @@ struct ec_stripe_new { struct closure iodone; - /* counts in flight writes, stripe is created when pin == 0 */ - atomic_t pin; + atomic_t ref[STRIPE_REF_NR]; int err; @@ -181,7 +186,7 @@ struct ec_stripe_head { unsigned target; unsigned algo; unsigned redundancy; - enum alloc_reserve reserve; + enum bch_watermark watermark; struct bch_devs_mask devs; unsigned nr_active_devs; @@ -205,7 +210,7 @@ int bch2_ec_stripe_new_alloc(struct bch_fs *, struct ec_stripe_head *); void bch2_ec_stripe_head_put(struct bch_fs *, struct ec_stripe_head *); struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *, unsigned, unsigned, unsigned, - enum alloc_reserve, struct closure *); + enum bch_watermark, struct closure *); void bch2_stripes_heap_update(struct bch_fs *, struct stripe *, size_t); void bch2_stripes_heap_del(struct bch_fs *, struct stripe *, size_t); @@ -213,24 +218,35 @@ void bch2_stripes_heap_insert(struct bch_fs *, struct stripe *, size_t); void bch2_do_stripe_deletes(struct bch_fs *); void bch2_ec_do_stripe_creates(struct bch_fs *); +void bch2_ec_stripe_new_free(struct bch_fs *, struct ec_stripe_new *); -static inline void ec_stripe_new_get(struct ec_stripe_new *s) +static inline void ec_stripe_new_get(struct ec_stripe_new *s, + enum ec_stripe_ref ref) { - atomic_inc(&s->pin); + atomic_inc(&s->ref[ref]); } -static inline void ec_stripe_new_put(struct bch_fs *c, struct ec_stripe_new *s) +static inline void ec_stripe_new_put(struct bch_fs *c, struct ec_stripe_new *s, + enum ec_stripe_ref ref) { - BUG_ON(atomic_read(&s->pin) <= 0); - BUG_ON(!s->err && !s->idx); - - if (atomic_dec_and_test(&s->pin)) - bch2_ec_do_stripe_creates(c); + BUG_ON(atomic_read(&s->ref[ref]) <= 0); + + if (atomic_dec_and_test(&s->ref[ref])) + switch (ref) { + case STRIPE_REF_stripe: + bch2_ec_stripe_new_free(c, s); + break; + case STRIPE_REF_io: + bch2_ec_do_stripe_creates(c); + break; + default: + unreachable(); + } } void bch2_ec_stop_dev(struct bch_fs *, struct bch_dev *); - -void bch2_ec_flush_new_stripes(struct bch_fs *); +void bch2_fs_ec_stop(struct bch_fs *); +void bch2_fs_ec_flush(struct bch_fs *); int bch2_stripes_read(struct bch_fs *);