All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guoqing Jiang <jgq516@gmail.com>
To: song@kernel.org
Cc: linux-raid@vger.kernel.org, artur.paszkiewicz@intel.com
Subject: [PATCH V2 5/7] md/raid1: enable io accounting
Date: Fri, 21 May 2021 08:55:19 +0800	[thread overview]
Message-ID: <20210521005521.713106-6-jiangguoqing@kylinos.cn> (raw)
In-Reply-To: <20210521005521.713106-1-jiangguoqing@kylinos.cn>

For raid1, we record the start time between split bio and clone bio,
and finish the accounting in the final endio.

Also introduce start_time in r1bio accordingly.

Signed-off-by: Guoqing Jiang <jiangguoqing@kylinos.cn>
---
 drivers/md/raid1.c | 7 +++++++
 drivers/md/raid1.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 696da6b8b7ed..51f2547c2007 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -300,6 +300,8 @@ static void call_bio_endio(struct r1bio *r1_bio)
 	if (!test_bit(R1BIO_Uptodate, &r1_bio->state))
 		bio->bi_status = BLK_STS_IOERR;
 
+	if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
+		bio_end_io_acct(bio, r1_bio->start_time);
 	bio_endio(bio);
 }
 
@@ -1292,6 +1294,9 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
 
 	r1_bio->read_disk = rdisk;
 
+	if (!r1bio_existed && blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
+		r1_bio->start_time = bio_start_io_acct(bio);
+
 	read_bio = bio_clone_fast(bio, gfp, &mddev->bio_set);
 
 	r1_bio->bios[rdisk] = read_bio;
@@ -1461,6 +1466,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
 		r1_bio->sectors = max_sectors;
 	}
 
+	if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
+		r1_bio->start_time = bio_start_io_acct(bio);
 	atomic_set(&r1_bio->remaining, 1);
 	atomic_set(&r1_bio->behind_remaining, 0);
 
diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h
index b7eb09e8c025..ccf10e59b116 100644
--- a/drivers/md/raid1.h
+++ b/drivers/md/raid1.h
@@ -158,6 +158,7 @@ struct r1bio {
 	sector_t		sector;
 	int			sectors;
 	unsigned long		state;
+	unsigned long		start_time;
 	struct mddev		*mddev;
 	/*
 	 * original bio going to /dev/mdx
-- 
2.25.1


  parent reply	other threads:[~2021-05-21  0:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  0:55 [PATCH V2 0/7] md: io stats accounting Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 1/7] md: revert " Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 2/7] md: add accounting_bio for raid0 and raid5 Guoqing Jiang
2021-05-24  5:48   ` Song Liu
2021-05-24  8:45   ` Christoph Hellwig
2021-05-21  0:55 ` [PATCH V2 3/7] md: the latest try for improve io stats accounting Guoqing Jiang
2021-05-21  7:32   ` Artur Paszkiewicz
2021-05-21  7:43     ` Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 4/7] md/raid1: rename print_msg with r1bio_existed Guoqing Jiang
2021-05-21  0:55 ` Guoqing Jiang [this message]
2021-05-21  0:55 ` [PATCH V2 6/7] md/raid10: enable io accounting Guoqing Jiang
2021-05-21  0:55 ` [PATCH V2 7/7] md: mark some personalities as deprecated Guoqing Jiang
2021-05-21  8:00 ` [UPDATE PATCH V2 3/7] md: the latest try for improve io stats accounting Guoqing Jiang
2021-05-24  5:49   ` Song Liu
2021-05-24  6:04 ` [PATCH V2 0/7] md: " Song Liu
2021-05-27 14:09   ` Paweł Wiejacha

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=20210521005521.713106-6-jiangguoqing@kylinos.cn \
    --to=jgq516@gmail.com \
    --cc=artur.paszkiewicz@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@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 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.