[PATCH 10/13] libmultipath: Add mpath_bdev_report_zones()

John Garry john.g.garry at oracle.com
Wed Feb 25 07:32:22 PST 2026


Add a multipath handler for block_device_operations.report_zones

Signed-off-by: John Garry <john.g.garry at oracle.com>
---
 include/linux/multipath.h |  2 ++
 lib/multipath.c           | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/include/linux/multipath.h b/include/linux/multipath.h
index 454826c385923..3846ea8cfd319 100644
--- a/include/linux/multipath.h
+++ b/include/linux/multipath.h
@@ -74,6 +74,8 @@ struct mpath_head_template {
 	enum mpath_access_state (*get_access_state)(struct mpath_device *);
 	int (*cdev_ioctl)(struct mpath_head *, struct mpath_device *,
 			blk_mode_t mode, unsigned int cmd, unsigned long arg, int srcu_idx);
+	int (*report_zones)(struct mpath_device *, sector_t sector,
+		unsigned int nr_zones, struct blk_report_zones_args *args);
 	int (*chr_uring_cmd)(struct mpath_device *, struct io_uring_cmd *ioucmd,
 		unsigned int issue_flags);
 	int (*chr_uring_cmd_iopoll)(struct io_uring_cmd *ioucmd,
diff --git a/lib/multipath.c b/lib/multipath.c
index 8ee2d12600035..4c57feefff480 100644
--- a/lib/multipath.c
+++ b/lib/multipath.c
@@ -40,6 +40,30 @@ int mpath_get_iopolicy(char *buf, int iopolicy)
 }
 EXPORT_SYMBOL_GPL(mpath_get_iopolicy);
 
+#ifdef CONFIG_BLK_DEV_ZONED
+static int mpath_bdev_report_zones(struct gendisk *disk, sector_t sector,
+		unsigned int nr_zones, struct blk_report_zones_args *args)
+{
+	struct mpath_disk *mpath_disk = mpath_gendisk_to_disk(disk);
+	struct mpath_head *mpath_head = mpath_disk->mpath_head;
+	struct mpath_device *mpath_device;
+	int srcu_idx, ret = -EWOULDBLOCK;
+
+	if (!mpath_head->mpdt->report_zones)
+		return -EOPNOTSUPP;
+
+	srcu_idx = srcu_read_lock(&mpath_head->srcu);
+	mpath_device = mpath_find_path(mpath_head);
+	if (mpath_device)
+		ret = mpath_head->mpdt->report_zones(mpath_device, sector,
+			nr_zones, args);
+	srcu_read_unlock(&mpath_head->srcu, srcu_idx);
+	return ret;
+}
+#else
+#define mpath_bdev_report_zones	NULL
+#endif /* CONFIG_BLK_DEV_ZONED */
+
 void mpath_synchronize(struct mpath_head *mpath_head)
 {
 	synchronize_srcu(&mpath_head->srcu);
@@ -622,6 +646,7 @@ const struct block_device_operations mpath_ops = {
 	.open		= mpath_bdev_open,
 	.release	= mpath_bdev_release,
 	.submit_bio	= mpath_bdev_submit_bio,
+	.report_zones	= mpath_bdev_report_zones,
 	.pr_ops		= &mpath_pr_ops,
 };
 EXPORT_SYMBOL_GPL(mpath_ops);
-- 
2.43.5




More information about the Linux-nvme mailing list