Commit 908930f3 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: stop calling submit_bio_hook for data inodes

Instead export and rename the function to btrfs_submit_data_bio and
call it directly in submit_one_bio. This avoids paying the cost for
speculative attacks mitigations and improves code readability.
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 be17b3af
...@@ -2969,6 +2969,8 @@ void btrfs_inode_safe_disk_i_size_write(struct inode *inode, u64 new_i_size); ...@@ -2969,6 +2969,8 @@ void btrfs_inode_safe_disk_i_size_write(struct inode *inode, u64 new_i_size);
u64 btrfs_file_extent_end(const struct btrfs_path *path); u64 btrfs_file_extent_end(const struct btrfs_path *path);
/* inode.c */ /* inode.c */
blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,
int mirror_num, unsigned long bio_flags);
int btrfs_verify_data_csum(struct btrfs_io_bio *io_bio, u64 phy_offset, int btrfs_verify_data_csum(struct btrfs_io_bio *io_bio, u64 phy_offset,
struct page *page, u64 start, u64 end, int mirror); struct page *page, u64 start, u64 end, int mirror);
struct extent_map *btrfs_get_extent_fiemap(struct btrfs_inode *inode, struct extent_map *btrfs_get_extent_fiemap(struct btrfs_inode *inode,
......
...@@ -168,8 +168,12 @@ int __must_check submit_one_bio(struct bio *bio, int mirror_num, ...@@ -168,8 +168,12 @@ int __must_check submit_one_bio(struct bio *bio, int mirror_num,
bio->bi_private = NULL; bio->bi_private = NULL;
ret = tree->ops->submit_bio_hook(tree->private_data, bio, mirror_num, if (is_data_inode(tree->private_data))
bio_flags); ret = btrfs_submit_data_bio(tree->private_data, bio, mirror_num,
bio_flags);
else
ret = tree->ops->submit_bio_hook(tree->private_data, bio,
mirror_num, bio_flags);
return blk_status_to_errno(ret); return blk_status_to_errno(ret);
} }
...@@ -2879,7 +2883,7 @@ static void end_bio_extent_readpage(struct bio *bio) ...@@ -2879,7 +2883,7 @@ static void end_bio_extent_readpage(struct bio *bio)
if (!btrfs_submit_read_repair(inode, bio, offset, page, if (!btrfs_submit_read_repair(inode, bio, offset, page,
start - page_offset(page), start - page_offset(page),
start, end, mirror, start, end, mirror,
tree->ops->submit_bio_hook)) { btrfs_submit_data_bio)) {
uptodate = !bio->bi_status; uptodate = !bio->bi_status;
offset += len; offset += len;
continue; continue;
......
...@@ -2184,9 +2184,8 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio, ...@@ -2184,9 +2184,8 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,
* *
* c-3) otherwise: async submit * c-3) otherwise: async submit
*/ */
static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio, blk_status_t btrfs_submit_data_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);
...@@ -10258,8 +10257,7 @@ static const struct file_operations btrfs_dir_file_operations = { ...@@ -10258,8 +10257,7 @@ static const struct file_operations btrfs_dir_file_operations = {
}; };
static const struct extent_io_ops btrfs_extent_io_ops = { static const struct extent_io_ops btrfs_extent_io_ops = {
/* mandatory callbacks */ .submit_bio_hook = NULL
.submit_bio_hook = btrfs_submit_bio_hook,
}; };
/* /*
......
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