Skip to content

Commit 908930f

Browse files
lorddoskiaskdave
authored andcommitted
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: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent be17b3a commit 908930f

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎fs/btrfs/ctree.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,6 +2969,8 @@ void btrfs_inode_safe_disk_i_size_write(struct inode *inode, u64 new_i_size);
29692969
u64 btrfs_file_extent_end(const struct btrfs_path *path);
29702970

29712971
/* inode.c */
2972+
blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,
2973+
int mirror_num, unsigned long bio_flags);
29722974
int btrfs_verify_data_csum(struct btrfs_io_bio *io_bio, u64 phy_offset,
29732975
struct page *page, u64 start, u64 end, int mirror);
29742976
struct extent_map *btrfs_get_extent_fiemap(struct btrfs_inode *inode,

‎fs/btrfs/extent_io.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ int __must_check submit_one_bio(struct bio *bio, int mirror_num,
168168

169169
bio->bi_private = NULL;
170170

171-
ret = tree->ops->submit_bio_hook(tree->private_data, bio, mirror_num,
172-
bio_flags);
171+
if (is_data_inode(tree->private_data))
172+
ret = btrfs_submit_data_bio(tree->private_data, bio, mirror_num,
173+
bio_flags);
174+
else
175+
ret = tree->ops->submit_bio_hook(tree->private_data, bio,
176+
mirror_num, bio_flags);
173177

174178
return blk_status_to_errno(ret);
175179
}
@@ -2879,7 +2883,7 @@ static void end_bio_extent_readpage(struct bio *bio)
28792883
if (!btrfs_submit_read_repair(inode, bio, offset, page,
28802884
start - page_offset(page),
28812885
start, end, mirror,
2882-
tree->ops->submit_bio_hook)) {
2886+
btrfs_submit_data_bio)) {
28832887
uptodate = !bio->bi_status;
28842888
offset += len;
28852889
continue;

‎fs/btrfs/inode.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,9 +2184,8 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,
21842184
*
21852185
* c-3) otherwise: async submit
21862186
*/
2187-
static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio,
2188-
int mirror_num,
2189-
unsigned long bio_flags)
2187+
blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,
2188+
int mirror_num, unsigned long bio_flags)
21902189

21912190
{
21922191
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -10258,8 +10257,7 @@ static const struct file_operations btrfs_dir_file_operations = {
1025810257
};
1025910258

1026010259
static const struct extent_io_ops btrfs_extent_io_ops = {
10261-
/* mandatory callbacks */
10262-
.submit_bio_hook = btrfs_submit_bio_hook,
10260+
.submit_bio_hook = NULL
1026310261
};
1026410262

1026510263
/*

0 commit comments

Comments
 (0)