On Thu, 2019-03-21 at 13:43 +0800, zhengbin wrote:
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 6a9040f..342e513 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -771,9 +771,20 @@ store_state_field(struct device *dev, struct 
> device_attribute *attr,
> 
>         mutex_lock(&sdev->state_mutex);
>         ret = scsi_device_set_state(sdev, state);
> +       /* If device state changes to SDEV_RUNNING, we need to run hw queue
> +        * to avoid io hung.
> +        */
> +       if ((ret == 0) && (state == SDEV_RUNNING))
> +               goto out_run_hw_queue;
>         mutex_unlock(&sdev->state_mutex);
> 
>         return ret == 0 ? count : -EINVAL;
> +
> +out_run_hw_queue:
> +       mutex_unlock(&sdev->state_mutex);
> +       blk_mq_run_hw_queues(sdev->request_queue, true);
> +
> +       return count;
>  }

Having two different code paths that call mutex_unlock() is unfortunate
because I don't think that is necessary to have two such paths, whether or
not blk_mq_run_hw_queues() is called with the state mutex held.

If you repost this patch, please remove the superfluous parentheses from
the if-condition.

Thanks,

Bart.

Reply via email to