diff options
-rw-r--r-- | block/blk-core.c | 7 | ||||
-rw-r--r-- | block/blk-merge.c | 4 | ||||
-rw-r--r-- | block/genhd.c | 4 | ||||
-rw-r--r-- | drivers/block/aoe/aoecmd.c | 2 | ||||
-rw-r--r-- | include/linux/genhd.h | 13 |
5 files changed, 19 insertions, 11 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 86d22e7d65c5..a0dc2e72fcbb 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -60,7 +60,7 @@ static void drive_stat_acct(struct request *rq, int new_io) | |||
60 | if (!blk_fs_request(rq) || !rq->rq_disk) | 60 | if (!blk_fs_request(rq) || !rq->rq_disk) |
61 | return; | 61 | return; |
62 | 62 | ||
63 | part = get_part(rq->rq_disk, rq->sector); | 63 | part = disk_map_sector(rq->rq_disk, rq->sector); |
64 | if (!new_io) | 64 | if (!new_io) |
65 | __all_stat_inc(rq->rq_disk, part, merges[rw], rq->sector); | 65 | __all_stat_inc(rq->rq_disk, part, merges[rw], rq->sector); |
66 | else { | 66 | else { |
@@ -1557,7 +1557,8 @@ static int __end_that_request_first(struct request *req, int error, | |||
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | if (blk_fs_request(req) && req->rq_disk) { | 1559 | if (blk_fs_request(req) && req->rq_disk) { |
1560 | struct hd_struct *part = get_part(req->rq_disk, req->sector); | 1560 | struct hd_struct *part = |
1561 | disk_map_sector(req->rq_disk, req->sector); | ||
1561 | const int rw = rq_data_dir(req); | 1562 | const int rw = rq_data_dir(req); |
1562 | 1563 | ||
1563 | all_stat_add(req->rq_disk, part, sectors[rw], | 1564 | all_stat_add(req->rq_disk, part, sectors[rw], |
@@ -1745,7 +1746,7 @@ static void end_that_request_last(struct request *req, int error) | |||
1745 | if (disk && blk_fs_request(req) && req != &req->q->bar_rq) { | 1746 | if (disk && blk_fs_request(req) && req != &req->q->bar_rq) { |
1746 | unsigned long duration = jiffies - req->start_time; | 1747 | unsigned long duration = jiffies - req->start_time; |
1747 | const int rw = rq_data_dir(req); | 1748 | const int rw = rq_data_dir(req); |
1748 | struct hd_struct *part = get_part(disk, req->sector); | 1749 | struct hd_struct *part = disk_map_sector(disk, req->sector); |
1749 | 1750 | ||
1750 | __all_stat_inc(disk, part, ios[rw], req->sector); | 1751 | __all_stat_inc(disk, part, ios[rw], req->sector); |
1751 | __all_stat_add(disk, part, ticks[rw], duration, req->sector); | 1752 | __all_stat_add(disk, part, ticks[rw], duration, req->sector); |
diff --git a/block/blk-merge.c b/block/blk-merge.c index d81d91419ff5..9b17da698d7c 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -387,8 +387,8 @@ static int attempt_merge(struct request_queue *q, struct request *req, | |||
387 | elv_merge_requests(q, req, next); | 387 | elv_merge_requests(q, req, next); |
388 | 388 | ||
389 | if (req->rq_disk) { | 389 | if (req->rq_disk) { |
390 | struct hd_struct *part | 390 | struct hd_struct *part = |
391 | = get_part(req->rq_disk, req->sector); | 391 | disk_map_sector(req->rq_disk, req->sector); |
392 | disk_round_stats(req->rq_disk); | 392 | disk_round_stats(req->rq_disk); |
393 | req->rq_disk->in_flight--; | 393 | req->rq_disk->in_flight--; |
394 | if (part) { | 394 | if (part) { |
diff --git a/block/genhd.c b/block/genhd.c index 8b9a9ff1a842..11038fbc75ed 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -568,7 +568,7 @@ static int diskstats_show(struct seq_file *s, void *v) | |||
568 | { | 568 | { |
569 | struct gendisk *gp = v; | 569 | struct gendisk *gp = v; |
570 | char buf[BDEVNAME_SIZE]; | 570 | char buf[BDEVNAME_SIZE]; |
571 | int n = 0; | 571 | int n; |
572 | 572 | ||
573 | /* | 573 | /* |
574 | if (&gp->dev.kobj.entry == block_class.devices.next) | 574 | if (&gp->dev.kobj.entry == block_class.devices.next) |
@@ -582,7 +582,7 @@ static int diskstats_show(struct seq_file *s, void *v) | |||
582 | disk_round_stats(gp); | 582 | disk_round_stats(gp); |
583 | preempt_enable(); | 583 | preempt_enable(); |
584 | seq_printf(s, "%4d %4d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n", | 584 | seq_printf(s, "%4d %4d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n", |
585 | gp->major, n + gp->first_minor, disk_name(gp, n, buf), | 585 | gp->major, gp->first_minor, disk_name(gp, 0, buf), |
586 | disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]), | 586 | disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]), |
587 | (unsigned long long)disk_stat_read(gp, sectors[0]), | 587 | (unsigned long long)disk_stat_read(gp, sectors[0]), |
588 | jiffies_to_msecs(disk_stat_read(gp, ticks[0])), | 588 | jiffies_to_msecs(disk_stat_read(gp, ticks[0])), |
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index 2f1746295d06..885d1409521f 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -757,7 +757,7 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector | |||
757 | const int rw = bio_data_dir(bio); | 757 | const int rw = bio_data_dir(bio); |
758 | struct hd_struct *part; | 758 | struct hd_struct *part; |
759 | 759 | ||
760 | part = get_part(disk, sector); | 760 | part = disk_map_sector(disk, sector); |
761 | all_stat_inc(disk, part, ios[rw], sector); | 761 | all_stat_inc(disk, part, ios[rw], sector); |
762 | all_stat_add(disk, part, ticks[rw], duration, sector); | 762 | all_stat_add(disk, part, ticks[rw], duration, sector); |
763 | all_stat_add(disk, part, sectors[rw], n_sect, sector); | 763 | all_stat_add(disk, part, sectors[rw], n_sect, sector); |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index be4f5e5bfe06..c64e659c9843 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -116,7 +116,7 @@ struct gendisk { | |||
116 | int minors; /* maximum number of minors, =1 for | 116 | int minors; /* maximum number of minors, =1 for |
117 | * disks that can't be partitioned. */ | 117 | * disks that can't be partitioned. */ |
118 | char disk_name[32]; /* name of major driver */ | 118 | char disk_name[32]; /* name of major driver */ |
119 | struct hd_struct **part; /* [indexed by minor] */ | 119 | struct hd_struct **part; /* [indexed by minor - 1] */ |
120 | struct block_device_operations *fops; | 120 | struct block_device_operations *fops; |
121 | struct request_queue *queue; | 121 | struct request_queue *queue; |
122 | void *private_data; | 122 | void *private_data; |
@@ -145,14 +145,21 @@ struct gendisk { | |||
145 | #endif | 145 | #endif |
146 | }; | 146 | }; |
147 | 147 | ||
148 | static inline struct gendisk *part_to_disk(struct hd_struct *part) | ||
149 | { | ||
150 | if (likely(part)) | ||
151 | return dev_to_disk((part)->dev.parent); | ||
152 | return NULL; | ||
153 | } | ||
154 | |||
148 | /* | 155 | /* |
149 | * Macros to operate on percpu disk statistics: | 156 | * Macros to operate on percpu disk statistics: |
150 | * | 157 | * |
151 | * The __ variants should only be called in critical sections. The full | 158 | * The __ variants should only be called in critical sections. The full |
152 | * variants disable/enable preemption. | 159 | * variants disable/enable preemption. |
153 | */ | 160 | */ |
154 | static inline struct hd_struct *get_part(struct gendisk *gendiskp, | 161 | static inline struct hd_struct *disk_map_sector(struct gendisk *gendiskp, |
155 | sector_t sector) | 162 | sector_t sector) |
156 | { | 163 | { |
157 | struct hd_struct *part; | 164 | struct hd_struct *part; |
158 | int i; | 165 | int i; |