Re: [PATCH 07/10] scsi: Do not allocate scsi command in scsi_ioctl_reset()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 23, 2023 at 11:28:34AM +0200, Hannes Reinecke wrote:
> As we now have moved the error handler functions to not rely on
> a scsi command we can drop the out-of-band scsi command allocation
> from scsi_ioctl_reset().
> 
> Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
> Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>
> ---
>  drivers/scsi/scsi_error.c | 95 ++++++++++++++++-----------------------
>  1 file changed, 39 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 7c9c376affda..63b762d5d66f 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -896,28 +895,29 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd)
>  
>  /**
>   * scsi_try_bus_reset - ask host to perform a bus reset
> - * @scmd:	SCSI cmd to send bus reset.
> + * @host:	SCSI host to send bus reset.
> + * @channel:	Number of the bus to be reset
>   */
> -static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd)
> +static enum scsi_disposition scsi_try_bus_reset(struct Scsi_Host *host,
> +						int channel)

This should be `unsigned int`, to align with `eh_bus_reset_handler()`.

>  {
>  	unsigned long flags;
>  	enum scsi_disposition rtn;
> -	struct Scsi_Host *host = scmd->device->host;
>  	const struct scsi_host_template *hostt = host->hostt;
>  
> -	SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
> -		"%s: Snd Bus RST\n", __func__));
> +	SCSI_LOG_ERROR_RECOVERY(3, shost_printk(KERN_INFO, host,
> +		"%s: Snd Bus RST to bus %d\n", __func__, channel));

And then this should be %u              ^^

>  
>  	if (!hostt->eh_bus_reset_handler)
>  		return FAILED;
>  
> -	rtn = hostt->eh_bus_reset_handler(host, scmd_channel(scmd));
> +	rtn = hostt->eh_bus_reset_handler(host, channel);
> @@ -1014,11 +1014,15 @@ scsi_try_to_abort_cmd(const struct scsi_host_template *hostt, struct scsi_cmnd *
>  
>  static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd)
>  {
> -	if (scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd) != SUCCESS)
> -		if (scsi_try_bus_device_reset(scmd) != SUCCESS)
> -			if (scsi_try_target_reset(scmd) != SUCCESS)
> -				if (scsi_try_bus_reset(scmd) != SUCCESS)
> -					scsi_try_host_reset(scmd);
> +	struct Scsi_Host *host = scmd->device->host;
> +	struct scsi_target *starget = scsi_target(scmd->device);
> +	int channel = scmd->device->channel;

Probably better
    
    unsigned int channel = scmd_channel(scmd);

> +
> +	if (scsi_try_to_abort_cmd(host->hostt, scmd) != SUCCESS)
> +		if (scsi_try_bus_device_reset(scmd->device) != SUCCESS)
> +			if (scsi_try_target_reset(host, starget) != SUCCESS)
> +				if (scsi_try_bus_reset(host, channel) != SUCCESS)
> +					scsi_try_host_reset(host);
>  }
>  
>  /**
> @@ -2470,22 +2456,22 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
>  			break;
>  		fallthrough;
>  	case SG_SCSI_RESET_BUS:
> -		rtn = scsi_try_bus_reset(scmd);
> +		rtn = scsi_try_bus_reset(shost, dev->channel);

Probably also use `sdev_channel(dev)`

>  		if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE))
>  			break;
>  		fallthrough;

-- 
Best Regards, Benjamin Block        /        Linux on IBM Z Kernel Development
IBM Deutschland Research & Development GmbH    /   https://www.ibm.com/privacy
Vors. Aufs.-R.: Gregor Pillen         /         Geschäftsführung: David Faller
Sitz der Ges.: Böblingen     /    Registergericht: AmtsG Stuttgart, HRB 243294



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux