linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org
Subject: [PATCH 24/24] ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback()
Date: Fri, 27 May 2022 16:50:36 +0100	[thread overview]
Message-ID: <20220527155036.524743-25-willy@infradead.org> (raw)
In-Reply-To: <20220527155036.524743-1-willy@infradead.org>

Remove the open-coding of filemap_fdatawait_range().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ocfs2/refcounttree.c | 42 ++++++-----------------------------------
 1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index e04358a46b68..1358981e80a3 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -3146,48 +3146,18 @@ int ocfs2_cow_sync_writeback(struct super_block *sb,
 			     struct inode *inode,
 			     u32 cpos, u32 num_clusters)
 {
-	int ret = 0;
-	loff_t offset, end, map_end;
-	pgoff_t page_index;
-	struct page *page;
+	int ret;
+	loff_t start, end;
 
 	if (ocfs2_should_order_data(inode))
 		return 0;
 
-	offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
-	end = offset + (num_clusters << OCFS2_SB(sb)->s_clustersize_bits);
+	start = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
+	end = start + (num_clusters << OCFS2_SB(sb)->s_clustersize_bits) - 1;
 
-	ret = filemap_fdatawrite_range(inode->i_mapping,
-				       offset, end - 1);
-	if (ret < 0) {
+	ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
+	if (ret < 0)
 		mlog_errno(ret);
-		return ret;
-	}
-
-	while (offset < end) {
-		page_index = offset >> PAGE_SHIFT;
-		map_end = ((loff_t)page_index + 1) << PAGE_SHIFT;
-		if (map_end > end)
-			map_end = end;
-
-		page = find_or_create_page(inode->i_mapping,
-					   page_index, GFP_NOFS);
-		BUG_ON(!page);
-
-		wait_on_page_writeback(page);
-		if (PageError(page)) {
-			ret = -EIO;
-			mlog_errno(ret);
-		} else
-			mark_page_accessed(page);
-
-		unlock_page(page);
-		put_page(page);
-		page = NULL;
-		offset = map_end;
-		if (ret)
-			break;
-	}
 
 	return ret;
 }
-- 
2.34.1



  parent reply	other threads:[~2022-05-27 15:50 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 15:50 [PATCH 00/24] Begin removing PageError Matthew Wilcox (Oracle)
2022-05-27 15:50 ` [PATCH 01/24] block: Remove check of PageError Matthew Wilcox (Oracle)
2022-05-28  5:47   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 02/24] afs: " Matthew Wilcox (Oracle)
2022-05-28  5:47   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 03/24] freevxfs: " Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 04/24] gfs: Check PageUptodate instead " Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 05/24] hfs: Remove check for PageError Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 06/24] hfsplus: " Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 07/24] ntfs: " Matthew Wilcox (Oracle)
2022-05-28  5:48   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 08/24] ext2: " Matthew Wilcox (Oracle)
2022-05-28  5:49   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 09/24] nilfs2: " Matthew Wilcox (Oracle)
2022-05-28  5:49   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 10/24] ntfs: " Matthew Wilcox (Oracle)
2022-05-28  5:49   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 11/24] ntfs3: " Matthew Wilcox (Oracle)
2022-05-28  5:51   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 12/24] reiserfs: " Matthew Wilcox (Oracle)
2022-05-28  5:52   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 13/24] ufs: Remove checks " Matthew Wilcox (Oracle)
2022-05-28  5:56   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 14/24] remap_range: Remove check of uptodate flag Matthew Wilcox (Oracle)
2022-05-28  5:59   ` Christoph Hellwig
2022-05-30 12:35     ` Matthew Wilcox
2022-05-27 15:50 ` [PATCH 15/24] jfs: Remove check for PageUptodate Matthew Wilcox (Oracle)
2022-05-28  5:59   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 16/24] iomap: Remove test for folio error Matthew Wilcox (Oracle)
2022-05-28  6:00   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 17/24] orangefs: " Matthew Wilcox (Oracle)
2022-05-28  6:00   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 18/24] buffer: Remove check for PageError Matthew Wilcox (Oracle)
2022-05-28  6:01   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 19/24] nfs: Leave pages in the pagecache if readpage failed Matthew Wilcox (Oracle)
2022-05-28  6:02   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 20/24] btrfs: Use a folio in wait_dev_supers() Matthew Wilcox (Oracle)
2022-05-28  6:03   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 21/24] buffer: Don't test folio error in block_read_full_folio() Matthew Wilcox (Oracle)
2022-05-28  6:05   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 22/24] squashfs: Return the actual error from squashfs_read_folio() Matthew Wilcox (Oracle)
2022-05-28  6:06   ` Christoph Hellwig
2022-05-27 15:50 ` [PATCH 23/24] hostfs: Handle page write errors correctly Matthew Wilcox (Oracle)
2022-05-28  6:06   ` Christoph Hellwig
2022-05-27 15:50 ` Matthew Wilcox (Oracle) [this message]
2022-05-28  6:07   ` [PATCH 24/24] ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback() Christoph Hellwig
2022-05-28  6:12 ` [PATCH 00/24] Begin removing PageError 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=20220527155036.524743-25-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.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