On Wed, Feb 25, 2026 at 03:36:13PM +0000, John Garry wrote:
> Add scsi_mpath_{start,end}_request() to handle updating private multipath
> request data, like nvme_mpath_{start,end}_request().
>
> Since we may need to update mpath_disk data, add a callbacks in
> scsi_driver to actually do this work for the scsi driver.
>
> Signed-off-by: John Garry <[email protected]>
> ---
> drivers/scsi/scsi_lib.c | 4 ++++
> include/scsi/scsi_driver.h | 2 ++
> include/scsi/scsi_multipath.h | 24 ++++++++++++++++++++++++
> 3 files changed, 30 insertions(+)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 7ed0defc8161e..61179caa7b2c8 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -654,6 +654,8 @@ static bool scsi_end_request(struct request *req,
> blk_status_t error,
> */
> destroy_rcu_head(&cmd->rcu);
>
> + scsi_mpath_end_request(req);
> +
> /*
> * In the MQ case the command gets freed by __blk_mq_end_request,
> * so we have to do all cleanup that depends on it earlier.
This looks wrong. We start accounting in scsi_queue_rq(), and we need to
end it whenever we complete or requeue the request, otherwise the
accounting will get off. But not all requests go through
scsi_end_request(). scsi_mpath_failover_req(), for instance, calls
blk_mq_end_request() directly, and other functions, like
scsi_queue_insert() call blk_mq_requeue_request(). I'm pretty sure that
this should go in scsi_complete(), as well in the error path of
scsi_queue_rq().
-Ben