On Fri, 2019-03-22 at 10:56 +-0800, zhengbin wrote: +AD4 When I use dd test a SCSI device which use blk-mq in the following steps: +AD4 1.echo +ACI-blocked+ACI +AD4-/sys/block/sda/device/state +AD4 2.dd if+AD0-/dev/sda of+AD0-/mnt/t.log bs+AD0-1M count+AD0-10 +AD4 3.echo +ACI-running+ACI +AD4-/sys/block/sda/device/state +AD4 dd should finish this work after step 3, unfortunately, still hung. +AD4 +AD4 After step2, the key code process is like this: +AD4 blk+AF8-mq+AF8-dispatch+AF8-rq+AF8-list--+AD4-scsi+AF8-queue+AF8-rq--+AD4-prep+AF8-to+AF8-mq +AD4 +AD4 prep+AF8-to+AF8-mq will return BLK+AF8-STS+AF8-RESOURCE, and scsi+AF8-queue+AF8-rq will transter +AD4 it to BLK+AF8-STS+AF8-DEV+AF8-RESOURCE, which means that driver can guarantee that +AD4 IO dispatch will be triggered in future when the resource is available. +AD4 Need to follow the rule if we set the device state to running. +AD4 +AD4 Signed-off-by: zhengbin +ADw-zhengbin13+AEA-huawei.com+AD4 +AD4 --- +AD4 drivers/scsi/scsi+AF8-sysfs.c +AHw 5 +++++1filechanged, 5 insertions() +AD4 +AD4 diff --git a/drivers/scsi/scsi+AF8-sysfs.c b/drivers/scsi/scsi+AF8-sysfs.c +AD4 index 6a9040f..67c214a 100644 +AD4 --- a/drivers/scsi/scsi+AF8-sysfs.c +AD4 +AEAAQA -771,6 +-771,11 +AEAAQA store+AF8-state+AF8-field(struct device +ACo-dev, struct device+AF8-attribute +ACo-attr, +AD4 +AD4 mutex+AF8-lock(+ACY-sdev-+AD4-state+AF8-mutex)+ADs +AD4 ret +AD0 scsi+AF8-device+AF8-set+AF8-state(sdev, state)+ADs +AD4 +- /+ACo If device state changes to SDEV+AF8-RUNNING, we need to run hw queue +AD4 +- +ACo to avoid io hung. +AD4 +- +ACo-/ I think that +ACI-device state+ACI should be changed into +ACI-the device state+ACI, +ACI-run hw queue+ACI into +ACI-run the queue+ACI and +ACI-hung+ACI into +ACI-hang+ACI. +AD4 +- if (ret +AD0APQ 0 +ACYAJg state +AD0APQ SDEV+AF8-RUNNING) +AD4 +- blk+AF8-mq+AF8-run+AF8-hw+AF8-queues(sdev-+AD4-request+AF8-queue, true)+ADs +AD4 mutex+AF8-unlock(+ACY-sdev-+AD4-state+AF8-mutex)+ADs +AD4 +AD4 return ret +AD0APQ 0 ? count : -EINVAL+ADs Anyway, since the code looks fine to me: Reviewed-by: Bart Van Assche +ADw-bvanassche+AEA-acm.org+AD4