public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.6 01/11] fs/writeback: bail out if there is no more inodes for IO and queued once
@ 2024-05-26  9:42 Sasha Levin
  2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 02/11] md: Fix overflow in is_mddev_idle Sasha Levin
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Sasha Levin @ 2024-05-26  9:42 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Kemeng Shi, Jan Kara, Christian Brauner, Sasha Levin, viro,
	linux-fsdevel

From: Kemeng Shi <shikemeng@huaweicloud.com>

[ Upstream commit d92109891f21cf367caa2cc6dff11a4411d917f4 ]

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 <shikemeng@huaweicloud.com>
Link: https://lore.kernel.org/r/20240228091958.288260-3-shikemeng@huaweicloud.com
Reviewed-by: Jan Kara <jack@suse.cz>
[brauner@kernel.org: fold in memory corruption fix from Jan in [1]]
Link: https://lore.kernel.org/r/20240405132346.bid7gibby3lxxhez@quack3 [1]
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/fs-writeback.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 1767493dffda7..0a498bc60f557 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2044,6 +2044,7 @@ static long wb_writeback(struct bdi_writeback *wb,
 	struct inode *inode;
 	long progress;
 	struct blk_plug plug;
+	bool queued = false;
 
 	blk_start_plug(&plug);
 	for (;;) {
@@ -2086,8 +2087,10 @@ static long wb_writeback(struct bdi_writeback *wb,
 			dirtied_before = jiffies;
 
 		trace_writeback_start(wb, work);
-		if (list_empty(&wb->b_io))
+		if (list_empty(&wb->b_io)) {
 			queue_io(wb, work, dirtied_before);
+			queued = true;
+		}
 		if (work->sb)
 			progress = writeback_sb_inodes(work->sb, wb, work);
 		else
@@ -2102,7 +2105,7 @@ static long wb_writeback(struct bdi_writeback *wb,
 		 * mean the overall work is done. So we keep looping as long
 		 * as made some progress on cleaning pages or inodes.
 		 */
-		if (progress) {
+		if (progress || !queued) {
 			spin_unlock(&wb->list_lock);
 			continue;
 		}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-05-26  9:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-26  9:42 [PATCH AUTOSEL 6.6 01/11] fs/writeback: bail out if there is no more inodes for IO and queued once Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 02/11] md: Fix overflow in is_mddev_idle Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 03/11] padata: Disable BH when taking works lock on MT path Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 04/11] crypto: hisilicon/sec - Fix memory leak for sec resource release Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 05/11] crypto: hisilicon/qm - Add the err memory release process to qm uninit Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 06/11] io_uring/sqpoll: work around a potential audit memory leak Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 07/11] rcutorture: Fix rcu_torture_one_read() pipe_count overflow comment Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 08/11] rcutorture: Make stall-tasks directly exit when rcutorture tests end Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 09/11] rcutorture: Fix invalid context warning when enable srcu barrier testing Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 10/11] binfmt_elf: Leave a gap between .bss and brk Sasha Levin
2024-05-26  9:42 ` [PATCH AUTOSEL 6.6 11/11] block/ioctl: prefer different overflow check Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox