]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/extents.c
Update bcachefs sources to 72405e7ff8 bcachefs: Fix bch2_check_extents_to_backpointers()
[bcachefs-tools-debian] / libbcachefs / extents.c
index 4fc581be7aaf545ab8ebd8b5d1f018bb768f62c0..e2c09ea4a3e013bd9bb55c2518da017e59dd69c7 100644 (file)
@@ -26,8 +26,6 @@
 
 #include <trace/events/bcachefs.h>
 
-static union bch_extent_entry *__bch2_bkey_drop_ptr(struct bkey_s, struct bch_extent_ptr *);
-
 static unsigned bch2_crc_field_size_max[] = {
        [BCH_EXTENT_ENTRY_crc32] = CRC32_SIZE_MAX,
        [BCH_EXTENT_ENTRY_crc64] = CRC64_SIZE_MAX,
@@ -512,7 +510,7 @@ restart_narrow_pointers:
 
        bkey_for_each_ptr_decode(&k->k, ptrs, p, i)
                if (can_narrow_crc(p.crc, n)) {
-                       __bch2_bkey_drop_ptr(bkey_i_to_s(k), &i->ptr);
+                       bch2_bkey_drop_ptr_noerror(bkey_i_to_s(k), &i->ptr);
                        p.ptr.offset += p.crc.offset;
                        p.crc = n;
                        bch2_extent_ptr_decoded_append(k, &p);
@@ -765,8 +763,8 @@ static void extent_entry_drop(struct bkey_s k, union bch_extent_entry *entry)
 /*
  * Returns pointer to the next entry after the one being dropped:
  */
-static union bch_extent_entry *__bch2_bkey_drop_ptr(struct bkey_s k,
-                                          struct bch_extent_ptr *ptr)
+union bch_extent_entry *bch2_bkey_drop_ptr_noerror(struct bkey_s k,
+                                                  struct bch_extent_ptr *ptr)
 {
        struct bkey_ptrs ptrs = bch2_bkey_ptrs(k);
        union bch_extent_entry *entry = to_entry(ptr), *next;
@@ -809,7 +807,7 @@ union bch_extent_entry *bch2_bkey_drop_ptr(struct bkey_s k,
 {
        bool have_dirty = bch2_bkey_dirty_devs(k.s_c).nr;
        union bch_extent_entry *ret =
-               __bch2_bkey_drop_ptr(k, ptr);
+               bch2_bkey_drop_ptr_noerror(k, ptr);
 
        /*
         * If we deleted all the dirty pointers and there's still cached
@@ -840,14 +838,13 @@ void bch2_bkey_drop_device(struct bkey_s k, unsigned dev)
 
 void bch2_bkey_drop_device_noerror(struct bkey_s k, unsigned dev)
 {
-       struct bch_extent_ptr *ptr = (void *) bch2_bkey_has_device(k.s_c, dev);
+       struct bch_extent_ptr *ptr = bch2_bkey_has_device(k, dev);
 
        if (ptr)
-               __bch2_bkey_drop_ptr(k, ptr);
+               bch2_bkey_drop_ptr_noerror(k, ptr);
 }
 
-const struct bch_extent_ptr *
-bch2_bkey_has_device(struct bkey_s_c k, unsigned dev)
+const struct bch_extent_ptr *bch2_bkey_has_device_c(struct bkey_s_c k, unsigned dev)
 {
        struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
        const struct bch_extent_ptr *ptr;
@@ -922,11 +919,11 @@ bool bch2_extents_match(struct bkey_s_c k1, struct bkey_s_c k2)
        }
 }
 
-bool bch2_extent_has_ptr(struct bkey_s_c k1, struct extent_ptr_decoded p1,
-                        struct bkey_s_c k2)
+struct bch_extent_ptr *
+bch2_extent_has_ptr(struct bkey_s_c k1, struct extent_ptr_decoded p1, struct bkey_s k2)
 {
-       struct bkey_ptrs_c ptrs2 = bch2_bkey_ptrs_c(k2);
-       const union bch_extent_entry *entry2;
+       struct bkey_ptrs ptrs2 = bch2_bkey_ptrs(k2);
+       union bch_extent_entry *entry2;
        struct extent_ptr_decoded p2;
 
        bkey_for_each_ptr_decode(k2.k, ptrs2, p2, entry2)
@@ -934,9 +931,9 @@ bool bch2_extent_has_ptr(struct bkey_s_c k1, struct extent_ptr_decoded p1,
                    p1.ptr.gen          == p2.ptr.gen &&
                    (s64) p1.ptr.offset + p1.crc.offset - bkey_start_offset(k1.k) ==
                    (s64) p2.ptr.offset + p2.crc.offset - bkey_start_offset(k2.k))
-                       return true;
+                       return &entry2->ptr;
 
-       return false;
+       return NULL;
 }
 
 void bch2_extent_ptr_set_cached(struct bkey_s k, struct bch_extent_ptr *ptr)
@@ -992,6 +989,9 @@ void bch2_bkey_ptrs_to_text(struct printbuf *out, struct bch_fs *c,
        struct bch_dev *ca;
        bool first = true;
 
+       if (c)
+               prt_printf(out, "durability: %u ", bch2_bkey_durability(c, k));
+
        bkey_extent_entry_for_each(ptrs, entry) {
                if (!first)
                        prt_printf(out, " ");