Skip to content

Commit 93c82d5

Browse files
committed
Btrfs: zero page past end of inline file items
When btrfs_get_extent is reading inline file items for readpage, it needs to copy the inline extent into the page. If the inline extent doesn't cover all of the page, that means there is a hole in the file, or that our file is smaller than one page. readpage does zeroing for the case where the file is smaller than one page, but nobody is currently zeroing for the case where there is a hole after the inline item. This commit changes btrfs_get_extent to zero fill the page past the end of the inline item. Signed-off-by: Chris Mason <[email protected]>
1 parent 50a9b21 commit 93c82d5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/btrfs/inode.c

+5
Original file line numberDiff line numberDiff line change
@@ -4233,6 +4233,11 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
42334233
map = kmap(page);
42344234
read_extent_buffer(leaf, map + pg_offset, ptr,
42354235
copy_size);
4236+
if (pg_offset + copy_size < PAGE_CACHE_SIZE) {
4237+
memset(map + pg_offset + copy_size, 0,
4238+
PAGE_CACHE_SIZE - pg_offset -
4239+
copy_size);
4240+
}
42364241
kunmap(page);
42374242
}
42384243
flush_dcache_page(page);

0 commit comments

Comments
 (0)