]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvme: add support multipath passthrough iostats
authorKeith Busch <kbusch@kernel.org>
Thu, 28 May 2026 01:00:41 +0000 (18:00 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 28 May 2026 15:35:38 +0000 (09:35 -0600)
Don't skip the io accounting for passthrough commands if the user
enabled tracking these.

Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260528010041.1533124-3-kbusch@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/ioctl.c
drivers/nvme/host/multipath.c

index 9597a87cf05dc32a7eb0373485f575502c32a105..b449da7798aaf1895d786d04b8220111da10da25 100644 (file)
@@ -102,8 +102,17 @@ static struct request *nvme_alloc_user_request(struct request_queue *q,
                struct nvme_command *cmd, blk_opf_t rq_flags,
                blk_mq_req_flags_t blk_flags)
 {
+       struct nvme_ns *ns = q->queuedata;
        struct request *req;
 
+       /*
+        * The NVME_MPATH flag is set only for IO commands sent to a namespace
+        * with a multipath enabled head. The request is not eligible for
+        * failover as passthrough requests also append REQ_FAILFAST_DRIVER.
+        */
+       if (ns && nvme_ns_head_multipath(ns->head))
+               rq_flags |= REQ_NVME_MPATH;
+
        req = blk_mq_alloc_request(q, nvme_req_op(cmd) | rq_flags, blk_flags);
        if (IS_ERR(req))
                return req;
index ff442bbf2937a2303b9c47e2bc4603a2be1f4ec4..bca8e7c975190f60e7247dac42a120fe9ef08886 100644 (file)
@@ -175,9 +175,12 @@ void nvme_mpath_start_request(struct request *rq)
                nvme_req(rq)->flags |= NVME_MPATH_CNT_ACTIVE;
        }
 
-       if (!blk_queue_io_stat(disk->queue) || blk_rq_is_passthrough(rq) ||
+       if (!blk_queue_io_stat(disk->queue) ||
            (nvme_req(rq)->flags & NVME_MPATH_IO_STATS))
                return;
+       if (blk_rq_is_passthrough(rq) &&
+           !blk_rq_passthrough_stats(rq, disk->queue))
+               return;
 
        nvme_req(rq)->flags |= NVME_MPATH_IO_STATS;
        nvme_req(rq)->start_time = bdev_start_io_acct(disk->part0, req_op(rq),