printk(KERN_INFO "Device %s not ready.\n", req->rq_disk ? req->rq_disk->disk_name : ""); 
if (!(req->flags & REQ_QUIET)) dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "Device not ready.\n"); 
void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,			unsigned int block_bytes){	int result = cmd->result;	int this_count = cmd->bufflen;	request_queue_t *q = cmd->device->request_queue;	struct request *req = cmd->request;	int clear_errors = 1;	struct scsi_sense_hdr sshdr;	int sense_valid = 0;	int sense_deferred = 0;	if (blk_complete_barrier_rq(q, req, good_bytes >> 9))		return;	/*	 * Free up any indirection buffers we allocated for DMA purposes. 	 * For the case of a READ, we need to copy the data out of the	 * bounce buffer and into the real buffer.	 */	if (cmd->use_sg)		scsi_free_sgtable(cmd->buffer, cmd->sglist_len);	else if (cmd->buffer != req->buffer) {		if (rq_data_dir(req) == READ) {			unsigned long flags;			char *to = bio_kmap_irq(req->bio, &flags);			memcpy(to, cmd->buffer, cmd->bufflen);			bio_kunmap_irq(to, &flags);		}		kfree(cmd->buffer);	}	if (result) {		sense_valid = scsi_command_normalize_sense(cmd, &sshdr);		if (sense_valid)			sense_deferred = scsi_sense_is_deferred(&sshdr);	}	if (blk_pc_request(req)) { /* SG_IO ioctl from block level */		req->errors = result;		if (result) {			clear_errors = 0;			if (sense_valid && req->sense) {				/*				 * SG_IO wants current and deferred errors				 */				int len = 8 + cmd->sense_buffer[7];				if (len > SCSI_SENSE_BUFFERSIZE)					len = SCSI_SENSE_BUFFERSIZE;				memcpy(req->sense, cmd->sense_buffer,  len);				req->sense_len = len;			}		} else			req->data_len = cmd->resid;	}	/*	 * Zero these out.  They now point to freed memory, and it is	 * dangerous to hang onto the pointers.	 */	cmd->buffer  = NULL;	cmd->bufflen = 0;	cmd->request_buffer = NULL;	cmd->request_bufflen = 0;	/*	 * Next deal with any sectors which we were able to correctly	 * handle.	 */	if (good_bytes >= 0) {		SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, %d bytes done.\n",					      req->nr_sectors, good_bytes));		SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg));		if (clear_errors)			req->errors = 0;		/*		 * If multiple sectors are requested in one buffer, then		 * they will have been finished off by the first command.		 * If not, then we have a multi-buffer command.		 *		 * If block_bytes != 0, it means we had a medium error		 * of some sort, and that we want to mark some number of		 * sectors as not uptodate.  Thus we want to inhibit		 * requeueing right here - we will requeue down below		 * when we handle the bad sectors.		 */		cmd = scsi_end_request(cmd, 1, good_bytes, result == 0);		/*		 * If the command completed without error, then either finish off the		 * rest of the command, or start a new one.		 */		if (result == 0 || cmd == NULL ) {			return;		}	}	/*	 * Now, if we were good little boys and girls, Santa left us a request	 * sense buffer.  We can extract information from this, so we	 * can choose a block to remap, etc.	 */	if (sense_valid && !sense_deferred) {		switch (sshdr.sense_key) {		case UNIT_ATTENTION:			if (cmd->device->removable) {				/* detected disc change.  set a bit 				 * and quietly refuse further access.				 */				cmd->device->changed = 1;				cmd = scsi_end_request(cmd, 0,						this_count, 1);				return;			} else {				/*				* Must have been a power glitch, or a				* bus reset.  Could not have been a				* media change, so we just retry the				* request and see what happens.  				*/				scsi_requeue_command(q, cmd);				return;			}			break;		case ILLEGAL_REQUEST:			/*		 	* If we had an ILLEGAL REQUEST returned, then we may		 	* have performed an unsupported command.  The only		 	* thing this should be would be a ten byte read where			* only a six byte read was supported.  Also, on a			* system where READ CAPACITY failed, we may have read			* past the end of the disk.		 	*/			if (cmd->device->use_10_for_rw &&			    (cmd->cmnd[0] == READ_10 ||			     cmd->cmnd[0] == WRITE_10)) {				cmd->device->use_10_for_rw = 0;				/*				 * This will cause a retry with a 6-byte				 * command.				 */				scsi_requeue_command(q, cmd);				result = 0;			} else {				cmd = scsi_end_request(cmd, 0, this_count, 1);				return;			}			break;		case NOT_READY:			/*			 * If the device is in the process of becoming ready,			 * retry.			 */			if (sshdr.asc == 0x04 && sshdr.ascq == 0x01) {				scsi_requeue_command(q, cmd);				return;			}			printk(KERN_INFO "Device %s not ready.\n",			       req->rq_disk ? req->rq_disk->disk_name : "");			cmd = scsi_end_request(cmd, 0, this_count, 1);			return;		case VOLUME_OVERFLOW:			printk(KERN_INFO "Volume overflow <%d %d %d %d> CDB: ",			       cmd->device->host->host_no,			       (int)cmd->device->channel,			       (int)cmd->device->id, (int)cmd->device->lun);			__scsi_print_command(cmd->data_cmnd);			scsi_print_sense("", cmd);			cmd = scsi_end_request(cmd, 0, block_bytes, 1);			return;		default:			break;		}	}			/* driver byte != 0 */	if (host_byte(result) == DID_RESET) {		/*		 * Third party bus reset or reset for error		 * recovery reasons.  Just retry the request		 * and see what happens.  		 */		scsi_requeue_command(q, cmd);		return;	}	if (result) {		if (!(req->flags & REQ_SPECIAL))			printk(KERN_INFO "SCSI error : <%d %d %d %d> return code "			       "= 0x%x\n", cmd->device->host->host_no,			       cmd->device->channel,			       cmd->device->id,			       cmd->device->lun, result);		if (driver_byte(result) & DRIVER_SENSE)			scsi_print_sense("", cmd);		/*		 * Mark a single buffer as not uptodate.  Queue the remainder.		 * We sometimes get this cruft in the event that a medium error		 * isn't properly reported.		 */		block_bytes = req->hard_cur_sectors << 9;		if (!block_bytes)			block_bytes = req->data_len;		cmd = scsi_end_request(cmd, 0, block_bytes, 1);	}}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/3173d8c342971a03857d8af749a3f57da7d06b57/scsi_lib.c/buggy/drivers/scsi/scsi_lib.c