Skip to content

Commit 1b36294

Browse files
lorddoskiaskdave
authored andcommitted
btrfs: call submit_bio_hook directly for metadata pages
No need to go through a function pointer indirection simply call submit_bio_hook directly by exporting and renaming the helper to btrfs_submit_metadata_bio. This makes the code more readable and should result in somewhat faster code due to no longer paying the price for specualtive attack mitigations that come with indirect function calls. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 908930f commit 1b36294

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎fs/btrfs/disk-io.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,8 @@ static int check_async_write(struct btrfs_fs_info *fs_info,
814814
return 1;
815815
}
816816

817-
static blk_status_t btree_submit_bio_hook(struct inode *inode, struct bio *bio,
818-
int mirror_num,
819-
unsigned long bio_flags)
817+
blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,
818+
int mirror_num, unsigned long bio_flags)
820819
{
821820
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
822821
int async = check_async_write(fs_info, BTRFS_I(inode));
@@ -4636,6 +4635,5 @@ static int btrfs_cleanup_transaction(struct btrfs_fs_info *fs_info)
46364635
}
46374636

46384637
static const struct extent_io_ops btree_extent_io_ops = {
4639-
/* mandatory callbacks */
4640-
.submit_bio_hook = btree_submit_bio_hook,
4638+
.submit_bio_hook = NULL
46414639
};

‎fs/btrfs/disk-io.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
7979
int btrfs_validate_metadata_buffer(struct btrfs_io_bio *io_bio, u64 phy_offset,
8080
struct page *page, u64 start, u64 end,
8181
int mirror);
82+
blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,
83+
int mirror_num, unsigned long bio_flags);
8284
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
8385
struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info);
8486
#endif

‎fs/btrfs/extent_io.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ int __must_check submit_one_bio(struct bio *bio, int mirror_num,
172172
ret = btrfs_submit_data_bio(tree->private_data, bio, mirror_num,
173173
bio_flags);
174174
else
175-
ret = tree->ops->submit_bio_hook(tree->private_data, bio,
176-
mirror_num, bio_flags);
175+
ret = btrfs_submit_metadata_bio(tree->private_data, bio,
176+
mirror_num, bio_flags);
177177

178178
return blk_status_to_errno(ret);
179179
}

0 commit comments

Comments
 (0)