diff options
author | Kent Overstreet <koverstreet@google.com> | 2013-05-15 20:13:45 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-07-01 17:43:48 -0400 |
commit | f3059a54610f6c516c0942d58b9435921768ce2d (patch) | |
tree | a4eae66f80deaba52e6361d7e8660511ce3bb484 /drivers/md/bcache/debug.c | |
parent | 36c9ea9837c1cb21c778781495101eaff7e5eb56 (diff) |
bcache: Delete fuzz tester
This code has rotted and it hasn't been used in ages anyways.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/debug.c')
-rw-r--r-- | drivers/md/bcache/debug.c | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 1c8fd319846e..ba2ceee0fdbb 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c | |||
@@ -412,149 +412,6 @@ void bch_debug_init_cache_set(struct cache_set *c) | |||
412 | 412 | ||
413 | #endif | 413 | #endif |
414 | 414 | ||
415 | /* Fuzz tester has rotted: */ | ||
416 | #if 0 | ||
417 | |||
418 | static ssize_t btree_fuzz(struct kobject *k, struct kobj_attribute *a, | ||
419 | const char *buffer, size_t size) | ||
420 | { | ||
421 | void dump(struct btree *b) | ||
422 | { | ||
423 | struct bset *i; | ||
424 | |||
425 | for (i = b->sets[0].data; | ||
426 | index(i, b) < btree_blocks(b) && | ||
427 | i->seq == b->sets[0].data->seq; | ||
428 | i = ((void *) i) + set_blocks(i, b->c) * block_bytes(b->c)) | ||
429 | dump_bset(b, i); | ||
430 | } | ||
431 | |||
432 | struct cache_sb *sb; | ||
433 | struct cache_set *c; | ||
434 | struct btree *all[3], *b, *fill, *orig; | ||
435 | int j; | ||
436 | |||
437 | struct btree_op op; | ||
438 | bch_btree_op_init_stack(&op); | ||
439 | |||
440 | sb = kzalloc(sizeof(struct cache_sb), GFP_KERNEL); | ||
441 | if (!sb) | ||
442 | return -ENOMEM; | ||
443 | |||
444 | sb->bucket_size = 128; | ||
445 | sb->block_size = 4; | ||
446 | |||
447 | c = bch_cache_set_alloc(sb); | ||
448 | if (!c) | ||
449 | return -ENOMEM; | ||
450 | |||
451 | for (j = 0; j < 3; j++) { | ||
452 | BUG_ON(list_empty(&c->btree_cache)); | ||
453 | all[j] = list_first_entry(&c->btree_cache, struct btree, list); | ||
454 | list_del_init(&all[j]->list); | ||
455 | |||
456 | all[j]->key = KEY(0, 0, c->sb.bucket_size); | ||
457 | bkey_copy_key(&all[j]->key, &MAX_KEY); | ||
458 | } | ||
459 | |||
460 | b = all[0]; | ||
461 | fill = all[1]; | ||
462 | orig = all[2]; | ||
463 | |||
464 | while (1) { | ||
465 | for (j = 0; j < 3; j++) | ||
466 | all[j]->written = all[j]->nsets = 0; | ||
467 | |||
468 | bch_bset_init_next(b); | ||
469 | |||
470 | while (1) { | ||
471 | struct bset *i = write_block(b); | ||
472 | struct bkey *k = op.keys.top; | ||
473 | unsigned rand; | ||
474 | |||
475 | bkey_init(k); | ||
476 | rand = get_random_int(); | ||
477 | |||
478 | op.type = rand & 1 | ||
479 | ? BTREE_INSERT | ||
480 | : BTREE_REPLACE; | ||
481 | rand >>= 1; | ||
482 | |||
483 | SET_KEY_SIZE(k, bucket_remainder(c, rand)); | ||
484 | rand >>= c->bucket_bits; | ||
485 | rand &= 1024 * 512 - 1; | ||
486 | rand += c->sb.bucket_size; | ||
487 | SET_KEY_OFFSET(k, rand); | ||
488 | #if 0 | ||
489 | SET_KEY_PTRS(k, 1); | ||
490 | #endif | ||
491 | bch_keylist_push(&op.keys); | ||
492 | bch_btree_insert_keys(b, &op); | ||
493 | |||
494 | if (should_split(b) || | ||
495 | set_blocks(i, b->c) != | ||
496 | __set_blocks(i, i->keys + 15, b->c)) { | ||
497 | i->csum = csum_set(i); | ||
498 | |||
499 | memcpy(write_block(fill), | ||
500 | i, set_bytes(i)); | ||
501 | |||
502 | b->written += set_blocks(i, b->c); | ||
503 | fill->written = b->written; | ||
504 | if (b->written == btree_blocks(b)) | ||
505 | break; | ||
506 | |||
507 | bch_btree_sort_lazy(b); | ||
508 | bch_bset_init_next(b); | ||
509 | } | ||
510 | } | ||
511 | |||
512 | memcpy(orig->sets[0].data, | ||
513 | fill->sets[0].data, | ||
514 | btree_bytes(c)); | ||
515 | |||
516 | bch_btree_sort(b); | ||
517 | fill->written = 0; | ||
518 | bch_btree_node_read_done(fill); | ||
519 | |||
520 | if (b->sets[0].data->keys != fill->sets[0].data->keys || | ||
521 | memcmp(b->sets[0].data->start, | ||
522 | fill->sets[0].data->start, | ||
523 | b->sets[0].data->keys * sizeof(uint64_t))) { | ||
524 | struct bset *i = b->sets[0].data; | ||
525 | struct bkey *k, *l; | ||
526 | |||
527 | for (k = i->start, | ||
528 | l = fill->sets[0].data->start; | ||
529 | k < end(i); | ||
530 | k = bkey_next(k), l = bkey_next(l)) | ||
531 | if (bkey_cmp(k, l) || | ||
532 | KEY_SIZE(k) != KEY_SIZE(l)) { | ||
533 | char buf1[80]; | ||
534 | char buf2[80]; | ||
535 | |||
536 | bch_bkey_to_text(buf1, sizeof(buf1), k); | ||
537 | bch_bkey_to_text(buf2, sizeof(buf2), l); | ||
538 | |||
539 | pr_err("key %zi differs: %s != %s", | ||
540 | (uint64_t *) k - i->d, | ||
541 | buf1, buf2); | ||
542 | } | ||
543 | |||
544 | for (j = 0; j < 3; j++) { | ||
545 | pr_err("**** Set %i ****", j); | ||
546 | dump(all[j]); | ||
547 | } | ||
548 | panic("\n"); | ||
549 | } | ||
550 | |||
551 | pr_info("fuzz complete: %i keys", b->sets[0].data->keys); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | kobj_attribute_write(fuzz, btree_fuzz); | ||
556 | #endif | ||
557 | |||
558 | void bch_debug_exit(void) | 415 | void bch_debug_exit(void) |
559 | { | 416 | { |
560 | if (!IS_ERR_OR_NULL(debug)) | 417 | if (!IS_ERR_OR_NULL(debug)) |
@@ -564,11 +421,6 @@ void bch_debug_exit(void) | |||
564 | int __init bch_debug_init(struct kobject *kobj) | 421 | int __init bch_debug_init(struct kobject *kobj) |
565 | { | 422 | { |
566 | int ret = 0; | 423 | int ret = 0; |
567 | #if 0 | ||
568 | ret = sysfs_create_file(kobj, &ksysfs_fuzz.attr); | ||
569 | if (ret) | ||
570 | return ret; | ||
571 | #endif | ||
572 | 424 | ||
573 | debug = debugfs_create_dir("bcache", NULL); | 425 | debug = debugfs_create_dir("bcache", NULL); |
574 | return ret; | 426 | return ret; |