From: Linus Torvalds Date: Mon, 13 Apr 2015 17:11:18 +0000 (-0700) Subject: Merge tag 'md/4.0-rc7-fix' of git://neil.brown.name/md X-Git-Tag: v4.1-rc1~188 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=67dbb3a099d0fe04df5974edddc0b8c64a9f7529;hp=900360131066f192c82311a098d03d6ac6429e20;p=linux-2.6-block.git Merge tag 'md/4.0-rc7-fix' of git://neil.brown.name/md Pull md fixes from Neil Brown: "Two regression fixes for md, one fairly recent and minor (diskstats has confusing data) and one older and more serious - RAID0 with non-power-of-2 chunksize corrupts data. I guess (almost) no-one uses non-power-of-2 chunks. Summary: - Revert recent change which broke IO accounting. - Fix bug with RAID0 arrays with non-power-of-2 chunk size" * tag 'md/4.0-rc7-fix' of git://neil.brown.name/md: md/raid0: fix bug with chunksize not a power of 2. md: fix md io stats accounting broken --- diff --git a/drivers/md/md.c b/drivers/md/md.c index 717daad71fb1..e6178787ce3d 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -249,6 +249,7 @@ static void md_make_request(struct request_queue *q, struct bio *bio) const int rw = bio_data_dir(bio); struct mddev *mddev = q->queuedata; unsigned int sectors; + int cpu; if (mddev == NULL || mddev->pers == NULL || !mddev->ready) { @@ -284,7 +285,10 @@ static void md_make_request(struct request_queue *q, struct bio *bio) sectors = bio_sectors(bio); mddev->pers->make_request(mddev, bio); - generic_start_io_acct(rw, sectors, &mddev->gendisk->part0); + cpu = part_stat_lock(); + part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); + part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors); + part_stat_unlock(); if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended) wake_up(&mddev->sb_wait); diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 3ed9f42ddca6..3b5d7f704aa3 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -313,7 +313,7 @@ static struct strip_zone *find_zone(struct r0conf *conf, /* * remaps the bio to the target device. we separate two flows. - * power 2 flow and a general flow for the sake of perfromance + * power 2 flow and a general flow for the sake of performance */ static struct md_rdev *map_sector(struct mddev *mddev, struct strip_zone *zone, sector_t sector, sector_t *sector_offset) @@ -524,6 +524,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio) split = bio; } + sector = bio->bi_iter.bi_sector; zone = find_zone(mddev->private, §or); tmp_dev = map_sector(mddev, zone, sector, §or); split->bi_bdev = tmp_dev->bdev;