aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/btree.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-09-11 01:53:34 -0400
committerKent Overstreet <kmo@daterainc.com>2014-01-08 16:05:12 -0500
commit67539e85289c14a76a1c4162613d14a5f05a0027 (patch)
tree7650b78775bf7b9f2b92113606d92a4a838a6753 /drivers/md/bcache/btree.c
parent911c9610099f26e9e6ea3d1962ce24f53890b163 (diff)
bcache: Add struct bset_sort_state
More disentangling bset.c from the rest of the bcache code - soon, the sorting routines won't have any dependencies on any outside structs. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/btree.c')
-rw-r--r--drivers/md/bcache/btree.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index e1e36e761724..78ba0b67ac16 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -263,7 +263,7 @@ void bch_btree_node_read_done(struct btree *b)
263 if (i->seq == b->sets[0].data->seq) 263 if (i->seq == b->sets[0].data->seq)
264 goto err; 264 goto err;
265 265
266 bch_btree_sort_and_fix_extents(b, iter); 266 bch_btree_sort_and_fix_extents(b, iter, &b->c->sort);
267 267
268 i = b->sets[0].data; 268 i = b->sets[0].data;
269 err = "short btree key"; 269 err = "short btree key";
@@ -476,7 +476,11 @@ void bch_btree_node_write(struct btree *b, struct closure *parent)
476 atomic_long_add(set_blocks(i, b->c) * b->c->sb.block_size, 476 atomic_long_add(set_blocks(i, b->c) * b->c->sb.block_size,
477 &PTR_CACHE(b->c, &b->key, 0)->btree_sectors_written); 477 &PTR_CACHE(b->c, &b->key, 0)->btree_sectors_written);
478 478
479 bch_btree_sort_lazy(b); 479 /* If not a leaf node, always sort */
480 if (b->level && b->nsets)
481 bch_btree_sort(b, &b->c->sort);
482 else
483 bch_btree_sort_lazy(b, &b->c->sort);
480 484
481 /* 485 /*
482 * do verify if there was more than one set initially (i.e. we did a 486 * do verify if there was more than one set initially (i.e. we did a
@@ -1125,8 +1129,10 @@ err:
1125static struct btree *btree_node_alloc_replacement(struct btree *b, bool wait) 1129static struct btree *btree_node_alloc_replacement(struct btree *b, bool wait)
1126{ 1130{
1127 struct btree *n = bch_btree_node_alloc(b->c, b->level, wait); 1131 struct btree *n = bch_btree_node_alloc(b->c, b->level, wait);
1128 if (!IS_ERR_OR_NULL(n)) 1132 if (!IS_ERR_OR_NULL(n)) {
1129 bch_btree_sort_into(b, n); 1133 bch_btree_sort_into(b, n, &b->c->sort);
1134 bkey_copy_key(&n->key, &b->key);
1135 }
1130 1136
1131 return n; 1137 return n;
1132} 1138}