]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/movinggc.c
Update bcachefs sources to fbb669e9de bcachefs: Kill btree_node_iter_large
[bcachefs-tools-debian] / libbcachefs / movinggc.c
index fe66efb418066a421f628f99ce1292c388233222..abdeef20fde9fe0a34e78eee0c545e836989b008 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Moving/copying garbage collector
  *
@@ -68,26 +69,19 @@ static bool __copygc_pred(struct bch_dev *ca,
                          struct bkey_s_c k)
 {
        copygc_heap *h = &ca->copygc_heap;
+       const struct bch_extent_ptr *ptr =
+               bch2_bkey_has_device(k, ca->dev_idx);
 
-       switch (k.k->type) {
-       case KEY_TYPE_extent: {
-               struct bkey_s_c_extent e = bkey_s_c_to_extent(k);
-               const struct bch_extent_ptr *ptr =
-                       bch2_extent_has_device(e, ca->dev_idx);
+       if (ptr) {
+               struct copygc_heap_entry search = { .offset = ptr->offset };
 
-               if (ptr) {
-                       struct copygc_heap_entry search = { .offset = ptr->offset };
+               ssize_t i = eytzinger0_find_le(h->data, h->used,
+                                              sizeof(h->data[0]),
+                                              bucket_offset_cmp, &search);
 
-                       ssize_t i = eytzinger0_find_le(h->data, h->used,
-                                                      sizeof(h->data[0]),
-                                                      bucket_offset_cmp, &search);
-
-                       return (i >= 0 &&
-                               ptr->offset < h->data[i].offset + ca->mi.bucket_size &&
-                               ptr->gen == h->data[i].gen);
-               }
-               break;
-       }
+               return (i >= 0 &&
+                       ptr->offset < h->data[i].offset + ca->mi.bucket_size &&
+                       ptr->gen == h->data[i].gen);
        }
 
        return false;
@@ -113,10 +107,10 @@ static bool have_copygc_reserve(struct bch_dev *ca)
 {
        bool ret;
 
-       spin_lock(&ca->freelist_lock);
+       spin_lock(&ca->fs->freelist_lock);
        ret = fifo_full(&ca->free[RESERVE_MOVINGGC]) ||
                ca->allocator_state != ALLOCATOR_RUNNING;
-       spin_unlock(&ca->freelist_lock);
+       spin_unlock(&ca->fs->freelist_lock);
 
        return ret;
 }