public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH v2] btrfs: Record btrfs_device directly btrfs_io_bio
Date: Fri,  3 Jul 2020 11:14:27 +0300	[thread overview]
Message-ID: <20200703081427.11984-1-nborisov@suse.com> (raw)
In-Reply-To: <20200702122335.9117-4-nborisov@suse.com>

Instead of recording stripe_index and using that to access correct
btrfs_device from btrfs_bio::stripes record the btrfs_device in
btrfs_io_bio. This will enable endio handlers to increment device
error counters on checksum errors.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

V2: Pass btrfs_device directly to submit_stripe_bio

 fs/btrfs/raid56.c  |  1 +
 fs/btrfs/volumes.c | 14 ++++----------
 fs/btrfs/volumes.h |  2 +-
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index c870ef70f817..4efd9ed1a30e 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1117,6 +1117,7 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio,

 	/* put a new bio on the list */
 	bio = btrfs_io_bio_alloc(bio_max_len >> PAGE_SHIFT ?: 1);
+	btrfs_io_bio(bio)->dev = stripe->dev;
 	bio->bi_iter.bi_size = 0;
 	bio_set_dev(bio, stripe->dev->bdev);
 	bio->bi_iter.bi_sector = disk_start >> 9;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index aabc6c922e04..074256c0cba2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6261,12 +6261,7 @@ static void btrfs_end_bio(struct bio *bio)
 		atomic_inc(&bbio->error);
 		if (bio->bi_status == BLK_STS_IOERR ||
 		    bio->bi_status == BLK_STS_TARGET) {
-			unsigned int stripe_index =
-				btrfs_io_bio(bio)->stripe_index;
-			struct btrfs_device *dev;
-
-			BUG_ON(stripe_index >= bbio->num_stripes);
-			dev = bbio->stripes[stripe_index].dev;
+			struct btrfs_device *dev = btrfs_io_bio(bio)->dev;
 			if (dev->bdev) {
 				if (bio_op(bio) == REQ_OP_WRITE)
 					btrfs_dev_stat_inc_and_print(dev,
@@ -6313,13 +6308,12 @@ static void btrfs_end_bio(struct bio *bio)
 }

 static void submit_stripe_bio(struct btrfs_bio *bbio, struct bio *bio,
-			      u64 physical, int dev_nr)
+			      u64 physical, struct btrfs_device *dev)
 {
-	struct btrfs_device *dev = bbio->stripes[dev_nr].dev;
 	struct btrfs_fs_info *fs_info = bbio->fs_info;

 	bio->bi_private = bbio;
-	btrfs_io_bio(bio)->stripe_index = dev_nr;
+	btrfs_io_bio(bio)->dev = dev;
 	bio->bi_end_io = btrfs_end_bio;
 	bio->bi_iter.bi_sector = physical >> 9;
 	btrfs_debug_in_rcu(fs_info,
@@ -6421,7 +6415,7 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
 			bio = first_bio;

 		submit_stripe_bio(bbio, bio, bbio->stripes[dev_nr].physical,
-				  dev_nr);
+				  dev);
 	}
 	btrfs_bio_counter_dec(fs_info);
 	return BLK_STS_OK;
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 75af2334b2e3..95aa0cca21e6 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -288,7 +288,7 @@ struct btrfs_fs_devices {
  */
 struct btrfs_io_bio {
 	unsigned int mirror_num;
-	unsigned int stripe_index;
+	struct btrfs_device *dev;
 	u64 logical;
 	u8 *csum;
 	u8 csum_inline[BTRFS_BIO_INLINE_CSUM_SIZE];
--
2.17.1


  parent reply	other threads:[~2020-07-03  8:14 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 12:23 [PATCH 0/7] Corrupt counter improvement Nikolay Borisov
2020-07-02 12:23 ` [PATCH 1/8] btrfs: Make get_state_failrec return failrec directly Nikolay Borisov
2020-07-02 13:07   ` Josef Bacik
2020-07-02 13:25     ` David Sterba
2020-07-02 12:23 ` [PATCH 2/8] btrfs: Streamline btrfs_get_io_failure_record logic Nikolay Borisov
2020-07-02 13:13   ` Josef Bacik
2020-07-02 12:23 ` [PATCH 3/8] btrfs: Record btrfs_device directly btrfs_io_bio Nikolay Borisov
2020-07-02 13:14   ` Josef Bacik
2020-07-02 13:16   ` Johannes Thumshirn
2020-07-03  8:14   ` Nikolay Borisov [this message]
2020-07-03 13:06     ` [PATCH v2] " Johannes Thumshirn
2020-07-02 12:23 ` [PATCH 4/8] btrfs: Don't check for btrfs_device::bdev in btrfs_end_bio Nikolay Borisov
2020-07-02 13:15   ` Josef Bacik
2020-07-02 12:23 ` [PATCH 5/8] btrfs: Increment device corruption error in case of checksum error Nikolay Borisov
2020-07-02 13:18   ` Josef Bacik
2020-07-02 13:21   ` Johannes Thumshirn
2020-07-02 14:44     ` Nikolay Borisov
2020-07-02 12:23 ` [PATCH 6/8] btrfs: Remove needless ASSERT Nikolay Borisov
2020-07-02 13:19   ` Josef Bacik
2020-07-02 13:26   ` Johannes Thumshirn
2020-07-02 12:23 ` [PATCH 7/8] btrfs: Increment corrupt device counter during compressed read Nikolay Borisov
2020-07-02 13:21   ` Josef Bacik
2020-07-02 13:28   ` Johannes Thumshirn
2020-07-02 12:23 ` [PATCH 8/8] btrfs: sysfs: Add bdi link to the fsid dir Nikolay Borisov
2020-07-02 13:25   ` Josef Bacik
2020-07-02 13:36     ` David Sterba
2020-07-02 14:41       ` Nikolay Borisov
2020-07-03  8:13   ` [PATCH v2] " Nikolay Borisov
2020-07-05 11:39     ` Anand Jain
2020-07-03 15:32 ` [PATCH 0/7] Corrupt counter improvement David Sterba

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=20200703081427.11984-1-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox