[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <006b6aefe94d73ee64931c769af4a908616439ad.1694592708.git.jacky_gam_2001@163.com>
Date: Wed, 13 Sep 2023 16:36:44 +0800
From: Ping Gan <jacky_gam_2001@....com>
To: kbusch@...nel.org, axboe@...nel.dk, hch@....de, sagi@...mberg.me,
kch@...dia.com, linux-kernel@...r.kernel.org,
linux-nvme@...ts.infradead.org
Cc: ping_gan@...l.com, jacky_gam_2001@....com
Subject: [PATCH 4/4] nvme-core: Get lowlevel disk for target polling queue task
When enabling multipath, if the block device of nvmet is
a nvme_ns_head disk, then we should get the lowlevel block
device to do bio split.
Signed-off-by: Ping Gan <jacky_gam_2001@....com>
---
drivers/nvme/host/multipath.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 0a88d7bdc5e3..f6063600e06e 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -371,6 +371,25 @@ static bool nvme_available_path(struct nvme_ns_head *head)
return false;
}
+//for polling queue task to get lowlevel block device
+struct block_device *nvme_mpath_get_bdev(struct block_device *bdev)
+{
+ struct nvme_ns_head *head = bdev->bd_disk->private_data;
+ int srcu_idx;
+ struct nvme_ns *ns;
+ struct block_device *ret = NULL;
+
+ if (!multipath)
+ return NULL;
+ srcu_idx = srcu_read_lock(&head->srcu);
+ ns = nvme_find_path(head);
+ if (likely(ns))
+ ret = ns->disk->part0;
+ srcu_read_unlock(&head->srcu, srcu_idx);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(nvme_mpath_get_bdev);
+
static void nvme_ns_head_submit_bio(struct bio *bio)
{
struct nvme_ns_head *head = bio->bi_bdev->bd_disk->private_data;
@@ -452,6 +471,7 @@ const struct block_device_operations nvme_ns_head_ops = {
.report_zones = nvme_ns_head_report_zones,
.pr_ops = &nvme_pr_ops,
};
+EXPORT_SYMBOL_GPL(nvme_ns_head_ops);
static inline struct nvme_ns_head *cdev_to_ns_head(struct cdev *cdev)
{
--
2.26.2
Powered by blists - more mailing lists