It is more logical that when bdi_process_work_items() returns, bdi->work_list is empty (modulo tiny races because we don't hold wb_lock anymore but that's not changed by this patch). So move the retry-loop from bdi_writeback_workfn() into bdi_process_work_items(). Signed-off-by: Jan Kara <jack@xxxxxxx> --- fs/fs-writeback.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index b7d05c0aad14..149f8b35bab2 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -883,6 +883,7 @@ static long bdi_process_work_items(struct backing_dev_info *bdi) long wrote = 0; set_bit(BDI_writeback_running, &bdi->state); +restart: while ((work = get_next_work_item(bdi)) != NULL) { trace_writeback_exec(bdi, work); @@ -904,6 +905,10 @@ static long bdi_process_work_items(struct backing_dev_info *bdi) */ wrote += wb_check_old_data_flush(bdi); wrote += wb_check_background_flush(bdi); + + /* New work may have been queued while we did background writeback */ + if (!list_empty(&bdi->work_list)) + goto restart; clear_bit(BDI_writeback_running, &bdi->state); return wrote; @@ -930,10 +935,7 @@ void bdi_writeback_workfn(struct work_struct *work) * if @bdi is shutting down even when we're running off the * rescuer as work_list needs to be drained. */ - do { - pages_written = bdi_process_work_items(bdi); - trace_writeback_pages_written(pages_written); - } while (!list_empty(&bdi->work_list)); + pages_written = bdi_process_work_items(bdi); } else { /* * bdi_wq can't get enough workers and we're running off @@ -948,8 +950,8 @@ void bdi_writeback_workfn(struct work_struct *work) }; pages_written = bdi_writeback(bdi, &work); - trace_writeback_pages_written(pages_written); } + trace_writeback_pages_written(pages_written); if (!list_empty(&bdi->work_list)) mod_delayed_work(bdi_wq, &bdi->dwork, 0); -- 1.8.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html