]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/ec.h
Update bcachefs sources to 70fa0c1ff4 fixup! bcachefs: Btree key cache improvements
[bcachefs-tools-debian] / libbcachefs / ec.h
index f124582fdc5fddf51004c01ba35afe07a7e2ef12..aba1e82bc889f7e7c6d878d7831fb0dc0c99b20a 100644 (file)
@@ -4,17 +4,19 @@
 
 #include "ec_types.h"
 #include "buckets_types.h"
-#include "keylist_types.h"
 
-const char *bch2_stripe_invalid(const struct bch_fs *, struct bkey_s_c);
+int bch2_stripe_invalid(const struct bch_fs *, struct bkey_s_c,
+                       int rw, struct printbuf *);
 void bch2_stripe_to_text(struct printbuf *, struct bch_fs *,
                         struct bkey_s_c);
 
-#define bch2_bkey_ops_stripe (struct bkey_ops) {       \
+#define bch2_bkey_ops_stripe ((struct bkey_ops) {      \
        .key_invalid    = bch2_stripe_invalid,          \
        .val_to_text    = bch2_stripe_to_text,          \
        .swab           = bch2_ptr_swab,                \
-}
+       .trans_trigger  = bch2_trans_mark_stripe,       \
+       .atomic_trigger = bch2_mark_stripe,             \
+})
 
 static inline unsigned stripe_csums_per_device(const struct bch_stripe *s)
 {
@@ -84,27 +86,42 @@ static inline void stripe_csum_set(struct bch_stripe *s,
        memcpy(stripe_csum(s, block, csum_idx), &csum, bch_crc_bytes[s->csum_type]);
 }
 
-static inline bool __bch2_ptr_matches_stripe(const struct bch_stripe *s,
-                                            const struct bch_extent_ptr *ptr,
-                                            unsigned block)
+static inline bool __bch2_ptr_matches_stripe(const struct bch_extent_ptr *stripe_ptr,
+                                            const struct bch_extent_ptr *data_ptr,
+                                            unsigned sectors)
+{
+       return  data_ptr->dev    == stripe_ptr->dev &&
+               data_ptr->gen    == stripe_ptr->gen &&
+               data_ptr->offset >= stripe_ptr->offset &&
+               data_ptr->offset  < stripe_ptr->offset + sectors;
+}
+
+static inline bool bch2_ptr_matches_stripe(const struct bch_stripe *s,
+                                          struct extent_ptr_decoded p)
 {
        unsigned nr_data = s->nr_blocks - s->nr_redundant;
 
-       if (block >= nr_data)
+       BUG_ON(!p.has_ec);
+
+       if (p.ec.block >= nr_data)
                return false;
 
-       return  ptr->dev    == s->ptrs[block].dev &&
-               ptr->gen    == s->ptrs[block].gen &&
-               ptr->offset >= s->ptrs[block].offset &&
-               ptr->offset  < s->ptrs[block].offset + le16_to_cpu(s->sectors);
+       return __bch2_ptr_matches_stripe(&s->ptrs[p.ec.block], &p.ptr,
+                                        le16_to_cpu(s->sectors));
 }
 
-static inline bool bch2_ptr_matches_stripe(const struct bch_stripe *s,
-                                          struct extent_ptr_decoded p)
+static inline bool bch2_ptr_matches_stripe_m(const struct gc_stripe *m,
+                                            struct extent_ptr_decoded p)
 {
+       unsigned nr_data = m->nr_blocks - m->nr_redundant;
+
        BUG_ON(!p.has_ec);
 
-       return __bch2_ptr_matches_stripe(s, &p.ptr, p.ec.block);
+       if (p.ec.block >= nr_data)
+               return false;
+
+       return __bch2_ptr_matches_stripe(&m->ptrs[p.ec.block], &p.ptr,
+                                        m->sectors);
 }
 
 struct bch_read_bio;
@@ -143,16 +160,11 @@ struct ec_stripe_new {
        bool                    pending;
        bool                    have_existing_stripe;
 
+       unsigned long           blocks_gotten[BITS_TO_LONGS(BCH_BKEY_PTRS_MAX)];
        unsigned long           blocks_allocated[BITS_TO_LONGS(BCH_BKEY_PTRS_MAX)];
-
-       struct open_buckets     blocks;
-       u8                      data_block_idx[BCH_BKEY_PTRS_MAX];
-       struct open_buckets     parity;
+       open_bucket_idx_t       blocks[BCH_BKEY_PTRS_MAX];
        struct disk_reservation res;
 
-       struct keylist          keys;
-       u64                     inline_keys[BKEY_U64s * 8];
-
        struct ec_stripe_buf    new_stripe;
        struct ec_stripe_buf    existing_stripe;
 };
@@ -180,8 +192,6 @@ struct ec_stripe_head {
 int bch2_ec_read_extent(struct bch_fs *, struct bch_read_bio *);
 
 void *bch2_writepoint_ec_buf(struct bch_fs *, struct write_point *);
-void bch2_ec_add_backpointer(struct bch_fs *, struct write_point *,
-                            struct bpos, unsigned);
 
 void bch2_ec_bucket_written(struct bch_fs *, struct open_bucket *);
 void bch2_ec_bucket_cancel(struct bch_fs *, struct open_bucket *);
@@ -202,16 +212,13 @@ void bch2_ec_flush_new_stripes(struct bch_fs *);
 
 void bch2_stripes_heap_start(struct bch_fs *);
 
-struct journal_keys;
-int bch2_stripes_read(struct bch_fs *, struct journal_keys *);
-int bch2_stripes_write(struct bch_fs *, unsigned);
-
-int bch2_ec_mem_alloc(struct bch_fs *, bool);
+int bch2_stripes_read(struct bch_fs *);
 
 void bch2_stripes_heap_to_text(struct printbuf *, struct bch_fs *);
 void bch2_new_stripes_to_text(struct printbuf *, struct bch_fs *);
 
 void bch2_fs_ec_exit(struct bch_fs *);
+void bch2_fs_ec_init_early(struct bch_fs *);
 int bch2_fs_ec_init(struct bch_fs *);
 
 #endif /* _BCACHEFS_EC_H */