diff options
-rw-r--r-- | drivers/md/bcache/btree_cache.c | 12 | ||||
-rw-r--r-- | drivers/md/bcache/btree_io.c | 5 | ||||
-rw-r--r-- | drivers/md/bcache/debug.c | 33 |
3 files changed, 28 insertions, 22 deletions
diff --git a/drivers/md/bcache/btree_cache.c b/drivers/md/bcache/btree_cache.c index 49d87cccaefe..0fd92253d376 100644 --- a/drivers/md/bcache/btree_cache.c +++ b/drivers/md/bcache/btree_cache.c @@ -163,10 +163,16 @@ static int mca_reap_notrace(struct cache_set *c, struct btree *b, bool flush) /* * Using the underscore version because we don't want to compact bsets - * after the write, since this node is about to be evicted: + * after the write, since this node is about to be evicted - unless + * btree verify mode is enabled, since it runs out of the post write + * cleanup: */ - if (btree_node_dirty(b)) - __bch_btree_node_write(c, b, NULL, SIX_LOCK_read, -1); + if (btree_node_dirty(b)) { + if (verify_btree_ondisk(c)) + bch_btree_node_write(c, b, NULL, SIX_LOCK_intent, -1); + else + __bch_btree_node_write(c, b, NULL, SIX_LOCK_read, -1); + } /* wait for any in flight btree write */ wait_on_bit_io(&b->flags, BTREE_NODE_write_in_flight, diff --git a/drivers/md/bcache/btree_io.c b/drivers/md/bcache/btree_io.c index 4b5c4de6b256..84584f8263db 100644 --- a/drivers/md/bcache/btree_io.c +++ b/drivers/md/bcache/btree_io.c @@ -762,9 +762,6 @@ void bch_btree_init_next(struct cache_set *c, struct btree *b, did_sort = btree_node_compact(c, b, iter); - if (did_sort && b->keys.nsets == 1) - bch_btree_verify(c, b); - bne = want_new_bset(c, b); if (bne) bch_bset_init_next(&b->keys, &bne->keys); @@ -1438,6 +1435,8 @@ bool bch_btree_post_write_cleanup(struct cache_set *c, struct btree *b) for_each_bset(&b->keys, t) set_needs_whiteout(t->data); + bch_btree_verify(c, b); + /* * If later we don't unconditionally sort down to a single bset, we have * to ensure this is still true: diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index cdbd37ce6b32..f932cc9999c3 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -94,7 +94,7 @@ void __bch_btree_verify(struct cache_set *c, struct btree *b) memcmp(inmemory->start, sorted->start, (void *) bset_bkey_last(inmemory) - (void *) inmemory->start)) { - unsigned block = 0; + unsigned offset = 0, sectors; struct bset *i; unsigned j; @@ -106,31 +106,32 @@ void __bch_btree_verify(struct cache_set *c, struct btree *b) printk(KERN_ERR "*** read back in:\n"); bch_dump_bset(&v->keys, sorted, 0); - while (block < btree_blocks(c)) { - if (!b->written) { + while (offset < b->written) { + if (!offset ) { i = &n_ondisk->keys; - block += __set_blocks(n_ondisk, - le16_to_cpu(n_ondisk->keys.u64s), - block_bytes(c)); + sectors = __set_blocks(n_ondisk, + le16_to_cpu(n_ondisk->keys.u64s), + block_bytes(c)) << + c->block_bits; } else { struct btree_node_entry *bne = - (void *) n_ondisk + - (block << (c->block_bits + 9)); + (void *) n_ondisk + (offset << 9); i = &bne->keys; - block += __set_blocks(bne, - le16_to_cpu(bne->keys.u64s), - block_bytes(c)); + sectors = __set_blocks(bne, + le16_to_cpu(bne->keys.u64s), + block_bytes(c)) << + c->block_bits; } - if (i->seq != n_ondisk->keys.seq) - break; + printk(KERN_ERR "*** on disk block %u:\n", offset); + bch_dump_bset(&b->keys, i, offset); - printk(KERN_ERR "*** on disk block %u:\n", block); - bch_dump_bset(&b->keys, i, block); + offset += sectors; } - printk(KERN_ERR "*** block %u not written\n", block); + printk(KERN_ERR "*** block %u/%u not written\n", + offset >> c->block_bits, btree_blocks(c)); for (j = 0; j < le16_to_cpu(inmemory->u64s); j++) if (inmemory->_data[j] != sorted->_data[j]) |