iomap: iomap_write_failed fix
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 6 May 2022 01:19:13 +0000 (18:19 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Sun, 8 May 2022 21:47:42 +0000 (14:47 -0700)
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>
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,