Re: [PATCH 12/24] scsi-multipath: provide callbacks for path state
From: Benjamin Marzinski
Date: Tue Mar 03 2026 - 00:32:15 EST
On Wed, Feb 25, 2026 at 03:36:15PM +0000, John Garry wrote:
> Until ALUA is supported, just always say that the path is optimized. In
> addition, just add basic scsi_device state tests for checking on path
> state.
>
> Signed-off-by: John Garry <john.g.garry@xxxxxxxxxx>
> ---
> drivers/scsi/scsi_multipath.c | 45 +++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/drivers/scsi/scsi_multipath.c b/drivers/scsi/scsi_multipath.c
> index 36f13605b44e7..6aeac20a350ff 100644
> --- a/drivers/scsi/scsi_multipath.c
> +++ b/drivers/scsi/scsi_multipath.c
> @@ -340,8 +340,53 @@ static int scsi_mpath_ioctl(struct block_device *bdev,
> return err;
> }
>
> +static bool scsi_mpath_is_disabled(struct mpath_device *mpath_device)
> +{
> + struct scsi_mpath_device *scsi_mpath_dev =
> + to_scsi_mpath_device(mpath_device);
> + struct scsi_device *sdev = scsi_mpath_dev->sdev;
> + enum scsi_device_state sdev_state = sdev->sdev_state;
> +
> + if (sdev_state == SDEV_RUNNING || sdev_state == SDEV_CANCEL)
> + return false;
> +
> + return true;
> +}
> +
> +static bool scsi_mpath_is_optimized(struct mpath_device *mpath_device)
> +{
> + if (scsi_mpath_is_disabled(mpath_device))
> + return false;
> + return true;
> +}
> +
> +/* Until we have ALUA support, we're always optimised */
> +static enum mpath_access_state scsi_mpath_get_access_state(
> + struct mpath_device *mpath_device)
> +{
> + if (scsi_mpath_is_disabled(mpath_device))
> + return MPATH_STATE_INVALID;
> + return MPATH_STATE_OPTIMIZED;
> +}
> +
> +static bool scsi_mpath_available_path(struct mpath_device *mpath_device, bool *available)
> +{
> + struct scsi_mpath_device *scsi_mpath_dev =
> + to_scsi_mpath_device(mpath_device);
> + struct scsi_device *sdev = scsi_mpath_dev->sdev;
> +
> + if (scsi_device_blocked(sdev))
> + return false;
> +
> + return scsi_device_online(sdev);
> +}
Here's another vote for redoing the mpath_available_path() interface.
scsi_mpath_available_path() is already ignoring the available pointer,
and treating the return value like it determines whether the path is
available.
-Ben