linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: hch@infradead.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-xfs@vger.kernel.org
Subject: [PATCH 2/2] iomap: Convert page_mkwrite to iter API
Date: Wed,  1 Apr 2020 08:25:22 -0700	[thread overview]
Message-ID: <20200401152522.20737-3-willy@infradead.org> (raw)
In-Reply-To: <20200401152522.20737-1-willy@infradead.org>

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

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

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 7c84c4c027c4..d91d1d5a0f84 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1051,50 +1051,37 @@ iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
 }
 EXPORT_SYMBOL_GPL(iomap_truncate_page);
 
-static loff_t
-iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length,
-		void *data, struct iomap *iomap, struct iomap *srcmap)
-{
-	struct page *page = data;
-	int ret;
-
-	if (iomap->flags & IOMAP_F_BUFFER_HEAD) {
-		ret = __block_write_begin_int(page, pos, length, NULL, iomap);
-		if (ret)
-			return ret;
-		block_commit_write(page, 0, length);
-	} else {
-		WARN_ON_ONCE(!PageUptodate(page));
-		iomap_page_create(inode, page);
-		set_page_dirty(page);
-	}
-
-	return length;
-}
-
 vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops)
 {
 	struct page *page = vmf->page;
 	struct inode *inode = file_inode(vmf->vma->vm_file);
-	unsigned long length;
-	loff_t offset;
-	ssize_t ret;
+	DEFINE_IOMAP_ITER(iter, inode, page_offset(page), 0,
+			IOMAP_WRITE | IOMAP_FAULT, ops);
+	loff_t ret, len = IOMAP_FIRST_CALL;
 
 	lock_page(page);
 	ret = page_mkwrite_check_truncate(page, inode);
 	if (ret < 0)
 		goto out_unlock;
-	length = ret;
+	iter.len = ret;
 
-	offset = page_offset(page);
-	while (length > 0) {
-		ret = iomap_apply(inode, offset, length,
-				IOMAP_WRITE | IOMAP_FAULT, ops, page,
-				iomap_page_mkwrite_actor);
+	for (;;) {
+		ret = iomap_iter(&iter, len);
 		if (unlikely(ret <= 0))
 			goto out_unlock;
-		offset += ret;
-		length -= ret;
+		len = ret;
+
+		if (iter.iomap.flags & IOMAP_F_BUFFER_HEAD) {
+			ret = __block_write_begin_int(page, iter.pos, len,
+					NULL, &iter.iomap);
+			if (ret)
+				goto out_unlock;
+			block_commit_write(page, 0, len);
+		} else {
+			WARN_ON_ONCE(!PageUptodate(page));
+			iomap_page_create(inode, page);
+			set_page_dirty(page);
+		}
 	}
 
 	wait_for_stable_page(page);
-- 
2.25.1


      parent reply	other threads:[~2020-04-01 15:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01 15:25 [RFC 0/2] Begin switching iomap from apply to iter Matthew Wilcox
2020-04-01 15:25 ` [PATCH 1/2] iomap: Add iomap_iter API Matthew Wilcox
2020-04-01 15:42   ` Christoph Hellwig
2020-04-01 18:42     ` Matthew Wilcox
2020-04-22 15:19       ` Jan Kara
2020-04-01 19:20     ` Matthew Wilcox
2020-04-02  7:48       ` Christoph Hellwig
2020-04-01 15:25 ` Matthew Wilcox [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=20200401152522.20737-3-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=hch@infradead.org \
    --cc=linux-xfs@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).