From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: linux-block@vger.kernel.org
Subject: [PATCH RFC 2/7] block: export part_stat_read_inflight
Date: Tue, 27 Oct 2020 07:55:05 +0800 [thread overview]
Message-ID: <187d1f02f82019d48f66c97c0d1b99c9a58cd553.1603751876.git.anand.jain@oracle.com> (raw)
In-Reply-To: <cover.1603751876.git.anand.jain@oracle.com>
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(-)
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);
--
2.25.1
next prev parent reply other threads:[~2020-10-26 23:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1603751876.git.anand.jain@oracle.com>
2020-10-26 23:55 ` [PATCH RFC 1/7] block: export part_stat_read_all Anand Jain
2020-10-27 18:09 ` Josef Bacik
2020-10-28 8:26 ` Anand Jain
2020-10-26 23:55 ` Anand Jain [this message]
2020-10-27 18:10 ` [PATCH RFC 2/7] block: export part_stat_read_inflight Josef Bacik
2020-10-28 8:32 ` Anand Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=187d1f02f82019d48f66c97c0d1b99c9a58cd553.1603751876.git.anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).