All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org, Anand Jain <anand.jain@oracle.com>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Qu Wenruo <wqu@suse.com>
Subject: [PATCH 07/10] btrfs: simplify finding the inode in submit_one_bio
Date: Tue,  7 Mar 2023 17:39:42 +0100	[thread overview]
Message-ID: <20230307163945.31770-8-hch@lst.de> (raw)
In-Reply-To: <20230307163945.31770-1-hch@lst.de>

struct btrfs_bio now has an always valid inode pointer that can be used
to find the inode in submit_one_bio, so use that and initialize all
variables for which it is possible at declaration time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/extent_io.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 2b9e24782b36f5..2670c479847094 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -123,23 +123,16 @@ struct btrfs_bio_ctrl {
 
 static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
 {
-	struct bio *bio;
-	struct bio_vec *bv;
-	struct inode *inode;
-	int mirror_num;
+	struct bio *bio = bio_ctrl->bio;
+	int mirror_num = bio_ctrl->mirror_num;
 
-	if (!bio_ctrl->bio)
+	if (!bio)
 		return;
 
-	bio = bio_ctrl->bio;
-	bv = bio_first_bvec_all(bio);
-	inode = bv->bv_page->mapping->host;
-	mirror_num = bio_ctrl->mirror_num;
-
 	/* Caller should ensure the bio has at least some range added */
 	ASSERT(bio->bi_iter.bi_size);
 
-	if (!is_data_inode(inode)) {
+	if (!is_data_inode(&btrfs_bio(bio)->inode->vfs_inode)) {
 		if (btrfs_op(bio) != BTRFS_MAP_WRITE) {
 			/*
 			 * For metadata read, we should have the parent_check,
-- 
2.39.1


  parent reply	other threads:[~2023-03-07 16:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 16:39 improve type safety by passing struct btrfs_bio where possible v2 Christoph Hellwig
2023-03-07 16:39 ` [PATCH 01/10] btrfs: remove unused members from struct btrfs_encoded_read_private Christoph Hellwig
2023-03-07 16:39 ` [PATCH 02/10] btrfs: cleanup btrfs_encoded_read_regular_fill_pages Christoph Hellwig
2023-03-07 16:39 ` [PATCH 03/10] btrfs: move zero filling of compressed read bios into common code Christoph Hellwig
2023-03-07 16:39 ` [PATCH 04/10] btrfs: pass a btrfs_bio to btrfs_submit_bio Christoph Hellwig
2023-03-07 16:39 ` [PATCH 05/10] btrfs: pass a btrfs_bio to btrfs_submit_compressed_read Christoph Hellwig
2023-03-07 16:39 ` [PATCH 06/10] btrfs: store a pointer to the original btrfs_bio in struct compressed_bio Christoph Hellwig
2023-03-07 16:39 ` Christoph Hellwig [this message]
2023-03-07 16:39 ` [PATCH 08/10] btrfs: store a pointer to a btrfs_bio in struct btrfs_bio_ctrl Christoph Hellwig
2023-03-07 16:39 ` [PATCH 09/10] btrfs: return a btrfs_bio from btrfs_bio_alloc Christoph Hellwig
2023-03-07 16:39 ` [PATCH 10/10] btrfs: make btrfs_split_bio work on struct btrfs_bio Christoph Hellwig
2023-03-09 17:34 ` improve type safety by passing struct btrfs_bio where possible v2 David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2023-03-01 13:42 improve type safety by passing struct btrfs_bio around Christoph Hellwig
2023-03-01 13:42 ` [PATCH 07/10] btrfs: simplify finding the inode in submit_one_bio Christoph Hellwig
2023-03-02 13:10   ` Johannes Thumshirn
2023-03-02 23:30   ` Qu Wenruo
2023-03-03  9:16   ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230307163945.31770-8-hch@lst.de \
    --to=hch@lst.de \
    --cc=anand.jain@oracle.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.