public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Amit Gud <amitgud@gmail.com>
To: chris.mason@oracle.com, linux-btrfs@vger.kernel.org
Subject: [PATCH] Fix race in worker_loop
Date: Sat, 21 Mar 2009 19:24:33 -0700	[thread overview]
Message-ID: <49C5A161.1000908@gmail.com> (raw)

[-- 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);

             reply	other threads:[~2009-03-22  2:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-22  2:24 Amit Gud [this message]
2009-03-23 16:51 ` [PATCH] Fix race in worker_loop Chris Mason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49C5A161.1000908@gmail.com \
    --to=amitgud@gmail.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox