diff mbox series

[RFC,14/31] btrfs: end EXTENT_MAP_INLINE writeback early

Message ID 6a5603135d159456d68a566900306cb86b5bbcb1.1623567940.git.rgoldwyn@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs buffered iomap support | expand

Commit Message

Goldwyn Rodrigues June 13, 2021, 1:39 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

writes to inline extent maps are finished immediately and does
not go through the entire writeback cycle of creation or submission of
bios.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/inode.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b8fcf9102eb2..0601cf375b9c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8346,7 +8346,22 @@  static int btrfs_map_blocks(struct iomap_writepage_ctx *wpc,
 		return ret;
 
 	/* TODO: handle compressed extents */
-	return btrfs_set_iomap(inode, offset, end - offset, &wpc->iomap);
+	ret = btrfs_set_iomap(inode, offset, end - offset, &wpc->iomap);
+	if (ret < 0) {
+		__endio_write_update_ordered(BTRFS_I(inode), start, end, false);
+		return ret;
+	}
+
+	if (wpc->iomap.type == IOMAP_INLINE) {
+		/*
+		 * In case of EXTENT_MAP_INLINE, call endio function
+		 * and reset type to IOMAP_HOLE, so iomap code does not
+		 * perform any action
+		 */
+		__endio_write_update_ordered(BTRFS_I(inode), start, end, true);
+		wpc->iomap.type = IOMAP_HOLE;
+	}
+	return 0;
 }
 
 static void btrfs_writepage_endio(struct bio *bio)