Commit eb7f44db authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fixes for unit tests

The unit tests hadn't been updated for various recent btree changes -
this patch makes them work again.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 71f892a4
...@@ -34,6 +34,7 @@ static int test_delete(struct bch_fs *c, u64 nr) ...@@ -34,6 +34,7 @@ static int test_delete(struct bch_fs *c, u64 nr)
int ret; int ret;
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p.snapshot = U32_MAX;
bch2_trans_init(&trans, c, 0, 0); bch2_trans_init(&trans, c, 0, 0);
...@@ -79,29 +80,27 @@ static int test_delete_written(struct bch_fs *c, u64 nr) ...@@ -79,29 +80,27 @@ static int test_delete_written(struct bch_fs *c, u64 nr)
int ret; int ret;
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p.snapshot = U32_MAX;
bch2_trans_init(&trans, c, 0, 0); bch2_trans_init(&trans, c, 0, 0);
iter = bch2_trans_get_iter(&trans, BTREE_ID_xattrs, k.k.p, iter = bch2_trans_get_iter(&trans, BTREE_ID_xattrs, k.k.p,
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
ret = bch2_btree_iter_traverse(iter);
if (ret) {
bch_err(c, "lookup error in test_delete_written: %i", ret);
goto err;
}
ret = __bch2_trans_do(&trans, NULL, NULL, 0, ret = __bch2_trans_do(&trans, NULL, NULL, 0,
bch2_btree_iter_traverse(iter) ?:
bch2_trans_update(&trans, iter, &k.k_i, 0)); bch2_trans_update(&trans, iter, &k.k_i, 0));
if (ret) { if (ret) {
bch_err(c, "update error in test_delete_written: %i", ret); bch_err(c, "update error in test_delete_written: %i", ret);
goto err; goto err;
} }
bch2_trans_unlock(&trans);
bch2_journal_flush_all_pins(&c->journal); bch2_journal_flush_all_pins(&c->journal);
ret = __bch2_trans_do(&trans, NULL, NULL, 0, ret = __bch2_trans_do(&trans, NULL, NULL, 0,
bch2_btree_delete_at(&trans, iter, 0)); bch2_btree_iter_traverse(iter) ?:
bch2_btree_delete_at(&trans, iter, 0));
if (ret) { if (ret) {
bch_err(c, "delete error in test_delete_written: %i", ret); bch_err(c, "delete error in test_delete_written: %i", ret);
goto err; goto err;
...@@ -131,6 +130,7 @@ static int test_iterate(struct bch_fs *c, u64 nr) ...@@ -131,6 +130,7 @@ static int test_iterate(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p.offset = i; k.k.p.offset = i;
k.k.p.snapshot = U32_MAX;
ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i, ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i,
NULL, NULL, 0); NULL, NULL, 0);
...@@ -185,6 +185,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr) ...@@ -185,6 +185,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p.offset = i + 8; k.k.p.offset = i + 8;
k.k.p.snapshot = U32_MAX;
k.k.size = 8; k.k.size = 8;
ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i, ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i,
...@@ -240,6 +241,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr) ...@@ -240,6 +241,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p.offset = i * 2; k.k.p.offset = i * 2;
k.k.p.snapshot = U32_MAX;
ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i, ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i,
NULL, NULL, 0); NULL, NULL, 0);
...@@ -303,6 +305,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr) ...@@ -303,6 +305,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p.offset = i + 16; k.k.p.offset = i + 16;
k.k.p.snapshot = U32_MAX;
k.k.size = 8; k.k.size = 8;
ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i, ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i,
...@@ -410,6 +413,7 @@ static int insert_test_extent(struct bch_fs *c, ...@@ -410,6 +413,7 @@ static int insert_test_extent(struct bch_fs *c,
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k_i.k.p.offset = end; k.k_i.k.p.offset = end;
k.k_i.k.p.snapshot = U32_MAX;
k.k_i.k.size = end - start; k.k_i.k.size = end - start;
k.k_i.k.version.lo = test_version++; k.k_i.k.version.lo = test_version++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment