Commit 6f16b535 authored by Mike Christie's avatar Mike Christie Committed by James Bottomley

[SCSI] set error value when failing commands in prep_fn

set DID_NO_CONNECT for the BLKPREP_KILL case and correct a few
BLKPREP_DEFER cases that weren't checking for the need to plug the
queue.
Signed-Off-By: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 146f7262
...@@ -1146,7 +1146,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) ...@@ -1146,7 +1146,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
if (unlikely(!scsi_device_online(sdev))) { if (unlikely(!scsi_device_online(sdev))) {
printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n", printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n",
sdev->host->host_no, sdev->id, sdev->lun); sdev->host->host_no, sdev->id, sdev->lun);
return BLKPREP_KILL; goto kill;
} }
if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { if (unlikely(sdev->sdev_state != SDEV_RUNNING)) {
/* OK, we're not in a running state don't prep /* OK, we're not in a running state don't prep
...@@ -1156,7 +1156,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) ...@@ -1156,7 +1156,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
* at all allowed down */ * at all allowed down */
printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to dead device\n", printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to dead device\n",
sdev->host->host_no, sdev->id, sdev->lun); sdev->host->host_no, sdev->id, sdev->lun);
return BLKPREP_KILL; goto kill;
} }
/* OK, we only allow special commands (i.e. not /* OK, we only allow special commands (i.e. not
* user initiated ones */ * user initiated ones */
...@@ -1188,11 +1188,11 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) ...@@ -1188,11 +1188,11 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) { if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) {
if(specials_only == SDEV_QUIESCE || if(specials_only == SDEV_QUIESCE ||
specials_only == SDEV_BLOCK) specials_only == SDEV_BLOCK)
return BLKPREP_DEFER; goto defer;
printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to device being removed\n", printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to device being removed\n",
sdev->host->host_no, sdev->id, sdev->lun); sdev->host->host_no, sdev->id, sdev->lun);
return BLKPREP_KILL; goto kill;
} }
...@@ -1210,7 +1210,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) ...@@ -1210,7 +1210,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
cmd->tag = req->tag; cmd->tag = req->tag;
} else { } else {
blk_dump_rq_flags(req, "SCSI bad req"); blk_dump_rq_flags(req, "SCSI bad req");
return BLKPREP_KILL; goto kill;
} }
/* note the overloading of req->special. When the tag /* note the overloading of req->special. When the tag
...@@ -1248,8 +1248,13 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) ...@@ -1248,8 +1248,13 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
* required). * required).
*/ */
ret = scsi_init_io(cmd); ret = scsi_init_io(cmd);
if (ret) /* BLKPREP_KILL return also releases the command */ switch(ret) {
return ret; case BLKPREP_KILL:
/* BLKPREP_KILL return also releases the command */
goto kill;
case BLKPREP_DEFER:
goto defer;
}
/* /*
* Initialize the actual SCSI command for this request. * Initialize the actual SCSI command for this request.
...@@ -1259,7 +1264,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) ...@@ -1259,7 +1264,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
if (unlikely(!drv->init_command(cmd))) { if (unlikely(!drv->init_command(cmd))) {
scsi_release_buffers(cmd); scsi_release_buffers(cmd);
scsi_put_command(cmd); scsi_put_command(cmd);
return BLKPREP_KILL; goto kill;
} }
} else { } else {
memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
...@@ -1290,6 +1295,9 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) ...@@ -1290,6 +1295,9 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
if (sdev->device_busy == 0) if (sdev->device_busy == 0)
blk_plug_device(q); blk_plug_device(q);
return BLKPREP_DEFER; return BLKPREP_DEFER;
kill:
req->errors = DID_NO_CONNECT << 16;
return BLKPREP_KILL;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment