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@163.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
Hi Ping,
kernel test robot noticed the following build warnings:
[auto build test WARNING on v6.6-rc1]
[also build test WARNING on linus/master next-20230913]
[cannot apply to hch-configfs/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ping-Gan/nvmet-Add-nvme-target-polling-queue-task-parameters/20230913-164112
base: v6.6-rc1
patch link: https://lore.kernel.org/r/006b6aefe94d73ee64931c769af4a908616439ad.1694592708.git.jacky_gam_2001%40163.com
patch subject: [PATCH 4/4] nvme-core: Get lowlevel disk for target polling queue task
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230913/202309131858.YUV19V9E-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/202309131858.YUV19V9E-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309131858.YUV19V9E-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/nvme/host/multipath.c:375:22: warning: no previous prototype for 'nvme_mpath_get_bdev' [-Wmissing-prototypes]
375 | struct block_device *nvme_mpath_get_bdev(struct block_device *bdev)
| ^~~~~~~~~~~~~~~~~~~
vim +/nvme_mpath_get_bdev +375 drivers/nvme/host/multipath.c
373
374 //for polling queue task to get lowlevel block device
> 375 struct block_device *nvme_mpath_get_bdev(struct block_device *bdev)
376 {
377 struct nvme_ns_head *head = bdev->bd_disk->private_data;
378 int srcu_idx;
379 struct nvme_ns *ns;
380 struct block_device *ret = NULL;
381
382 if (!multipath)
383 return NULL;
384 srcu_idx = srcu_read_lock(&head->srcu);
385 ns = nvme_find_path(head);
386 if (likely(ns))
387 ret = ns->disk->part0;
388 srcu_read_unlock(&head->srcu, srcu_idx);
389 return ret;
390 }
391 EXPORT_SYMBOL_GPL(nvme_mpath_get_bdev);
392
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.