aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/locking.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/locking.c')
-rw-r--r--fs/btrfs/locking.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 058a506a0dd8..01a9ac2be3f7 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -29,32 +29,31 @@ int btrfs_tree_lock(struct extent_buffer *eb)
29{ 29{
30 int i; 30 int i;
31 31
32 if (!TestSetPageLocked(eb->first_page)) 32 if (mutex_trylock(&eb->mutex))
33 return 0; 33 return 0;
34 for (i = 0; i < 512; i++) { 34 for (i = 0; i < 512; i++) {
35 cpu_relax(); 35 cpu_relax();
36 if (!TestSetPageLocked(eb->first_page)) 36 if (mutex_trylock(&eb->mutex))
37 return 0; 37 return 0;
38 } 38 }
39 cpu_relax(); 39 cpu_relax();
40 lock_page(eb->first_page); 40 mutex_lock(&eb->mutex);
41 return 0; 41 return 0;
42} 42}
43 43
44int btrfs_try_tree_lock(struct extent_buffer *eb) 44int btrfs_try_tree_lock(struct extent_buffer *eb)
45{ 45{
46 return TestSetPageLocked(eb->first_page); 46 return mutex_trylock(&eb->mutex);
47} 47}
48 48
49int btrfs_tree_unlock(struct extent_buffer *eb) 49int btrfs_tree_unlock(struct extent_buffer *eb)
50{ 50{
51 WARN_ON(!PageLocked(eb->first_page)); 51 mutex_unlock(&eb->mutex);
52 unlock_page(eb->first_page);
53 return 0; 52 return 0;
54} 53}
55 54
56int btrfs_tree_locked(struct extent_buffer *eb) 55int btrfs_tree_locked(struct extent_buffer *eb)
57{ 56{
58 return PageLocked(eb->first_page); 57 return mutex_is_locked(&eb->mutex);
59} 58}
60 59