]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/alloc_background.c
Update bcachefs sources to c7defb5793 bcachefs: Split btree_iter_traverse and bch2_bt...
[bcachefs-tools-debian] / libbcachefs / alloc_background.c
index 796a061d99946e75b8275203f33e0b4ee3f84620..48971fcf2d5bb393c818732e3b0f1be50c179ebc 100644 (file)
@@ -139,25 +139,6 @@ static void bch2_alloc_unpack_v1(struct bkey_alloc_unpacked *out,
 #undef  x
 }
 
-static void bch2_alloc_pack_v1(struct bkey_alloc_buf *dst,
-                              const struct bkey_alloc_unpacked src)
-{
-       struct bkey_i_alloc *a = bkey_alloc_init(&dst->k);
-       void *d = a->v.data;
-       unsigned bytes, idx = 0;
-
-       a->k.p          = POS(src.dev, src.bucket);
-       a->v.fields     = 0;
-       a->v.gen        = src.gen;
-
-#define x(_name, _bits)        alloc_field_v1_put(a, &d, idx++, src._name);
-       BCH_ALLOC_FIELDS_V1()
-#undef  x
-       bytes = (void *) d - (void *) &a->v;
-       set_bkey_val_bytes(&a->k, bytes);
-       memset_u64s_tail(&a->v, 0, bytes);
-}
-
 static int bch2_alloc_unpack_v2(struct bkey_alloc_unpacked *out,
                                struct bkey_s_c k)
 {
@@ -250,10 +231,7 @@ void bch2_alloc_pack(struct bch_fs *c,
                     struct bkey_alloc_buf *dst,
                     const struct bkey_alloc_unpacked src)
 {
-       if (c->sb.features & (1ULL << BCH_FEATURE_alloc_v2))
-               bch2_alloc_pack_v2(dst, src);
-       else
-               bch2_alloc_pack_v1(dst, src);
+       bch2_alloc_pack_v2(dst, src);
 }
 
 static unsigned bch_alloc_val_u64s(const struct bch_alloc *a)
@@ -410,7 +388,6 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags)
        int ret = 0;
 
        bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0);
-
        iter = bch2_trans_get_iter(&trans, BTREE_ID_alloc, POS_MIN,
                                   BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
 
@@ -430,6 +407,7 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags)
                }
        }
 err:
+       bch2_trans_iter_put(&trans, iter);
        bch2_trans_exit(&trans);
        return ret;
 }
@@ -959,7 +937,6 @@ static int bch2_invalidate_buckets(struct bch_fs *c, struct bch_dev *ca)
        int ret = 0;
 
        bch2_trans_init(&trans, c, 0, 0);
-
        iter = bch2_trans_get_iter(&trans, BTREE_ID_alloc,
                                   POS(ca->dev_idx, 0),
                                   BTREE_ITER_CACHED|
@@ -975,6 +952,7 @@ static int bch2_invalidate_buckets(struct bch_fs *c, struct bch_dev *ca)
                                (!fifo_empty(&ca->free_inc)
                                 ? BTREE_INSERT_NOWAIT : 0));
 
+       bch2_trans_iter_put(&trans, iter);
        bch2_trans_exit(&trans);
 
        /* If we used NOWAIT, don't return the error: */