diff mbox series

[RFC,2/7] block: export part_stat_read_inflight

Message ID 187d1f02f82019d48f66c97c0d1b99c9a58cd553.1603751876.git.anand.jain@oracle.com
State New, archived
Headers show
Series [RFC,1/7] block: export part_stat_read_all | expand

Commit Message

Anand Jain Oct. 26, 2020, 11:55 p.m. UTC
The exported function part_in_flight() returns commands in-flight in the
given block device.

Cc: linux-block@vger.kernel.org
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 block/genhd.c         | 19 +++++++++++--------
 include/linux/genhd.h |  2 ++
 2 files changed, 13 insertions(+), 8 deletions(-)

Comments

Josef Bacik Oct. 27, 2020, 6:10 p.m. UTC | #1
On 10/26/20 7:55 PM, Anand Jain wrote:
> The exported function part_in_flight() returns commands in-flight in the
> given block device.
> 
> Cc: linux-block@vger.kernel.org
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

This is much more internal to block and I'd rather not rely on it, I feel like 
getting the average latency is good enough.  Thanks,

Josef
Anand Jain Oct. 28, 2020, 8:32 a.m. UTC | #2
On 28/10/20 2:10 am, Josef Bacik wrote:
> On 10/26/20 7:55 PM, Anand Jain wrote:
>> The exported function part_in_flight() returns commands in-flight in the
>> given block device.
>>
>> Cc: linux-block@vger.kernel.org
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> 
> This is much more internal to block and I'd rather not rely on it, I 
> feel like getting the average latency is good enough.  Thanks,
> 

And also, as mentioned in the cover letter, it is hard to know the 
relation between the number of inflight commands and its effect on avg 
latency.

So ok, we don't need this.

Thanks, Anand


> Josef
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index 81b10b90de71..21876d4cf2fb 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -125,6 +125,15 @@  static unsigned int part_in_flight(struct hd_struct *part)
 	return inflight;
 }
 
+unsigned int part_stat_read_inflight(struct request_queue *q, struct hd_struct *p)
+{
+	if (queue_is_mq(q))
+		return blk_mq_in_flight(q, p);
+	else
+		return part_in_flight(p);
+}
+EXPORT_SYMBOL_GPL(part_stat_read_inflight);
+
 static void part_in_flight_rw(struct hd_struct *part, unsigned int inflight[2])
 {
 	int cpu;
@@ -1291,10 +1300,7 @@  ssize_t part_stat_show(struct device *dev,
 	unsigned int inflight;
 
 	part_stat_read_all(p, &stat);
-	if (queue_is_mq(q))
-		inflight = blk_mq_in_flight(q, p);
-	else
-		inflight = part_in_flight(p);
+	inflight = part_stat_read_inflight(q, p);
 
 	return sprintf(buf,
 		"%8lu %8lu %8llu %8u "
@@ -1613,10 +1619,7 @@  static int diskstats_show(struct seq_file *seqf, void *v)
 	disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
 	while ((hd = disk_part_iter_next(&piter))) {
 		part_stat_read_all(hd, &stat);
-		if (queue_is_mq(gp->queue))
-			inflight = blk_mq_in_flight(gp->queue, hd);
-		else
-			inflight = part_in_flight(hd);
+		inflight = part_stat_read_inflight(gp->queue, hd);
 
 		seq_printf(seqf, "%4d %7d %s "
 			   "%lu %lu %lu %u "
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index eb77e0ac8a82..93dd7a96d444 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -282,6 +282,8 @@  struct disk_part_iter {
 };
 
 extern void part_stat_read_all(struct hd_struct *part, struct disk_stats *stat);
+extern unsigned int part_stat_read_inflight(struct request_queue *q,
+					    struct hd_struct *part);
 extern void disk_part_iter_init(struct disk_part_iter *piter,
 				 struct gendisk *disk, unsigned int flags);
 extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter);