diff options
-rw-r--r-- | block/blk-mq.c | 19 | ||||
-rw-r--r-- | block/blk-mq.h | 4 | ||||
-rw-r--r-- | block/genhd.c | 12 | ||||
-rw-r--r-- | block/partition-generic.c | 10 | ||||
-rw-r--r-- | include/linux/genhd.h | 4 |
5 files changed, 43 insertions, 6 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index 5450cbc61f8d..9ce9cac16c3f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -115,6 +115,25 @@ void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, | |||
115 | blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); | 115 | blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); |
116 | } | 116 | } |
117 | 117 | ||
118 | static void blk_mq_check_inflight_rw(struct blk_mq_hw_ctx *hctx, | ||
119 | struct request *rq, void *priv, | ||
120 | bool reserved) | ||
121 | { | ||
122 | struct mq_inflight *mi = priv; | ||
123 | |||
124 | if (rq->part == mi->part) | ||
125 | mi->inflight[rq_data_dir(rq)]++; | ||
126 | } | ||
127 | |||
128 | void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, | ||
129 | unsigned int inflight[2]) | ||
130 | { | ||
131 | struct mq_inflight mi = { .part = part, .inflight = inflight, }; | ||
132 | |||
133 | inflight[0] = inflight[1] = 0; | ||
134 | blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight_rw, &mi); | ||
135 | } | ||
136 | |||
118 | void blk_freeze_queue_start(struct request_queue *q) | 137 | void blk_freeze_queue_start(struct request_queue *q) |
119 | { | 138 | { |
120 | int freeze_depth; | 139 | int freeze_depth; |
diff --git a/block/blk-mq.h b/block/blk-mq.h index 89b5cd3a6c70..e1bb420dc5d6 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h | |||
@@ -188,7 +188,9 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx) | |||
188 | } | 188 | } |
189 | 189 | ||
190 | void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, | 190 | void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, |
191 | unsigned int inflight[2]); | 191 | unsigned int inflight[2]); |
192 | void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, | ||
193 | unsigned int inflight[2]); | ||
192 | 194 | ||
193 | static inline void blk_mq_put_dispatch_budget(struct blk_mq_hw_ctx *hctx) | 195 | static inline void blk_mq_put_dispatch_budget(struct blk_mq_hw_ctx *hctx) |
194 | { | 196 | { |
diff --git a/block/genhd.c b/block/genhd.c index dc7e089373b9..c4513fe1adda 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -82,6 +82,18 @@ void part_in_flight(struct request_queue *q, struct hd_struct *part, | |||
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, | ||
86 | unsigned int inflight[2]) | ||
87 | { | ||
88 | if (q->mq_ops) { | ||
89 | blk_mq_in_flight_rw(q, part, inflight); | ||
90 | return; | ||
91 | } | ||
92 | |||
93 | inflight[0] = atomic_read(&part->in_flight[0]); | ||
94 | inflight[1] = atomic_read(&part->in_flight[1]); | ||
95 | } | ||
96 | |||
85 | struct hd_struct *__disk_get_part(struct gendisk *disk, int partno) | 97 | struct hd_struct *__disk_get_part(struct gendisk *disk, int partno) |
86 | { | 98 | { |
87 | struct disk_part_tbl *ptbl = rcu_dereference(disk->part_tbl); | 99 | struct disk_part_tbl *ptbl = rcu_dereference(disk->part_tbl); |
diff --git a/block/partition-generic.c b/block/partition-generic.c index 08dabcd8b6ae..db57cced9b98 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c | |||
@@ -145,13 +145,15 @@ ssize_t part_stat_show(struct device *dev, | |||
145 | jiffies_to_msecs(part_stat_read(p, time_in_queue))); | 145 | jiffies_to_msecs(part_stat_read(p, time_in_queue))); |
146 | } | 146 | } |
147 | 147 | ||
148 | ssize_t part_inflight_show(struct device *dev, | 148 | ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr, |
149 | struct device_attribute *attr, char *buf) | 149 | char *buf) |
150 | { | 150 | { |
151 | struct hd_struct *p = dev_to_part(dev); | 151 | struct hd_struct *p = dev_to_part(dev); |
152 | struct request_queue *q = part_to_disk(p)->queue; | ||
153 | unsigned int inflight[2]; | ||
152 | 154 | ||
153 | return sprintf(buf, "%8u %8u\n", atomic_read(&p->in_flight[0]), | 155 | part_in_flight_rw(q, p, inflight); |
154 | atomic_read(&p->in_flight[1])); | 156 | return sprintf(buf, "%8u %8u\n", inflight[0], inflight[1]); |
155 | } | 157 | } |
156 | 158 | ||
157 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 159 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index c826b0b5232a..6cb8a5789668 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -368,7 +368,9 @@ static inline void free_part_stats(struct hd_struct *part) | |||
368 | part_stat_add(cpu, gendiskp, field, -subnd) | 368 | part_stat_add(cpu, gendiskp, field, -subnd) |
369 | 369 | ||
370 | void part_in_flight(struct request_queue *q, struct hd_struct *part, | 370 | void part_in_flight(struct request_queue *q, struct hd_struct *part, |
371 | unsigned int inflight[2]); | 371 | unsigned int inflight[2]); |
372 | void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, | ||
373 | unsigned int inflight[2]); | ||
372 | void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, | 374 | void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, |
373 | int rw); | 375 | int rw); |
374 | void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, | 376 | void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, |