]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: attach delayed ref updates to delayed ref heads
authorJosef Bacik <jbacik@fb.com>
Thu, 23 Jan 2014 14:21:38 +0000 (09:21 -0500)
committerChris Mason <clm@fb.com>
Tue, 28 Jan 2014 21:20:25 +0000 (13:20 -0800)
commit8b91a4f5a16debd1e9f5821348e50926318f2a0a
tree63e3adda6e56db27b13d0df28840a873ceac5855
parent22bcbdab68a55c2dbc665e6aa32902aacac1426e
Btrfs: attach delayed ref updates to delayed ref heads

Currently we have two rb-trees, one for delayed ref heads and one for all of the
delayed refs, including the delayed ref heads.  When we process the delayed refs
we have to hold onto the delayed ref lock for all of the selecting and merging
and such, which results in quite a bit of lock contention.  This was solved by
having a waitqueue and only one flusher at a time, however this hurts if we get
a lot of delayed refs queued up.

So instead just have an rb tree for the delayed ref heads, and then attach the
delayed ref updates to an rb tree that is per delayed ref head.  Then we only
need to take the delayed ref lock when adding new delayed refs and when
selecting a delayed ref head to process, all the rest of the time we deal with a
per delayed ref head lock which will be much less contentious.

The locking rules for this get a little more complicated since we have to lock
up to 3 things to properly process delayed refs, but I will address that problem
later.  For now this passes all of xfstests and my overnight stress tests.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/backref.c
fs/btrfs/delayed-ref.c
fs/btrfs/delayed-ref.h
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/transaction.c