Commit 1b36294a authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

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: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 908930f3
...@@ -814,9 +814,8 @@ static int check_async_write(struct btrfs_fs_info *fs_info, ...@@ -814,9 +814,8 @@ static int check_async_write(struct btrfs_fs_info *fs_info,
return 1; return 1;
} }
static blk_status_t btree_submit_bio_hook(struct inode *inode, struct bio *bio, blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,
int mirror_num, int mirror_num, unsigned long bio_flags)
unsigned long bio_flags)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
int async = check_async_write(fs_info, BTRFS_I(inode)); 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) ...@@ -4636,6 +4635,5 @@ static int btrfs_cleanup_transaction(struct btrfs_fs_info *fs_info)
} }
static const struct extent_io_ops btree_extent_io_ops = { static const struct extent_io_ops btree_extent_io_ops = {
/* mandatory callbacks */ .submit_bio_hook = NULL
.submit_bio_hook = btree_submit_bio_hook,
}; };
...@@ -79,6 +79,8 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info, ...@@ -79,6 +79,8 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
int btrfs_validate_metadata_buffer(struct btrfs_io_bio *io_bio, u64 phy_offset, int btrfs_validate_metadata_buffer(struct btrfs_io_bio *io_bio, u64 phy_offset,
struct page *page, u64 start, u64 end, struct page *page, u64 start, u64 end,
int mirror); int mirror);
blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,
int mirror_num, unsigned long bio_flags);
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info); struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info);
#endif #endif
......
...@@ -172,7 +172,7 @@ int __must_check submit_one_bio(struct bio *bio, int mirror_num, ...@@ -172,7 +172,7 @@ int __must_check submit_one_bio(struct bio *bio, int mirror_num,
ret = btrfs_submit_data_bio(tree->private_data, bio, mirror_num, ret = btrfs_submit_data_bio(tree->private_data, bio, mirror_num,
bio_flags); bio_flags);
else else
ret = tree->ops->submit_bio_hook(tree->private_data, bio, ret = btrfs_submit_metadata_bio(tree->private_data, bio,
mirror_num, bio_flags); mirror_num, bio_flags);
return blk_status_to_errno(ret); return blk_status_to_errno(ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment