If a block pc request is failed in the request_fn or prep_fn we are not setting a error value. This is a problem for dm-multipath's path testers and hw_handlers and everyone doing SG_IO since they see the command as completing successfully. Patch was made against scsi-misc. diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1047,6 +1047,10 @@ static int scsi_init_io(struct scsi_cmnd /* release the command and kill it */ scsi_release_buffers(cmd); scsi_put_command(cmd); + + if (blk_pc_request(req)) + req->errors = DID_NO_CONNECT << 16; + return BLKPREP_KILL; } @@ -1118,6 +1122,8 @@ static int scsi_prep_fn(struct request_q if (unlikely(!scsi_device_online(sdev))) { printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n", sdev->host->host_no, sdev->id, sdev->lun); + if (blk_pc_request(req)) + req->errors = DID_NO_CONNECT << 16; return BLKPREP_KILL; } if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { @@ -1128,6 +1134,8 @@ static int scsi_prep_fn(struct request_q * at all allowed down */ printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to dead device\n", sdev->host->host_no, sdev->id, sdev->lun); + if (blk_pc_request(req)) + req->errors = DID_NO_CONNECT << 16; return BLKPREP_KILL; } /* OK, we only allow special commands (i.e. not @@ -1164,6 +1172,10 @@ static int scsi_prep_fn(struct request_q printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to device being removed\n", sdev->host->host_no, sdev->id, sdev->lun); + + if (blk_pc_request(req)) + req->errors = DID_NO_CONNECT << 16; + return BLKPREP_KILL; } @@ -1231,6 +1243,10 @@ static int scsi_prep_fn(struct request_q if (unlikely(!drv->init_command(cmd))) { scsi_release_buffers(cmd); scsi_put_command(cmd); + + if (blk_pc_request(req)) + req->errors = DID_NO_CONNECT << 16; + return BLKPREP_KILL; } } else { @@ -1345,6 +1361,8 @@ static void scsi_kill_requests(request_q while ((req = elv_next_request(q)) != NULL) { blkdev_dequeue_request(req); req->flags |= REQ_QUIET; + if (blk_pc_request(req)) + req->errors = DID_NO_CONNECT << 16; while (end_that_request_first(req, 0, req->nr_sectors)) ; end_that_request_last(req); @@ -1400,6 +1418,8 @@ static void scsi_request_fn(struct reque sdev->host->host_no, sdev->id, sdev->lun); blkdev_dequeue_request(req); req->flags |= REQ_QUIET; + if (blk_pc_request(req)) + req->errors = DID_NO_CONNECT << 16; while (end_that_request_first(req, 0, req->nr_sectors)) ; end_that_request_last(req); - : send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html