[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: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Mike Christie and committed by James Bottomley 6f16b535 146f7262

+16 -8
+16 -8
drivers/scsi/scsi_lib.c
··· 1146 if (unlikely(!scsi_device_online(sdev))) { 1147 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n", 1148 sdev->host->host_no, sdev->id, sdev->lun); 1149 - return BLKPREP_KILL; 1150 } 1151 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { 1152 /* OK, we're not in a running state don't prep ··· 1156 * at all allowed down */ 1157 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to dead device\n", 1158 sdev->host->host_no, sdev->id, sdev->lun); 1159 - return BLKPREP_KILL; 1160 } 1161 /* OK, we only allow special commands (i.e. not 1162 * user initiated ones */ ··· 1188 if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) { 1189 if(specials_only == SDEV_QUIESCE || 1190 specials_only == SDEV_BLOCK) 1191 - return BLKPREP_DEFER; 1192 1193 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to device being removed\n", 1194 sdev->host->host_no, sdev->id, sdev->lun); 1195 - return BLKPREP_KILL; 1196 } 1197 1198 ··· 1210 cmd->tag = req->tag; 1211 } else { 1212 blk_dump_rq_flags(req, "SCSI bad req"); 1213 - return BLKPREP_KILL; 1214 } 1215 1216 /* note the overloading of req->special. When the tag ··· 1248 * required). 1249 */ 1250 ret = scsi_init_io(cmd); 1251 - if (ret) /* BLKPREP_KILL return also releases the command */ 1252 - return ret; 1253 1254 /* 1255 * Initialize the actual SCSI command for this request. ··· 1264 if (unlikely(!drv->init_command(cmd))) { 1265 scsi_release_buffers(cmd); 1266 scsi_put_command(cmd); 1267 - return BLKPREP_KILL; 1268 } 1269 } else { 1270 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); ··· 1295 if (sdev->device_busy == 0) 1296 blk_plug_device(q); 1297 return BLKPREP_DEFER; 1298 } 1299 1300 /*
··· 1146 if (unlikely(!scsi_device_online(sdev))) { 1147 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n", 1148 sdev->host->host_no, sdev->id, sdev->lun); 1149 + goto kill; 1150 } 1151 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { 1152 /* OK, we're not in a running state don't prep ··· 1156 * at all allowed down */ 1157 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to dead device\n", 1158 sdev->host->host_no, sdev->id, sdev->lun); 1159 + goto kill; 1160 } 1161 /* OK, we only allow special commands (i.e. not 1162 * user initiated ones */ ··· 1188 if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) { 1189 if(specials_only == SDEV_QUIESCE || 1190 specials_only == SDEV_BLOCK) 1191 + goto defer; 1192 1193 printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to device being removed\n", 1194 sdev->host->host_no, sdev->id, sdev->lun); 1195 + goto kill; 1196 } 1197 1198 ··· 1210 cmd->tag = req->tag; 1211 } else { 1212 blk_dump_rq_flags(req, "SCSI bad req"); 1213 + goto kill; 1214 } 1215 1216 /* note the overloading of req->special. When the tag ··· 1248 * required). 1249 */ 1250 ret = scsi_init_io(cmd); 1251 + switch(ret) { 1252 + case BLKPREP_KILL: 1253 + /* BLKPREP_KILL return also releases the command */ 1254 + goto kill; 1255 + case BLKPREP_DEFER: 1256 + goto defer; 1257 + } 1258 1259 /* 1260 * Initialize the actual SCSI command for this request. ··· 1259 if (unlikely(!drv->init_command(cmd))) { 1260 scsi_release_buffers(cmd); 1261 scsi_put_command(cmd); 1262 + goto kill; 1263 } 1264 } else { 1265 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); ··· 1290 if (sdev->device_busy == 0) 1291 blk_plug_device(q); 1292 return BLKPREP_DEFER; 1293 + kill: 1294 + req->errors = DID_NO_CONNECT << 16; 1295 + return BLKPREP_KILL; 1296 } 1297 1298 /*