From cafe563591446cf80bfbc2fe3bc72a2e36cf1060 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 23 Mar 2013 16:11:31 -0700 Subject: bcache: A block layer cache Does writethrough and writeback caching, handles unclean shutdown, and has a bunch of other nifty features motivated by real world usage. See the wiki at http://bcache.evilpiepirate.org for more. Signed-off-by: Kent Overstreet --- drivers/md/bcache/debug.c | 563 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 563 insertions(+) create mode 100644 drivers/md/bcache/debug.c (limited to 'drivers/md/bcache/debug.c') diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c new file mode 100644 index 000000000000..4b37ef2b80e5 --- /dev/null +++ b/drivers/md/bcache/debug.c @@ -0,0 +1,563 @@ +/* + * Assorted bcache debug code + * + * Copyright 2010, 2011 Kent Overstreet + * Copyright 2012 Google, Inc. + */ + +#include "bcache.h" +#include "btree.h" +#include "debug.h" +#include "request.h" + +#include +#include +#include +#include +#include + +static struct dentry *debug; + +const char *bch_ptr_status(struct cache_set *c, const struct bkey *k) +{ + unsigned i; + + for (i = 0; i < KEY_PTRS(k); i++) + if (ptr_available(c, k, i)) { + struct cache *ca = PTR_CACHE(c, k, i); + size_t bucket = PTR_BUCKET_NR(c, k, i); + size_t r = bucket_remainder(c, PTR_OFFSET(k, i)); + + if (KEY_SIZE(k) + r > c->sb.bucket_size) + return "bad, length too big"; + if (bucket < ca->sb.first_bucket) + return "bad, short offset"; + if (bucket >= ca->sb.nbuckets) + return "bad, offset past end of device"; + if (ptr_stale(c, k, i)) + return "stale"; + } + + if (!bkey_cmp(k, &ZERO_KEY)) + return "bad, null key"; + if (!KEY_PTRS(k)) + return "bad, no pointers"; + if (!KEY_SIZE(k)) + return "zeroed key"; + return ""; +} + +struct keyprint_hack bch_pkey(const struct bkey *k) +{ + unsigned i = 0; + struct keyprint_hack r; + char *out = r.s, *end = r.s + KEYHACK_SIZE; + +#define p(...) (out += scnprintf(out, end - out, __VA_ARGS__)) + + p("%llu:%llu len %llu -> [", KEY_INODE(k), KEY_OFFSET(k), KEY_SIZE(k)); + + if (KEY_PTRS(k)) + while (1) { + p("%llu:%llu gen %llu", + PTR_DEV(k, i), PTR_OFFSET(k, i), PTR_GEN(k, i)); + + if (++i == KEY_PTRS(k)) + break; + + p(", "); + } + + p("]"); + + if (KEY_DIRTY(k)) + p(" dirty"); + if (KEY_CSUM(k)) + p(" cs%llu %llx", KEY_CSUM(k), k->ptr[1]); +#undef p + return r; +} + +struct keyprint_hack bch_pbtree(const struct btree *b) +{ + struct keyprint_hack r; + + snprintf(r.s, 40, "%li level %i/%i", PTR_BUCKET_NR(b->c, &b->key, 0), + b->level, b->c->root ? b->c->root->level : -1); + return r; +} + +#if defined(CONFIG_BCACHE_DEBUG) || defined(CONFIG_BCACHE_EDEBUG) + +static bool skipped_backwards(struct btree *b, struct bkey *k) +{ + return bkey_cmp(k, (!b->level) + ? &START_KEY(bkey_next(k)) + : bkey_next(k)) > 0; +} + +static void dump_bset(struct btree *b, struct bset *i) +{ + struct bkey *k; + unsigned j; + + for (k = i->start; k < end(i); k = bkey_next(k)) { + printk(KERN_ERR "block %zu key %zi/%u: %s", index(i, b), + (uint64_t *) k - i->d, i->keys, pkey(k)); + + for (j = 0; j < KEY_PTRS(k); j++) { + size_t n = PTR_BUCKET_NR(b->c, k, j); + printk(" bucket %zu", n); + + if (n >= b->c->sb.first_bucket && n < b->c->sb.nbuckets) + printk(" prio %i", + PTR_BUCKET(b->c, k, j)->prio); + } + + printk(" %s\n", bch_ptr_status(b->c, k)); + + if (bkey_next(k) < end(i) && + skipped_backwards(b, k)) + printk(KERN_ERR "Key skipped backwards\n"); + } +} + +#endif + +#ifdef CONFIG_BCACHE_DEBUG + +void bch_btree_verify(struct btree *b, struct bset *new) +{ + struct btree *v = b->c->verify_data; + struct closure cl; + closure_init_stack(&cl); + + if (!b->c->verify) + return; + + closure_wait_event(&b->io.wait, &cl, + atomic_read(&b->io.cl.remaining) == -1); + + mutex_lock(&b->c->verify_lock); + + bkey_copy(&v->key, &b->key); + v->written = 0; + v->level = b->level; + + bch_btree_read(v); + closure_wait_event(&v->io.wait, &cl, + atomic_read(&b->io.cl.remaining) == -1); + + if (new->keys != v->sets[0].data->keys || + memcmp(new->start, + v->sets[0].data->start, + (void *) end(new) - (void *) new->start)) { + unsigned i, j; + + console_lock(); + + printk(KERN_ERR "*** original memory node:\n"); + for (i = 0; i <= b->nsets; i++) + dump_bset(b, b->sets[i].data); + + printk(KERN_ERR "*** sorted memory node:\n"); + dump_bset(b, new); + + printk(KERN_ERR "*** on disk node:\n"); + dump_bset(v, v->sets[0].data); + + for (j = 0; j < new->keys; j++) + if (new->d[j] != v->sets[0].data->d[j]) + break; + + console_unlock(); + panic("verify failed at %u\n", j); + } + + mutex_unlock(&b->c->verify_lock); +} + +static void data_verify_endio(struct bio *bio, int error) +{ + struct closure *cl = bio->bi_private; + closure_put(cl); +} + +void bch_data_verify(struct search *s) +{ + char name[BDEVNAME_SIZE]; + struct cached_dev *dc = container_of(s->d, struct cached_dev, disk); + struct closure *cl = &s->cl; + struct bio *check; + struct bio_vec *bv; + int i; + + if (!s->unaligned_bvec) + bio_for_each_segment(bv, s->orig_bio, i) + bv->bv_offset = 0, bv->bv_len = PAGE_SIZE; + + check = bio_clone(s->orig_bio, GFP_NOIO); + if (!check) + return; + + if (bio_alloc_pages(check, GFP_NOIO)) + goto out_put; + + check->bi_rw = READ_SYNC; + check->bi_private = cl; + check->bi_end_io = data_verify_endio; + + closure_bio_submit(check, cl, &dc->disk); + closure_sync(cl); + + bio_for_each_segment(bv, s->orig_bio, i) { + void *p1 = kmap(bv->bv_page); + void *p2 = kmap(check->bi_io_vec[i].bv_page); + + if (memcmp(p1 + bv->bv_offset, + p2 + bv->bv_offset, + bv->bv_len)) + printk(KERN_ERR "bcache (%s): verify failed" + " at sector %llu\n", + bdevname(dc->bdev, name), + (uint64_t) s->orig_bio->bi_sector); + + kunmap(bv->bv_page); + kunmap(check->bi_io_vec[i].bv_page); + } + + __bio_for_each_segment(bv, check, i, 0) + __free_page(bv->bv_page); +out_put: + bio_put(check); +} + +#endif + +#ifdef CONFIG_BCACHE_EDEBUG + +unsigned bch_count_data(struct btree *b) +{ + unsigned ret = 0; + struct btree_iter iter; + struct bkey *k; + + if (!b->level) + for_each_key(b, k, &iter) + ret += KEY_SIZE(k); + return ret; +} + +static void vdump_bucket_and_panic(struct btree *b, const char *fmt, + va_list args) +{ + unsigned i; + + console_lock(); + + for (i = 0; i <= b->nsets; i++) + dump_bset(b, b->sets[i].data); + + vprintk(fmt, args); + + console_unlock(); + + panic("at %s\n", pbtree(b)); +} + +void bch_check_key_order_msg(struct btree *b, struct bset *i, + const char *fmt, ...) +{ + struct bkey *k; + + if (!i->keys) + return; + + for (k = i->start; bkey_next(k) < end(i); k = bkey_next(k)) + if (skipped_backwards(b, k)) { + va_list args; + va_start(args, fmt); + + vdump_bucket_and_panic(b, fmt, args); + va_end(args); + } +} + +void bch_check_keys(struct btree *b, const char *fmt, ...) +{ + va_list args; + struct bkey *k, *p = NULL; + struct btree_iter iter; + + if (b->level) + return; + + for_each_key(b, k, &iter) { + if (p && bkey_cmp(&START_KEY(p), &START_KEY(k)) > 0) { + printk(KERN_ERR "Keys out of order:\n"); + goto bug; + } + + if (bch_ptr_invalid(b, k)) + continue; + + if (p && bkey_cmp(p, &START_KEY(k)) > 0) { + printk(KERN_ERR "Overlapping keys:\n"); + goto bug; + } + p = k; + } + return; +bug: + va_start(args, fmt); + vdump_bucket_and_panic(b, fmt, args); + va_end(args); +} + +#endif + +#ifdef CONFIG_DEBUG_FS + +/* XXX: cache set refcounting */ + +struct dump_iterator { + char buf[PAGE_SIZE]; + size_t bytes; + struct cache_set *c; + struct keybuf keys; +}; + +static bool dump_pred(struct keybuf *buf, struct bkey *k) +{ + return true; +} + +static ssize_t bch_dump_read(struct file *file, char __user *buf, + size_t size, loff_t *ppos) +{ + struct dump_iterator *i = file->private_data; + ssize_t ret = 0; + + while (size) { + struct keybuf_key *w; + unsigned bytes = min(i->bytes, size); + + int err = copy_to_user(buf, i->buf, bytes); + if (err) + return err; + + ret += bytes; + buf += bytes; + size -= bytes; + i->bytes -= bytes; + memmove(i->buf, i->buf + bytes, i->bytes); + + if (i->bytes) + break; + + w = bch_keybuf_next_rescan(i->c, &i->keys, &MAX_KEY); + if (!w) + break; + + i->bytes = snprintf(i->buf, PAGE_SIZE, "%s\n", pkey(&w->key)); + bch_keybuf_del(&i->keys, w); + } + + return ret; +} + +static int bch_dump_open(struct inode *inode, struct file *file) +{ + struct cache_set *c = inode->i_private; + struct dump_iterator *i; + + i = kzalloc(sizeof(struct dump_iterator), GFP_KERNEL); + if (!i) + return -ENOMEM; + + file->private_data = i; + i->c = c; + bch_keybuf_init(&i->keys, dump_pred); + i->keys.last_scanned = KEY(0, 0, 0); + + return 0; +} + +static int bch_dump_release(struct inode *inode, struct file *file) +{ + kfree(file->private_data); + return 0; +} + +static const struct file_operations cache_set_debug_ops = { + .owner = THIS_MODULE, + .open = bch_dump_open, + .read = bch_dump_read, + .release = bch_dump_release +}; + +void bch_debug_init_cache_set(struct cache_set *c) +{ + if (!IS_ERR_OR_NULL(debug)) { + char name[50]; + snprintf(name, 50, "bcache-%pU", c->sb.set_uuid); + + c->debug = debugfs_create_file(name, 0400, debug, c, + &cache_set_debug_ops); + } +} + +#endif + +#ifdef CONFIG_BCACHE_DEBUG +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_read_done(&fill->io.cl); + + 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)) + pr_err("key %zi differs: %s " + "!= %s", (uint64_t *) k - i->d, + pkey(k), pkey(l)); + + 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)) + debugfs_remove_recursive(debug); +} + +int __init bch_debug_init(struct kobject *kobj) +{ + int ret = 0; +#ifdef CONFIG_BCACHE_DEBUG + ret = sysfs_create_file(kobj, &ksysfs_fuzz.attr); + if (ret) + return ret; +#endif + + debug = debugfs_create_dir("bcache", NULL); + return ret; +} -- cgit v1.2.3 From b1a67b0f4c747ca10c96ebb24f04e2a74b3c298d Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 25 Mar 2013 11:46:44 -0700 Subject: bcache: Style/checkpatch fixes Took out some nested functions, and fixed some more checkpatch complaints. Signed-off-by: Kent Overstreet Cc: linux-bcache@vger.kernel.org Signed-off-by: Jens Axboe --- drivers/md/bcache/alloc.c | 22 ++++++---------------- drivers/md/bcache/bcache.h | 10 +++++----- drivers/md/bcache/bset.c | 9 +++++---- drivers/md/bcache/btree.c | 4 ++-- drivers/md/bcache/debug.c | 8 ++++---- drivers/md/bcache/journal.c | 8 ++++---- drivers/md/bcache/movinggc.c | 24 ++++++++++++------------ drivers/md/bcache/request.c | 12 +++++++----- drivers/md/bcache/stats.c | 3 ++- drivers/md/bcache/super.c | 7 ++++--- 10 files changed, 51 insertions(+), 56 deletions(-) (limited to 'drivers/md/bcache/debug.c') diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index ed18115e078e..2879487d036a 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -229,24 +229,14 @@ static void invalidate_one_bucket(struct cache *ca, struct bucket *b) fifo_push(&ca->free_inc, b - ca->buckets); } -static void invalidate_buckets_lru(struct cache *ca) -{ - unsigned bucket_prio(struct bucket *b) - { - return ((unsigned) (b->prio - ca->set->min_prio)) * - GC_SECTORS_USED(b); - } - - bool bucket_max_cmp(struct bucket *l, struct bucket *r) - { - return bucket_prio(l) < bucket_prio(r); - } +#define bucket_prio(b) \ + (((unsigned) (b->prio - ca->set->min_prio)) * GC_SECTORS_USED(b)) - bool bucket_min_cmp(struct bucket *l, struct bucket *r) - { - return bucket_prio(l) > bucket_prio(r); - } +#define bucket_max_cmp(l, r) (bucket_prio(l) < bucket_prio(r)) +#define bucket_min_cmp(l, r) (bucket_prio(l) > bucket_prio(r)) +static void invalidate_buckets_lru(struct cache *ca) +{ struct bucket *b; ssize_t i; diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index d01a553f63f3..b2846e70149b 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -644,8 +644,8 @@ struct gc_stat { * we'll continue to run normally for awhile with CACHE_SET_STOPPING set (i.e. * flushing dirty data). * - * CACHE_SET_STOPPING_2 gets set at the last phase, when it's time to shut down the - * allocation thread. + * CACHE_SET_STOPPING_2 gets set at the last phase, when it's time to shut down + * the allocation thread. */ #define CACHE_SET_UNREGISTERING 0 #define CACHE_SET_STOPPING 1 @@ -1012,11 +1012,11 @@ static inline struct bucket *PTR_BUCKET(struct cache_set *c, * searches - it told you where a key started. It's not used anymore, * and can probably be safely dropped. */ -#define KEY(dev, sector, len) (struct bkey) \ -{ \ +#define KEY(dev, sector, len) \ +((struct bkey) { \ .high = (1ULL << 63) | ((uint64_t) (len) << 20) | (dev), \ .low = (sector) \ -} +}) static inline void bkey_init(struct bkey *k) { diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c index 79fe1f0190f7..4dc9cb4efacb 100644 --- a/drivers/md/bcache/bset.c +++ b/drivers/md/bcache/bset.c @@ -161,9 +161,9 @@ bool bch_ptr_bad(struct btree *b, const struct bkey *k) #ifdef CONFIG_BCACHE_EDEBUG bug: mutex_unlock(&b->c->bucket_lock); - btree_bug(b, "inconsistent pointer %s: bucket %zu pin %i " - "prio %i gen %i last_gc %i mark %llu gc_gen %i", pkey(k), - PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin), + btree_bug(b, +"inconsistent pointer %s: bucket %zu pin %i prio %i gen %i last_gc %i mark %llu gc_gen %i", + pkey(k), PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin), g->prio, g->gen, g->last_gc, GC_MARK(g), g->gc_gen); return true; #endif @@ -1049,7 +1049,8 @@ void bch_btree_sort_partial(struct btree *b, unsigned start) for (i = start; i <= b->nsets; i++) keys += b->sets[i].data->keys; - order = roundup_pow_of_two(__set_bytes(b->sets->data, keys)) / PAGE_SIZE; + order = roundup_pow_of_two(__set_bytes(b->sets->data, + keys)) / PAGE_SIZE; if (order) order = ilog2(order); } diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index af9ea4a96330..24b678059091 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -1021,8 +1021,8 @@ retry: goto err_free; if (!b) { - cache_bug(c, "Tried to allocate bucket" - " that was in btree cache"); + cache_bug(c, + "Tried to allocate bucket that was in btree cache"); __bkey_put(c, &k.key); goto retry; } diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 4b37ef2b80e5..141a5cac11ad 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -217,8 +217,8 @@ void bch_data_verify(struct search *s) if (memcmp(p1 + bv->bv_offset, p2 + bv->bv_offset, bv->bv_len)) - printk(KERN_ERR "bcache (%s): verify failed" - " at sector %llu\n", + printk(KERN_ERR + "bcache (%s): verify failed at sector %llu\n", bdevname(dc->bdev, name), (uint64_t) s->orig_bio->bi_sector); @@ -525,8 +525,8 @@ static ssize_t btree_fuzz(struct kobject *k, struct kobj_attribute *a, k = bkey_next(k), l = bkey_next(l)) if (bkey_cmp(k, l) || KEY_SIZE(k) != KEY_SIZE(l)) - pr_err("key %zi differs: %s " - "!= %s", (uint64_t *) k - i->d, + pr_err("key %zi differs: %s != %s", + (uint64_t *) k - i->d, pkey(k), pkey(l)); for (j = 0; j < 3; j++) { diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index c871ffaabbb0..21fd1010cf5d 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -293,9 +293,9 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list, BUG_ON(i->pin && atomic_read(i->pin) != 1); if (n != i->j.seq) - pr_err("journal entries %llu-%llu " - "missing! (replaying %llu-%llu)\n", - n, i->j.seq - 1, start, end); + pr_err( + "journal entries %llu-%llu missing! (replaying %llu-%llu)\n", + n, i->j.seq - 1, start, end); for (k = i->j.start; k < end(&i->j); @@ -439,7 +439,7 @@ static void do_journal_discard(struct cache *ca) bio_init(bio); bio->bi_sector = bucket_to_sector(ca->set, - ca->sb.d[ja->discard_idx]); + ca->sb.d[ja->discard_idx]); bio->bi_bdev = ca->bdev; bio->bi_rw = REQ_WRITE|REQ_DISCARD; bio->bi_max_vecs = 1; diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index c69fc92b02cf..e3ec0a550b00 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c @@ -183,6 +183,16 @@ err: if (!IS_ERR_OR_NULL(w->private)) closure_return(cl); } +static bool bucket_cmp(struct bucket *l, struct bucket *r) +{ + return GC_SECTORS_USED(l) < GC_SECTORS_USED(r); +} + +static unsigned bucket_heap_top(struct cache *ca) +{ + return GC_SECTORS_USED(heap_peek(&ca->heap)); +} + void bch_moving_gc(struct closure *cl) { struct cache_set *c = container_of(cl, struct cache_set, gc.cl); @@ -190,16 +200,6 @@ void bch_moving_gc(struct closure *cl) struct bucket *b; unsigned i; - bool bucket_cmp(struct bucket *l, struct bucket *r) - { - return GC_SECTORS_USED(l) < GC_SECTORS_USED(r); - } - - unsigned top(struct cache *ca) - { - return GC_SECTORS_USED(heap_peek(&ca->heap)); - } - if (!c->copy_gc_enabled) closure_return(cl); @@ -220,7 +220,7 @@ void bch_moving_gc(struct closure *cl) sectors_to_move += GC_SECTORS_USED(b); heap_add(&ca->heap, b, bucket_cmp); } else if (bucket_cmp(b, heap_peek(&ca->heap))) { - sectors_to_move -= top(ca); + sectors_to_move -= bucket_heap_top(ca); sectors_to_move += GC_SECTORS_USED(b); ca->heap.data[0] = b; @@ -233,7 +233,7 @@ void bch_moving_gc(struct closure *cl) sectors_to_move -= GC_SECTORS_USED(b); } - ca->gc_move_threshold = top(ca); + ca->gc_move_threshold = bucket_heap_top(ca); pr_debug("threshold %u", ca->gc_move_threshold); } diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 4f552de49aaa..dbda9646ef38 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -1117,11 +1117,13 @@ static void add_sequential(struct task_struct *t) t->sequential_io = 0; } -static void check_should_skip(struct cached_dev *dc, struct search *s) +static struct hlist_head *iohash(struct cached_dev *dc, uint64_t k) { - struct hlist_head *iohash(uint64_t k) - { return &dc->io_hash[hash_64(k, RECENT_IO_BITS)]; } + return &dc->io_hash[hash_64(k, RECENT_IO_BITS)]; +} +static void check_should_skip(struct cached_dev *dc, struct search *s) +{ struct cache_set *c = s->op.c; struct bio *bio = &s->bio.bio; @@ -1162,7 +1164,7 @@ static void check_should_skip(struct cached_dev *dc, struct search *s) spin_lock(&dc->io_lock); - hlist_for_each_entry(i, iohash(bio->bi_sector), hash) + hlist_for_each_entry(i, iohash(dc, bio->bi_sector), hash) if (i->last == bio->bi_sector && time_before(jiffies, i->jiffies)) goto found; @@ -1180,7 +1182,7 @@ found: s->task->sequential_io = i->sequential; hlist_del(&i->hash); - hlist_add_head(&i->hash, iohash(i->last)); + hlist_add_head(&i->hash, iohash(dc, i->last)); list_move_tail(&i->lru, &dc->io_lru); spin_unlock(&dc->io_lock); diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c index bf6cf9518c89..64e679449c2a 100644 --- a/drivers/md/bcache/stats.c +++ b/drivers/md/bcache/stats.c @@ -95,7 +95,8 @@ static KTYPE(bch_stats); static void scale_accounting(unsigned long data); -void bch_cache_accounting_init(struct cache_accounting *acc, struct closure *parent) +void bch_cache_accounting_init(struct cache_accounting *acc, + struct closure *parent) { kobject_init(&acc->total.kobj, &bch_stats_ktype); kobject_init(&acc->five_minute.kobj, &bch_stats_ktype); diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 7b8efc770871..484ae6c8f43a 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -526,7 +526,8 @@ void bch_prio_write(struct cache *ca) for (i = prio_buckets(ca) - 1; i >= 0; --i) { long bucket; struct prio_set *p = ca->disk_buckets; - struct bucket_disk *d = p->data, *end = d + prios_per_bucket(ca); + struct bucket_disk *d = p->data; + struct bucket_disk *end = d + prios_per_bucket(ca); for (b = ca->buckets + i * prios_per_bucket(ca); b < ca->buckets + ca->sb.nbuckets && d < end; @@ -865,8 +866,8 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) if (dc->sb.block_size < c->sb.block_size) { /* Will die */ - pr_err("Couldn't attach %s: block size " - "less than set's block size", buf); + pr_err("Couldn't attach %s: block size less than set's block size", + buf); return -EINVAL; } -- cgit v1.2.3 From 169ef1cf6171d35550fef85645b83b960e241cff Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 28 Mar 2013 12:50:55 -0600 Subject: bcache: Don't export utility code, prefix with bch_ Signed-off-by: Kent Overstreet Cc: linux-bcache@vger.kernel.org Signed-off-by: Jens Axboe --- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/bset.c | 4 ++-- drivers/md/bcache/btree.c | 18 +++++++-------- drivers/md/bcache/debug.c | 2 +- drivers/md/bcache/journal.c | 4 ++-- drivers/md/bcache/movinggc.c | 4 ++-- drivers/md/bcache/request.c | 14 +++++------ drivers/md/bcache/super.c | 18 +++++++-------- drivers/md/bcache/sysfs.c | 24 +++++++++---------- drivers/md/bcache/sysfs.h | 2 +- drivers/md/bcache/util.c | 38 +++++++++++------------------- drivers/md/bcache/util.h | 54 +++++++++++++++++++++---------------------- drivers/md/bcache/writeback.c | 6 ++--- 13 files changed, 89 insertions(+), 101 deletions(-) (limited to 'drivers/md/bcache/debug.c') diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index b2846e70149b..f05723565f17 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -1033,7 +1033,7 @@ static inline void bkey_init(struct bkey *k) * jset: The checksum is _always_ the first 8 bytes of these structs */ #define csum_set(i) \ - crc64(((void *) (i)) + sizeof(uint64_t), \ + bch_crc64(((void *) (i)) + sizeof(uint64_t), \ ((void *) end(i)) - (((void *) (i)) + sizeof(uint64_t))) /* Error handling macros */ diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c index 4dc9cb4efacb..0b33aac1f146 100644 --- a/drivers/md/bcache/bset.c +++ b/drivers/md/bcache/bset.c @@ -1026,7 +1026,7 @@ static void __btree_sort(struct btree *b, struct btree_iter *iter, if (!start) { spin_lock(&b->c->sort_time_lock); - time_stats_update(&b->c->sort_time, start_time); + bch_time_stats_update(&b->c->sort_time, start_time); spin_unlock(&b->c->sort_time_lock); } } @@ -1076,7 +1076,7 @@ void bch_btree_sort_into(struct btree *b, struct btree *new) btree_mergesort(b, new->sets->data, &iter, false, true); spin_lock(&b->c->sort_time_lock); - time_stats_update(&b->c->sort_time, start_time); + bch_time_stats_update(&b->c->sort_time, start_time); spin_unlock(&b->c->sort_time_lock); bkey_copy_key(&new->key, &b->key); diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 24b678059091..f2b2c653c5a5 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -129,7 +129,7 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i) uint64_t crc = b->key.ptr[0]; void *data = (void *) i + 8, *end = end(i); - crc = crc64_update(crc, data, end - data); + crc = bch_crc64_update(crc, data, end - data); return crc ^ 0xffffffffffffffff; } @@ -231,7 +231,7 @@ out: mutex_unlock(&b->c->fill_lock); spin_lock(&b->c->btree_read_time_lock); - time_stats_update(&b->c->btree_read_time, b->io_start_time); + bch_time_stats_update(&b->c->btree_read_time, b->io_start_time); spin_unlock(&b->c->btree_read_time_lock); smp_wmb(); /* read_done is our write lock */ @@ -259,7 +259,7 @@ void bch_btree_read(struct btree *b) b->bio->bi_rw = REQ_META|READ_SYNC; b->bio->bi_size = KEY_SIZE(&b->key) << 9; - bio_map(b->bio, b->sets[0].data); + bch_bio_map(b->bio, b->sets[0].data); pr_debug("%s", pbtree(b)); trace_bcache_btree_read(b->bio); @@ -327,12 +327,12 @@ static void do_btree_write(struct btree *b) btree_bio_init(b); b->bio->bi_rw = REQ_META|WRITE_SYNC; b->bio->bi_size = set_blocks(i, b->c) * block_bytes(b->c); - bio_map(b->bio, i); + bch_bio_map(b->bio, i); bkey_copy(&k.key, &b->key); SET_PTR_OFFSET(&k.key, 0, PTR_OFFSET(&k.key, 0) + bset_offset(b, i)); - if (!bio_alloc_pages(b->bio, GFP_NOIO)) { + if (!bch_bio_alloc_pages(b->bio, GFP_NOIO)) { int j; struct bio_vec *bv; void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); @@ -347,7 +347,7 @@ static void do_btree_write(struct btree *b) continue_at(cl, btree_write_done, NULL); } else { b->bio->bi_vcnt = 0; - bio_map(b->bio, i); + bch_bio_map(b->bio, i); trace_bcache_btree_write(b->bio); bch_submit_bbio(b->bio, b->c, &k.key, 0); @@ -815,7 +815,7 @@ retry: void bch_cannibalize_unlock(struct cache_set *c, struct closure *cl) { if (c->try_harder == cl) { - time_stats_update(&c->try_harder_time, c->try_harder_start); + bch_time_stats_update(&c->try_harder_time, c->try_harder_start); c->try_harder = NULL; __closure_wake_up(&c->try_wait); } @@ -1536,7 +1536,7 @@ static void bch_btree_gc(struct closure *cl) available = bch_btree_gc_finish(c); - time_stats_update(&c->btree_gc_time, start_time); + bch_time_stats_update(&c->btree_gc_time, start_time); stats.key_bytes *= sizeof(uint64_t); stats.dirty <<= 9; @@ -2007,7 +2007,7 @@ static int btree_split(struct btree *b, struct btree_op *op) rw_unlock(true, n1); btree_node_free(b, op); - time_stats_update(&b->c->btree_split_time, start_time); + bch_time_stats_update(&b->c->btree_split_time, start_time); return 0; err_free2: diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 141a5cac11ad..732234d9ec04 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -200,7 +200,7 @@ void bch_data_verify(struct search *s) if (!check) return; - if (bio_alloc_pages(check, GFP_NOIO)) + if (bch_bio_alloc_pages(check, GFP_NOIO)) goto out_put; check->bi_rw = READ_SYNC; diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index 21fd1010cf5d..b0a3d0577d13 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -54,7 +54,7 @@ reread: left = ca->sb.bucket_size - offset; bio->bi_end_io = journal_read_endio; bio->bi_private = &op->cl; - bio_map(bio, data); + bch_bio_map(bio, data); closure_bio_submit(bio, &op->cl, ca); closure_sync(&op->cl); @@ -621,7 +621,7 @@ static void journal_write_unlocked(struct closure *cl) bio->bi_end_io = journal_write_endio; bio->bi_private = w; - bio_map(bio, w->data); + bch_bio_map(bio, w->data); trace_bcache_journal_write(bio); bio_list_add(&list, bio); diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index e3ec0a550b00..8589512c972e 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c @@ -85,7 +85,7 @@ static void moving_init(struct moving_io *io) PAGE_SECTORS); bio->bi_private = &io->s.cl; bio->bi_io_vec = bio->bi_inline_vecs; - bio_map(bio, NULL); + bch_bio_map(bio, NULL); } static void write_moving(struct closure *cl) @@ -159,7 +159,7 @@ static void read_moving(struct closure *cl) bio->bi_rw = READ; bio->bi_end_io = read_moving_endio; - if (bio_alloc_pages(bio, GFP_KERNEL)) + if (bch_bio_alloc_pages(bio, GFP_KERNEL)) goto err; pr_debug("%s", pkey(&w->key)); diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index dbda9646ef38..83731dc36f34 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -58,8 +58,8 @@ static ssize_t cache_mode_read(struct cgroup *cgrp, struct cftype *cft, char __user *buf, size_t nbytes, loff_t *ppos) { char tmp[1024]; - int len = snprint_string_list(tmp, PAGE_SIZE, bch_cache_modes, - cgroup_to_bcache(cgrp)->cache_mode + 1); + int len = bch_snprint_string_list(tmp, PAGE_SIZE, bch_cache_modes, + cgroup_to_bcache(cgrp)->cache_mode + 1); if (len < 0) return len; @@ -70,7 +70,7 @@ static ssize_t cache_mode_read(struct cgroup *cgrp, struct cftype *cft, static int cache_mode_write(struct cgroup *cgrp, struct cftype *cft, const char *buf) { - int v = read_string_list(buf, bch_cache_modes); + int v = bch_read_string_list(buf, bch_cache_modes); if (v < 0) return v; @@ -205,7 +205,7 @@ static void bio_csum(struct bio *bio, struct bkey *k) bio_for_each_segment(bv, bio, i) { void *d = kmap(bv->bv_page) + bv->bv_offset; - csum = crc64_update(csum, d, bv->bv_len); + csum = bch_crc64_update(csum, d, bv->bv_len); kunmap(bv->bv_page); } @@ -835,7 +835,7 @@ static void request_read_done(struct closure *cl) s->op.cache_bio->bi_sector = s->cache_miss->bi_sector; s->op.cache_bio->bi_bdev = s->cache_miss->bi_bdev; s->op.cache_bio->bi_size = s->cache_bio_sectors << 9; - bio_map(s->op.cache_bio, NULL); + bch_bio_map(s->op.cache_bio, NULL); src = bio_iovec(s->op.cache_bio); dst = bio_iovec(s->cache_miss); @@ -962,8 +962,8 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s, if (!bch_btree_insert_check_key(b, &s->op, s->op.cache_bio)) goto out_put; - bio_map(s->op.cache_bio, NULL); - if (bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO)) + bch_bio_map(s->op.cache_bio, NULL); + if (bch_bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO)) goto out_put; s->cache_miss = miss; diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 484ae6c8f43a..f47ecb5cb318 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -142,7 +142,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev, goto err; err = "Bad UUID"; - if (is_zero(sb->uuid, 16)) + if (bch_is_zero(sb->uuid, 16)) goto err; err = "Unsupported superblock version"; @@ -170,7 +170,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev, goto out; err = "Bad UUID"; - if (is_zero(sb->set_uuid, 16)) + if (bch_is_zero(sb->set_uuid, 16)) goto err; err = "Bad cache device number in set"; @@ -218,7 +218,7 @@ static void __write_super(struct cache_sb *sb, struct bio *bio) bio->bi_sector = SB_SECTOR; bio->bi_rw = REQ_SYNC|REQ_META; bio->bi_size = SB_SIZE; - bio_map(bio, NULL); + bch_bio_map(bio, NULL); out->offset = cpu_to_le64(sb->offset); out->version = cpu_to_le64(sb->version); @@ -332,7 +332,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw, bio->bi_end_io = uuid_endio; bio->bi_private = cl; - bio_map(bio, c->uuids); + bch_bio_map(bio, c->uuids); bch_submit_bbio(bio, c, k, i); @@ -344,7 +344,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw, pkey(&c->uuid_bucket)); for (u = c->uuids; u < c->uuids + c->nr_uuids; u++) - if (!is_zero(u->uuid, 16)) + if (!bch_is_zero(u->uuid, 16)) pr_debug("Slot %zi: %pU: %s: 1st: %u last: %u inv: %u", u - c->uuids, u->uuid, u->label, u->first_reg, u->last_reg, u->invalidated); @@ -491,7 +491,7 @@ static void prio_io(struct cache *ca, uint64_t bucket, unsigned long rw) bio->bi_end_io = prio_endio; bio->bi_private = ca; - bio_map(bio, ca->disk_buckets); + bch_bio_map(bio, ca->disk_buckets); closure_bio_submit(bio, &ca->prio, ca); closure_sync(cl); @@ -538,7 +538,7 @@ void bch_prio_write(struct cache *ca) p->next_bucket = ca->prio_buckets[i + 1]; p->magic = pset_magic(ca); - p->csum = crc64(&p->magic, bucket_bytes(ca) - 8); + p->csum = bch_crc64(&p->magic, bucket_bytes(ca) - 8); bucket = bch_bucket_alloc(ca, WATERMARK_PRIO, &cl); BUG_ON(bucket == -1); @@ -585,7 +585,7 @@ static void prio_read(struct cache *ca, uint64_t bucket) prio_io(ca, bucket, READ_SYNC); - if (p->csum != crc64(&p->magic, bucket_bytes(ca) - 8)) + if (p->csum != bch_crc64(&p->magic, bucket_bytes(ca) - 8)) pr_warn("bad csum reading priorities"); if (p->magic != pset_magic(ca)) @@ -898,7 +898,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) sysfs_remove_file(&dc->kobj, &sysfs_attach); */ - if (is_zero(u->uuid, 16)) { + if (bch_is_zero(u->uuid, 16)) { struct closure cl; closure_init_stack(&cl); diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 5c7e77073b1f..4d9cca47e4c6 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -105,9 +105,9 @@ SHOW(__bch_cached_dev) #define var(stat) (dc->stat) if (attr == &sysfs_cache_mode) - return snprint_string_list(buf, PAGE_SIZE, - bch_cache_modes + 1, - BDEV_CACHE_MODE(&dc->sb)); + return bch_snprint_string_list(buf, PAGE_SIZE, + bch_cache_modes + 1, + BDEV_CACHE_MODE(&dc->sb)); sysfs_printf(data_csum, "%i", dc->disk.data_csum); var_printf(verify, "%i"); @@ -126,10 +126,10 @@ SHOW(__bch_cached_dev) char dirty[20]; char derivative[20]; char target[20]; - hprint(dirty, + bch_hprint(dirty, atomic_long_read(&dc->disk.sectors_dirty) << 9); - hprint(derivative, dc->writeback_rate_derivative << 9); - hprint(target, dc->writeback_rate_target << 9); + bch_hprint(derivative, dc->writeback_rate_derivative << 9); + bch_hprint(target, dc->writeback_rate_target << 9); return sprintf(buf, "rate:\t\t%u\n" @@ -202,7 +202,7 @@ STORE(__cached_dev) bch_cached_dev_run(dc); if (attr == &sysfs_cache_mode) { - ssize_t v = read_string_list(buf, bch_cache_modes + 1); + ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1); if (v < 0) return v; @@ -224,7 +224,7 @@ STORE(__cached_dev) } if (attr == &sysfs_attach) { - if (parse_uuid(buf, dc->sb.set_uuid) < 16) + if (bch_parse_uuid(buf, dc->sb.set_uuid) < 16) return -EINVAL; list_for_each_entry(c, &bch_cache_sets, list) { @@ -657,9 +657,9 @@ SHOW(__bch_cache) ((size_t) ca->sb.nbuckets)); if (attr == &sysfs_cache_replacement_policy) - return snprint_string_list(buf, PAGE_SIZE, - cache_replacement_policies, - CACHE_REPLACEMENT(&ca->sb)); + return bch_snprint_string_list(buf, PAGE_SIZE, + cache_replacement_policies, + CACHE_REPLACEMENT(&ca->sb)); if (attr == &sysfs_priority_stats) { int cmp(const void *l, const void *r) @@ -747,7 +747,7 @@ STORE(__bch_cache) } if (attr == &sysfs_cache_replacement_policy) { - ssize_t v = read_string_list(buf, cache_replacement_policies); + ssize_t v = bch_read_string_list(buf, cache_replacement_policies); if (v < 0) return v; diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h index 34e4ba1184fe..0526fe92a683 100644 --- a/drivers/md/bcache/sysfs.h +++ b/drivers/md/bcache/sysfs.h @@ -62,7 +62,7 @@ do { \ #define sysfs_hprint(file, val) \ do { \ if (attr == &sysfs_ ## file) { \ - ssize_t ret = hprint(buf, val); \ + ssize_t ret = bch_hprint(buf, val); \ strcat(buf, "\n"); \ return ret + 1; \ } \ diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index dcec2e4f84ad..22324d8b2840 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -19,7 +19,7 @@ #define simple_strtouint(c, end, base) simple_strtoul(c, end, base) #define STRTO_H(name, type) \ -int name ## _h(const char *cp, type *res) \ +int bch_ ## name ## _h(const char *cp, type *res) \ { \ int u = 0; \ char *e; \ @@ -67,14 +67,13 @@ int name ## _h(const char *cp, type *res) \ *res = i; \ return 0; \ } \ -EXPORT_SYMBOL_GPL(name ## _h); STRTO_H(strtoint, int) STRTO_H(strtouint, unsigned int) STRTO_H(strtoll, long long) STRTO_H(strtoull, unsigned long long) -ssize_t hprint(char *buf, int64_t v) +ssize_t bch_hprint(char *buf, int64_t v) { static const char units[] = "?kMGTPEZY"; char dec[3] = ""; @@ -93,9 +92,8 @@ ssize_t hprint(char *buf, int64_t v) return sprintf(buf, "%lli%s%c", v, dec, units[u]); } -EXPORT_SYMBOL_GPL(hprint); -ssize_t snprint_string_list(char *buf, size_t size, const char * const list[], +ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[], size_t selected) { char *out = buf; @@ -108,9 +106,8 @@ ssize_t snprint_string_list(char *buf, size_t size, const char * const list[], out[-1] = '\n'; return out - buf; } -EXPORT_SYMBOL_GPL(snprint_string_list); -ssize_t read_string_list(const char *buf, const char * const list[]) +ssize_t bch_read_string_list(const char *buf, const char * const list[]) { size_t i; char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL); @@ -130,9 +127,8 @@ ssize_t read_string_list(const char *buf, const char * const list[]) return i; } -EXPORT_SYMBOL_GPL(read_string_list); -bool is_zero(const char *p, size_t n) +bool bch_is_zero(const char *p, size_t n) { size_t i; @@ -141,9 +137,8 @@ bool is_zero(const char *p, size_t n) return false; return true; } -EXPORT_SYMBOL_GPL(is_zero); -int parse_uuid(const char *s, char *uuid) +int bch_parse_uuid(const char *s, char *uuid) { size_t i, j, x; memset(uuid, 0, 16); @@ -170,9 +165,8 @@ int parse_uuid(const char *s, char *uuid) } return i; } -EXPORT_SYMBOL_GPL(parse_uuid); -void time_stats_update(struct time_stats *stats, uint64_t start_time) +void bch_time_stats_update(struct time_stats *stats, uint64_t start_time) { uint64_t now = local_clock(); uint64_t duration = time_after64(now, start_time) @@ -195,9 +189,8 @@ void time_stats_update(struct time_stats *stats, uint64_t start_time) stats->last = now ?: 1; } -EXPORT_SYMBOL_GPL(time_stats_update); -unsigned next_delay(struct ratelimit *d, uint64_t done) +unsigned bch_next_delay(struct ratelimit *d, uint64_t done) { uint64_t now = local_clock(); @@ -207,9 +200,8 @@ unsigned next_delay(struct ratelimit *d, uint64_t done) ? div_u64(d->next - now, NSEC_PER_SEC / HZ) : 0; } -EXPORT_SYMBOL_GPL(next_delay); -void bio_map(struct bio *bio, void *base) +void bch_bio_map(struct bio *bio, void *base) { size_t size = bio->bi_size; struct bio_vec *bv = bio->bi_io_vec; @@ -235,9 +227,8 @@ start: bv->bv_len = min_t(size_t, PAGE_SIZE - bv->bv_offset, size -= bv->bv_len; } } -EXPORT_SYMBOL_GPL(bio_map); -int bio_alloc_pages(struct bio *bio, gfp_t gfp) +int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp) { int i; struct bio_vec *bv; @@ -253,7 +244,6 @@ int bio_alloc_pages(struct bio *bio, gfp_t gfp) return 0; } -EXPORT_SYMBOL_GPL(bio_alloc_pages); /* * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any @@ -365,7 +355,7 @@ static const uint64_t crc_table[256] = { 0x9AFCE626CE85B507 }; -uint64_t crc64_update(uint64_t crc, const void *_data, size_t len) +uint64_t bch_crc64_update(uint64_t crc, const void *_data, size_t len) { const unsigned char *data = _data; @@ -376,14 +366,12 @@ uint64_t crc64_update(uint64_t crc, const void *_data, size_t len) return crc; } -EXPORT_SYMBOL(crc64_update); -uint64_t crc64(const void *data, size_t len) +uint64_t bch_crc64(const void *data, size_t len) { uint64_t crc = 0xffffffffffffffff; - crc = crc64_update(crc, data, len); + crc = bch_crc64_update(crc, data, len); return crc ^ 0xffffffffffffffff; } -EXPORT_SYMBOL(crc64); diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index 56705fdcc149..577393e38c3a 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h @@ -307,42 +307,42 @@ do { \ #define ANYSINT_MAX(t) \ ((((t) 1 << (sizeof(t) * 8 - 2)) - (t) 1) * (t) 2 + (t) 1) -int strtoint_h(const char *, int *); -int strtouint_h(const char *, unsigned int *); -int strtoll_h(const char *, long long *); -int strtoull_h(const char *, unsigned long long *); +int bch_strtoint_h(const char *, int *); +int bch_strtouint_h(const char *, unsigned int *); +int bch_strtoll_h(const char *, long long *); +int bch_strtoull_h(const char *, unsigned long long *); -static inline int strtol_h(const char *cp, long *res) +static inline int bch_strtol_h(const char *cp, long *res) { #if BITS_PER_LONG == 32 - return strtoint_h(cp, (int *) res); + return bch_strtoint_h(cp, (int *) res); #else - return strtoll_h(cp, (long long *) res); + return bch_strtoll_h(cp, (long long *) res); #endif } -static inline int strtoul_h(const char *cp, long *res) +static inline int bch_strtoul_h(const char *cp, long *res) { #if BITS_PER_LONG == 32 - return strtouint_h(cp, (unsigned int *) res); + return bch_strtouint_h(cp, (unsigned int *) res); #else - return strtoull_h(cp, (unsigned long long *) res); + return bch_strtoull_h(cp, (unsigned long long *) res); #endif } #define strtoi_h(cp, res) \ (__builtin_types_compatible_p(typeof(*res), int) \ - ? strtoint_h(cp, (void *) res) \ + ? bch_strtoint_h(cp, (void *) res) \ : __builtin_types_compatible_p(typeof(*res), long) \ - ? strtol_h(cp, (void *) res) \ + ? bch_strtol_h(cp, (void *) res) \ : __builtin_types_compatible_p(typeof(*res), long long) \ - ? strtoll_h(cp, (void *) res) \ + ? bch_strtoll_h(cp, (void *) res) \ : __builtin_types_compatible_p(typeof(*res), unsigned int) \ - ? strtouint_h(cp, (void *) res) \ + ? bch_strtouint_h(cp, (void *) res) \ : __builtin_types_compatible_p(typeof(*res), unsigned long) \ - ? strtoul_h(cp, (void *) res) \ + ? bch_strtoul_h(cp, (void *) res) \ : __builtin_types_compatible_p(typeof(*res), unsigned long long)\ - ? strtoull_h(cp, (void *) res) : -EINVAL) + ? bch_strtoull_h(cp, (void *) res) : -EINVAL) #define strtoul_safe(cp, var) \ ({ \ @@ -379,15 +379,15 @@ static inline int strtoul_h(const char *cp, long *res) __builtin_types_compatible_p(typeof(var), const char *) \ ? "%s\n" : "%i\n", var) -ssize_t hprint(char *buf, int64_t v); +ssize_t bch_hprint(char *buf, int64_t v); -bool is_zero(const char *p, size_t n); -int parse_uuid(const char *s, char *uuid); +bool bch_is_zero(const char *p, size_t n); +int bch_parse_uuid(const char *s, char *uuid); -ssize_t snprint_string_list(char *buf, size_t size, const char * const list[], +ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[], size_t selected); -ssize_t read_string_list(const char *buf, const char * const list[]); +ssize_t bch_read_string_list(const char *buf, const char * const list[]); struct time_stats { /* @@ -400,7 +400,7 @@ struct time_stats { uint64_t last; }; -void time_stats_update(struct time_stats *stats, uint64_t time); +void bch_time_stats_update(struct time_stats *stats, uint64_t time); #define NSEC_PER_ns 1L #define NSEC_PER_us NSEC_PER_USEC @@ -462,7 +462,7 @@ static inline void ratelimit_reset(struct ratelimit *d) d->next = local_clock(); } -unsigned next_delay(struct ratelimit *d, uint64_t done); +unsigned bch_next_delay(struct ratelimit *d, uint64_t done); #define __DIV_SAFE(n, d, zero) \ ({ \ @@ -568,9 +568,9 @@ static inline unsigned fract_exp_two(unsigned x, unsigned fract_bits) #define bio_end(bio) ((bio)->bi_sector + bio_sectors(bio)) -void bio_map(struct bio *bio, void *base); +void bch_bio_map(struct bio *bio, void *base); -int bio_alloc_pages(struct bio *bio, gfp_t gfp); +int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp); static inline sector_t bdev_sectors(struct block_device *bdev) { @@ -583,7 +583,7 @@ do { \ bch_generic_make_request(bio, &(dev)->bio_split_hook); \ } while (0) -uint64_t crc64_update(uint64_t, const void *, size_t); -uint64_t crc64(const void *, size_t); +uint64_t bch_crc64_update(uint64_t, const void *, size_t); +uint64_t bch_crc64(const void *, size_t); #endif /* _BCACHE_UTIL_H */ diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index a80ee5373fd8..93e7e31a4bd3 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -95,7 +95,7 @@ static unsigned writeback_delay(struct cached_dev *dc, unsigned sectors) !dc->writeback_percent) return 0; - return next_delay(&dc->writeback_rate, sectors * 10000000ULL); + return bch_next_delay(&dc->writeback_rate, sectors * 10000000ULL); } /* Background writeback */ @@ -118,7 +118,7 @@ static void dirty_init(struct keybuf_key *w) bio->bi_max_vecs = DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS); bio->bi_private = w; bio->bi_io_vec = bio->bi_inline_vecs; - bio_map(bio, NULL); + bch_bio_map(bio, NULL); } static void refill_dirty(struct closure *cl) @@ -349,7 +349,7 @@ static void read_dirty(struct closure *cl) io->bio.bi_rw = READ; io->bio.bi_end_io = read_dirty_endio; - if (bio_alloc_pages(&io->bio, GFP_KERNEL)) + if (bch_bio_alloc_pages(&io->bio, GFP_KERNEL)) goto err_free; pr_debug("%s", pkey(&w->key)); -- cgit v1.2.3 From c19ed23a0b1848eca6b6f22c1ee233abe54d37f9 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 26 Mar 2013 13:49:02 -0700 Subject: bcache: Sparse fixes Signed-off-by: Kent Overstreet --- drivers/md/bcache/btree.c | 2 +- drivers/md/bcache/debug.c | 2 +- drivers/md/bcache/journal.c | 2 + drivers/md/bcache/util.c | 176 ++++++++++++++++++++++---------------------- 4 files changed, 92 insertions(+), 90 deletions(-) (limited to 'drivers/md/bcache/debug.c') diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index f2b2c653c5a5..767b3fbc2fbe 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -130,7 +130,7 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i) void *data = (void *) i + 8, *end = end(i); crc = bch_crc64_update(crc, data, end - data); - return crc ^ 0xffffffffffffffff; + return crc ^ 0xffffffffffffffffULL; } static void btree_bio_endio(struct bio *bio, int error) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 732234d9ec04..24a5a2fed6d3 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -82,7 +82,7 @@ struct keyprint_hack bch_pbtree(const struct btree *b) { struct keyprint_hack r; - snprintf(r.s, 40, "%li level %i/%i", PTR_BUCKET_NR(b->c, &b->key, 0), + snprintf(r.s, 40, "%zu level %i/%i", PTR_BUCKET_NR(b->c, &b->key, 0), b->level, b->c->root ? b->c->root->level : -1); return r; } diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index b0a3d0577d13..8c8dfdcd9d4c 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -563,6 +563,7 @@ static void journal_write_done(struct closure *cl) } static void journal_write_unlocked(struct closure *cl) + __releases(c->journal.lock) { struct cache_set *c = container_of(cl, struct cache_set, journal.io.cl); struct cache *ca; @@ -652,6 +653,7 @@ static void journal_write(struct closure *cl) } static void __journal_try_write(struct cache_set *c, bool noflush) + __releases(c->journal.lock) { struct closure *cl = &c->journal.io.cl; diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 22324d8b2840..a9619d880354 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -267,92 +267,92 @@ int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp) */ static const uint64_t crc_table[256] = { - 0x0000000000000000, 0x42F0E1EBA9EA3693, 0x85E1C3D753D46D26, - 0xC711223CFA3E5BB5, 0x493366450E42ECDF, 0x0BC387AEA7A8DA4C, - 0xCCD2A5925D9681F9, 0x8E224479F47CB76A, 0x9266CC8A1C85D9BE, - 0xD0962D61B56FEF2D, 0x17870F5D4F51B498, 0x5577EEB6E6BB820B, - 0xDB55AACF12C73561, 0x99A54B24BB2D03F2, 0x5EB4691841135847, - 0x1C4488F3E8F96ED4, 0x663D78FF90E185EF, 0x24CD9914390BB37C, - 0xE3DCBB28C335E8C9, 0xA12C5AC36ADFDE5A, 0x2F0E1EBA9EA36930, - 0x6DFEFF5137495FA3, 0xAAEFDD6DCD770416, 0xE81F3C86649D3285, - 0xF45BB4758C645C51, 0xB6AB559E258E6AC2, 0x71BA77A2DFB03177, - 0x334A9649765A07E4, 0xBD68D2308226B08E, 0xFF9833DB2BCC861D, - 0x388911E7D1F2DDA8, 0x7A79F00C7818EB3B, 0xCC7AF1FF21C30BDE, - 0x8E8A101488293D4D, 0x499B3228721766F8, 0x0B6BD3C3DBFD506B, - 0x854997BA2F81E701, 0xC7B97651866BD192, 0x00A8546D7C558A27, - 0x4258B586D5BFBCB4, 0x5E1C3D753D46D260, 0x1CECDC9E94ACE4F3, - 0xDBFDFEA26E92BF46, 0x990D1F49C77889D5, 0x172F5B3033043EBF, - 0x55DFBADB9AEE082C, 0x92CE98E760D05399, 0xD03E790CC93A650A, - 0xAA478900B1228E31, 0xE8B768EB18C8B8A2, 0x2FA64AD7E2F6E317, - 0x6D56AB3C4B1CD584, 0xE374EF45BF6062EE, 0xA1840EAE168A547D, - 0x66952C92ECB40FC8, 0x2465CD79455E395B, 0x3821458AADA7578F, - 0x7AD1A461044D611C, 0xBDC0865DFE733AA9, 0xFF3067B657990C3A, - 0x711223CFA3E5BB50, 0x33E2C2240A0F8DC3, 0xF4F3E018F031D676, - 0xB60301F359DBE0E5, 0xDA050215EA6C212F, 0x98F5E3FE438617BC, - 0x5FE4C1C2B9B84C09, 0x1D14202910527A9A, 0x93366450E42ECDF0, - 0xD1C685BB4DC4FB63, 0x16D7A787B7FAA0D6, 0x5427466C1E109645, - 0x4863CE9FF6E9F891, 0x0A932F745F03CE02, 0xCD820D48A53D95B7, - 0x8F72ECA30CD7A324, 0x0150A8DAF8AB144E, 0x43A04931514122DD, - 0x84B16B0DAB7F7968, 0xC6418AE602954FFB, 0xBC387AEA7A8DA4C0, - 0xFEC89B01D3679253, 0x39D9B93D2959C9E6, 0x7B2958D680B3FF75, - 0xF50B1CAF74CF481F, 0xB7FBFD44DD257E8C, 0x70EADF78271B2539, - 0x321A3E938EF113AA, 0x2E5EB66066087D7E, 0x6CAE578BCFE24BED, - 0xABBF75B735DC1058, 0xE94F945C9C3626CB, 0x676DD025684A91A1, - 0x259D31CEC1A0A732, 0xE28C13F23B9EFC87, 0xA07CF2199274CA14, - 0x167FF3EACBAF2AF1, 0x548F120162451C62, 0x939E303D987B47D7, - 0xD16ED1D631917144, 0x5F4C95AFC5EDC62E, 0x1DBC74446C07F0BD, - 0xDAAD56789639AB08, 0x985DB7933FD39D9B, 0x84193F60D72AF34F, - 0xC6E9DE8B7EC0C5DC, 0x01F8FCB784FE9E69, 0x43081D5C2D14A8FA, - 0xCD2A5925D9681F90, 0x8FDAB8CE70822903, 0x48CB9AF28ABC72B6, - 0x0A3B7B1923564425, 0x70428B155B4EAF1E, 0x32B26AFEF2A4998D, - 0xF5A348C2089AC238, 0xB753A929A170F4AB, 0x3971ED50550C43C1, - 0x7B810CBBFCE67552, 0xBC902E8706D82EE7, 0xFE60CF6CAF321874, - 0xE224479F47CB76A0, 0xA0D4A674EE214033, 0x67C58448141F1B86, - 0x253565A3BDF52D15, 0xAB1721DA49899A7F, 0xE9E7C031E063ACEC, - 0x2EF6E20D1A5DF759, 0x6C0603E6B3B7C1CA, 0xF6FAE5C07D3274CD, - 0xB40A042BD4D8425E, 0x731B26172EE619EB, 0x31EBC7FC870C2F78, - 0xBFC9838573709812, 0xFD39626EDA9AAE81, 0x3A28405220A4F534, - 0x78D8A1B9894EC3A7, 0x649C294A61B7AD73, 0x266CC8A1C85D9BE0, - 0xE17DEA9D3263C055, 0xA38D0B769B89F6C6, 0x2DAF4F0F6FF541AC, - 0x6F5FAEE4C61F773F, 0xA84E8CD83C212C8A, 0xEABE6D3395CB1A19, - 0x90C79D3FEDD3F122, 0xD2377CD44439C7B1, 0x15265EE8BE079C04, - 0x57D6BF0317EDAA97, 0xD9F4FB7AE3911DFD, 0x9B041A914A7B2B6E, - 0x5C1538ADB04570DB, 0x1EE5D94619AF4648, 0x02A151B5F156289C, - 0x4051B05E58BC1E0F, 0x87409262A28245BA, 0xC5B073890B687329, - 0x4B9237F0FF14C443, 0x0962D61B56FEF2D0, 0xCE73F427ACC0A965, - 0x8C8315CC052A9FF6, 0x3A80143F5CF17F13, 0x7870F5D4F51B4980, - 0xBF61D7E80F251235, 0xFD913603A6CF24A6, 0x73B3727A52B393CC, - 0x31439391FB59A55F, 0xF652B1AD0167FEEA, 0xB4A25046A88DC879, - 0xA8E6D8B54074A6AD, 0xEA16395EE99E903E, 0x2D071B6213A0CB8B, - 0x6FF7FA89BA4AFD18, 0xE1D5BEF04E364A72, 0xA3255F1BE7DC7CE1, - 0x64347D271DE22754, 0x26C49CCCB40811C7, 0x5CBD6CC0CC10FAFC, - 0x1E4D8D2B65FACC6F, 0xD95CAF179FC497DA, 0x9BAC4EFC362EA149, - 0x158E0A85C2521623, 0x577EEB6E6BB820B0, 0x906FC95291867B05, - 0xD29F28B9386C4D96, 0xCEDBA04AD0952342, 0x8C2B41A1797F15D1, - 0x4B3A639D83414E64, 0x09CA82762AAB78F7, 0x87E8C60FDED7CF9D, - 0xC51827E4773DF90E, 0x020905D88D03A2BB, 0x40F9E43324E99428, - 0x2CFFE7D5975E55E2, 0x6E0F063E3EB46371, 0xA91E2402C48A38C4, - 0xEBEEC5E96D600E57, 0x65CC8190991CB93D, 0x273C607B30F68FAE, - 0xE02D4247CAC8D41B, 0xA2DDA3AC6322E288, 0xBE992B5F8BDB8C5C, - 0xFC69CAB42231BACF, 0x3B78E888D80FE17A, 0x7988096371E5D7E9, - 0xF7AA4D1A85996083, 0xB55AACF12C735610, 0x724B8ECDD64D0DA5, - 0x30BB6F267FA73B36, 0x4AC29F2A07BFD00D, 0x08327EC1AE55E69E, - 0xCF235CFD546BBD2B, 0x8DD3BD16FD818BB8, 0x03F1F96F09FD3CD2, - 0x41011884A0170A41, 0x86103AB85A2951F4, 0xC4E0DB53F3C36767, - 0xD8A453A01B3A09B3, 0x9A54B24BB2D03F20, 0x5D45907748EE6495, - 0x1FB5719CE1045206, 0x919735E51578E56C, 0xD367D40EBC92D3FF, - 0x1476F63246AC884A, 0x568617D9EF46BED9, 0xE085162AB69D5E3C, - 0xA275F7C11F7768AF, 0x6564D5FDE549331A, 0x279434164CA30589, - 0xA9B6706FB8DFB2E3, 0xEB46918411358470, 0x2C57B3B8EB0BDFC5, - 0x6EA7525342E1E956, 0x72E3DAA0AA188782, 0x30133B4B03F2B111, - 0xF7021977F9CCEAA4, 0xB5F2F89C5026DC37, 0x3BD0BCE5A45A6B5D, - 0x79205D0E0DB05DCE, 0xBE317F32F78E067B, 0xFCC19ED95E6430E8, - 0x86B86ED5267CDBD3, 0xC4488F3E8F96ED40, 0x0359AD0275A8B6F5, - 0x41A94CE9DC428066, 0xCF8B0890283E370C, 0x8D7BE97B81D4019F, - 0x4A6ACB477BEA5A2A, 0x089A2AACD2006CB9, 0x14DEA25F3AF9026D, - 0x562E43B4931334FE, 0x913F6188692D6F4B, 0xD3CF8063C0C759D8, - 0x5DEDC41A34BBEEB2, 0x1F1D25F19D51D821, 0xD80C07CD676F8394, - 0x9AFCE626CE85B507 + 0x0000000000000000ULL, 0x42F0E1EBA9EA3693ULL, 0x85E1C3D753D46D26ULL, + 0xC711223CFA3E5BB5ULL, 0x493366450E42ECDFULL, 0x0BC387AEA7A8DA4CULL, + 0xCCD2A5925D9681F9ULL, 0x8E224479F47CB76AULL, 0x9266CC8A1C85D9BEULL, + 0xD0962D61B56FEF2DULL, 0x17870F5D4F51B498ULL, 0x5577EEB6E6BB820BULL, + 0xDB55AACF12C73561ULL, 0x99A54B24BB2D03F2ULL, 0x5EB4691841135847ULL, + 0x1C4488F3E8F96ED4ULL, 0x663D78FF90E185EFULL, 0x24CD9914390BB37CULL, + 0xE3DCBB28C335E8C9ULL, 0xA12C5AC36ADFDE5AULL, 0x2F0E1EBA9EA36930ULL, + 0x6DFEFF5137495FA3ULL, 0xAAEFDD6DCD770416ULL, 0xE81F3C86649D3285ULL, + 0xF45BB4758C645C51ULL, 0xB6AB559E258E6AC2ULL, 0x71BA77A2DFB03177ULL, + 0x334A9649765A07E4ULL, 0xBD68D2308226B08EULL, 0xFF9833DB2BCC861DULL, + 0x388911E7D1F2DDA8ULL, 0x7A79F00C7818EB3BULL, 0xCC7AF1FF21C30BDEULL, + 0x8E8A101488293D4DULL, 0x499B3228721766F8ULL, 0x0B6BD3C3DBFD506BULL, + 0x854997BA2F81E701ULL, 0xC7B97651866BD192ULL, 0x00A8546D7C558A27ULL, + 0x4258B586D5BFBCB4ULL, 0x5E1C3D753D46D260ULL, 0x1CECDC9E94ACE4F3ULL, + 0xDBFDFEA26E92BF46ULL, 0x990D1F49C77889D5ULL, 0x172F5B3033043EBFULL, + 0x55DFBADB9AEE082CULL, 0x92CE98E760D05399ULL, 0xD03E790CC93A650AULL, + 0xAA478900B1228E31ULL, 0xE8B768EB18C8B8A2ULL, 0x2FA64AD7E2F6E317ULL, + 0x6D56AB3C4B1CD584ULL, 0xE374EF45BF6062EEULL, 0xA1840EAE168A547DULL, + 0x66952C92ECB40FC8ULL, 0x2465CD79455E395BULL, 0x3821458AADA7578FULL, + 0x7AD1A461044D611CULL, 0xBDC0865DFE733AA9ULL, 0xFF3067B657990C3AULL, + 0x711223CFA3E5BB50ULL, 0x33E2C2240A0F8DC3ULL, 0xF4F3E018F031D676ULL, + 0xB60301F359DBE0E5ULL, 0xDA050215EA6C212FULL, 0x98F5E3FE438617BCULL, + 0x5FE4C1C2B9B84C09ULL, 0x1D14202910527A9AULL, 0x93366450E42ECDF0ULL, + 0xD1C685BB4DC4FB63ULL, 0x16D7A787B7FAA0D6ULL, 0x5427466C1E109645ULL, + 0x4863CE9FF6E9F891ULL, 0x0A932F745F03CE02ULL, 0xCD820D48A53D95B7ULL, + 0x8F72ECA30CD7A324ULL, 0x0150A8DAF8AB144EULL, 0x43A04931514122DDULL, + 0x84B16B0DAB7F7968ULL, 0xC6418AE602954FFBULL, 0xBC387AEA7A8DA4C0ULL, + 0xFEC89B01D3679253ULL, 0x39D9B93D2959C9E6ULL, 0x7B2958D680B3FF75ULL, + 0xF50B1CAF74CF481FULL, 0xB7FBFD44DD257E8CULL, 0x70EADF78271B2539ULL, + 0x321A3E938EF113AAULL, 0x2E5EB66066087D7EULL, 0x6CAE578BCFE24BEDULL, + 0xABBF75B735DC1058ULL, 0xE94F945C9C3626CBULL, 0x676DD025684A91A1ULL, + 0x259D31CEC1A0A732ULL, 0xE28C13F23B9EFC87ULL, 0xA07CF2199274CA14ULL, + 0x167FF3EACBAF2AF1ULL, 0x548F120162451C62ULL, 0x939E303D987B47D7ULL, + 0xD16ED1D631917144ULL, 0x5F4C95AFC5EDC62EULL, 0x1DBC74446C07F0BDULL, + 0xDAAD56789639AB08ULL, 0x985DB7933FD39D9BULL, 0x84193F60D72AF34FULL, + 0xC6E9DE8B7EC0C5DCULL, 0x01F8FCB784FE9E69ULL, 0x43081D5C2D14A8FAULL, + 0xCD2A5925D9681F90ULL, 0x8FDAB8CE70822903ULL, 0x48CB9AF28ABC72B6ULL, + 0x0A3B7B1923564425ULL, 0x70428B155B4EAF1EULL, 0x32B26AFEF2A4998DULL, + 0xF5A348C2089AC238ULL, 0xB753A929A170F4ABULL, 0x3971ED50550C43C1ULL, + 0x7B810CBBFCE67552ULL, 0xBC902E8706D82EE7ULL, 0xFE60CF6CAF321874ULL, + 0xE224479F47CB76A0ULL, 0xA0D4A674EE214033ULL, 0x67C58448141F1B86ULL, + 0x253565A3BDF52D15ULL, 0xAB1721DA49899A7FULL, 0xE9E7C031E063ACECULL, + 0x2EF6E20D1A5DF759ULL, 0x6C0603E6B3B7C1CAULL, 0xF6FAE5C07D3274CDULL, + 0xB40A042BD4D8425EULL, 0x731B26172EE619EBULL, 0x31EBC7FC870C2F78ULL, + 0xBFC9838573709812ULL, 0xFD39626EDA9AAE81ULL, 0x3A28405220A4F534ULL, + 0x78D8A1B9894EC3A7ULL, 0x649C294A61B7AD73ULL, 0x266CC8A1C85D9BE0ULL, + 0xE17DEA9D3263C055ULL, 0xA38D0B769B89F6C6ULL, 0x2DAF4F0F6FF541ACULL, + 0x6F5FAEE4C61F773FULL, 0xA84E8CD83C212C8AULL, 0xEABE6D3395CB1A19ULL, + 0x90C79D3FEDD3F122ULL, 0xD2377CD44439C7B1ULL, 0x15265EE8BE079C04ULL, + 0x57D6BF0317EDAA97ULL, 0xD9F4FB7AE3911DFDULL, 0x9B041A914A7B2B6EULL, + 0x5C1538ADB04570DBULL, 0x1EE5D94619AF4648ULL, 0x02A151B5F156289CULL, + 0x4051B05E58BC1E0FULL, 0x87409262A28245BAULL, 0xC5B073890B687329ULL, + 0x4B9237F0FF14C443ULL, 0x0962D61B56FEF2D0ULL, 0xCE73F427ACC0A965ULL, + 0x8C8315CC052A9FF6ULL, 0x3A80143F5CF17F13ULL, 0x7870F5D4F51B4980ULL, + 0xBF61D7E80F251235ULL, 0xFD913603A6CF24A6ULL, 0x73B3727A52B393CCULL, + 0x31439391FB59A55FULL, 0xF652B1AD0167FEEAULL, 0xB4A25046A88DC879ULL, + 0xA8E6D8B54074A6ADULL, 0xEA16395EE99E903EULL, 0x2D071B6213A0CB8BULL, + 0x6FF7FA89BA4AFD18ULL, 0xE1D5BEF04E364A72ULL, 0xA3255F1BE7DC7CE1ULL, + 0x64347D271DE22754ULL, 0x26C49CCCB40811C7ULL, 0x5CBD6CC0CC10FAFCULL, + 0x1E4D8D2B65FACC6FULL, 0xD95CAF179FC497DAULL, 0x9BAC4EFC362EA149ULL, + 0x158E0A85C2521623ULL, 0x577EEB6E6BB820B0ULL, 0x906FC95291867B05ULL, + 0xD29F28B9386C4D96ULL, 0xCEDBA04AD0952342ULL, 0x8C2B41A1797F15D1ULL, + 0x4B3A639D83414E64ULL, 0x09CA82762AAB78F7ULL, 0x87E8C60FDED7CF9DULL, + 0xC51827E4773DF90EULL, 0x020905D88D03A2BBULL, 0x40F9E43324E99428ULL, + 0x2CFFE7D5975E55E2ULL, 0x6E0F063E3EB46371ULL, 0xA91E2402C48A38C4ULL, + 0xEBEEC5E96D600E57ULL, 0x65CC8190991CB93DULL, 0x273C607B30F68FAEULL, + 0xE02D4247CAC8D41BULL, 0xA2DDA3AC6322E288ULL, 0xBE992B5F8BDB8C5CULL, + 0xFC69CAB42231BACFULL, 0x3B78E888D80FE17AULL, 0x7988096371E5D7E9ULL, + 0xF7AA4D1A85996083ULL, 0xB55AACF12C735610ULL, 0x724B8ECDD64D0DA5ULL, + 0x30BB6F267FA73B36ULL, 0x4AC29F2A07BFD00DULL, 0x08327EC1AE55E69EULL, + 0xCF235CFD546BBD2BULL, 0x8DD3BD16FD818BB8ULL, 0x03F1F96F09FD3CD2ULL, + 0x41011884A0170A41ULL, 0x86103AB85A2951F4ULL, 0xC4E0DB53F3C36767ULL, + 0xD8A453A01B3A09B3ULL, 0x9A54B24BB2D03F20ULL, 0x5D45907748EE6495ULL, + 0x1FB5719CE1045206ULL, 0x919735E51578E56CULL, 0xD367D40EBC92D3FFULL, + 0x1476F63246AC884AULL, 0x568617D9EF46BED9ULL, 0xE085162AB69D5E3CULL, + 0xA275F7C11F7768AFULL, 0x6564D5FDE549331AULL, 0x279434164CA30589ULL, + 0xA9B6706FB8DFB2E3ULL, 0xEB46918411358470ULL, 0x2C57B3B8EB0BDFC5ULL, + 0x6EA7525342E1E956ULL, 0x72E3DAA0AA188782ULL, 0x30133B4B03F2B111ULL, + 0xF7021977F9CCEAA4ULL, 0xB5F2F89C5026DC37ULL, 0x3BD0BCE5A45A6B5DULL, + 0x79205D0E0DB05DCEULL, 0xBE317F32F78E067BULL, 0xFCC19ED95E6430E8ULL, + 0x86B86ED5267CDBD3ULL, 0xC4488F3E8F96ED40ULL, 0x0359AD0275A8B6F5ULL, + 0x41A94CE9DC428066ULL, 0xCF8B0890283E370CULL, 0x8D7BE97B81D4019FULL, + 0x4A6ACB477BEA5A2AULL, 0x089A2AACD2006CB9ULL, 0x14DEA25F3AF9026DULL, + 0x562E43B4931334FEULL, 0x913F6188692D6F4BULL, 0xD3CF8063C0C759D8ULL, + 0x5DEDC41A34BBEEB2ULL, 0x1F1D25F19D51D821ULL, 0xD80C07CD676F8394ULL, + 0x9AFCE626CE85B507ULL, }; uint64_t bch_crc64_update(uint64_t crc, const void *_data, size_t len) @@ -369,9 +369,9 @@ uint64_t bch_crc64_update(uint64_t crc, const void *_data, size_t len) uint64_t bch_crc64(const void *data, size_t len) { - uint64_t crc = 0xffffffffffffffff; + uint64_t crc = 0xffffffffffffffffULL; crc = bch_crc64_update(crc, data, len); - return crc ^ 0xffffffffffffffff; + return crc ^ 0xffffffffffffffffULL; } -- cgit v1.2.3 From cef5279735d3f6f0243e626963e6d5c84efade0a Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 5 Apr 2013 14:20:29 -0700 Subject: bcache: Disable broken btree fuzz tester Reported-by: Signed-off-by: Kent Overstreet --- drivers/md/bcache/debug.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/md/bcache/debug.c') diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 24a5a2fed6d3..89fd5204924e 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -409,7 +409,9 @@ void bch_debug_init_cache_set(struct cache_set *c) #endif -#ifdef CONFIG_BCACHE_DEBUG +/* Fuzz tester has rotted: */ +#if 0 + static ssize_t btree_fuzz(struct kobject *k, struct kobj_attribute *a, const char *buffer, size_t size) { @@ -552,7 +554,7 @@ void bch_debug_exit(void) int __init bch_debug_init(struct kobject *kobj) { int ret = 0; -#ifdef CONFIG_BCACHE_DEBUG +#if 0 ret = sysfs_create_file(kobj, &ksysfs_fuzz.attr); if (ret) return ret; -- cgit v1.2.3