diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 38 | ||||
-rw-r--r-- | block/blk-mq.c | 12 |
2 files changed, 33 insertions, 17 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 6ad2b8602c1d..d836c84ad3da 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -1470,17 +1470,12 @@ static void add_acct_request(struct request_queue *q, struct request *rq, | |||
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | static void part_round_stats_single(struct request_queue *q, int cpu, | 1472 | static void part_round_stats_single(struct request_queue *q, int cpu, |
1473 | struct hd_struct *part, unsigned long now) | 1473 | struct hd_struct *part, unsigned long now, |
1474 | unsigned int inflight) | ||
1474 | { | 1475 | { |
1475 | int inflight[2]; | 1476 | if (inflight) { |
1476 | |||
1477 | if (now == part->stamp) | ||
1478 | return; | ||
1479 | |||
1480 | part_in_flight(q, part, inflight); | ||
1481 | if (inflight[0]) { | ||
1482 | __part_stat_add(cpu, part, time_in_queue, | 1477 | __part_stat_add(cpu, part, time_in_queue, |
1483 | inflight[0] * (now - part->stamp)); | 1478 | inflight * (now - part->stamp)); |
1484 | __part_stat_add(cpu, part, io_ticks, (now - part->stamp)); | 1479 | __part_stat_add(cpu, part, io_ticks, (now - part->stamp)); |
1485 | } | 1480 | } |
1486 | part->stamp = now; | 1481 | part->stamp = now; |
@@ -1505,12 +1500,29 @@ static void part_round_stats_single(struct request_queue *q, int cpu, | |||
1505 | */ | 1500 | */ |
1506 | void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part) | 1501 | void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part) |
1507 | { | 1502 | { |
1503 | struct hd_struct *part2 = NULL; | ||
1508 | unsigned long now = jiffies; | 1504 | unsigned long now = jiffies; |
1505 | unsigned int inflight[2]; | ||
1506 | int stats = 0; | ||
1507 | |||
1508 | if (part->stamp != now) | ||
1509 | stats |= 1; | ||
1510 | |||
1511 | if (part->partno) { | ||
1512 | part2 = &part_to_disk(part)->part0; | ||
1513 | if (part2->stamp != now) | ||
1514 | stats |= 2; | ||
1515 | } | ||
1516 | |||
1517 | if (!stats) | ||
1518 | return; | ||
1519 | |||
1520 | part_in_flight(q, part, inflight); | ||
1509 | 1521 | ||
1510 | if (part->partno) | 1522 | if (stats & 2) |
1511 | part_round_stats_single(q, cpu, &part_to_disk(part)->part0, | 1523 | part_round_stats_single(q, cpu, part2, now, inflight[1]); |
1512 | now); | 1524 | if (stats & 1) |
1513 | part_round_stats_single(q, cpu, part, now); | 1525 | part_round_stats_single(q, cpu, part, now, inflight[0]); |
1514 | } | 1526 | } |
1515 | EXPORT_SYMBOL_GPL(part_round_stats); | 1527 | EXPORT_SYMBOL_GPL(part_round_stats); |
1516 | 1528 | ||
diff --git a/block/blk-mq.c b/block/blk-mq.c index 0dfc7a9984b6..fe764ca16993 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -97,11 +97,15 @@ static void blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx, | |||
97 | if (test_bit(REQ_ATOM_STARTED, &rq->atomic_flags) && | 97 | if (test_bit(REQ_ATOM_STARTED, &rq->atomic_flags) && |
98 | !test_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags)) { | 98 | !test_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags)) { |
99 | /* | 99 | /* |
100 | * Count as inflight if it either matches the partition we | 100 | * index[0] counts the specific partition that was asked |
101 | * asked for, or if it's the root | 101 | * for. index[1] counts the ones that are active on the |
102 | * whole device, so increment that if mi->part is indeed | ||
103 | * a partition, and not a whole device. | ||
102 | */ | 104 | */ |
103 | if (rq->part == mi->part || mi->part->partno) | 105 | if (rq->part == mi->part) |
104 | mi->inflight[0]++; | 106 | mi->inflight[0]++; |
107 | if (mi->part->partno) | ||
108 | mi->inflight[1]++; | ||
105 | } | 109 | } |
106 | } | 110 | } |
107 | 111 | ||
@@ -110,7 +114,7 @@ void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, | |||
110 | { | 114 | { |
111 | struct mq_inflight mi = { .part = part, .inflight = inflight, }; | 115 | struct mq_inflight mi = { .part = part, .inflight = inflight, }; |
112 | 116 | ||
113 | inflight[0] = 0; | 117 | inflight[0] = inflight[1] = 0; |
114 | blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); | 118 | blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); |
115 | } | 119 | } |
116 | 120 | ||