Message ID | 20230202204428.3267832-6-willy@infradead.org |
---|---|
State | Not Applicable |
Headers | show |
Series | Fix a minor POSIX conformance problem | expand |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 98a800b8bd43..b61ec4bb9cf0 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5234,6 +5234,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) i_size_write(inode, newsize); btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0); pagecache_isize_extended(inode, oldsize, newsize); + truncate_pagecache(inode, oldsize); ret = btrfs_update_inode(trans, root, BTRFS_I(inode)); btrfs_drew_write_unlock(&root->snapshot_lock); btrfs_end_transaction(trans);
POSIX requires that "If the file size is increased, the extended area shall appear as if it were zero-filled". It is possible to use mmap to write past EOF and that data will become visible instead of zeroes. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- fs/btrfs/inode.c | 1 + 1 file changed, 1 insertion(+)