diff mbox series

[3/6] btrfs: directly wait for buffer writeback completion in btrfs_wait_buffers

Message ID 20230515192256.29006-4-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/6] btrfs: use a linked list for tracking per-transaction/log dirty buffers | expand

Commit Message

Christoph Hellwig May 15, 2023, 7:22 p.m. UTC
Don't bother to got to filemap_fdatawait_range to look up each page in an
extent_buffer and then wait for writeback completion on each page, but
instead just call wait_on_extent_buffer_writeback on the buffer.  All
write errors are propagated through the EXTENT_BUFFER_WRITE_ERR bit on
the extent_buffer itself, so there is no need to check for per-page
errors either.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/extent_buffer.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/extent_buffer.c b/fs/btrfs/extent_buffer.c
index d20fc0d113968f..70a6a5f2e0e0a8 100644
--- a/fs/btrfs/extent_buffer.c
+++ b/fs/btrfs/extent_buffer.c
@@ -63,19 +63,15 @@  int btrfs_write_buffers(struct btrfs_fs_info *fs_info, struct list_head *list)
 
 int btrfs_wait_buffers(struct btrfs_fs_info *fs_info, struct list_head *list)
 {
-	struct address_space *mapping = fs_info->btree_inode->i_mapping;
 	struct dirty_buffer *db;
-	int werr = 0, err;
+	int werr = 0;
 
 	while ((db = list_first_entry_or_null(list, struct dirty_buffer,
 			wb_entry))) {
 		list_del_init(&db->wb_entry);
 
-		err = filemap_fdatawait_range(mapping, db->eb->start,
-					      db->eb->start + db->eb->len - 1);
-		if (err)
-			werr = err;
-		if (!werr && test_bit(EXTENT_BUFFER_WRITE_ERR, &db->eb->bflags))
+		wait_on_extent_buffer_writeback(db->eb);
+		if (test_bit(EXTENT_BUFFER_WRITE_ERR, &db->eb->bflags))
 			werr = -EIO;
 		free_extent_buffer(db->eb);
 		kfree(db);