mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
btrfs: use kvmalloc() for uncompress_inline()
Although btrfs doesn't support inlined extents larger than PAGE_SIZE for bs > ps cases, it's still possible for the experimental bs > ps support to mount a btrfs created on a system with a much larger page size, thus can still hit an inlined extent that is way larger than the current page size. E.g. a compressed inline extent which has 32K compressed size, is created on 64K page sized ARM64 with 64K sectorsize, then mounted on x86_64 with the experimental bs > ps support. In that case, when reading the compressed inline extent, we need to allocate a buffer that is the same size as the compressed inline extent (32K). That kmalloc() call will request physically contiguous memory for that 32K allocation, and if the system has a very fragmented memory space, such allocation can fail. But there is really no reason that we require such buffer to be physically contiguous, so change it to kvmalloc() to reduce the chance of allocation failure for bs > ps cases. And for all bs <= ps cases, the kvmalloc() call will just be fulfilled by kmalloc() so this will not bring any change to the most common cases. Only bs > ps will get the benefit of less memory allocation failure. Reviewed-by: Daniel Vacek <neelx@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
0d8c05fe05
commit
883a1a260c
|
|
@ -7149,7 +7149,7 @@ static noinline int uncompress_inline(struct btrfs_path *path,
|
|||
compress_type = btrfs_file_extent_compression(leaf, item);
|
||||
max_size = btrfs_file_extent_ram_bytes(leaf, item);
|
||||
inline_size = btrfs_file_extent_inline_item_len(leaf, path->slots[0]);
|
||||
tmp = kmalloc(inline_size, GFP_NOFS);
|
||||
tmp = kvmalloc(inline_size, GFP_NOFS);
|
||||
if (!tmp)
|
||||
return -ENOMEM;
|
||||
ptr = btrfs_file_extent_inline_start(item);
|
||||
|
|
@ -7170,7 +7170,7 @@ static noinline int uncompress_inline(struct btrfs_path *path,
|
|||
|
||||
if (max_size < blocksize)
|
||||
folio_zero_range(folio, max_size, blocksize - max_size);
|
||||
kfree(tmp);
|
||||
kvfree(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user