blk-stat: fix a few cases of missing batch flushing wb-buf-throttle-v4.8
authorJens Axboe <axboe@fb.com>
Fri, 9 Dec 2016 23:16:30 +0000 (16:16 -0700)
committerJens Axboe <axboe@fb.com>
Fri, 9 Dec 2016 23:18:02 +0000 (16:18 -0700)
Everytime we need to read ->nr_samples, we should have flushed
the batch first. The non-mq read path also needs to flush the
batch.

Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-stat.c

index bdb16d84b91472c4b7b807ec878b6ec7b9e539d7..f6ede163fe12dc6ae015dfb2ee542a26fb175fe6 100644 (file)
@@ -61,6 +61,9 @@ static void blk_mq_stat_get(struct request_queue *q, struct blk_rq_stat *dst)
 
                queue_for_each_hw_ctx(q, hctx, i) {
                        hctx_for_each_ctx(hctx, ctx, j) {
+                               blk_stat_flush_batch(&ctx->stat[0]);
+                               blk_stat_flush_batch(&ctx->stat[1]);
+
                                if (!ctx->stat[0].nr_samples &&
                                    !ctx->stat[1].nr_samples)
                                        continue;
@@ -106,6 +109,8 @@ void blk_queue_stat_get(struct request_queue *q, struct blk_rq_stat *dst)
        if (q->mq_ops)
                blk_mq_stat_get(q, dst);
        else {
+               blk_stat_flush_batch(&q->rq_stats[0]);
+               blk_stat_flush_batch(&q->rq_stats[1]);
                memcpy(&dst[0], &q->rq_stats[0], sizeof(struct blk_rq_stat));
                memcpy(&dst[1], &q->rq_stats[1], sizeof(struct blk_rq_stat));
        }
@@ -121,6 +126,9 @@ void blk_hctx_stat_get(struct blk_mq_hw_ctx *hctx, struct blk_rq_stat *dst)
                uint64_t newest = 0;
 
                hctx_for_each_ctx(hctx, ctx, i) {
+                       blk_stat_flush_batch(&ctx->stat[0]);
+                       blk_stat_flush_batch(&ctx->stat[1]);
+
                        if (!ctx->stat[0].nr_samples &&
                            !ctx->stat[1].nr_samples)
                                continue;