提交 5775e213 编写于 作者: K Kent Overstreet

bcache: Performance fix for when journal entry is full

We were unnecessarily waiting on a journal write to complete when we just needed
to start a journal write and start setting up the next one.
Signed-off-by: NKent Overstreet <kmo@daterainc.com>
上级 b3fa7e77
...@@ -673,6 +673,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c, ...@@ -673,6 +673,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c,
{ {
size_t sectors; size_t sectors;
struct closure cl; struct closure cl;
bool wait = false;
closure_init_stack(&cl); closure_init_stack(&cl);
...@@ -689,9 +690,12 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c, ...@@ -689,9 +690,12 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c,
PAGE_SECTORS << JSET_BITS)) PAGE_SECTORS << JSET_BITS))
return w; return w;
/* XXX: tracepoint */ if (wait)
closure_wait(&c->journal.wait, &cl);
if (!journal_full(&c->journal)) { if (!journal_full(&c->journal)) {
trace_bcache_journal_entry_full(c); if (wait)
trace_bcache_journal_entry_full(c);
/* /*
* XXX: If we were inserting so many keys that they * XXX: If we were inserting so many keys that they
...@@ -701,12 +705,11 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c, ...@@ -701,12 +705,11 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c,
*/ */
BUG_ON(!w->data->keys); BUG_ON(!w->data->keys);
closure_wait(&w->wait, &cl);
journal_try_write(c); /* unlocks */ journal_try_write(c); /* unlocks */
} else { } else {
trace_bcache_journal_full(c); if (wait)
trace_bcache_journal_full(c);
closure_wait(&c->journal.wait, &cl);
journal_reclaim(c); journal_reclaim(c);
spin_unlock(&c->journal.lock); spin_unlock(&c->journal.lock);
...@@ -715,6 +718,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c, ...@@ -715,6 +718,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c,
closure_sync(&cl); closure_sync(&cl);
spin_lock(&c->journal.lock); spin_lock(&c->journal.lock);
wait = true;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册