read_extent_buffer(leaf, tmp, ptr, inline_size);
+ ret = btrfs_decompress(compress_type, tmp, page,
+ extent_offset, inline_size, max_size);
/*
- * We can't have max_size > PAGE_CACHE_SIZE because we only
- * allocated one page. We can't have max_size < PAGE_CACHE_SIZE
- * because we might extend the file past the end of the page,
- * so we need to memset the end of the buffer to zero. Since
- * max_size can't be anything other than PAGE_CACHE_SIZE,
- * just set it to that value.
+ * Zero out any bytes at the end of the extent. This does not
+ * happen often, but it does happen.
*/
WARN_ON(max_size > PAGE_CACHE_SIZE);
- max_size = PAGE_CACHE_SIZE;
- ret = btrfs_decompress(compress_type, tmp, page,
- extent_offset, inline_size, max_size);
- if (inline_size < PAGE_CACHE_SIZE) {
+ if (max_size < PAGE_CACHE_SIZE) {
char *map = kmap(page);
- memset(map + inline_size, 0, PAGE_CACHE_SIZE - inline_size);
+ memset(map + max_size, 0, PAGE_CACHE_SIZE - max_size);
kunmap(page);
}
kfree(tmp);