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>,
	"Darrick J . Wong" <djwong@kernel.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Gao Xiang <xiang@kernel.org>
Subject: [PATCH 2/2] iomap: Use folio_copy_tail()
Date: Fri,  3 Mar 2023 06:43:15 +0000	[thread overview]
Message-ID: <20230303064315.701090-3-willy@infradead.org> (raw)
In-Reply-To: <20230303064315.701090-1-willy@infradead.org>

The iomap handling of tails doesn't support multi-page folios, so
convert it to call folio_copy_tail(), which does.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/iomap/buffered-io.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 10a203515583..d08edf2de19c 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -215,31 +215,20 @@ static int iomap_read_inline_data(const struct iomap_iter *iter,
 {
 	struct iomap_page *iop;
 	const struct iomap *iomap = iomap_iter_srcmap(iter);
-	size_t size = i_size_read(iter->inode) - iomap->offset;
-	size_t poff = offset_in_page(iomap->offset);
-	size_t offset = offset_in_folio(folio, iomap->offset);
-	void *addr;
+	loff_t pos = iomap->offset;
 
 	if (folio_test_uptodate(folio))
 		return 0;
 
-	if (WARN_ON_ONCE(size > PAGE_SIZE - poff))
-		return -EIO;
-	if (WARN_ON_ONCE(size > PAGE_SIZE -
-			 offset_in_page(iomap->inline_data)))
-		return -EIO;
-	if (WARN_ON_ONCE(size > iomap->length))
-		return -EIO;
-	if (offset > 0)
+	if (pos > folio_pos(folio))
 		iop = iomap_page_create(iter->inode, folio, iter->flags);
 	else
 		iop = to_iomap_page(folio);
 
-	addr = kmap_local_folio(folio, offset);
-	memcpy(addr, iomap->inline_data, size);
-	memset(addr + size, 0, PAGE_SIZE - poff - size);
-	kunmap_local(addr);
-	iomap_set_range_uptodate(folio, iop, offset, PAGE_SIZE - poff);
+	folio_copy_tail(folio, pos, iomap->inline_data,
+			iomap->length);
+	iomap_set_range_uptodate(folio, iop, pos - folio_pos(folio),
+			folio_size(folio) - offset_in_folio(folio, pos));
 	return 0;
 }
 
-- 
2.39.1


      parent reply	other threads:[~2023-03-03  6:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03  6:43 [PATCH 0/2] folio_copy_tail Matthew Wilcox (Oracle)
2023-03-03  6:43 ` [PATCH 1/2] filemap: Add folio_copy_tail() Matthew Wilcox (Oracle)
2023-03-03 12:05   ` kernel test robot
2023-03-03  6:43 ` Matthew Wilcox (Oracle) [this message]

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=20230303064315.701090-3-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=agruenba@redhat.com \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=xiang@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).