btrfs: replace div_u64 by shift in free_space_bitmap_size
Change free_space_bitmap_size to take btrfs_fs_info so we can get the sectorsize_bits to do calculations. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Родитель
ab108d992b
Коммит
098e63082b
|
@ -136,9 +136,10 @@ static int btrfs_search_prev_slot(struct btrfs_trans_handle *trans,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline u32 free_space_bitmap_size(u64 size, u32 sectorsize)
|
||||
static inline u32 free_space_bitmap_size(const struct btrfs_fs_info *fs_info,
|
||||
u64 size)
|
||||
{
|
||||
return DIV_ROUND_UP((u32)div_u64(size, sectorsize), BITS_PER_BYTE);
|
||||
return DIV_ROUND_UP(size >> fs_info->sectorsize_bits, BITS_PER_BYTE);
|
||||
}
|
||||
|
||||
static unsigned long *alloc_bitmap(u32 bitmap_size)
|
||||
|
@ -200,8 +201,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
|
|||
int done = 0, nr;
|
||||
int ret;
|
||||
|
||||
bitmap_size = free_space_bitmap_size(block_group->length,
|
||||
fs_info->sectorsize);
|
||||
bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
|
||||
bitmap = alloc_bitmap(bitmap_size);
|
||||
if (!bitmap) {
|
||||
ret = -ENOMEM;
|
||||
|
@ -290,8 +290,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
|
|||
u32 data_size;
|
||||
|
||||
extent_size = min(end - i, bitmap_range);
|
||||
data_size = free_space_bitmap_size(extent_size,
|
||||
fs_info->sectorsize);
|
||||
data_size = free_space_bitmap_size(fs_info, extent_size);
|
||||
|
||||
key.objectid = i;
|
||||
key.type = BTRFS_FREE_SPACE_BITMAP_KEY;
|
||||
|
@ -339,8 +338,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
|
|||
int done = 0, nr;
|
||||
int ret;
|
||||
|
||||
bitmap_size = free_space_bitmap_size(block_group->length,
|
||||
fs_info->sectorsize);
|
||||
bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
|
||||
bitmap = alloc_bitmap(bitmap_size);
|
||||
if (!bitmap) {
|
||||
ret = -ENOMEM;
|
||||
|
@ -383,8 +381,8 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
|
|||
fs_info->sectorsize *
|
||||
BITS_PER_BYTE);
|
||||
bitmap_cursor = ((char *)bitmap) + bitmap_pos;
|
||||
data_size = free_space_bitmap_size(found_key.offset,
|
||||
fs_info->sectorsize);
|
||||
data_size = free_space_bitmap_size(fs_info,
|
||||
found_key.offset);
|
||||
|
||||
ptr = btrfs_item_ptr_offset(leaf, path->slots[0] - 1);
|
||||
read_extent_buffer(leaf, bitmap_cursor, ptr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче