public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH] mm/page_io: use folios in sio_write_complete()
@ 2026-03-23 17:04 David Carlier
  2026-03-23 22:54 ` Andrew Morton
  2026-03-23 23:13 ` [PATCH] mm/page_io: fix PSWPIN undercount for large folios in sio_read_complete() David Carlier
  0 siblings, 2 replies; 4+ messages in thread
From: David Carlier @ 2026-03-23 17:04 UTC (permalink / raw)
  To: Kairui Song, Chris Li, Andrew Morton, Kemeng Shi; +Cc: linux-mm, David Carlier

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



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

end of thread, other threads:[~2026-03-23 23:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 17:04 [PATCH] mm/page_io: use folios in sio_write_complete() David Carlier
2026-03-23 22:54 ` Andrew Morton
2026-03-23 23:07   ` David CARLIER
2026-03-23 23:13 ` [PATCH] mm/page_io: fix PSWPIN undercount for large folios in sio_read_complete() David Carlier

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