Re: [PATCH v2] blk-mq: fix a hung issue when set device state to blocked and restore running

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

 



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.




[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