iomap: iomap_write_failed fix
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 6 May 2022 01:19:13 +0000 (18:19 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:55 +0000 (10:22 +0200)
[ Upstream commit b71450e2cc4b3c79f33c5bd276d152af9bd54f79 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/iomap/buffered-io.c

index fe10d8a30f6bdff13e966c2c42497403c06b1269..87a4f5a2ded0e521f15a009a2b59d0aea6f2c8d2 100644 (file)
@@ -525,7 +525,8 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
         * 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