On 4/19/19 6:05 PM, Coly Li wrote:
In btree_flush_write(), iterating all cached btree nodes and adding them into ordered heap c->flush_btree takes quite long time. In order to protect ordered heap c->flush_btree, spin lock c->journal.lock is held for all the iteration and heap ordering. When journal space is fully occupied, btree_flush_write() might be called frequently, if the cached btree node iteration takes too much time, kenrel will complain that normal journal kworkers are blocked too long. Of cause write performance drops at this moment. This patch introduces a new spin lock member in struct journal, named flush_write_lock. This lock is only used in btree_flush_write() and protect the ordered heap c->flush_btree during all the cached btree node iteration. Then there won't be lock contention on c->journal.lock. After this fix, when journal space is fully occupied, it is very rare to observe the journal kworker blocking timeout warning. Signed-off-by: Coly Li <colyli@xxxxxxx> --- drivers/md/bcache/journal.c | 5 +++-- drivers/md/bcache/journal.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Hannes Reinecke <hare@xxxxxxxx> Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@xxxxxxx +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)