writeback: do not lose wake-ups in the forker thread - 2
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 25 Jul 2010 11:29:14 +0000 (14:29 +0300)
committerJens Axboe <jaxboe@fusionio.com>
Sat, 7 Aug 2010 16:53:55 +0000 (18:53 +0200)
Currently, if someone submits jobs for the default bdi, we can lose wake-up
events. E.g., this can happen if 'bdi_queue_work()' is called when
'bdi_forker_thread()' is executing code after 'wb_do_writeback(me, 0)', but
before 'set_current_state(TASK_INTERRUPTIBLE)'.

This situation is unlikely, and the result is not very severe - we'll just
delay the execution of the work, but this is still not very nice.

This patch fixes the issue by checking whether the default bdi has works before
the forker thread goes sleep.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
mm/backing-dev.c

index b1dc2d4..72e6eb9 100644 (file)
@@ -358,6 +358,10 @@ static int bdi_forker_thread(void *ptr)
                        bdi_add_default_flusher_thread(bdi);
                }
 
+               /* Keep working if default bdi still has things to do */
+               if (!list_empty(&me->bdi->work_list))
+                       __set_current_state(TASK_RUNNING);
+
                if (list_empty(&bdi_pending_list)) {
                        unsigned long wait;