Skip to content

Commit a015983

Browse files
GuoqingJiang-Linuxliu-song-6
authored andcommitted
md/raid1: enable io accounting
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 <[email protected]> Signed-off-by: Song Liu <[email protected]>
1 parent 9b8ae7b commit a015983

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/md/raid1.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ static void call_bio_endio(struct r1bio *r1_bio)
300300
if (!test_bit(R1BIO_Uptodate, &r1_bio->state))
301301
bio->bi_status = BLK_STS_IOERR;
302302

303+
if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
304+
bio_end_io_acct(bio, r1_bio->start_time);
303305
bio_endio(bio);
304306
}
305307

@@ -1292,6 +1294,9 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
12921294

12931295
r1_bio->read_disk = rdisk;
12941296

1297+
if (!r1bio_existed && blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
1298+
r1_bio->start_time = bio_start_io_acct(bio);
1299+
12951300
read_bio = bio_clone_fast(bio, gfp, &mddev->bio_set);
12961301

12971302
r1_bio->bios[rdisk] = read_bio;
@@ -1461,6 +1466,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
14611466
r1_bio->sectors = max_sectors;
14621467
}
14631468

1469+
if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
1470+
r1_bio->start_time = bio_start_io_acct(bio);
14641471
atomic_set(&r1_bio->remaining, 1);
14651472
atomic_set(&r1_bio->behind_remaining, 0);
14661473

drivers/md/raid1.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ struct r1bio {
158158
sector_t sector;
159159
int sectors;
160160
unsigned long state;
161+
unsigned long start_time;
161162
struct mddev *mddev;
162163
/*
163164
* original bio going to /dev/mdx

0 commit comments

Comments
 (0)