فهرست منبع

Btrfs: Check kthread_should_stop() before schedule() in worker_loop

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.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
yanhai zhu 16 سال پیش
والد
کامیت
0df49b911d
1فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  1. 2 1
      fs/btrfs/async-thread.c

+ 2 - 1
fs/btrfs/async-thread.c

@@ -171,7 +171,8 @@ static int worker_loop(void *arg)
 		} else {
 		} else {
 			set_current_state(TASK_INTERRUPTIBLE);
 			set_current_state(TASK_INTERRUPTIBLE);
 			spin_unlock_irq(&worker->lock);
 			spin_unlock_irq(&worker->lock);
-			schedule();
+			if (!kthread_should_stop())
+				schedule();
 			__set_current_state(TASK_RUNNING);
 			__set_current_state(TASK_RUNNING);
 		}
 		}
 	} while (!kthread_should_stop());
 	} while (!kthread_should_stop());