]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Add a perf test for multiple updates per commit
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 14 Apr 2021 16:10:17 +0000 (12:10 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:00 +0000 (17:09 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/tests.c

index 3de48c593963752daec79d185b206bde699cafa8..bb475656637744a480ccbe6d838f6ac54e32ab05 100644 (file)
@@ -497,6 +497,42 @@ static int rand_insert(struct bch_fs *c, u64 nr)
        return ret;
 }
 
+static int rand_insert_multi(struct bch_fs *c, u64 nr)
+{
+       struct btree_trans trans;
+       struct bkey_i_cookie k[8];
+       int ret = 0;
+       unsigned j;
+       u64 i;
+
+       bch2_trans_init(&trans, c, 0, 0);
+
+       for (i = 0; i < nr; i += ARRAY_SIZE(k)) {
+               for (j = 0; j < ARRAY_SIZE(k); j++) {
+                       bkey_cookie_init(&k[j].k_i);
+                       k[j].k.p.offset = test_rand();
+                       k[j].k.p.snapshot = U32_MAX;
+               }
+
+               ret = __bch2_trans_do(&trans, NULL, NULL, 0,
+                       __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[0].k_i) ?:
+                       __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[1].k_i) ?:
+                       __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[2].k_i) ?:
+                       __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[3].k_i) ?:
+                       __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[4].k_i) ?:
+                       __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[5].k_i) ?:
+                       __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[6].k_i) ?:
+                       __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[7].k_i));
+               if (ret) {
+                       bch_err(c, "error in rand_insert_multi: %i", ret);
+                       break;
+               }
+       }
+
+       bch2_trans_exit(&trans);
+       return ret;
+}
+
 static int rand_lookup(struct bch_fs *c, u64 nr)
 {
        struct btree_trans trans;
@@ -765,6 +801,7 @@ int bch2_btree_perf_test(struct bch_fs *c, const char *testname,
        if (!strcmp(testname, #_test)) j.fn = _test
 
        perf_test(rand_insert);
+       perf_test(rand_insert_multi);
        perf_test(rand_lookup);
        perf_test(rand_mixed);
        perf_test(rand_delete);