Skip to content

Commit 5ef1286

Browse files
adam900710kdave
authored andcommitted
btrfs: cache max and min order inside btrfs_fs_info
Inside btrfs_fs_info we cache several bits shift like sectorsize_bits. Apply this to max and min folio orders so that every time mapping order needs to be applied we can skip the calculation. Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent c1e038a commit 5ef1286

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

fs/btrfs/btrfs_inode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ static inline void btrfs_set_inode_mapping_order(struct btrfs_inode *inode)
532532

533533
/* We only allow BITS_PER_LONGS blocks for each bitmap. */
534534
#ifdef CONFIG_BTRFS_EXPERIMENTAL
535-
mapping_set_folio_order_range(inode->vfs_inode.i_mapping, 0,
536-
ilog2(((BITS_PER_LONG << inode->root->fs_info->sectorsize_bits)
537-
>> PAGE_SHIFT)));
535+
mapping_set_folio_order_range(inode->vfs_inode.i_mapping,
536+
inode->root->fs_info->block_min_order,
537+
inode->root->fs_info->block_max_order);
538538
#endif
539539
}
540540

fs/btrfs/disk-io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3383,6 +3383,8 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
33833383
fs_info->nodesize_bits = ilog2(nodesize);
33843384
fs_info->sectorsize = sectorsize;
33853385
fs_info->sectorsize_bits = ilog2(sectorsize);
3386+
fs_info->block_min_order = ilog2(round_up(sectorsize, PAGE_SIZE) >> PAGE_SHIFT);
3387+
fs_info->block_max_order = ilog2((BITS_PER_LONG << fs_info->sectorsize_bits) >> PAGE_SHIFT);
33863388
fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size;
33873389
fs_info->stripesize = stripesize;
33883390
fs_info->fs_devices->fs_info = fs_info;

fs/btrfs/fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,8 @@ struct btrfs_fs_info {
825825
u32 sectorsize;
826826
/* ilog2 of sectorsize, use to avoid 64bit division */
827827
u32 sectorsize_bits;
828+
u32 block_min_order;
829+
u32 block_max_order;
828830
u32 csum_size;
829831
u32 csums_per_leaf;
830832
u32 stripesize;

0 commit comments

Comments
 (0)