* [PATCHv2 0/2] block, nvme: enable passthrough iostats @ 2026-05-26 15:39 Keith Busch 2026-05-26 15:39 ` [PATCHv2 1/2] block: export passthrough stats enabled Keith Busch 2026-05-26 15:39 ` [PATCHv2 2/2] nvme: add support multipath passthrough iostats Keith Busch 0 siblings, 2 replies; 12+ messages in thread From: Keith Busch @ 2026-05-26 15:39 UTC (permalink / raw) To: linux-block, linux-nvme; +Cc: axboe, hch, nilay, Keith Busch From: Keith Busch <kbusch@kernel.org> v1->v2: Split the block and nvme parts into separate patches. Fixed up the nvme driver to ensure passthrough commands go through the multipath start/end functions. Have the helper function take a request_queue parameter since the queue accumulating the stats for multipath isn't the same as the request's queue. Keith Busch (2): block: export passthrough stats enabled nvme: add support multipath passthrough iostats block/blk-mq.c | 32 +------------------------------- drivers/nvme/host/ioctl.c | 4 ++++ drivers/nvme/host/multipath.c | 5 ++++- include/linux/blk-mq.h | 30 ++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 32 deletions(-) -- 2.53.0-Meta ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 1/2] block: export passthrough stats enabled 2026-05-26 15:39 [PATCHv2 0/2] block, nvme: enable passthrough iostats Keith Busch @ 2026-05-26 15:39 ` Keith Busch 2026-05-27 6:15 ` Nilay Shroff ` (2 more replies) 2026-05-26 15:39 ` [PATCHv2 2/2] nvme: add support multipath passthrough iostats Keith Busch 1 sibling, 3 replies; 12+ messages in thread From: Keith Busch @ 2026-05-26 15:39 UTC (permalink / raw) To: linux-block, linux-nvme; +Cc: axboe, hch, nilay, Keith Busch From: Keith Busch <kbusch@kernel.org> A user can enable io accounting for passthrough requests, so export the helper that checks if the request should be tracked. This will enable stacking drivers to to report iostats for passthrough workloads. Signed-off-by: Keith Busch <kbusch@kernel.org> --- block/blk-mq.c | 32 +------------------------------- include/linux/blk-mq.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 28c2d931e75ea..48115e1d9d6a8 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1088,43 +1088,13 @@ static inline void blk_account_io_done(struct request *req, u64 now) } } -static inline bool blk_rq_passthrough_stats(struct request *req) -{ - struct bio *bio = req->bio; - - if (!blk_queue_passthrough_stat(req->q)) - return false; - - /* Requests without a bio do not transfer data. */ - if (!bio) - return false; - - /* - * Stats are accumulated in the bdev, so must have one attached to a - * bio to track stats. Most drivers do not set the bdev for passthrough - * requests, but nvme is one that will set it. - */ - if (!bio->bi_bdev) - return false; - - /* - * We don't know what a passthrough command does, but we know the - * payload size and data direction. Ensuring the size is aligned to the - * block size filters out most commands with payloads that don't - * represent sector access. - */ - if (blk_rq_bytes(req) & (bdev_logical_block_size(bio->bi_bdev) - 1)) - return false; - return true; -} - static inline void blk_account_io_start(struct request *req) { trace_block_io_start(req); if (!blk_queue_io_stat(req->q)) return; - if (blk_rq_is_passthrough(req) && !blk_rq_passthrough_stats(req)) + if (blk_rq_is_passthrough(req) && !blk_rq_passthrough_stats(req, req->q)) return; req->rq_flags |= RQF_IO_STAT; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 18a2388ba581d..25931a8076d2a 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -1243,4 +1243,34 @@ static inline int blk_rq_map_sg(struct request *rq, struct scatterlist *sglist) } void blk_dump_rq_flags(struct request *, char *); +static inline bool blk_rq_passthrough_stats(struct request *req, + struct request_queue *q) +{ + struct bio *bio = req->bio; + + if (!blk_queue_passthrough_stat(q)) + return false; + + /* Requests without a bio do not transfer data. */ + if (!bio) + return false; + + /* + * Stats are accumulated in the bdev, so must have one attached to a + * bio to track stats. Most drivers do not set the bdev for passthrough + * requests, but nvme is one that will set it. + */ + if (!bio->bi_bdev) + return false; + + /* + * We don't know what a passthrough command does, but we know the + * payload size and data direction. Ensuring the size is aligned to the + * block size filters out most commands with payloads that don't + * represent sector access. + */ + if (blk_rq_bytes(req) & (bdev_logical_block_size(bio->bi_bdev) - 1)) + return false; + return true; +} #endif /* BLK_MQ_H */ -- 2.53.0-Meta ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 1/2] block: export passthrough stats enabled 2026-05-26 15:39 ` [PATCHv2 1/2] block: export passthrough stats enabled Keith Busch @ 2026-05-27 6:15 ` Nilay Shroff 2026-05-27 6:46 ` Nitesh Shetty 2026-05-27 13:14 ` Christoph Hellwig 2 siblings, 0 replies; 12+ messages in thread From: Nilay Shroff @ 2026-05-27 6:15 UTC (permalink / raw) To: Keith Busch, linux-block, linux-nvme; +Cc: axboe, hch, Keith Busch On 5/26/26 9:09 PM, Keith Busch wrote: > From: Keith Busch<kbusch@kernel.org> > > A user can enable io accounting for passthrough requests, so export the > helper that checks if the request should be tracked. This will enable > stacking drivers to to report iostats for passthrough workloads. > > Signed-off-by: Keith Busch<kbusch@kernel.org> > --- > block/blk-mq.c | 32 +------------------------------- > include/linux/blk-mq.h | 30 ++++++++++++++++++++++++++++++ > 2 files changed, 31 insertions(+), 31 deletions(-) Looks good to me. Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 1/2] block: export passthrough stats enabled 2026-05-26 15:39 ` [PATCHv2 1/2] block: export passthrough stats enabled Keith Busch 2026-05-27 6:15 ` Nilay Shroff @ 2026-05-27 6:46 ` Nitesh Shetty 2026-05-27 13:14 ` Christoph Hellwig 2 siblings, 0 replies; 12+ messages in thread From: Nitesh Shetty @ 2026-05-27 6:46 UTC (permalink / raw) To: Keith Busch; +Cc: linux-block, linux-nvme, axboe, hch, nilay, Keith Busch [-- Attachment #1: Type: text/plain, Size: 393 bytes --] On 26/05/26 08:39AM, Keith Busch wrote: >From: Keith Busch <kbusch@kernel.org> > >A user can enable io accounting for passthrough requests, so export the >helper that checks if the request should be tracked. This will enable >stacking drivers to to report iostats for passthrough workloads. > >Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com> [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 1/2] block: export passthrough stats enabled 2026-05-26 15:39 ` [PATCHv2 1/2] block: export passthrough stats enabled Keith Busch 2026-05-27 6:15 ` Nilay Shroff 2026-05-27 6:46 ` Nitesh Shetty @ 2026-05-27 13:14 ` Christoph Hellwig 2026-05-27 13:22 ` Keith Busch 2 siblings, 1 reply; 12+ messages in thread From: Christoph Hellwig @ 2026-05-27 13:14 UTC (permalink / raw) To: Keith Busch; +Cc: linux-block, linux-nvme, axboe, hch, nilay, Keith Busch > +static inline bool blk_rq_passthrough_stats(struct request *req, > + struct request_queue *q) The kerneldoc requested last time would be really nice to have. Also, now that this is a public API killing the q argument and just using req->q would make the API easier to understand. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 1/2] block: export passthrough stats enabled 2026-05-27 13:14 ` Christoph Hellwig @ 2026-05-27 13:22 ` Keith Busch 2026-05-27 13:28 ` Christoph Hellwig 0 siblings, 1 reply; 12+ messages in thread From: Keith Busch @ 2026-05-27 13:22 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Keith Busch, linux-block, linux-nvme, axboe, nilay On Wed, May 27, 2026 at 03:14:58PM +0200, Christoph Hellwig wrote: > > +static inline bool blk_rq_passthrough_stats(struct request *req, > > + struct request_queue *q) > > The kerneldoc requested last time would be really nice to have. > Also, now that this is a public API killing the q argument and > just using req->q would make the API easier to understand. Oh, my missing kerneldoc is clearly a problem. We need a separate argument for the request_queue because the q we want to count stats for may not be the one providing the request. For nvme multipath, we want to count stats against the head's request_queue, but the request comes from the ns path, so we need both args. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 1/2] block: export passthrough stats enabled 2026-05-27 13:22 ` Keith Busch @ 2026-05-27 13:28 ` Christoph Hellwig 0 siblings, 0 replies; 12+ messages in thread From: Christoph Hellwig @ 2026-05-27 13:28 UTC (permalink / raw) To: Keith Busch Cc: Christoph Hellwig, Keith Busch, linux-block, linux-nvme, axboe, nilay On Wed, May 27, 2026 at 07:22:11AM -0600, Keith Busch wrote: > On Wed, May 27, 2026 at 03:14:58PM +0200, Christoph Hellwig wrote: > > > +static inline bool blk_rq_passthrough_stats(struct request *req, > > > + struct request_queue *q) > > > > The kerneldoc requested last time would be really nice to have. > > Also, now that this is a public API killing the q argument and > > just using req->q would make the API easier to understand. > > Oh, my missing kerneldoc is clearly a problem. We need a separate > argument for the request_queue because the q we want to count stats for > may not be the one providing the request. Even more argument for having the documentation :) ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 2/2] nvme: add support multipath passthrough iostats 2026-05-26 15:39 [PATCHv2 0/2] block, nvme: enable passthrough iostats Keith Busch 2026-05-26 15:39 ` [PATCHv2 1/2] block: export passthrough stats enabled Keith Busch @ 2026-05-26 15:39 ` Keith Busch 2026-05-27 6:15 ` Nilay Shroff ` (2 more replies) 1 sibling, 3 replies; 12+ messages in thread From: Keith Busch @ 2026-05-26 15:39 UTC (permalink / raw) To: linux-block, linux-nvme; +Cc: axboe, hch, nilay, Keith Busch From: Keith Busch <kbusch@kernel.org> Don't skip io accounting for passthrough commands if the user enabled tracking these. Signed-off-by: Keith Busch <kbusch@kernel.org> --- drivers/nvme/host/ioctl.c | 4 ++++ drivers/nvme/host/multipath.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 08889b20e5d8c..38ca04567406a 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -102,8 +102,12 @@ 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; + 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; diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 263161cb8ac06..d0a95cde181c4 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -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), -- 2.53.0-Meta ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/2] nvme: add support multipath passthrough iostats 2026-05-26 15:39 ` [PATCHv2 2/2] nvme: add support multipath passthrough iostats Keith Busch @ 2026-05-27 6:15 ` Nilay Shroff 2026-05-27 6:46 ` Nitesh Shetty 2026-05-27 13:16 ` Christoph Hellwig 2 siblings, 0 replies; 12+ messages in thread From: Nilay Shroff @ 2026-05-27 6:15 UTC (permalink / raw) To: Keith Busch, linux-block, linux-nvme; +Cc: axboe, hch, Keith Busch On 5/26/26 9:09 PM, Keith Busch wrote: > From: Keith Busch<kbusch@kernel.org> > > Don't skip io accounting for passthrough commands if the user enabled > tracking these. > > Signed-off-by: Keith Busch<kbusch@kernel.org> > --- > drivers/nvme/host/ioctl.c | 4 ++++ > drivers/nvme/host/multipath.c | 5 ++++- > 2 files changed, 8 insertions(+), 1 deletion(-) Looks good to me. Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/2] nvme: add support multipath passthrough iostats 2026-05-26 15:39 ` [PATCHv2 2/2] nvme: add support multipath passthrough iostats Keith Busch 2026-05-27 6:15 ` Nilay Shroff @ 2026-05-27 6:46 ` Nitesh Shetty 2026-05-27 13:16 ` Christoph Hellwig 2 siblings, 0 replies; 12+ messages in thread From: Nitesh Shetty @ 2026-05-27 6:46 UTC (permalink / raw) To: Keith Busch; +Cc: linux-block, linux-nvme, axboe, hch, nilay, Keith Busch [-- Attachment #1: Type: text/plain, Size: 276 bytes --] On 26/05/26 08:39AM, Keith Busch wrote: >From: Keith Busch <kbusch@kernel.org> > >Don't skip io accounting for passthrough commands if the user enabled >tracking these. > >Signed-off-by: Keith Busch <kbusch@kernel.org> >--- Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com> [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/2] nvme: add support multipath passthrough iostats 2026-05-26 15:39 ` [PATCHv2 2/2] nvme: add support multipath passthrough iostats Keith Busch 2026-05-27 6:15 ` Nilay Shroff 2026-05-27 6:46 ` Nitesh Shetty @ 2026-05-27 13:16 ` Christoph Hellwig 2026-05-27 13:27 ` Keith Busch 2 siblings, 1 reply; 12+ messages in thread From: Christoph Hellwig @ 2026-05-27 13:16 UTC (permalink / raw) To: Keith Busch; +Cc: linux-block, linux-nvme, axboe, hch, nilay, Keith Busch On Tue, May 26, 2026 at 08:39:21AM -0700, Keith Busch wrote: > + struct nvme_ns *ns = q->queuedata; > struct request *req; > > + if (ns && nvme_ns_head_multipath(ns->head)) > + rq_flags |= REQ_NVME_MPATH; I just wanted to come with reasons why it this is wrong, but it actually seems already - we only have a ns for multipath nodes if multipathing is enabled. Maybe throw a little comment in on that? Otherwise looks good. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/2] nvme: add support multipath passthrough iostats 2026-05-27 13:16 ` Christoph Hellwig @ 2026-05-27 13:27 ` Keith Busch 0 siblings, 0 replies; 12+ messages in thread From: Keith Busch @ 2026-05-27 13:27 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Keith Busch, linux-block, linux-nvme, axboe, nilay On Wed, May 27, 2026 at 03:16:57PM +0200, Christoph Hellwig wrote: > On Tue, May 26, 2026 at 08:39:21AM -0700, Keith Busch wrote: > > + struct nvme_ns *ns = q->queuedata; > > struct request *req; > > > > + if (ns && nvme_ns_head_multipath(ns->head)) > > + rq_flags |= REQ_NVME_MPATH; > > I just wanted to come with reasons why it this is wrong, but it actually > seems already - we only have a ns for multipath nodes if multipathing > is enabled. Maybe throw a little comment in on that? Yes. An added subtlety here is that we unconditionally set REQ_FAILFAST_DRIVER for passthrough requests, so it does not get failover consideration. You can't steal bio's from a REQ_DRV_IN/OUT request because all the necessary driver info is attached to the original request, which doesn't follow the bio. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-05-27 13:28 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-26 15:39 [PATCHv2 0/2] block, nvme: enable passthrough iostats Keith Busch 2026-05-26 15:39 ` [PATCHv2 1/2] block: export passthrough stats enabled Keith Busch 2026-05-27 6:15 ` Nilay Shroff 2026-05-27 6:46 ` Nitesh Shetty 2026-05-27 13:14 ` Christoph Hellwig 2026-05-27 13:22 ` Keith Busch 2026-05-27 13:28 ` Christoph Hellwig 2026-05-26 15:39 ` [PATCHv2 2/2] nvme: add support multipath passthrough iostats Keith Busch 2026-05-27 6:15 ` Nilay Shroff 2026-05-27 6:46 ` Nitesh Shetty 2026-05-27 13:16 ` Christoph Hellwig 2026-05-27 13:27 ` Keith Busch
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox