diff options
author | tsutomu.owa@toshiba.co.jp <tsutomu.owa@toshiba.co.jp> | 2017-09-12 08:56:30 +0000 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2017-09-25 12:45:21 -0500 |
commit | e412f9201de255a503ae3d67f46aae580c79006c (patch) | |
tree | 25b56ecf9d3dfe37d93a75bd51391398b12b9a89 /fs/dlm | |
parent | c553e173b022347dcb34721688f55167c654466d (diff) | |
download | op-kernel-dev-e412f9201de255a503ae3d67f46aae580c79006c.zip op-kernel-dev-e412f9201de255a503ae3d67f46aae580c79006c.tar.gz |
DLM: fix race condition between dlm_recoverd_stop and dlm_recoverd
When dlm_recoverd_stop() is called between kthread_should_stop() and
set_task_state(TASK_INTERRUPTIBLE), dlm_recoverd will not wake up.
Signed-off-by: Tadashi Miyauchi <miyauchi@toshiba-tops.co.jp>
Signed-off-by: Tsutomu Owa <tsutomu.owa@toshiba.co.jp>
Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm')
-rw-r--r-- | fs/dlm/recoverd.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/dlm/recoverd.c b/fs/dlm/recoverd.c index 6859b4b..d2ad1ca 100644 --- a/fs/dlm/recoverd.c +++ b/fs/dlm/recoverd.c @@ -287,8 +287,17 @@ static int dlm_recoverd(void *arg) set_bit(LSFL_RECOVER_LOCK, &ls->ls_flags); wake_up(&ls->ls_recover_lock_wait); - while (!kthread_should_stop()) { + while (1) { + /* + * We call kthread_should_stop() after set_current_state(). + * This is because it works correctly if kthread_stop() is + * called just before set_current_state(). + */ set_current_state(TASK_INTERRUPTIBLE); + if (kthread_should_stop()) { + set_current_state(TASK_RUNNING); + break; + } if (!test_bit(LSFL_RECOVER_WORK, &ls->ls_flags) && !test_bit(LSFL_RECOVER_DOWN, &ls->ls_flags)) schedule(); |