Blob Blame History Raw
From b71450e2cc4b3c79f33c5bd276d152af9bd54f79 Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruenba@redhat.com>
Date: Thu, 5 May 2022 18:19:13 -0700
Subject: [PATCH] iomap: iomap_write_failed fix
Git-commit: b71450e2cc4b3c79f33c5bd276d152af9bd54f79
Patch-mainline: v5.19-rc1
References: bsc#1200829

The @lend parameter of truncate_pagecache_range() should be the offset
of the last byte of the hole, not the first byte beyond it.

Fixes: ae259a9c8593 ("fs: introduce iomap infrastructure")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Acked-by: Jan Kara <jack@suse.cz>

---
 fs/iomap.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -530,7 +530,8 @@ iomap_write_failed(struct inode *inode,
 	 * write started inside the existing inode size.
 	 */
 	if (pos + len > i_size)
-		truncate_pagecache_range(inode, max(pos, i_size), pos + len);
+		truncate_pagecache_range(inode, max(pos, i_size),
+					 pos + len - 1);
 }
 
 static int