bcache: btree locking rework
authorKent Overstreet <kmo@daterainc.com>
Wed, 5 Mar 2014 00:42:42 +0000 (16:42 -0800)
committerKent Overstreet <kmo@daterainc.com>
Tue, 18 Mar 2014 19:23:35 +0000 (12:23 -0700)
commit2a285686c109816ba71a00b9278262cf02648258
tree83be424d1b213a72a36de69b7ed98357c28cbfca
parent05335cff9f01555b769ac97b7bacc472b7ed047a
bcache: btree locking rework

Add a new lock, b->write_lock, which is required to actually modify - or write -
a btree node; this lock is only held for short durations.

This means we can write out a btree node without taking b->lock, which _is_ held
for long durations - solving a deadlock when btree_flush_write() (from the
journalling code) is called with a btree node locked.

Right now just occurs in bch_btree_set_root(), but with an upcoming journalling
rework is going to happen a lot more.

This also turns b->lock is now more of a read/intent lock instead of a
read/write lock - but not completely, since it still blocks readers. May turn it
into a real intent lock at some point in the future.

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
drivers/md/bcache/btree.c
drivers/md/bcache/btree.h
drivers/md/bcache/journal.c
drivers/md/bcache/super.c