linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH] freevxfs: Convert vxfs_immed_read_folio to the new folio APIs
Date: Wed,  6 Dec 2023 20:46:29 +0000	[thread overview]
Message-ID: <20231206204629.771797-1-willy@infradead.org> (raw)

Use folio_fill_tail() and folio_end_read() instead of open-coding them.
Add a sanity check in case a folio is allocated above index 0.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/freevxfs/vxfs_immed.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/fs/freevxfs/vxfs_immed.c b/fs/freevxfs/vxfs_immed.c
index 9b49ec36e667..b9c6c7118e58 100644
--- a/fs/freevxfs/vxfs_immed.c
+++ b/fs/freevxfs/vxfs_immed.c
@@ -28,19 +28,16 @@
  * Locking status:
  *   @folio is locked and will be unlocked.
  */
-static int vxfs_immed_read_folio(struct file *fp, struct folio *folio)
+static int vxfs_immed_read_folio(struct file *file, struct folio *folio)
 {
 	struct vxfs_inode_info *vip = VXFS_INO(folio->mapping->host);
-	void *src = vip->vii_immed.vi_immed + folio_pos(folio);
-	unsigned long i;
+	size_t len = VXFS_NIMMED;
 
-	for (i = 0; i < folio_nr_pages(folio); i++) {
-		memcpy_to_page(folio_page(folio, i), 0, src, PAGE_SIZE);
-		src += PAGE_SIZE;
-	}
+	if (folio->index > 0)
+		len = 0;
 
-	folio_mark_uptodate(folio);
-	folio_unlock(folio);
+	folio_fill_tail(folio, 0, vip->vii_immed.vi_immed, len);
+	folio_end_read(folio, true);
 
 	return 0;
 }
-- 
2.42.0


             reply	other threads:[~2023-12-06 20:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 20:46 Matthew Wilcox (Oracle) [this message]
2023-12-07  5:24 ` [PATCH] freevxfs: Convert vxfs_immed_read_folio to the new folio APIs Christoph Hellwig
2023-12-07 13:22   ` Matthew Wilcox
2023-12-12  7:44     ` Christoph Hellwig

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=20231206204629.771797-1-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).