btrfs: open code BTRFS_BYTES_TO_BLKS()

That macro is only utilized 4 times, all inside file.c, while we have
tons of open-coded usages.  And since it's a macro, there is no proper
type checks at all.

There isn't much need for such a rarely utilized macro.

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:
Qu Wenruo
2026-08-07 19:17:17 +02:00
committed by David Sterba
parent 67bd829a14
commit 4d36517021
2 changed files with 4 additions and 6 deletions
+4 -4
View File
@@ -2661,8 +2661,8 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
lockstart = round_up(offset, fs_info->sectorsize);
lockend = round_down(offset + len, fs_info->sectorsize) - 1;
same_block = (BTRFS_BYTES_TO_BLKS(fs_info, offset))
== (BTRFS_BYTES_TO_BLKS(fs_info, offset + len - 1));
same_block = (offset >> fs_info->sectorsize_bits) ==
((offset + len - 1) >> fs_info->sectorsize_bits);
/*
* Only do this if we are in the same block and we aren't doing the
* entire block.
@@ -2945,8 +2945,8 @@ static int btrfs_zero_range(struct inode *inode,
}
btrfs_free_extent_map(em);
if (BTRFS_BYTES_TO_BLKS(fs_info, offset) ==
BTRFS_BYTES_TO_BLKS(fs_info, offset + len - 1)) {
if ((offset >> fs_info->sectorsize_bits) ==
((offset + len - 1) >> fs_info->sectorsize_bits)) {
em = btrfs_get_extent(BTRFS_I(inode), NULL, alloc_start, sectorsize);
if (IS_ERR(em)) {
ret = PTR_ERR(em);
-2
View File
@@ -1060,8 +1060,6 @@ static inline u64 btrfs_calc_metadata_size(const struct btrfs_fs_info *fs_info,
#define BTRFS_MAX_EXTENT_ITEM_SIZE(r) ((BTRFS_LEAF_DATA_SIZE(r->fs_info) >> 4) - \
sizeof(struct btrfs_item))
#define BTRFS_BYTES_TO_BLKS(fs_info, bytes) ((bytes) >> (fs_info)->sectorsize_bits)
static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info)
{
return IS_ENABLED(CONFIG_BLK_DEV_ZONED) && fs_info->zone_size > 0;