]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: switch the btrfs tree locks to reader/writer
authorChris Mason <chris.mason@oracle.com>
Sat, 16 Jul 2011 19:23:14 +0000 (15:23 -0400)
committerChris Mason <chris.mason@oracle.com>
Wed, 27 Jul 2011 16:46:46 +0000 (12:46 -0400)
commitb42d96e99520a03ac45f1ddfa2379603e0043549
treebb10ec6ef876b4d7a553cbe54976ec49a0d10b21
parent831e12870b9e50524997ab5b3928af8e219bb4a5
Btrfs: switch the btrfs tree locks to reader/writer

The btrfs metadata btree is the source of significant
lock contention, especially in the root node.   This
commit changes our locking to use a reader/writer
lock.

The lock is built on top of rw spinlocks, and it
extends the lock tracking to remember if we have a
read lock or a write lock when we go to blocking.  Atomics
count the number of blocking readers or writers at any
given time.

It removes all of the adaptive spinning from the old code
and uses only the spinning/blocking hints inside of btrfs
to decide when it should continue spinning.

In read heavy workloads this is dramatically faster.  In write
heavy workloads we're still faster because of less contention
on the root node lock.

We suffer slightly in dbench because we schedule more often
during write locks, but all other benchmarks so far are improved.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/delayed-inode.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/locking.c
fs/btrfs/locking.h
fs/btrfs/tree-log.c