浏览代码

sbp2: fix another deadlock after disconnection

If there were commands enqueued but not completed before an SBP-2 unit
was unplugged (or an attempt to reconnect failed), knodemgrd or any
process which tried to remove the device would sleep uninterruptibly
in blk_execute_rq().  Therefore make sure that all commands are
completed when sbp2 retreats.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
(cherry picked from 61daa34c132c5d4ed8630e2c46e9bf2f0c7b3428 commit)
Stefan Richter 19 年之前
父节点
当前提交
bf637ec3ef
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      drivers/ieee1394/sbp2.c

+ 8 - 2
drivers/ieee1394/sbp2.c

@@ -643,9 +643,15 @@ static int sbp2_remove(struct device *dev)
 	if (!scsi_id)
 	if (!scsi_id)
 		return 0;
 		return 0;
 
 
-	/* Trigger shutdown functions in scsi's highlevel. */
-	if (scsi_id->scsi_host)
+	if (scsi_id->scsi_host) {
+		/* Get rid of enqueued commands if there is no chance to
+		 * send them. */
+		if (!sbp2util_node_is_available(scsi_id))
+			sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
+		/* scsi_remove_device() will trigger shutdown functions of SCSI
+		 * highlevel drivers which would deadlock if blocked. */
 		scsi_unblock_requests(scsi_id->scsi_host);
 		scsi_unblock_requests(scsi_id->scsi_host);
+	}
 	sdev = scsi_id->sdev;
 	sdev = scsi_id->sdev;
 	if (sdev) {
 	if (sdev) {
 		scsi_id->sdev = NULL;
 		scsi_id->sdev = NULL;