linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iomap: Fix error handling in iomap_zero_iter()
@ 2021-12-21  4:44 Matthew Wilcox (Oracle)
  2021-12-21  8:27 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-12-21  4:44 UTC (permalink / raw)
  To: Dan Williams
  Cc: Matthew Wilcox (Oracle),
	Christoph Hellwig, linux-fsdevel, linux-xfs, nvdimm,
	Darrick J. Wong, Dan Carpenter

iomap_write_end() does not return a negative errno to indicate an
error, but the number of bytes successfully copied.  It cannot return
an error today, so include a debugging assertion like the one in
iomap_unshare_iter().

Fixes: c6f40468657d ("fsdax: decouple zeroing from the iomap buffered I/O code")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/iomap/buffered-io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index f3176cf90351..955f51f94b3f 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -901,8 +901,8 @@ static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero)
 		mark_page_accessed(page);
 
 		bytes = iomap_write_end(iter, pos, bytes, bytes, page);
-		if (bytes < 0)
-			return bytes;
+		if (WARN_ON_ONCE(bytes == 0))
+			return -EIO;
 
 		pos += bytes;
 		length -= bytes;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iomap: Fix error handling in iomap_zero_iter()
  2021-12-21  4:44 [PATCH] iomap: Fix error handling in iomap_zero_iter() Matthew Wilcox (Oracle)
@ 2021-12-21  8:27 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2021-12-21  8:27 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: Dan Williams, Christoph Hellwig, linux-fsdevel, linux-xfs,
	nvdimm, Darrick J. Wong, Dan Carpenter

On Tue, Dec 21, 2021 at 04:44:50AM +0000, Matthew Wilcox (Oracle) wrote:
> iomap_write_end() does not return a negative errno to indicate an
> error, but the number of bytes successfully copied.  It cannot return
> an error today, so include a debugging assertion like the one in
> iomap_unshare_iter().

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-21  8:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21  4:44 [PATCH] iomap: Fix error handling in iomap_zero_iter() Matthew Wilcox (Oracle)
2021-12-21  8:27 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).