Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139464
b: refs/heads/master
c: 66d7e85
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason committed Mar 24, 2009
1 parent 3b1c193 commit 2c6b6d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7f366cfecfc126731f8ac505d72026d691dac79a
refs/heads/master: 66d7e85ea7c3628189d19b265495358f756cb463
10 changes: 8 additions & 2 deletions trunk/fs/btrfs/locking.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ void btrfs_clear_lock_blocking(struct extent_buffer *eb)
static int btrfs_spin_on_block(struct extent_buffer *eb)
{
int i;

for (i = 0; i < 512; i++) {
cpu_relax();
if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
return 1;
if (need_resched())
break;
cpu_relax();
}
return 0;
}
Expand All @@ -102,6 +103,7 @@ int btrfs_try_spin_lock(struct extent_buffer *eb)

/* spin for a bit on the BLOCKING flag */
for (i = 0; i < 2; i++) {
cpu_relax();
if (!btrfs_spin_on_block(eb))
break;

Expand Down Expand Up @@ -148,6 +150,9 @@ int btrfs_tree_lock(struct extent_buffer *eb)
DEFINE_WAIT(wait);
wait.func = btrfs_wake_function;

if (!btrfs_spin_on_block(eb))
goto sleep;

while(1) {
spin_nested(eb);

Expand All @@ -165,9 +170,10 @@ int btrfs_tree_lock(struct extent_buffer *eb)
* spin for a bit, and if the blocking flag goes away,
* loop around
*/
cpu_relax();
if (btrfs_spin_on_block(eb))
continue;

sleep:
prepare_to_wait_exclusive(&eb->lock_wq, &wait,
TASK_UNINTERRUPTIBLE);

Expand Down

0 comments on commit 2c6b6d0

Please sign in to comment.