* [PATCH] BTRFS: fix data race
@ 2009-05-27 12:43 홍신 shin hong
0 siblings, 0 replies; only message in thread
From: 홍신 shin hong @ 2009-05-27 12:43 UTC (permalink / raw)
To: linux-btrfs
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() writes workers->worker
before it starts a child thread with worker_loop() in order to
resolve possible race condition.
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -273,10 +273,10 @@
INIT_LIST_HEAD(&worker->worker_list);
spin_lock_init(&worker->lock);
atomic_set(&worker->num_pending, 0);
+ worker->workers = workers;
worker->task = kthread_run(worker_loop, worker,
"btrfs-%s-%d", workers->name,
workers->num_workers + i);
- worker->workers = workers;
if (IS_ERR(worker->task)) {
kfree(worker);
ret = PTR_ERR(worker->task);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-27 12:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-27 12:43 [PATCH] BTRFS: fix data race 홍신 shin hong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox