summaryrefslogtreecommitdiff
path: root/fs/btrfs/locking.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/locking.c')
-rw-r--r--fs/btrfs/locking.c10
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 @@
int btrfs_tree_lock(struct extent_buffer *eb)
{
+ int i;
+
+ if (!TestSetPageLocked(eb->first_page))
+ return 0;
+ for (i = 0; i < 512; i++) {
+ cpu_relax();
+ if (!TestSetPageLocked(eb->first_page))
+ return 0;
+ }
+ cpu_relax();
lock_page(eb->first_page);
return 0;
}