Commit fe6498c9 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] md: Collect device IO statistics for MD personalities.

From: NeilBrown <neilb@cse.unsw.edu.au>

Update {read,write}{s,_sectors} on each request to an MD array.
parent 403c2172
...@@ -208,6 +208,14 @@ static int linear_make_request (request_queue_t *q, struct bio *bio) ...@@ -208,6 +208,14 @@ static int linear_make_request (request_queue_t *q, struct bio *bio)
dev_info_t *tmp_dev; dev_info_t *tmp_dev;
sector_t block; sector_t block;
if (bio_data_dir(bio)==WRITE) {
disk_stat_inc(mddev->gendisk, writes);
disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bio));
} else {
disk_stat_inc(mddev->gendisk, reads);
disk_stat_add(mddev->gendisk, read_sectors, bio_sectors(bio));
}
tmp_dev = which_dev(mddev, bio->bi_sector); tmp_dev = which_dev(mddev, bio->bi_sector);
block = bio->bi_sector >> 1; block = bio->bi_sector >> 1;
......
...@@ -167,6 +167,13 @@ static int multipath_make_request (request_queue_t *q, struct bio * bio) ...@@ -167,6 +167,13 @@ static int multipath_make_request (request_queue_t *q, struct bio * bio)
mp_bh->master_bio = bio; mp_bh->master_bio = bio;
mp_bh->mddev = mddev; mp_bh->mddev = mddev;
if (bio_data_dir(bio)==WRITE) {
disk_stat_inc(mddev->gendisk, writes);
disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bio));
} else {
disk_stat_inc(mddev->gendisk, reads);
disk_stat_add(mddev->gendisk, read_sectors, bio_sectors(bio));
}
/* /*
* read balancing logic: * read balancing logic:
*/ */
......
...@@ -365,6 +365,14 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio) ...@@ -365,6 +365,14 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio)
unsigned long chunk; unsigned long chunk;
sector_t block, rsect; sector_t block, rsect;
if (bio_data_dir(bio)==WRITE) {
disk_stat_inc(mddev->gendisk, writes);
disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bio));
} else {
disk_stat_inc(mddev->gendisk, reads);
disk_stat_add(mddev->gendisk, read_sectors, bio_sectors(bio));
}
chunk_size = mddev->chunk_size >> 10; chunk_size = mddev->chunk_size >> 10;
chunk_sects = mddev->chunk_size >> 9; chunk_sects = mddev->chunk_size >> 9;
chunksize_bits = ffz(~chunk_size); chunksize_bits = ffz(~chunk_size);
......
...@@ -474,6 +474,14 @@ static int make_request(request_queue_t *q, struct bio * bio) ...@@ -474,6 +474,14 @@ static int make_request(request_queue_t *q, struct bio * bio)
conf->nr_pending++; conf->nr_pending++;
spin_unlock_irq(&conf->resync_lock); spin_unlock_irq(&conf->resync_lock);
if (bio_data_dir(bio)==WRITE) {
disk_stat_inc(mddev->gendisk, writes);
disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bio));
} else {
disk_stat_inc(mddev->gendisk, reads);
disk_stat_add(mddev->gendisk, read_sectors, bio_sectors(bio));
}
/* /*
* make_request() can abort the operation when READA is being * make_request() can abort the operation when READA is being
* used and no empty request is available. * used and no empty request is available.
......
...@@ -1326,6 +1326,14 @@ static int make_request (request_queue_t *q, struct bio * bi) ...@@ -1326,6 +1326,14 @@ static int make_request (request_queue_t *q, struct bio * bi)
sector_t logical_sector, last_sector; sector_t logical_sector, last_sector;
struct stripe_head *sh; struct stripe_head *sh;
if (bio_data_dir(bi)==WRITE) {
disk_stat_inc(mddev->gendisk, writes);
disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bi));
} else {
disk_stat_inc(mddev->gendisk, reads);
disk_stat_add(mddev->gendisk, read_sectors, bio_sectors(bi));
}
logical_sector = bi->bi_sector & ~(STRIPE_SECTORS-1); logical_sector = bi->bi_sector & ~(STRIPE_SECTORS-1);
last_sector = bi->bi_sector + (bi->bi_size>>9); last_sector = bi->bi_sector + (bi->bi_size>>9);
......
...@@ -1488,6 +1488,14 @@ static int make_request (request_queue_t *q, struct bio * bi) ...@@ -1488,6 +1488,14 @@ static int make_request (request_queue_t *q, struct bio * bi)
sector_t logical_sector, last_sector; sector_t logical_sector, last_sector;
struct stripe_head *sh; struct stripe_head *sh;
if (bio_data_dir(bi)==WRITE) {
disk_stat_inc(mddev->gendisk, writes);
disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bi));
} else {
disk_stat_inc(mddev->gendisk, reads);
disk_stat_add(mddev->gendisk, read_sectors, bio_sectors(bi));
}
logical_sector = bi->bi_sector & ~(STRIPE_SECTORS-1); logical_sector = bi->bi_sector & ~(STRIPE_SECTORS-1);
last_sector = bi->bi_sector + (bi->bi_size>>9); last_sector = bi->bi_sector + (bi->bi_size>>9);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment