btrfs: add wrapper for counting BTRFS_MAX_EXTENT_SIZE
The expression is open-coded in several places, this asks for a wrapper. As we know the MAX_EXTENT fits to u32, we can use the appropirate division helper. This cascades to the result type updates. Compiler is clever enough to use shift instead of integer division, so there's no change in the generated assembly. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
@@ -5844,11 +5844,9 @@ static unsigned drop_outstanding_extent(struct inode *inode, u64 num_bytes)
|
||||
{
|
||||
unsigned drop_inode_space = 0;
|
||||
unsigned dropped_extents = 0;
|
||||
unsigned num_extents = 0;
|
||||
unsigned num_extents;
|
||||
|
||||
num_extents = (unsigned)div64_u64(num_bytes +
|
||||
BTRFS_MAX_EXTENT_SIZE - 1,
|
||||
BTRFS_MAX_EXTENT_SIZE);
|
||||
num_extents = count_max_extents(num_bytes);
|
||||
ASSERT(num_extents);
|
||||
ASSERT(BTRFS_I(inode)->outstanding_extents >= num_extents);
|
||||
BTRFS_I(inode)->outstanding_extents -= num_extents;
|
||||
@@ -5927,7 +5925,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
|
||||
struct btrfs_block_rsv *block_rsv = &fs_info->delalloc_block_rsv;
|
||||
u64 to_reserve = 0;
|
||||
u64 csum_bytes;
|
||||
unsigned nr_extents = 0;
|
||||
unsigned nr_extents;
|
||||
enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_FLUSH_ALL;
|
||||
int ret = 0;
|
||||
bool delalloc_lock = true;
|
||||
@@ -5960,9 +5958,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
|
||||
num_bytes = ALIGN(num_bytes, fs_info->sectorsize);
|
||||
|
||||
spin_lock(&BTRFS_I(inode)->lock);
|
||||
nr_extents = (unsigned)div64_u64(num_bytes +
|
||||
BTRFS_MAX_EXTENT_SIZE - 1,
|
||||
BTRFS_MAX_EXTENT_SIZE);
|
||||
nr_extents = count_max_extents(num_bytes);
|
||||
BTRFS_I(inode)->outstanding_extents += nr_extents;
|
||||
|
||||
nr_extents = 0;
|
||||
|
Reference in New Issue
Block a user