Blob Blame History Raw
From 14284fedf59f1647264f4603d64418cf1fcd3eb0 Mon Sep 17 00:00:00 2001
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Date: Thu, 10 Sep 2020 08:26:18 -0700
Subject: [PATCH] iomap: Mark read blocks uptodate in write_begin
Git-commit: 14284fedf59f1647264f4603d64418cf1fcd3eb0
Patch-mainline: v5.10-rc1
References: bsc#1179684

When bringing (portions of) a page uptodate, we were marking blocks that
were zeroed as being uptodate, but not blocks that were read from storage.

Like the previous commit, this problem was found with generic/127 and
a kernel which failed readahead I/Os.  This bug causes writes to be
silently lost when working with flaky storage.

Fixes: 9dc55f1389f9 ("iomap: add support for sub-pagesize buffered I/O without buffer heads")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jan Kara <jack@suse.cz>

---
 fs/iomap/buffered-io.c |    1 +
 1 file changed, 1 insertion(+)

--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -587,6 +587,7 @@ __iomap_write_begin(struct inode *inode,
 					poff, plen, from, to, iomap);
 			if (status)
 				break;
+			iomap_set_range_uptodate(page, poff, plen);
 		}
 
 	} while ((block_start += plen) < block_end);