public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Artem.Bityutskiy@nokia.com
Cc: bjschuma@netapp.com, jaxboe@fusionio.com,
	linux-nfs@vger.kernel.org, trond@netapp.com, hch@lst.de
Subject: Re: hang in writeback code on nfsv4 mount
Date: Fri, 27 Aug 2010 17:06:26 -0400	[thread overview]
Message-ID: <20100827210626.GB27694@fieldses.org> (raw)
In-Reply-To: <10B234E0D3A1CA469E00963BF106CA392D0DB78354@NOK-EUMSG-02.mgdnok.nokia.com>

On Fri, Aug 27, 2010 at 06:17:36PM +0200, Artem.Bityutskiy@nokia.com wrote:
> I need to look more. But so far I do not really understand what could make kthread_stop() wait
> forever. I looked into the code, and thought may be barriers are missing there, but I is unlikely
> this generic type of code would have bugs.

Hm, is the way you go to sleep in the writeback thread safe?  Surely
there's a race like:

while(!kthread_should_stop()) {

				kthread_stop():
					kthread->should_stop = 1;
					wake_up_process(k);
					wait_for_completion(&kthread->exited);

	/* oops, lose the wake_up here: */
	set_current_state(TASK_INTERRUPTIBLE);
	...
	/* sleep forever: */
	schedule();

Maybe the following?

--b.

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 7d9d06b..ea76550 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -808,7 +808,7 @@ int bdi_writeback_thread(void *data)
 			wb->last_active = jiffies;
 
 		set_current_state(TASK_INTERRUPTIBLE);
-		if (!list_empty(&bdi->work_list)) {
+		if (!list_empty(&bdi->work_list) || kthread_should_stop()) {
 			__set_current_state(TASK_RUNNING);
 			continue;
 		}

  parent reply	other threads:[~2010-08-27 21:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-25  2:34 hang in writeback code on nfsv4 mount J. Bruce Fields
2010-08-25  4:09 ` Artem.Bityutskiy
2010-08-25  6:32 ` Artem Bityutskiy
2010-08-25 15:25   ` Bryan Schumaker
2010-08-25 15:44   ` J. Bruce Fields
2010-08-25 18:46     ` Artem Bityutskiy
2010-08-26 11:24     ` Artem Bityutskiy
2010-08-26 13:20       ` Artem Bityutskiy
2010-08-27  6:13 ` Artem Bityutskiy
2010-08-27  7:12   ` Jens Axboe
2010-08-27  9:36   ` Artem Bityutskiy
2010-08-27 13:06     ` Bryan Schumaker
2010-08-27 16:09       ` J. Bruce Fields
2010-08-27 16:17         ` Artem.Bityutskiy
     [not found]           ` <10B234E0D3A1CA469E00963BF106CA392D0DB78354-xJW1crHCIS+8kqYwC468Frtp2NbXvJi8gfoxzgwHRXE@public.gmane.org>
2010-08-27 16:21             ` Artem.Bityutskiy
2010-08-27 21:06           ` J. Bruce Fields [this message]
2010-08-27 21:28             ` [PATCH] Fix lost wake-up shutting down writeback thread J. Bruce Fields
2010-08-28  1:17               ` Artem.Bityutskiy
2010-08-28  6:50               ` Jens Axboe
2010-08-29 12:21                 ` Artem.Bityutskiy
     [not found]                   ` <10B234E0D3A1CA469E00963BF106CA392D0DB78357-xJW1crHCIS+8kqYwC468Frtp2NbXvJi8gfoxzgwHRXE@public.gmane.org>
2010-08-30 11:56                     ` Jens Axboe

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=20100827210626.GB27694@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Artem.Bityutskiy@nokia.com \
    --cc=bjschuma@netapp.com \
    --cc=hch@lst.de \
    --cc=jaxboe@fusionio.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond@netapp.com \
    /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