summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/async-thread.c
diff options
context:
space:
mode:
authorAmit Gud <amitgud@gmail.com>2009-04-02 17:01:27 -0400
committerChris Mason <chris.mason@oracle.com>2009-04-02 17:01:27 -0400
commitb5555f77115bfba3630fefff2d4e68140b644171 (patch)
tree5a2712105e9e5e493ebf01b9b382828d91e046b8 /fs/btrfs/async-thread.c
parentdccae99995089641fbac452ebc7f0cab18751ddb (diff)
downloadblackbird-op-linux-b5555f77115bfba3630fefff2d4e68140b644171.tar.gz
blackbird-op-linux-b5555f77115bfba3630fefff2d4e68140b644171.zip
Btrfs: fix race in worker_loop
Need to check kthread_should_stop after schedule_timeout() before calling schedule(). This causes threads to sleep with potentially no one to wake them up causing mount(2) to hang in btrfs_stop_workers waiting for threads to stop. Signed-off-by: Amit Gud <gud@ksu.edu> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/async-thread.c')
-rw-r--r--fs/btrfs/async-thread.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index c84ca1f5259a..cba701dba350 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -195,6 +195,9 @@ again_locked:
if (!list_empty(&worker->pending))
continue;
+ if (kthread_should_stop())
+ break;
+
/* still no more work?, sleep for real */
spin_lock_irq(&worker->lock);
set_current_state(TASK_INTERRUPTIBLE);
@@ -208,7 +211,8 @@ again_locked:
worker->working = 0;
spin_unlock_irq(&worker->lock);
- schedule();
+ if (!kthread_should_stop())
+ schedule();
}
__set_current_state(TASK_RUNNING);
}
OpenPOWER on IntegriCloud