Skip to content

Commit 297252c

Browse files
Artem BityutskiyJens Axboe
authored andcommitted
writeback: do not lose wake-ups in bdi threads
Currently, bdi threads ('bdi_writeback_thread()') can lose wake-ups. For example, if 'bdi_queue_work()' is executed after the bdi thread have had finished 'wb_do_writeback()' but before it called 'schedule_timeout_interruptible()'. To fix this issue, we have to check whether we have works to process after we have changed the task state to 'TASK_INTERRUPTIBLE'. This patch also clean-ups handling of the cases when 'dirty_writeback_interval' is zero or non-zero. Additionally, this patch also removes unneeded 'list_empty_careful()' call. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent c4ec790 commit 297252c

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎fs/fs-writeback.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -848,17 +848,18 @@ int bdi_writeback_thread(void *data)
848848
break;
849849
}
850850

851-
if (dirty_writeback_interval) {
852-
wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10);
853-
schedule_timeout_interruptible(wait_jiffies);
854-
} else {
855-
set_current_state(TASK_INTERRUPTIBLE);
856-
if (list_empty_careful(&wb->bdi->work_list) &&
857-
!kthread_should_stop())
858-
schedule();
851+
set_current_state(TASK_INTERRUPTIBLE);
852+
if (!list_empty(&bdi->work_list)) {
859853
__set_current_state(TASK_RUNNING);
854+
continue;
860855
}
861856

857+
if (dirty_writeback_interval) {
858+
wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10);
859+
schedule_timeout(wait_jiffies);
860+
} else
861+
schedule();
862+
862863
try_to_freeze();
863864
}
864865

0 commit comments

Comments
 (0)