public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: [PATCH] set error value when failing block pc commands
Date: Fri, 09 Sep 2005 14:27:50 -0500	[thread overview]
Message-ID: <1126294070.2647.2.camel@max> (raw)

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);



                 reply	other threads:[~2005-09-09 19:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1126294070.2647.2.camel@max \
    --to=michaelc@cs.wisc.edu \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox