[PATCH] mm/page_io: use folios in sio_write_complete()

David Carlier
2026-03-23T17:04:56Z

Convert sio_write_complete() from legacy page APIs to folio equivalents,
matching the conversion already done for sio_read_complete() in commit
6a8c068774ad ("mm/page_io: use a folio in sio_read_complete()").

Replace set_page_dirty(), ClearPageReclaim() and end_page_writeback()
with folio_mark_dirty(), folio_clear_reclaim() and folio_end_writeback()
respectively, saving implicit calls to compound_head().

Also replace page_swap_entry() with a direct folio->swap access since
bvec entries are always set via bvec_set_folio(), meaning bv_page is
always the head page.

Signed-off-by: David Carlier <devnexen@gmail.com>
---
mm/page_io.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 63b262f4c5a9..6c7ab3c394ad 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -348,7 +348,6 @@ int sio_pool_init(void)
static void sio_write_complete(struct kiocb *iocb, long ret)
{
struct swap_iocb *sio = container_of(iocb, struct swap_iocb, iocb);
- struct page *page = sio->bvec[0].bv_page;
int p;

if (ret != sio->len) {
@@ -356,21 +355,24 @@ static void sio_write_complete(struct kiocb *iocb, long ret)
* In the case of swap-over-nfs, this can be a
* temporary failure if the system has limited
* memory for allocating transmit buffers.
- * Mark the page dirty and avoid
+ * Mark the folio dirty and avoid
* folio_rotate_reclaimable but rate-limit the
* messages.
*/
+ struct folio *folio = page_folio(sio->bvec[0].bv_page);
pr_err_ratelimited("Write error %ld on dio swapfile (%llu)\n",
- ret, swap_dev_pos(page_swap_entry(page)));
+ ret, swap_dev_pos(folio->swap));
for (p = 0; p < sio->pages; p++) {
- page = sio->bvec[p].bv_page;
- set_page_dirty(page);
- ClearPageReclaim(page);
+ folio = page_folio(sio->bvec[p].bv_page);
+ folio_mark_dirty(folio);
+ folio_clear_reclaim(folio);
}
}

- for (p = 0; p < sio->pages; p++)
- end_page_writeback(sio->bvec[p].bv_page);
+ for (p = 0; p < sio->pages; p++) {
+ struct folio *folio = page_folio(sio->bvec[p].bv_page);
+ folio_end_writeback(folio);
+ }

mempool_free(sio, sio_pool);
}
--
2.53.0