Re: [PATCH] ext4: cancel dirty accounting for folios without buffers
From: Zhu Jia
Date: Wed Jun 24 2026 - 06:07:18 EST
Hi Yi,
Thanks for taking a look.
Yes, clearing PAGECACHE_TAG_DIRTY/TOWRITE would make the page-cache state
cleaner. I had a version that did this by adding a helper around
folio_cancel_dirty() and clearing the xarray tags after confirming the
folio was still the same clean page-cache entry.
It looked like this:
static void ext4_cancel_dirty_folio(struct address_space *mapping,
struct folio *folio)
{
XA_STATE(xas, &mapping->i_pages, folio->index);
unsigned long flags;
folio_cancel_dirty(folio);
xas_lock_irqsave(&xas, flags);
if (xas_load(&xas) == folio && !folio_test_dirty(folio)) {
xas_clear_mark(&xas, PAGECACHE_TAG_DIRTY);
xas_clear_mark(&xas, PAGECACHE_TAG_TOWRITE);
}
xas_unlock_irqrestore(&xas, flags);
}
The reason I left the tags unchanged in this version is that I was not sure
whether it is appropriate for ext4 to open-code xarray tag cleanup directly.
If you think this is the right direction, I can add the helper back and
send a v2.
Thanks,
Jia