]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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:30:08 +0000 (10:30 +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 8ce8720093b9afc41187175422f73a4fbf250b8f..358ee1fb6f0dbccebe62ea1a45230dffb41c2dc4 100644 (file)
@@ -531,7 +531,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 iomap_read_folio_sync(loff_t block_start, struct folio *folio,