Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e412f920 authored by tsutomu.owa@toshiba.co.jp's avatar tsutomu.owa@toshiba.co.jp Committed by David Teigland
Browse files

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: default avatarTadashi Miyauchi <miyauchi@toshiba-tops.co.jp>
Signed-off-by: default avatarTsutomu Owa <tsutomu.owa@toshiba.co.jp>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent c553e173
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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();