* [PATCH v2 RESEND] ext4: cancel dirty accounting for folios without buffers
@ 2026-12-03 9:00 Jia Zhu
2026-12-03 9:11 ` sashiko-bot
2026-12-03 9:12 ` Muchun Song
0 siblings, 2 replies; 3+ messages in thread
From: Jia Zhu @ 2026-12-03 9:00 UTC (permalink / raw)
To: Theodore Ts'o, Andreas Dilger
Cc: Baokun Li, Jan Kara, Ojaswin Mujoo, Ritesh Harjani, Zhang Yi,
Zhang Yi, Muchun Song, linux-ext4, linux-kernel, stable
Since commit cc5095747edf ("ext4: don't BUG if someone dirty pages
without asking ext4 first"), mpage_prepare_extent_to_map() handles dirty
folios without buffer heads by warning, clearing PG_dirty, and skipping
them. ext4 cannot write these folios because there are no buffer heads to
map and submit.
That recovery leaves dirty accounting behind: folio_clear_dirty() clears
PG_dirty but does not undo the accounting charged when the folio was
dirtied. We have seen this in production as Dirty/nr_dirty staying high
while Writeback/nr_writeback and device write IO stayed near zero, with
many writer tasks blocked in balance_dirty_pages() throttling. Thus the
warning-and-skip recovery can still become a dirty-throttle DoS.
Use folio_cancel_dirty() so dropping PG_dirty also cancels the dirty
accounting. Then cycle the folio through writeback state so the generic
writeback helpers update the xarray DIRTY/TOWRITE tags.
Fixes: cc5095747edf ("ext4: don't BUG if someone dirty pages without asking ext4 first")
Cc: stable@vger.kernel.org
Suggested-by: Zhang Yi <yizhang089@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>
---
Resend notes:
- No code changes since v2 (rebased onto v7.4-rc4+, commit ca20d5a011d3).
- Collected Reviewed-by from Zhang Yi.
- Previous submission:
https://lore.kernel.org/all/20260626100740.52455-1-zhujia.zj@bytedance.com/
Changes since v1:
- After folio_cancel_dirty(), cycle the folio through writeback state so
generic writeback helpers update PAGECACHE_TAG_DIRTY/TOWRITE, as
suggested by Yi and Jan.
fs/ext4/inode.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 07a62d8569d3..2716b859f759 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2913,7 +2913,15 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
*/
if (!folio_buffers(folio)) {
ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", folio->index);
- folio_clear_dirty(folio);
+ /*
+ * folio_cancel_dirty() pairs the dropped dirty
+ * state with dirty accounting. Cycle through
+ * writeback state so the generic writeback
+ * helpers update the xarray tags.
+ */
+ folio_cancel_dirty(folio);
+ folio_start_writeback(folio);
+ folio_end_writeback(folio);
folio_unlock(folio);
continue;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2 RESEND] ext4: cancel dirty accounting for folios without buffers
2026-12-03 9:00 [PATCH v2 RESEND] ext4: cancel dirty accounting for folios without buffers Jia Zhu
@ 2026-12-03 9:11 ` sashiko-bot
2026-12-03 9:12 ` Muchun Song
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-03 9:11 UTC (permalink / raw)
To: Jia Zhu; +Cc: linux-ext4, tytso
> Since commit cc5095747edf ("ext4: don't BUG if someone dirty pages
> without asking ext4 first"), mpage_prepare_extent_to_map() handles dirty
> folios without buffer heads by warning, clearing PG_dirty, and skipping
> them. ext4 cannot write these folios because there are no buffer heads to
> map and submit.
>
> That recovery leaves dirty accounting behind: folio_clear_dirty() clears
> PG_dirty but does not undo the accounting charged when the folio was
> dirtied. We have seen this in production as Dirty/nr_dirty staying high
> while Writeback/nr_writeback and device write IO stayed near zero, with
> many writer tasks blocked in balance_dirty_pages() throttling. Thus the
> warning-and-skip recovery can still become a dirty-throttle DoS.
>
> Use folio_cancel_dirty() so dropping PG_dirty also cancels the dirty
> accounting. Then cycle the folio through writeback state so the generic
> writeback helpers update the xarray DIRTY/TOWRITE tags.
>
> Fixes: cc5095747edf ("ext4: don't BUG if someone dirty pages without asking ext4 first")
> Cc: stable@vger.kernel.org
> Suggested-by: Zhang Yi <yizhang089@gmail.com>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
> Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203090009.16730-1-zhujia.zj@bytedance.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2 RESEND] ext4: cancel dirty accounting for folios without buffers
2026-12-03 9:00 [PATCH v2 RESEND] ext4: cancel dirty accounting for folios without buffers Jia Zhu
2026-12-03 9:11 ` sashiko-bot
@ 2026-12-03 9:12 ` Muchun Song
1 sibling, 0 replies; 3+ messages in thread
From: Muchun Song @ 2026-12-03 9:12 UTC (permalink / raw)
To: Jia Zhu
Cc: Muchun Song, Theodore Ts'o, Andreas Dilger, Baokun Li,
Jan Kara, Ojaswin Mujoo, Ritesh Harjani, Zhang Yi, Zhang Yi,
linux-ext4, linux-kernel, stable
> On Dec 3, 2026, at 17:00, Jia Zhu <zhujia.zj@bytedance.com> wrote:
>
> Since commit cc5095747edf ("ext4: don't BUG if someone dirty pages
> without asking ext4 first"), mpage_prepare_extent_to_map() handles dirty
> folios without buffer heads by warning, clearing PG_dirty, and skipping
> them. ext4 cannot write these folios because there are no buffer heads to
> map and submit.
>
> That recovery leaves dirty accounting behind: folio_clear_dirty() clears
> PG_dirty but does not undo the accounting charged when the folio was
> dirtied. We have seen this in production as Dirty/nr_dirty staying high
> while Writeback/nr_writeback and device write IO stayed near zero, with
> many writer tasks blocked in balance_dirty_pages() throttling. Thus the
> warning-and-skip recovery can still become a dirty-throttle DoS.
>
> Use folio_cancel_dirty() so dropping PG_dirty also cancels the dirty
> accounting. Then cycle the folio through writeback state so the generic
> writeback helpers update the xarray DIRTY/TOWRITE tags.
>
> Fixes: cc5095747edf ("ext4: don't BUG if someone dirty pages without asking ext4 first")
> Cc: stable@vger.kernel.org
> Suggested-by: Zhang Yi <yizhang089@gmail.com>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
> Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>
Acked-by: Muchun Song (ByteDance) <muchun.song@linux.dev>
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 9:00 [PATCH v2 RESEND] ext4: cancel dirty accounting for folios without buffers Jia Zhu
2026-12-03 9:11 ` sashiko-bot
2026-12-03 9:12 ` Muchun Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox