Skip to content

Commit

Permalink
Linux: use filemap_invalidate_lock
Browse files Browse the repository at this point in the history
to put all the inode pagecache truncations under a single roof

Signed-off-by: Pavel Snajdr <[email protected]>
  • Loading branch information
snajpa committed Nov 3, 2024
1 parent ad5de6f commit 63c5598
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions module/os/linux/zfs/zfs_znode_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 63c5598

Please sign in to comment.