Skip to content

Commit 63c5598

Browse files
committed
Linux: use filemap_invalidate_lock
to put all the inode pagecache truncations under a single roof Signed-off-by: Pavel Snajdr <[email protected]>
1 parent ad5de6f commit 63c5598

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

module/os/linux/zfs/zfs_znode_os.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,7 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
17611761
sizeof (mode))) != 0)
17621762
return (error);
17631763

1764+
filemap_invalidate_lock(ZTOI(zp)->i_mapping);
17641765
if (off > zp->z_size) {
17651766
error = zfs_extend(zp, off+len);
17661767
if (error == 0 && log)
@@ -1803,13 +1804,9 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
18031804
error = 0;
18041805

18051806
out:
1806-
/*
1807-
* Truncate the page cache - for file truncate operations, use
1808-
* the purpose-built API for truncations. For punching operations,
1809-
* the truncation is handled under a range lock in zfs_free_range.
1810-
*/
1811-
if (len == 0)
1807+
if (!len)
18121808
truncate_setsize(ZTOI(zp), off);
1809+
filemap_invalidate_unlock(ZTOI(zp)->i_mapping);
18131810
return (error);
18141811
}
18151812

0 commit comments

Comments
 (0)