md fixes for 4.0-rc7

Revert recent change which broke IO accounting.
 Fix bug with RAID0 arrays with non-power-of-2 chunk size.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIVAwUAVSdh1Dnsnt1WYoG5AQKfwg/8CxlcxanaBffiiTg48a1GfDhV92CAAFB4
 M+rEsTzpE+4osTBVZDQ3c768EK9Tc6nGeJc3gKBhuXczxtK7Caxu5xiwBEk3vFc1
 DxINpwkQhovFZwrvQPjY3aaeEYaaVG+YYjD20CWGrJH/IFA+Dd8NWEcWps871nip
 xOnoO6V0M+8N4VUL84oITyidcdgwehQDncI64EU4MCGsmtkX8ITEqAdtf0ITqhi2
 FwSBsWSNBpvUWxsx6gUcRlK5QfvnHK1gH28AdqGlbELDFGriLnCYU7Dj0BMqWCDI
 aUp9nfBWZ1/NKqIn/kq0ZLbxLGyb014HigmTlsqmXhr3YctitCvrUZNRSVWEn/w1
 7+FzA5HnBrPPtrNUYyO3REyt2Jx3dDIhOOzSiwAX1aQFD3Gew4fqfGKvuuJDZds6
 JylUkqRct61Zwi7xTR3vB58fESjkylmo3+psHxQ08bKq6qZiSEVjkxjmUMqTMK7K
 HQ8lxqO0SdktaA3wQR3ho6bxJ7s0EB2noo6GaAf7ICpeQfboEMZ1ywgFey23iO0k
 N6MvKo+W8IoCBV8m5MJcU/ftl88/rbUu6d5BkIvmHJkDxfczDIbhoxdu4qmCW8Xt
 Fbbpj52dykTZUEFk0Gf8F+ojyX/H8wkA43ntS6SxejwxRUS+Oo0e9OvBzjxpmhm3
 jvcGtxniYtk=
 =l6UZ
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2015-04-13 10:11:18 -07:00
commit 67dbb3a099
2 changed files with 7 additions and 2 deletions

View File

@ -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);

View File

@ -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, &sector);
tmp_dev = map_sector(mddev, zone, sector, &sector);
split->bi_bdev = tmp_dev->bdev;