Linux filesystem development
 help / color / mirror / Atom feed
From: Chi Zhiling <chizhiling@163.com>
To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: brauner@kernel.org, djwong@kernel.org, hch@lst.de,
	sj1557.seo@samsung.com, yuezhang.mo@sony.com,
	Chi Zhiling <chizhiling@kylinos.cn>,
	Namjae Jeon <linkinjeon@kernel.org>
Subject: [PATCH] iomap: add dirty page control to iomap_zero_iter
Date: Sun, 10 May 2026 14:47:37 +0800	[thread overview]
Message-ID: <20260510064737.437597-1-chizhiling@163.com> (raw)

From: Chi Zhiling <chizhiling@kylinos.cn>

This patch prepares the iomap framework for exFAT's upcoming migration to
iomap. During testing of the exFAT iomap branch with xfstests generic/299
on a VM with 8GB RAM and a 40GB disk, system unresponsiveness was observed.

iomap_zero_iter() lacked dirty page throttling, which could cause memory
pressure when exFAT's valid_size mechanism triggers large-scale zeroing
operations during writes beyond valid_size.

Align iomap_zero_iter() with iomap_write_iter() by adding
balance_dirty_pages_ratelimited() to throttle dirty page generation during
large zeroing operations. Also add cond_resched() to provide voluntary
rescheduling points during long-running loops.

Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Cc: Namjae Jeon <linkinjeon@kernel.org>
---

exFAT iomap migration:
https://lore.kernel.org/linux-fsdevel/20260507124238.7313-1-linkinjeon@kernel.org/

 fs/iomap/buffered-io.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index d7b648421a70..f6955786c8ad 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1543,6 +1543,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
 		size_t offset;
 		bool ret;
 
+		balance_dirty_pages_ratelimited(iter->inode->i_mapping);
+
 		bytes = min_t(u64, SIZE_MAX, bytes);
 		status = iomap_write_begin(iter, write_ops, &folio, &offset,
 				&bytes);
@@ -1571,6 +1573,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
 		if (WARN_ON_ONCE(!ret))
 			return -EIO;
 
+		cond_resched();
+
 		status = iomap_iter_advance(iter, bytes);
 		if (status)
 			break;
-- 
2.43.0


             reply	other threads:[~2026-05-10  6:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-10  6:47 Chi Zhiling [this message]
2026-05-11  8:57 ` [PATCH] iomap: add dirty page control to iomap_zero_iter Christoph Hellwig
2026-05-11  9:09   ` Chi Zhiling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260510064737.437597-1-chizhiling@163.com \
    --to=chizhiling@163.com \
    --cc=brauner@kernel.org \
    --cc=chizhiling@kylinos.cn \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=yuezhang.mo@sony.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox