]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drbd: fix a race stopping the worker thread
authorLars Ellenberg <lars.ellenberg@linbit.com>
Fri, 27 Dec 2013 16:17:25 +0000 (17:17 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 10 Jul 2014 16:34:50 +0000 (18:34 +0200)
We may implicitly call drbd_send() from inside wait_for_work(),
via maybe_send_barrier().

If the "stop" signal was send just before that, drbd_send() would call
flush_signals(), and we would run an unbounded schedule() afterwards.

Fix: check for thread_state == RUNNING before we schedule()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_worker.c

index 59158858b17ab336153361fc11faee3b1fe7030c..47bc84017b5b11b4d1652efb82ce690a698c1cc2 100644 (file)
@@ -1930,6 +1930,9 @@ static void wait_for_work(struct drbd_connection *connection, struct list_head *
                if (send_barrier)
                        maybe_send_barrier(connection,
                                        connection->send.current_epoch_nr + 1);
+               /* drbd_send() may have called flush_signals() */
+               if (get_t_state(&connection->worker) != RUNNING)
+                       break;
                schedule();
                /* may be woken up for other things but new work, too,
                 * e.g. if the current epoch got closed.