Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: "yanhai zhu" <zhu.yanhai@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] Check kthread_should_stop() before schedule() in worker_loop
Date: Thu, 6 Nov 2008 20:50:14 +0800	[thread overview]
Message-ID: <977a2be20811060450s3eee9bb5n2f71b01d03b95987@mail.gmail.com> (raw)

Hello,
  In worker_loop(), the func should check whether it has been requested to stop
before it decides to schedule out. Otherwise if the stop request(also
the last wake_up())
sent by btrfs_stop_workers() happens when worker_loop() running after
the "while" judgement
and before schedule(), woker_loop() will schedule away and never be woken up,
which will also cause btrfs_stop_workers() wait forever.

Thanks,
Zhu Yanhai
---
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index d82efd7..423ef27 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -119,7 +119,8 @@ static int worker_loop(void *arg)
                } else {
                        set_current_state(TASK_INTERRUPTIBLE);
                        spin_unlock_irq(&worker->lock);
-                       schedule();
+                       if (!kthread_should_stop())
+                               schedule();
                        __set_current_state(TASK_RUNNING);
                }
        } while (!kthread_should_stop());
---

                 reply	other threads:[~2008-11-06 12:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=977a2be20811060450s3eee9bb5n2f71b01d03b95987@mail.gmail.com \
    --to=zhu.yanhai@gmail.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