public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix race in worker_loop
@ 2009-03-22  2:24 Amit Gud
  2009-03-23 16:51 ` Chris Mason
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Gud @ 2009-03-22  2:24 UTC (permalink / raw)
  To: chris.mason, linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]

Hello Chris,

Experiencing sporadic hangs during umount(2) on UML. Patch below seem to
fix it if not already fixed. Based on 2.6.29-rc8. Tested with mounting
and umounting iteratively 100 times. Without the fix, the race is hit
within 10 tries.


AG
-- 
May the source be with you.
http://www.cis.ksu.edu/~gud


[-- Attachment #2: btrfs-fix-umount-hang.patch --]
[-- Type: text/x-patch, Size: 738 bytes --]

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. Race, IMO, is more evident on UP than on SMP.

Signed-off-by: Amit Gud <gud@ksu.edu>

diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index c84ca1f..4c1f3e5 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())
+					return 0;
+
 				/* still no more work?, sleep for real */
 				spin_lock_irq(&worker->lock);
 				set_current_state(TASK_INTERRUPTIBLE);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-23 16:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-22  2:24 [PATCH] Fix race in worker_loop Amit Gud
2009-03-23 16:51 ` Chris Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox