diff mbox series

[1/2] btrfs: clear folio writeback after completing ordered range

Message ID 9198bf5c9c56df6dc78a45ed2341595cb6307fef.1724095925.git.rgoldwyn@suse.com (mailing list archive)
State New, archived
Headers show
Series Reduce scope of extent locking while reading | expand

Commit Message

Goldwyn Rodrigues Aug. 19, 2024, 8 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Mark the folio as completed writeback only after ordered range has been
marked as finished. This is to make sure that the CRCs are written to
disk before a disk read is performed.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/extent_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 0bc4fa1f15cb..695589f02263 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -470,11 +470,11 @@  static void end_bbio_data_write(struct btrfs_bio *bbio)
 		"incomplete page write with offset %zu and length %zu",
 				   fi.offset, fi.length);
 
-		btrfs_finish_ordered_extent(bbio->ordered, folio, start, len,
-					    !error);
 		if (error)
 			mapping_set_error(folio->mapping, error);
 		btrfs_folio_clear_writeback(fs_info, folio, start, len);
+		btrfs_finish_ordered_extent(bbio->ordered, folio, start, len,
+					    !error);
 	}
 
 	bio_put(bio);