|
@@ -412,149 +412,6 @@ void bch_debug_init_cache_set(struct cache_set *c)
|
|
|
|
|
|
#endif
|
|
|
|
|
|
-/* Fuzz tester has rotted: */
|
|
|
-#if 0
|
|
|
-
|
|
|
-static ssize_t btree_fuzz(struct kobject *k, struct kobj_attribute *a,
|
|
|
- const char *buffer, size_t size)
|
|
|
-{
|
|
|
- void dump(struct btree *b)
|
|
|
- {
|
|
|
- struct bset *i;
|
|
|
-
|
|
|
- for (i = b->sets[0].data;
|
|
|
- index(i, b) < btree_blocks(b) &&
|
|
|
- i->seq == b->sets[0].data->seq;
|
|
|
- i = ((void *) i) + set_blocks(i, b->c) * block_bytes(b->c))
|
|
|
- dump_bset(b, i);
|
|
|
- }
|
|
|
-
|
|
|
- struct cache_sb *sb;
|
|
|
- struct cache_set *c;
|
|
|
- struct btree *all[3], *b, *fill, *orig;
|
|
|
- int j;
|
|
|
-
|
|
|
- struct btree_op op;
|
|
|
- bch_btree_op_init_stack(&op);
|
|
|
-
|
|
|
- sb = kzalloc(sizeof(struct cache_sb), GFP_KERNEL);
|
|
|
- if (!sb)
|
|
|
- return -ENOMEM;
|
|
|
-
|
|
|
- sb->bucket_size = 128;
|
|
|
- sb->block_size = 4;
|
|
|
-
|
|
|
- c = bch_cache_set_alloc(sb);
|
|
|
- if (!c)
|
|
|
- return -ENOMEM;
|
|
|
-
|
|
|
- for (j = 0; j < 3; j++) {
|
|
|
- BUG_ON(list_empty(&c->btree_cache));
|
|
|
- all[j] = list_first_entry(&c->btree_cache, struct btree, list);
|
|
|
- list_del_init(&all[j]->list);
|
|
|
-
|
|
|
- all[j]->key = KEY(0, 0, c->sb.bucket_size);
|
|
|
- bkey_copy_key(&all[j]->key, &MAX_KEY);
|
|
|
- }
|
|
|
-
|
|
|
- b = all[0];
|
|
|
- fill = all[1];
|
|
|
- orig = all[2];
|
|
|
-
|
|
|
- while (1) {
|
|
|
- for (j = 0; j < 3; j++)
|
|
|
- all[j]->written = all[j]->nsets = 0;
|
|
|
-
|
|
|
- bch_bset_init_next(b);
|
|
|
-
|
|
|
- while (1) {
|
|
|
- struct bset *i = write_block(b);
|
|
|
- struct bkey *k = op.keys.top;
|
|
|
- unsigned rand;
|
|
|
-
|
|
|
- bkey_init(k);
|
|
|
- rand = get_random_int();
|
|
|
-
|
|
|
- op.type = rand & 1
|
|
|
- ? BTREE_INSERT
|
|
|
- : BTREE_REPLACE;
|
|
|
- rand >>= 1;
|
|
|
-
|
|
|
- SET_KEY_SIZE(k, bucket_remainder(c, rand));
|
|
|
- rand >>= c->bucket_bits;
|
|
|
- rand &= 1024 * 512 - 1;
|
|
|
- rand += c->sb.bucket_size;
|
|
|
- SET_KEY_OFFSET(k, rand);
|
|
|
-#if 0
|
|
|
- SET_KEY_PTRS(k, 1);
|
|
|
-#endif
|
|
|
- bch_keylist_push(&op.keys);
|
|
|
- bch_btree_insert_keys(b, &op);
|
|
|
-
|
|
|
- if (should_split(b) ||
|
|
|
- set_blocks(i, b->c) !=
|
|
|
- __set_blocks(i, i->keys + 15, b->c)) {
|
|
|
- i->csum = csum_set(i);
|
|
|
-
|
|
|
- memcpy(write_block(fill),
|
|
|
- i, set_bytes(i));
|
|
|
-
|
|
|
- b->written += set_blocks(i, b->c);
|
|
|
- fill->written = b->written;
|
|
|
- if (b->written == btree_blocks(b))
|
|
|
- break;
|
|
|
-
|
|
|
- bch_btree_sort_lazy(b);
|
|
|
- bch_bset_init_next(b);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- memcpy(orig->sets[0].data,
|
|
|
- fill->sets[0].data,
|
|
|
- btree_bytes(c));
|
|
|
-
|
|
|
- bch_btree_sort(b);
|
|
|
- fill->written = 0;
|
|
|
- bch_btree_node_read_done(fill);
|
|
|
-
|
|
|
- if (b->sets[0].data->keys != fill->sets[0].data->keys ||
|
|
|
- memcmp(b->sets[0].data->start,
|
|
|
- fill->sets[0].data->start,
|
|
|
- b->sets[0].data->keys * sizeof(uint64_t))) {
|
|
|
- struct bset *i = b->sets[0].data;
|
|
|
- struct bkey *k, *l;
|
|
|
-
|
|
|
- for (k = i->start,
|
|
|
- l = fill->sets[0].data->start;
|
|
|
- k < end(i);
|
|
|
- k = bkey_next(k), l = bkey_next(l))
|
|
|
- if (bkey_cmp(k, l) ||
|
|
|
- KEY_SIZE(k) != KEY_SIZE(l)) {
|
|
|
- char buf1[80];
|
|
|
- char buf2[80];
|
|
|
-
|
|
|
- bch_bkey_to_text(buf1, sizeof(buf1), k);
|
|
|
- bch_bkey_to_text(buf2, sizeof(buf2), l);
|
|
|
-
|
|
|
- pr_err("key %zi differs: %s != %s",
|
|
|
- (uint64_t *) k - i->d,
|
|
|
- buf1, buf2);
|
|
|
- }
|
|
|
-
|
|
|
- for (j = 0; j < 3; j++) {
|
|
|
- pr_err("**** Set %i ****", j);
|
|
|
- dump(all[j]);
|
|
|
- }
|
|
|
- panic("\n");
|
|
|
- }
|
|
|
-
|
|
|
- pr_info("fuzz complete: %i keys", b->sets[0].data->keys);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-kobj_attribute_write(fuzz, btree_fuzz);
|
|
|
-#endif
|
|
|
-
|
|
|
void bch_debug_exit(void)
|
|
|
{
|
|
|
if (!IS_ERR_OR_NULL(debug))
|
|
@@ -564,11 +421,6 @@ void bch_debug_exit(void)
|
|
|
int __init bch_debug_init(struct kobject *kobj)
|
|
|
{
|
|
|
int ret = 0;
|
|
|
-#if 0
|
|
|
- ret = sysfs_create_file(kobj, &ksysfs_fuzz.attr);
|
|
|
- if (ret)
|
|
|
- return ret;
|
|
|
-#endif
|
|
|
|
|
|
debug = debugfs_create_dir("bcache", NULL);
|
|
|
return ret;
|