Skip to content

Commit 74672d0

Browse files
Gu Zhengneilbrown
authored andcommitted
md: fix md io stats accounting broken
Simon reported the md io stats accounting issue: " I'm seeing "iostat -x -k 1" print this after a RAID1 rebuild on 4.0-rc5. It's not abnormal other than it's 3-disk, with one being SSD (sdc) and the other two being write-mostly: Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdc 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 md0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 345.00 0.00 0.00 0.00 0.00 100.00 md2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 58779.00 0.00 0.00 0.00 0.00 100.00 md1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12.00 0.00 0.00 0.00 0.00 100.00 " The cause is commit "18c0b223cf9901727ef3b02da6711ac930b4e5d4" uses the generic_start_io_acct to account the disk stats rather than the open code, but it also introduced the increase to .in_flight[rw] which is needless to md. So we re-use the open code here to fix it. Reported-by: Simon Kirby <[email protected]> Cc: <[email protected]> 3.19 Signed-off-by: Gu Zheng <[email protected]> Signed-off-by: NeilBrown <[email protected]>
1 parent f22e6e8 commit 74672d0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/md/md.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
249249
const int rw = bio_data_dir(bio);
250250
struct mddev *mddev = q->queuedata;
251251
unsigned int sectors;
252+
int cpu;
252253

253254
if (mddev == NULL || mddev->pers == NULL
254255
|| !mddev->ready) {
@@ -284,7 +285,10 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
284285
sectors = bio_sectors(bio);
285286
mddev->pers->make_request(mddev, bio);
286287

287-
generic_start_io_acct(rw, sectors, &mddev->gendisk->part0);
288+
cpu = part_stat_lock();
289+
part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);
290+
part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors);
291+
part_stat_unlock();
288292

289293
if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
290294
wake_up(&mddev->sb_wait);

0 commit comments

Comments
 (0)