mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
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>
This commit is contained in:
parent
4eedeb75e7
commit
fd0fb038d5
1 changed files with 1 additions and 1 deletions
|
@ -294,10 +294,10 @@ int btrfs_start_workers(struct btrfs_workers *workers, int num_workers)
|
||||||
INIT_LIST_HEAD(&worker->worker_list);
|
INIT_LIST_HEAD(&worker->worker_list);
|
||||||
spin_lock_init(&worker->lock);
|
spin_lock_init(&worker->lock);
|
||||||
atomic_set(&worker->num_pending, 0);
|
atomic_set(&worker->num_pending, 0);
|
||||||
|
worker->workers = workers;
|
||||||
worker->task = kthread_run(worker_loop, worker,
|
worker->task = kthread_run(worker_loop, worker,
|
||||||
"btrfs-%s-%d", workers->name,
|
"btrfs-%s-%d", workers->name,
|
||||||
workers->num_workers + i);
|
workers->num_workers + i);
|
||||||
worker->workers = workers;
|
|
||||||
if (IS_ERR(worker->task)) {
|
if (IS_ERR(worker->task)) {
|
||||||
kfree(worker);
|
kfree(worker);
|
||||||
ret = PTR_ERR(worker->task);
|
ret = PTR_ERR(worker->task);
|
||||||
|
|
Loading…
Reference in a new issue