diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-06-25 16:14:04 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:04 -0400 |
commit | f9efa9c784aa3b801feb367f72c6867d26fb348e (patch) | |
tree | d9f678310c6c8a4daf2003fa4f6b4164111dbbd7 /fs/btrfs/locking.c | |
parent | 3f157a2fd2ad731e1ed9964fecdc5f459f04a4a4 (diff) |
Btrfs: Reduce contention on the root node
This calls unlock_up sooner in btrfs_search_slot in order to decrease the
amount of work done with the higher level tree locks held.
Also, it changes btrfs_tree_lock to spin for a big against the page lock
before scheduling. This makes a big difference in context switch rate under
highly contended workloads.
Longer term, a better locking structure is needed than the page lock.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/locking.c')
-rw-r--r-- | fs/btrfs/locking.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c index 80813a307b4b..058a506a0dd8 100644 --- a/fs/btrfs/locking.c +++ b/fs/btrfs/locking.c | |||
@@ -27,6 +27,16 @@ | |||
27 | 27 | ||
28 | int btrfs_tree_lock(struct extent_buffer *eb) | 28 | int btrfs_tree_lock(struct extent_buffer *eb) |
29 | { | 29 | { |
30 | int i; | ||
31 | |||
32 | if (!TestSetPageLocked(eb->first_page)) | ||
33 | return 0; | ||
34 | for (i = 0; i < 512; i++) { | ||
35 | cpu_relax(); | ||
36 | if (!TestSetPageLocked(eb->first_page)) | ||
37 | return 0; | ||
38 | } | ||
39 | cpu_relax(); | ||
30 | lock_page(eb->first_page); | 40 | lock_page(eb->first_page); |
31 | return 0; | 41 | return 0; |
32 | } | 42 | } |