[PATCH] iomap: Handle I/O errors gracefully in page_mkwrite

From: Matthew Wilcox
Date: Thu Jun 04 2020 - 16:23:50 EST


From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>

Test generic/019 often results in:

WARNING: at fs/iomap/buffered-io.c:1069 iomap_page_mkwrite_actor+0x57/0x70

Since this can happen due to a storage error, we should not WARN for it.
Just return -EIO, which will be converted to a SIGBUS for the hapless
task attempting to write to the page that we can't read.

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
fs/iomap/buffered-io.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 89e21961d1ad..ae6c5e38f0e8 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1066,7 +1066,8 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length,
return ret;
block_commit_write(page, 0, length);
} else {
- WARN_ON_ONCE(!PageUptodate(page));
+ if (!PageUptodate(page))
+ return -EIO;
iomap_page_create(inode, page);
set_page_dirty(page);
}
--
2.26.2