Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

md/raid10: switch to use md_account_bio() for io accounting

Make sure that 'active_io' will represent inflight io instead of io that
is dispatching, and io accounting from all levels will be consistent.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230621165110.1498313-6-yukuai1@huaweicloud.com

authored by

Yu Kuai and committed by
Song Liu
82045523 bb2a9ace

+9 -12
+9 -11
drivers/md/raid10.c
··· 325 325 if (!test_bit(R10BIO_Uptodate, &r10_bio->state)) 326 326 bio->bi_status = BLK_STS_IOERR; 327 327 328 - if (r10_bio->start_time) 329 - bio_end_io_acct(bio, r10_bio->start_time); 330 328 bio_endio(bio); 331 329 /* 332 330 * Wake up any possible resync thread that waits for the device ··· 1170 1172 } 1171 1173 1172 1174 static void raid10_read_request(struct mddev *mddev, struct bio *bio, 1173 - struct r10bio *r10_bio) 1175 + struct r10bio *r10_bio, bool io_accounting) 1174 1176 { 1175 1177 struct r10conf *conf = mddev->private; 1176 1178 struct bio *read_bio; ··· 1241 1243 } 1242 1244 slot = r10_bio->read_slot; 1243 1245 1244 - if (!r10_bio->start_time && 1245 - blk_queue_io_stat(bio->bi_bdev->bd_disk->queue)) 1246 - r10_bio->start_time = bio_start_io_acct(bio); 1246 + if (io_accounting) { 1247 + md_account_bio(mddev, &bio); 1248 + r10_bio->master_bio = bio; 1249 + } 1247 1250 read_bio = bio_alloc_clone(rdev->bdev, bio, gfp, &mddev->bio_set); 1248 1251 1249 1252 r10_bio->devs[slot].bio = read_bio; ··· 1542 1543 r10_bio->master_bio = bio; 1543 1544 } 1544 1545 1545 - if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue)) 1546 - r10_bio->start_time = bio_start_io_acct(bio); 1546 + md_account_bio(mddev, &bio); 1547 + r10_bio->master_bio = bio; 1547 1548 atomic_set(&r10_bio->remaining, 1); 1548 1549 md_bitmap_startwrite(mddev->bitmap, r10_bio->sector, r10_bio->sectors, 0); 1549 1550 ··· 1570 1571 r10_bio->sector = bio->bi_iter.bi_sector; 1571 1572 r10_bio->state = 0; 1572 1573 r10_bio->read_slot = -1; 1573 - r10_bio->start_time = 0; 1574 1574 memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) * 1575 1575 conf->geo.raid_disks); 1576 1576 1577 1577 if (bio_data_dir(bio) == READ) 1578 - raid10_read_request(mddev, bio, r10_bio); 1578 + raid10_read_request(mddev, bio, r10_bio, true); 1579 1579 else 1580 1580 raid10_write_request(mddev, bio, r10_bio); 1581 1581 } ··· 2983 2985 2984 2986 rdev_dec_pending(rdev, mddev); 2985 2987 r10_bio->state = 0; 2986 - raid10_read_request(mddev, r10_bio->master_bio, r10_bio); 2988 + raid10_read_request(mddev, r10_bio->master_bio, r10_bio, false); 2987 2989 /* 2988 2990 * allow_barrier after re-submit to ensure no sync io 2989 2991 * can be issued while regular io pending.
-1
drivers/md/raid10.h
··· 123 123 sector_t sector; /* virtual sector number */ 124 124 int sectors; 125 125 unsigned long state; 126 - unsigned long start_time; 127 126 struct mddev *mddev; 128 127 /* 129 128 * original bio going to /dev/mdx