linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hare@kernel.org
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
	linux-nvme@lists.infradead.org, Hannes Reinecke <hare@kernel.org>
Subject: [PATCH 4/6] nvme: add 'sector' parameter to nvme_find_path()
Date: Tue, 29 Jul 2025 09:06:51 +0200	[thread overview]
Message-ID: <20250729070653.125258-5-hare@kernel.org> (raw)
In-Reply-To: <20250729070653.125258-1-hare@kernel.org>

From: Hannes Reinecke <hare@kernel.org>

An nvme multipath iopolicy might need to make scheduling decisions based
on the starting sector of the I/O, so add an argument 'sector' to
nvme_find_path().

Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
 drivers/nvme/host/ioctl.c     | 7 ++++---
 drivers/nvme/host/multipath.c | 8 ++++----
 drivers/nvme/host/nvme.h      | 2 +-
 drivers/nvme/host/pr.c        | 2 +-
 drivers/nvme/host/sysfs.c     | 2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 6b3ac8ae3f34..e210908ad78b 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -716,7 +716,8 @@ int nvme_ns_head_ioctl(struct block_device *bdev, blk_mode_t mode,
 		flags |= NVME_IOCTL_PARTITION;
 
 	srcu_idx = srcu_read_lock(&head->srcu);
-	ns = nvme_find_path(head);
+	/* TBD: extract LBA and size to get the routing right */
+	ns = nvme_find_path(head, 0);
 	if (!ns)
 		goto out_unlock;
 
@@ -747,7 +748,7 @@ long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
 	int srcu_idx, ret = -EWOULDBLOCK;
 
 	srcu_idx = srcu_read_lock(&head->srcu);
-	ns = nvme_find_path(head);
+	ns = nvme_find_path(head, 0);
 	if (!ns)
 		goto out_unlock;
 
@@ -767,7 +768,7 @@ int nvme_ns_head_chr_uring_cmd(struct io_uring_cmd *ioucmd,
 	struct cdev *cdev = file_inode(ioucmd->file)->i_cdev;
 	struct nvme_ns_head *head = container_of(cdev, struct nvme_ns_head, cdev);
 	int srcu_idx = srcu_read_lock(&head->srcu);
-	struct nvme_ns *ns = nvme_find_path(head);
+	struct nvme_ns *ns = nvme_find_path(head, 0);
 	int ret = -EINVAL;
 
 	if (ns)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 696c2f817bed..dee40bd73449 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -466,7 +466,7 @@ static struct nvme_ns *nvme_numa_path(struct nvme_ns_head *head)
 	return ns;
 }
 
-inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
+inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head, sector_t sector)
 {
 	switch (READ_ONCE(head->subsys->iopolicy)) {
 	case NVME_IOPOLICY_QD:
@@ -528,7 +528,7 @@ static void nvme_ns_head_submit_bio(struct bio *bio)
 		return;
 
 	srcu_idx = srcu_read_lock(&head->srcu);
-	ns = nvme_find_path(head);
+	ns = nvme_find_path(head, bio->bi_iter.bi_sector);
 	if (likely(ns)) {
 		bio_set_dev(bio, ns->disk->part0);
 		bio->bi_opf |= REQ_NVME_MPATH;
@@ -570,7 +570,7 @@ static int nvme_ns_head_get_unique_id(struct gendisk *disk, u8 id[16],
 	int srcu_idx, ret = -EWOULDBLOCK;
 
 	srcu_idx = srcu_read_lock(&head->srcu);
-	ns = nvme_find_path(head);
+	ns = nvme_find_path(head, 0);
 	if (ns)
 		ret = nvme_ns_get_unique_id(ns, id, type);
 	srcu_read_unlock(&head->srcu, srcu_idx);
@@ -586,7 +586,7 @@ static int nvme_ns_head_report_zones(struct gendisk *disk, sector_t sector,
 	int srcu_idx, ret = -EWOULDBLOCK;
 
 	srcu_idx = srcu_read_lock(&head->srcu);
-	ns = nvme_find_path(head);
+	ns = nvme_find_path(head, sector);
 	if (ns)
 		ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
 	srcu_read_unlock(&head->srcu, srcu_idx);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 2aff8df55d1c..73b966a6653a 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -951,7 +951,7 @@ extern const struct block_device_operations nvme_bdev_ops;
 struct nvme_subsystem *nvme_find_get_subsystem(const char *subsysnqn);
 void nvme_put_subsystem(struct nvme_subsystem *subsys);
 void nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl);
-struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
+struct nvme_ns *nvme_find_path(struct nvme_ns_head *head, sector_t sector);
 #ifdef CONFIG_NVME_MULTIPATH
 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
 {
diff --git a/drivers/nvme/host/pr.c b/drivers/nvme/host/pr.c
index ca6a74607b13..ba8cee2d6001 100644
--- a/drivers/nvme/host/pr.c
+++ b/drivers/nvme/host/pr.c
@@ -54,7 +54,7 @@ static int nvme_send_ns_head_pr_command(struct block_device *bdev,
 {
 	struct nvme_ns_head *head = bdev->bd_disk->private_data;
 	int srcu_idx = srcu_read_lock(&head->srcu);
-	struct nvme_ns *ns = nvme_find_path(head);
+	struct nvme_ns *ns = nvme_find_path(head, 0);
 	int ret = -EWOULDBLOCK;
 
 	if (ns) {
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 378107cf7a21..ebbdf512a31d 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -194,7 +194,7 @@ static int ns_head_update_nuse(struct nvme_ns_head *head)
 		return 0;
 
 	srcu_idx = srcu_read_lock(&head->srcu);
-	ns = nvme_find_path(head);
+	ns = nvme_find_path(head, 0);
 	if (!ns)
 		goto out_unlock;
 
-- 
2.43.0



  parent reply	other threads:[~2025-07-29  7:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29  7:06 [RFC PATCH 0/6] nvme multipath eBPF path selector hare
2025-07-29  7:06 ` [PATCH 1/6] nvme-multipath: do not assign ->current_path in __nvme_find_path() hare
2025-07-29  7:06 ` [PATCH 2/6] nvme: export nvme_find_get_subsystem()/nvme_put_subsystem() hare
2025-07-29  7:06 ` [PATCH 3/6] nvme: add per-namespace iopolicy sysfs attribute hare
2025-07-29  7:06 ` hare [this message]
2025-07-29  7:06 ` [PATCH 5/6] nvme-bpf: eBPF struct_ops path selectors hare
2025-07-29  7:06 ` [PATCH 6/6] tools/testing/selftests: add sample nvme bpf path selector hare
2025-07-30  2:03   ` Geliang Tang
2025-07-30  5:56     ` Hannes Reinecke
2025-07-29  7:54 ` [RFC PATCH 0/6] nvme multipath eBPF " Christoph Hellwig
2025-07-29 14:53   ` Mike Christie
2025-07-30 14:06     ` Christoph Hellwig
2025-07-30  2:03 ` Geliang Tang

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=20250729070653.125258-5-hare@kernel.org \
    --to=hare@kernel.org \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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).