diff options
author | Jerome Marchand <jmarchan@redhat.com> | 2009-03-27 05:31:51 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-04-07 02:12:38 -0400 |
commit | 26308eab69aa193f7b3fb50764a64ae14544a39b (patch) | |
tree | 758f6100395a23228d042c3a9d6f7dc1922d7530 /block | |
parent | 6c7e8cee6a9128eeb7f83c3ad1cb243f77f5cb16 (diff) |
block: fix inconsistency in I/O stat accounting code
This forces in_flight to be zero when turning off or on the I/O stat
accounting and stops updating I/O stats in attempt_merge() when
accounting is turned off.
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 13 | ||||
-rw-r--r-- | block/blk-merge.c | 29 | ||||
-rw-r--r-- | block/blk-sysfs.c | 4 | ||||
-rw-r--r-- | block/blk.h | 10 | ||||
-rw-r--r-- | block/elevator.c | 2 |
5 files changed, 32 insertions, 26 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 25572802dac2..3688abff2430 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -64,12 +64,11 @@ static struct workqueue_struct *kblockd_workqueue; | |||
64 | 64 | ||
65 | static void drive_stat_acct(struct request *rq, int new_io) | 65 | static void drive_stat_acct(struct request *rq, int new_io) |
66 | { | 66 | { |
67 | struct gendisk *disk = rq->rq_disk; | ||
68 | struct hd_struct *part; | 67 | struct hd_struct *part; |
69 | int rw = rq_data_dir(rq); | 68 | int rw = rq_data_dir(rq); |
70 | int cpu; | 69 | int cpu; |
71 | 70 | ||
72 | if (!blk_fs_request(rq) || !disk || !blk_do_io_stat(disk->queue)) | 71 | if (!blk_fs_request(rq) || !blk_do_io_stat(rq)) |
73 | return; | 72 | return; |
74 | 73 | ||
75 | cpu = part_stat_lock(); | 74 | cpu = part_stat_lock(); |
@@ -1675,9 +1674,7 @@ EXPORT_SYMBOL(blkdev_dequeue_request); | |||
1675 | 1674 | ||
1676 | static void blk_account_io_completion(struct request *req, unsigned int bytes) | 1675 | static void blk_account_io_completion(struct request *req, unsigned int bytes) |
1677 | { | 1676 | { |
1678 | struct gendisk *disk = req->rq_disk; | 1677 | if (!blk_do_io_stat(req)) |
1679 | |||
1680 | if (!disk || !blk_do_io_stat(disk->queue)) | ||
1681 | return; | 1678 | return; |
1682 | 1679 | ||
1683 | if (blk_fs_request(req)) { | 1680 | if (blk_fs_request(req)) { |
@@ -1694,9 +1691,7 @@ static void blk_account_io_completion(struct request *req, unsigned int bytes) | |||
1694 | 1691 | ||
1695 | static void blk_account_io_done(struct request *req) | 1692 | static void blk_account_io_done(struct request *req) |
1696 | { | 1693 | { |
1697 | struct gendisk *disk = req->rq_disk; | 1694 | if (!blk_do_io_stat(req)) |
1698 | |||
1699 | if (!disk || !blk_do_io_stat(disk->queue)) | ||
1700 | return; | 1695 | return; |
1701 | 1696 | ||
1702 | /* | 1697 | /* |
@@ -1711,7 +1706,7 @@ static void blk_account_io_done(struct request *req) | |||
1711 | int cpu; | 1706 | int cpu; |
1712 | 1707 | ||
1713 | cpu = part_stat_lock(); | 1708 | cpu = part_stat_lock(); |
1714 | part = disk_map_sector_rcu(disk, req->sector); | 1709 | part = disk_map_sector_rcu(req->rq_disk, req->sector); |
1715 | 1710 | ||
1716 | part_stat_inc(cpu, part, ios[rw]); | 1711 | part_stat_inc(cpu, part, ios[rw]); |
1717 | part_stat_add(cpu, part, ticks[rw], duration); | 1712 | part_stat_add(cpu, part, ticks[rw], duration); |
diff --git a/block/blk-merge.c b/block/blk-merge.c index e39cb24b7679..63760ca3da0f 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -338,6 +338,22 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req, | |||
338 | return 1; | 338 | return 1; |
339 | } | 339 | } |
340 | 340 | ||
341 | static void blk_account_io_merge(struct request *req) | ||
342 | { | ||
343 | if (blk_do_io_stat(req)) { | ||
344 | struct hd_struct *part; | ||
345 | int cpu; | ||
346 | |||
347 | cpu = part_stat_lock(); | ||
348 | part = disk_map_sector_rcu(req->rq_disk, req->sector); | ||
349 | |||
350 | part_round_stats(cpu, part); | ||
351 | part_dec_in_flight(part); | ||
352 | |||
353 | part_stat_unlock(); | ||
354 | } | ||
355 | } | ||
356 | |||
341 | /* | 357 | /* |
342 | * Has to be called with the request spinlock acquired | 358 | * Has to be called with the request spinlock acquired |
343 | */ | 359 | */ |
@@ -386,18 +402,7 @@ static int attempt_merge(struct request_queue *q, struct request *req, | |||
386 | 402 | ||
387 | elv_merge_requests(q, req, next); | 403 | elv_merge_requests(q, req, next); |
388 | 404 | ||
389 | if (req->rq_disk) { | 405 | blk_account_io_merge(req); |
390 | struct hd_struct *part; | ||
391 | int cpu; | ||
392 | |||
393 | cpu = part_stat_lock(); | ||
394 | part = disk_map_sector_rcu(req->rq_disk, req->sector); | ||
395 | |||
396 | part_round_stats(cpu, part); | ||
397 | part_dec_in_flight(part); | ||
398 | |||
399 | part_stat_unlock(); | ||
400 | } | ||
401 | 406 | ||
402 | req->ioprio = ioprio_best(req->ioprio, next->ioprio); | 407 | req->ioprio = ioprio_best(req->ioprio, next->ioprio); |
403 | if (blk_rq_cpu_valid(next)) | 408 | if (blk_rq_cpu_valid(next)) |
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 3ff9bba3379a..73f36beff5cd 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c | |||
@@ -209,10 +209,14 @@ static ssize_t queue_iostats_store(struct request_queue *q, const char *page, | |||
209 | ssize_t ret = queue_var_store(&stats, page, count); | 209 | ssize_t ret = queue_var_store(&stats, page, count); |
210 | 210 | ||
211 | spin_lock_irq(q->queue_lock); | 211 | spin_lock_irq(q->queue_lock); |
212 | elv_quisce_start(q); | ||
213 | |||
212 | if (stats) | 214 | if (stats) |
213 | queue_flag_set(QUEUE_FLAG_IO_STAT, q); | 215 | queue_flag_set(QUEUE_FLAG_IO_STAT, q); |
214 | else | 216 | else |
215 | queue_flag_clear(QUEUE_FLAG_IO_STAT, q); | 217 | queue_flag_clear(QUEUE_FLAG_IO_STAT, q); |
218 | |||
219 | elv_quisce_end(q); | ||
216 | spin_unlock_irq(q->queue_lock); | 220 | spin_unlock_irq(q->queue_lock); |
217 | 221 | ||
218 | return ret; | 222 | return ret; |
diff --git a/block/blk.h b/block/blk.h index 22043c2886c7..24fcaeeaf620 100644 --- a/block/blk.h +++ b/block/blk.h | |||
@@ -112,12 +112,14 @@ static inline int blk_cpu_to_group(int cpu) | |||
112 | #endif | 112 | #endif |
113 | } | 113 | } |
114 | 114 | ||
115 | static inline int blk_do_io_stat(struct request_queue *q) | 115 | static inline int blk_do_io_stat(struct request *rq) |
116 | { | 116 | { |
117 | if (q) | 117 | struct gendisk *disk = rq->rq_disk; |
118 | return blk_queue_io_stat(q); | ||
119 | 118 | ||
120 | return 0; | 119 | if (!disk || !disk->queue) |
120 | return 0; | ||
121 | |||
122 | return blk_queue_io_stat(disk->queue) && (rq->cmd_flags & REQ_ELVPRIV); | ||
121 | } | 123 | } |
122 | 124 | ||
123 | #endif | 125 | #endif |
diff --git a/block/elevator.c b/block/elevator.c index c6744913ff4a..fb81bcc14a8c 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -573,7 +573,7 @@ void elv_requeue_request(struct request_queue *q, struct request *rq) | |||
573 | elv_insert(q, rq, ELEVATOR_INSERT_REQUEUE); | 573 | elv_insert(q, rq, ELEVATOR_INSERT_REQUEUE); |
574 | } | 574 | } |
575 | 575 | ||
576 | static void elv_drain_elevator(struct request_queue *q) | 576 | void elv_drain_elevator(struct request_queue *q) |
577 | { | 577 | { |
578 | static int printed; | 578 | static int printed; |
579 | while (q->elevator->ops->elevator_dispatch_fn(q, 1)) | 579 | while (q->elevator->ops->elevator_dispatch_fn(q, 1)) |