aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorJerome Marchand <jmarchan@redhat.com>2009-04-22 08:01:49 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-04-24 02:54:21 -0400
commit42dad7647aec49b3ad20dd0cb832b232a6ae514f (patch)
treeb70d4cb7706f2647e65426e24f078ddf14d6e139 /block
parent097102c2d04974bdfcfa16a5f3062d499842139c (diff)
block: simplify I/O stat accounting
This simplifies I/O stat accounting switching code and separates it completely from I/O scheduler switch code. Requests are accounted according to the state of their request queue at the time of the request allocation. There is no need anymore to flush the request queue when switching I/O accounting state. 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.c6
-rw-r--r--block/blk-merge.c5
-rw-r--r--block/blk-sysfs.c4
-rw-r--r--block/blk.h7
4 files changed, 9 insertions, 13 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 07ab75403e1a..2998fe3a2377 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -643,7 +643,7 @@ static inline void blk_free_request(struct request_queue *q, struct request *rq)
643} 643}
644 644
645static struct request * 645static struct request *
646blk_alloc_request(struct request_queue *q, int rw, int priv, gfp_t gfp_mask) 646blk_alloc_request(struct request_queue *q, int flags, int priv, gfp_t gfp_mask)
647{ 647{
648 struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask); 648 struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask);
649 649
@@ -652,7 +652,7 @@ blk_alloc_request(struct request_queue *q, int rw, int priv, gfp_t gfp_mask)
652 652
653 blk_rq_init(q, rq); 653 blk_rq_init(q, rq);
654 654
655 rq->cmd_flags = rw | REQ_ALLOCED; 655 rq->cmd_flags = flags | REQ_ALLOCED;
656 656
657 if (priv) { 657 if (priv) {
658 if (unlikely(elv_set_request(q, rq, gfp_mask))) { 658 if (unlikely(elv_set_request(q, rq, gfp_mask))) {
@@ -792,6 +792,8 @@ static struct request *get_request(struct request_queue *q, int rw_flags,
792 if (priv) 792 if (priv)
793 rl->elvpriv++; 793 rl->elvpriv++;
794 794
795 if (blk_queue_io_stat(q))
796 rw_flags |= REQ_IO_STAT;
795 spin_unlock_irq(q->queue_lock); 797 spin_unlock_irq(q->queue_lock);
796 798
797 rq = blk_alloc_request(q, rw_flags, priv, gfp_mask); 799 rq = blk_alloc_request(q, rw_flags, priv, gfp_mask);
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 63760ca3da0f..23d2a6fe34a3 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -402,7 +402,10 @@ static int attempt_merge(struct request_queue *q, struct request *req,
402 402
403 elv_merge_requests(q, req, next); 403 elv_merge_requests(q, req, next);
404 404
405 blk_account_io_merge(req); 405 /*
406 * 'next' is going away, so update stats accordingly
407 */
408 blk_account_io_merge(next);
406 409
407 req->ioprio = ioprio_best(req->ioprio, next->ioprio); 410 req->ioprio = ioprio_best(req->ioprio, next->ioprio);
408 if (blk_rq_cpu_valid(next)) 411 if (blk_rq_cpu_valid(next))
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index cac4e9febe6a..3ff9bba3379a 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -209,14 +209,10 @@ 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_quiesce_start(q);
213
214 if (stats) 212 if (stats)
215 queue_flag_set(QUEUE_FLAG_IO_STAT, q); 213 queue_flag_set(QUEUE_FLAG_IO_STAT, q);
216 else 214 else
217 queue_flag_clear(QUEUE_FLAG_IO_STAT, q); 215 queue_flag_clear(QUEUE_FLAG_IO_STAT, q);
218
219 elv_quiesce_end(q);
220 spin_unlock_irq(q->queue_lock); 216 spin_unlock_irq(q->queue_lock);
221 217
222 return ret; 218 return ret;
diff --git a/block/blk.h b/block/blk.h
index 5dfc41267a08..79c85f7c9ff5 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -114,12 +114,7 @@ static inline int blk_cpu_to_group(int cpu)
114 114
115static inline int blk_do_io_stat(struct request *rq) 115static inline int blk_do_io_stat(struct request *rq)
116{ 116{
117 struct gendisk *disk = rq->rq_disk; 117 return rq->rq_disk && blk_rq_io_stat(rq);
118
119 if (!disk || !disk->queue)
120 return 0;
121
122 return blk_queue_io_stat(disk->queue) && (rq->cmd_flags & REQ_ELVPRIV);
123} 118}
124 119
125#endif 120#endif