Merge git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm
[cascardo/linux.git] / drivers / scsi / scsi_lib.c
index c664242..9ade720 100644 (file)
@@ -85,7 +85,7 @@ static void scsi_unprep_request(struct request *req)
 {
        struct scsi_cmnd *cmd = req->special;
 
-       req->cmd_flags &= ~REQ_DONTPREP;
+       blk_unprep_request(req);
        req->special = NULL;
 
        scsi_put_command(cmd);
@@ -722,7 +722,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
                        sense_deferred = scsi_sense_is_deferred(&sshdr);
        }
 
-       if (blk_pc_request(req)) { /* SG_IO ioctl from block level */
+       if (req->cmd_type == REQ_TYPE_BLOCK_PC) { /* SG_IO ioctl from block level */
                req->errors = result;
                if (result) {
                        if (sense_valid && req->sense) {
@@ -757,7 +757,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
                }
        }
 
-       BUG_ON(blk_bidi_rq(req)); /* bidi not support for !blk_pc_request yet */
+       /* no bidi support for !REQ_TYPE_BLOCK_PC yet */
+       BUG_ON(blk_bidi_rq(req));
 
        /*
         * Next deal with any sectors which we were able to correctly
@@ -773,8 +774,14 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
         * we already took a copy of the original into rq->errors which
         * is what gets returned to the user
         */
-       if (sense_valid && sshdr.sense_key == RECOVERED_ERROR) {
-               if (!(req->cmd_flags & REQ_QUIET))
+       if (sense_valid && (sshdr.sense_key == RECOVERED_ERROR)) {
+               /* if ATA PASS-THROUGH INFORMATION AVAILABLE skip
+                * print since caller wants ATA registers. Only occurs on
+                * SCSI ATA PASS_THROUGH commands when CK_COND=1
+                */
+               if ((sshdr.asc == 0x0) && (sshdr.ascq == 0x1d))
+                       ;
+               else if (!(req->cmd_flags & REQ_QUIET))
                        scsi_print_sense("", cmd);
                result = 0;
                /* BLOCK_PC may have set error */
@@ -1004,11 +1011,8 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
 
 err_exit:
        scsi_release_buffers(cmd);
-       if (error == BLKPREP_KILL)
-               scsi_put_command(cmd);
-       else /* BLKPREP_DEFER */
-               scsi_unprep_request(cmd->request);
-
+       scsi_put_command(cmd);
+       cmd->request->special = NULL;
        return error;
 }
 EXPORT_SYMBOL(scsi_init_io);
@@ -1366,12 +1370,6 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
 
        blk_start_request(req);
 
-       if (unlikely(cmd == NULL)) {
-               printk(KERN_CRIT "impossible request in %s.\n",
-                                __func__);
-               BUG();
-       }
-
        sdev = cmd->device;
        starget = scsi_target(sdev);
        shost = sdev->host;
@@ -1624,10 +1622,10 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
        /*
         * this limit is imposed by hardware restrictions
         */
-       blk_queue_max_hw_segments(q, shost->sg_tablesize);
-       blk_queue_max_phys_segments(q, SCSI_MAX_SG_CHAIN_SEGMENTS);
+       blk_queue_max_segments(q, min_t(unsigned short, shost->sg_tablesize,
+                                       SCSI_MAX_SG_CHAIN_SEGMENTS));
 
-       blk_queue_max_sectors(q, shost->max_sectors);
+       blk_queue_max_hw_sectors(q, shost->max_sectors);
        blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
        blk_queue_segment_boundary(q, shost->dma_boundary);
        dma_set_seg_boundary(dev, shost->dma_boundary);