Add a callback for the scsi_mpath_ioctl.bdev_ioctl . Since this is concerned with the mpath_disk, we rely on the scsi_driver to handle the ioctl.
Signed-off-by: John Garry <[email protected]> --- drivers/scsi/scsi_multipath.c | 21 +++++++++++++++++++++ include/scsi/scsi_driver.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/drivers/scsi/scsi_multipath.c b/drivers/scsi/scsi_multipath.c index 16b1f84fc552c..36f13605b44e7 100644 --- a/drivers/scsi/scsi_multipath.c +++ b/drivers/scsi/scsi_multipath.c @@ -320,7 +320,28 @@ static enum mpath_iopolicy_e scsi_mpath_get_iopolicy(struct mpath_head *mpath_he return mpath_read_iopolicy(&scsi_mpath_head->iopolicy); } +static int scsi_mpath_ioctl(struct block_device *bdev, + struct mpath_device *mpath_device, + blk_mode_t mode, unsigned int cmd, + unsigned long arg, int srcu_idx) +{ + struct gendisk *disk = bdev->bd_disk; + struct mpath_disk *mpath_disk = mpath_gendisk_to_disk(disk); + struct mpath_head *mpath_head = mpath_disk->mpath_head; + struct scsi_mpath_device *scsi_mpath_dev = + to_scsi_mpath_device(mpath_device); + struct scsi_device *sdev = scsi_mpath_dev->sdev; + struct scsi_driver *drv = to_scsi_driver(sdev->sdev_gendev.driver); + int err; + + err = drv->mpath_ioctl(sdev, mode & BLK_OPEN_WRITE, cmd, arg); + + mpath_head_read_unlock(mpath_head, srcu_idx); + return err; +} + struct mpath_head_template smpdt_pr = { + .bdev_ioctl = scsi_mpath_ioctl, .get_iopolicy = scsi_mpath_get_iopolicy, .clone_bio = scsi_mpath_clone_bio, }; diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h index 44e50229a75e7..799071b8bdee2 100644 --- a/include/scsi/scsi_driver.h +++ b/include/scsi/scsi_driver.h @@ -22,6 +22,8 @@ struct scsi_driver { #ifdef CONFIG_SCSI_MULTIPATH void (*mpath_start_cmd)(struct scsi_cmnd *); void (*mpath_end_cmd)(struct scsi_cmnd *); + int (*mpath_ioctl)(struct scsi_device *sdev, blk_mode_t mode, + unsigned int cmd, unsigned long arg); struct mpath_disk *(*to_mpath_disk)(struct request *); #endif }; -- 2.43.5

