Add a multipath handler for block_device_operations.report_zones

Signed-off-by: John Garry <[email protected]>
---
 lib/multipath.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/multipath.c b/lib/multipath.c
index d2270c70b9913..c72f35e02e2ab 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_head *mpath_head = mpath_gendisk_to_head(disk);
+       struct mpath_device *mpath_device;
+       int srcu_idx, ret = -EWOULDBLOCK;
+
+       srcu_idx = srcu_read_lock(&mpath_head->srcu);
+       mpath_device = mpath_find_path(mpath_head);
+       if (mpath_device) {
+               if (mpath_device->disk->fops->report_zones)
+                       ret = mpath_device->disk->fops->report_zones
+                               (mpath_device->disk, sector, nr_zones, args);
+               else
+                       ret = -EOPNOTSUPP;
+       }
+       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);
@@ -652,6 +676,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


Reply via email to