blk-stat: fix blk_stat_sum() if all samples are batched
authorOmar Sandoval <osandov@fb.com>
Thu, 16 Mar 2017 15:46:14 +0000 (09:46 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 21 Mar 2017 16:00:55 +0000 (10:00 -0600)
We need to flush the batch _before_ we check the number of samples,
otherwise we'll miss all of the batched samples.

Fixes: cf43e6b ("block: add scalable completion tracking of requests")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-stat.c

index 9b43efb8933fb9a0f352922029b86903e5b7c8e7..186fcb981e9b1d9696e3e000b0fde7b86e1a9663 100644 (file)
@@ -30,11 +30,11 @@ static void blk_stat_flush_batch(struct blk_rq_stat *stat)
 
 static void blk_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src)
 {
+       blk_stat_flush_batch(src);
+
        if (!src->nr_samples)
                return;
 
-       blk_stat_flush_batch(src);
-
        dst->min = min(dst->min, src->min);
        dst->max = max(dst->max, src->max);