All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Carlier <devnexen@gmail.com>
To: Kairui Song <kasong@tencent.com>, Chris Li <chrisl@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kemeng Shi <shikemeng@huaweicloud.com>
Cc: linux-mm@kvack.org, David Carlier <devnexen@gmail.com>
Subject: [PATCH] mm/page_io: use folios in sio_write_complete()
Date: Mon, 23 Mar 2026 17:04:49 +0000	[thread overview]
Message-ID: <20260323170449.26333-1-devnexen@gmail.com> (raw)

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



             reply	other threads:[~2026-03-23 17:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 17:04 David Carlier [this message]
2026-03-23 22:54 ` [PATCH] mm/page_io: use folios in sio_write_complete() 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
2026-03-30  6:37   ` David Hildenbrand (Arm)

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=20260323170449.26333-1-devnexen@gmail.com \
    --to=devnexen@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisl@kernel.org \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=shikemeng@huaweicloud.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.