diff mbox series

[1/3] btrfs: don't use bio->bi_private to pass the inode to submit_one_bio

Message ID 20220603071103.43440-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/3] btrfs: don't use bio->bi_private to pass the inode to submit_one_bio | expand

Commit Message

Christoph Hellwig June 3, 2022, 7:11 a.m. UTC
submit_one_bio is only used for page cache I/O, so the inode can be
trivially derived from the first page in the bio.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/extent_io.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Qu Wenruo June 3, 2022, 10:33 a.m. UTC | #1
On 2022/6/3 15:11, Christoph Hellwig wrote:
> submit_one_bio is only used for page cache I/O, so the inode can be
> trivially derived from the first page in the bio.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Qu Wenruo <wqu@suse.com>

> ---
>   fs/btrfs/extent_io.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 7b5f872d2eb9f..025349aeec31f 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -181,10 +181,7 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,
>   static void submit_one_bio(struct bio *bio, int mirror_num,
>   			   enum btrfs_compression_type compress_type)
>   {
> -	struct extent_io_tree *tree = bio->bi_private;
> -	struct inode *inode = tree->private_data;
> -
> -	bio->bi_private = NULL;
> +	struct inode *inode = bio_first_page_all(bio)->mapping->host;
>
>   	/* Caller should ensure the bio has at least some range added */
>   	ASSERT(bio->bi_iter.bi_size);
> @@ -3360,7 +3357,6 @@ static int alloc_new_bio(struct btrfs_inode *inode,
>   	bio_ctrl->bio = bio;
>   	bio_ctrl->compress_type = compress_type;
>   	bio->bi_end_io = end_io_func;
> -	bio->bi_private = &inode->io_tree;

And what the heck that we're passing io_tree into bi_private??
At least we should try passing inode.

Anyway, the old behavior makes no sense, great we can get rid of it.

BTW, I didn't see modification in btrfs_repair_one_sector(), it is not a
problem since we no longer utilize bi_private, but it may be better
explicitly remove that call site too.

Thanks,
Qu
>   	bio->bi_opf = opf;
>   	ret = calc_bio_boundaries(bio_ctrl, inode, file_offset);
>   	if (ret < 0)
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 7b5f872d2eb9f..025349aeec31f 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -181,10 +181,7 @@  static int add_extent_changeset(struct extent_state *state, u32 bits,
 static void submit_one_bio(struct bio *bio, int mirror_num,
 			   enum btrfs_compression_type compress_type)
 {
-	struct extent_io_tree *tree = bio->bi_private;
-	struct inode *inode = tree->private_data;
-
-	bio->bi_private = NULL;
+	struct inode *inode = bio_first_page_all(bio)->mapping->host;
 
 	/* Caller should ensure the bio has at least some range added */
 	ASSERT(bio->bi_iter.bi_size);
@@ -3360,7 +3357,6 @@  static int alloc_new_bio(struct btrfs_inode *inode,
 	bio_ctrl->bio = bio;
 	bio_ctrl->compress_type = compress_type;
 	bio->bi_end_io = end_io_func;
-	bio->bi_private = &inode->io_tree;
 	bio->bi_opf = opf;
 	ret = calc_bio_boundaries(bio_ctrl, inode, file_offset);
 	if (ret < 0)