Commit 0044ae11 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: make free space cache size consistent across different PAGE_SIZE

Currently free space cache inode size is determined by two factors:

- block group size
- PAGE_SIZE

This means, for the same sized block groups, with different PAGE_SIZE,
it will result in different inode sizes.

This will not be a good thing for subpage support, so change the
requirement for PAGE_SIZE to sectorsize.

Now for the same 4K sectorsize btrfs, it should result the same inode
size no matter what the PAGE_SIZE is.
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 8df507cb
......@@ -2505,7 +2505,7 @@ static int cache_save_setup(struct btrfs_block_group *block_group,
struct extent_changeset *data_reserved = NULL;
u64 alloc_hint = 0;
int dcs = BTRFS_DC_ERROR;
u64 num_pages = 0;
u64 cache_size = 0;
int retries = 0;
int ret = 0;
......@@ -2617,20 +2617,20 @@ static int cache_save_setup(struct btrfs_block_group *block_group,
* taking up quite a bit since it's not folded into the other space
* cache.
*/
num_pages = div_u64(block_group->length, SZ_256M);
if (!num_pages)
num_pages = 1;
cache_size = div_u64(block_group->length, SZ_256M);
if (!cache_size)
cache_size = 1;
num_pages *= 16;
num_pages *= PAGE_SIZE;
cache_size *= 16;
cache_size *= fs_info->sectorsize;
ret = btrfs_check_data_free_space(BTRFS_I(inode), &data_reserved, 0,
num_pages);
cache_size);
if (ret)
goto out_put;
ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages,
num_pages, num_pages,
ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, cache_size,
cache_size, cache_size,
&alloc_hint);
/*
* Our cache requires contiguous chunks so that we don't modify a bunch
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment