Skip to content

Commit d921098

Browse files
Kemeng Shibrauner
Kemeng Shi
authored andcommitted
fs/writeback: bail out if there is no more inodes for IO and queued once
For case there is no more inodes for IO in io list from last wb_writeback, We may bail out early even there is inode in dirty list should be written back. Only bail out when we queued once to avoid missing dirtied inode. This is from code reading... Signed-off-by: Kemeng Shi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jan Kara <[email protected]> [[email protected]: fold in memory corruption fix from Jan in [1]] Link: https://lore.kernel.org/r/20240405132346.bid7gibby3lxxhez@quack3 [1] Signed-off-by: Christian Brauner <[email protected]>
1 parent ac0c18f commit d921098

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/fs-writeback.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,7 @@ static long wb_writeback(struct bdi_writeback *wb,
20762076
struct inode *inode;
20772077
long progress;
20782078
struct blk_plug plug;
2079+
bool queued = false;
20792080

20802081
blk_start_plug(&plug);
20812082
for (;;) {
@@ -2118,8 +2119,10 @@ static long wb_writeback(struct bdi_writeback *wb,
21182119
dirtied_before = jiffies;
21192120

21202121
trace_writeback_start(wb, work);
2121-
if (list_empty(&wb->b_io))
2122+
if (list_empty(&wb->b_io)) {
21222123
queue_io(wb, work, dirtied_before);
2124+
queued = true;
2125+
}
21232126
if (work->sb)
21242127
progress = writeback_sb_inodes(work->sb, wb, work);
21252128
else
@@ -2134,7 +2137,7 @@ static long wb_writeback(struct bdi_writeback *wb,
21342137
* mean the overall work is done. So we keep looping as long
21352138
* as made some progress on cleaning pages or inodes.
21362139
*/
2137-
if (progress) {
2140+
if (progress || !queued) {
21382141
spin_unlock(&wb->list_lock);
21392142
continue;
21402143
}

0 commit comments

Comments
 (0)