summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-07-23 20:48:29 -0700
committerKent Overstreet <kmo@daterainc.com>2013-11-10 21:56:36 -0800
commitf269af5a078302712de8ee70d273eba2eb4485ca (patch)
tree789f938bd0609edc4e4db96b4e13dbe676a466c5 /drivers
parent0eacac22034ca21c73fe49e800d0b938b2047250 (diff)
bcache: Add btree_node_write_sync()
More refactoring - mostly making the interfaces more explicit about what we actually want to do. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/bcache/btree.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 773b0e929ff..7d6204c4184 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -474,6 +474,15 @@ void bch_btree_node_write(struct btree *b, struct closure *parent)
bch_bset_init_next(b);
}
+static void bch_btree_node_write_sync(struct btree *b)
+{
+ struct closure cl;
+
+ closure_init_stack(&cl);
+ bch_btree_node_write(b, &cl);
+ closure_sync(&cl);
+}
+
static void btree_node_write_work(struct work_struct *w)
{
struct btree *b = container_of(to_delayed_work(w), struct btree, work);
@@ -655,10 +664,8 @@ static int mca_reap(struct btree *b, unsigned min_order, bool flush)
return -ENOMEM;
}
- if (btree_node_dirty(b)) {
- bch_btree_node_write(b, &cl);
- closure_sync(&cl);
- }
+ if (btree_node_dirty(b))
+ bch_btree_node_write_sync(b);
/* wait for any in flight btree write */
closure_wait_event(&b->io.wait, &cl,
@@ -1411,9 +1418,6 @@ static int bch_btree_gc_root(struct btree *b, struct btree_op *op,
struct btree *n = NULL;
unsigned keys = 0;
int ret = 0, stale = btree_gc_mark_node(b, &keys, gc);
- struct closure cl;
-
- closure_init_stack(&cl);
if (b->level || stale > 10)
n = btree_node_alloc_replacement(b);
@@ -1424,12 +1428,10 @@ static int bch_btree_gc_root(struct btree *b, struct btree_op *op,
if (b->level)
ret = btree_gc_recurse(b, op, writes, gc);
- if (!b->written || btree_node_dirty(b)) {
- bch_btree_node_write(b, n ? &cl : NULL);
- }
+ if (!b->written || btree_node_dirty(b))
+ bch_btree_node_write_sync(b);
if (!IS_ERR_OR_NULL(n)) {
- closure_sync(&cl);
bch_btree_set_root(b);
btree_node_free(n);
rw_unlock(true, b);
@@ -2104,15 +2106,10 @@ static int bch_btree_insert_node(struct btree *b, struct btree_op *op,
if (bch_btree_insert_keys(b, op, insert_keys,
replace_key)) {
- if (!b->level) {
+ if (!b->level)
bch_btree_leaf_dirty(b, journal_ref);
- } else {
- struct closure cl;
-
- closure_init_stack(&cl);
- bch_btree_node_write(b, &cl);
- closure_sync(&cl);
- }
+ else
+ bch_btree_node_write_sync(b);
}
}
} while (!bch_keylist_empty(&split_keys));