From 63c5598588c9e52939101df8fa78d8d9ec3f9351 Mon Sep 17 00:00:00 2001 From: Pavel Snajdr Date: Sun, 3 Nov 2024 22:17:03 +0100 Subject: [PATCH] Linux: use filemap_invalidate_lock to put all the inode pagecache truncations under a single roof Signed-off-by: Pavel Snajdr --- module/os/linux/zfs/zfs_znode_os.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/module/os/linux/zfs/zfs_znode_os.c b/module/os/linux/zfs/zfs_znode_os.c index a779f56b9fcd..9af3a13575ea 100644 --- a/module/os/linux/zfs/zfs_znode_os.c +++ b/module/os/linux/zfs/zfs_znode_os.c @@ -1761,6 +1761,7 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log) sizeof (mode))) != 0) return (error); + filemap_invalidate_lock(ZTOI(zp)->i_mapping); if (off > zp->z_size) { error = zfs_extend(zp, off+len); if (error == 0 && log) @@ -1803,13 +1804,9 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log) error = 0; out: - /* - * Truncate the page cache - for file truncate operations, use - * the purpose-built API for truncations. For punching operations, - * the truncation is handled under a range lock in zfs_free_range. - */ - if (len == 0) + if (!len) truncate_setsize(ZTOI(zp), off); + filemap_invalidate_unlock(ZTOI(zp)->i_mapping); return (error); }