[PATCH] block: account flush request in inflight sysfs files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So sysfs files which show the number of inflight IOs
(e.g. /sys/block/xxx/inflight) will account the flush
request. It's specially useful for debugging purpose
when the completion of flush request is slow, but
the containing request is fast.

Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
---
 block/blk-flush.c |  1 +
 block/blk-mq.c    | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index c7f396e3d5e2..14606f1e9273 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -329,6 +329,7 @@ static void blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq,
 	flush_rq->cmd_flags |= (flags & REQ_DRV) | (flags & REQ_FAILFAST_MASK);
 	flush_rq->rq_flags |= RQF_FLUSH_SEQ;
 	flush_rq->rq_disk = first_rq->rq_disk;
+	flush_rq->part = first_rq->part;
 	flush_rq->end_io = flush_end_io;
 
 	blk_flush_queue_rq(flush_rq, false);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index a7785df2c944..1ed420a9a316 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -96,14 +96,22 @@ struct mq_inflight {
 	unsigned int inflight[2];
 };
 
+static inline int op_is_write_or_flush(unsigned int op)
+{
+	return op_is_write(op) || op == REQ_OP_FLUSH;
+}
+
 static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx,
 				  struct request *rq, void *priv,
 				  bool reserved)
 {
 	struct mq_inflight *mi = priv;
 
-	if (rq->part == mi->part)
-		mi->inflight[rq_data_dir(rq)]++;
+	if (rq->part == mi->part) {
+		int rw = op_is_write_or_flush(req_op(rq));
+
+		mi->inflight[rw]++;
+	}
 
 	return true;
 }
-- 
2.25.0.4.g0ad7144999




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux