diff options
author | Shin Hong <hongshin@gmail.com> | 2009-06-10 20:11:29 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-06-10 20:11:29 -0400 |
commit | fd0fb038d5a308c7faddd1701be5e70aaffec98b (patch) | |
tree | 50b0f3cda5a957bad1090ec4d7bd4e49f43171da /fs/btrfs/async-thread.c | |
parent | 4eedeb75e7f15ffdb12d1ad559b565e7505bdbaf (diff) |
Btrfs: init worker struct fields before kthread-run
This patch fixes a bug which may result race condition
between btrfs_start_workers() and worker_loop().
btrfs_start_workers() executed in a parent thread writes
on workers->worker and worker_loop() in a child thread
reads workers->worker. However, there is no synchronization
enforcing the order of two operations.
This patch makes btrfs_start_workers() fill workers->worker
before it starts a child thread with worker_loop()
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/async-thread.c')
-rw-r--r-- | fs/btrfs/async-thread.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index 502c3d61de62..7f88628a1a72 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c | |||
@@ -294,10 +294,10 @@ int btrfs_start_workers(struct btrfs_workers *workers, int num_workers) | |||
294 | INIT_LIST_HEAD(&worker->worker_list); | 294 | INIT_LIST_HEAD(&worker->worker_list); |
295 | spin_lock_init(&worker->lock); | 295 | spin_lock_init(&worker->lock); |
296 | atomic_set(&worker->num_pending, 0); | 296 | atomic_set(&worker->num_pending, 0); |
297 | worker->workers = workers; | ||
297 | worker->task = kthread_run(worker_loop, worker, | 298 | worker->task = kthread_run(worker_loop, worker, |
298 | "btrfs-%s-%d", workers->name, | 299 | "btrfs-%s-%d", workers->name, |
299 | workers->num_workers + i); | 300 | workers->num_workers + i); |
300 | worker->workers = workers; | ||
301 | if (IS_ERR(worker->task)) { | 301 | if (IS_ERR(worker->task)) { |
302 | kfree(worker); | 302 | kfree(worker); |
303 | ret = PTR_ERR(worker->task); | 303 | ret = PTR_ERR(worker->task); |