diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 3a07f6d8bc0b..7cc67e39e7a4 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -649,6 +649,16 @@ static long wb_writeback(struct bdi_writeback *wb, if (work->nr_pages <= 0) break; + /* + * Background writeout and kupdate-style writeback may + * run forever. Stop them if there is other work to do + * so that e.g. sync can proceed. They'll be restarted + * after the other works are all done. + */ + if ((work->for_background || work->for_kupdate) && + !list_empty(&wb->bdi->work_list)) + break; + /* * For background writeout, stop when we are below the * background dirty threshold