On 3/20/19 8:21 PM, zhengbin wrote:
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 6a9040f..ce60408 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -770,7 +770,20 @@ store_state_field(struct device *dev, struct 
device_attribute *attr,
                return -EINVAL;

        mutex_lock(&sdev->state_mutex);
+       enum scsi_device_state oldstate = sdev->sdev_state;
        ret = scsi_device_set_state(sdev, state);
+       if (ret == 0) {
+               /* If device use blk-mq, the device state changes from
+                * SDEV_BLOCK to SDEV_RUNNING, we need to run hw queue
+                * to avoid io hung.
+                */
+               if ((state == SDEV_RUNNING) && (oldstate == SDEV_BLOCK)) {
+                       struct request_queue *q = sdev->request_queue;
+
+                       if (q->mq_ops)
+                               blk_mq_run_hw_queues(q, true);
+               }
+       }
        mutex_unlock(&sdev->state_mutex);

Hi Zhengbin,

In addition to what Ming asked, please combine the nested if-statements into a single if-statement and leave out the superfluous parentheses.

Thanks,

Bart.

Reply via email to