]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/scsi_lib.c
Merge with ../linux-2.6-smp
[linux-2.6-omap-h63xx.git] / drivers / scsi / scsi_lib.c
index d230c699c728e3a8db456034bf5bf30c7b1c5452..10506f9cd0c929da622b667c22fcee071c522bd2 100644 (file)
@@ -44,7 +44,7 @@ struct scsi_host_sg_pool {
 #endif
 
 #define SP(x) { x, "sgpool-" #x } 
-struct scsi_host_sg_pool scsi_sg_pools[] = { 
+static struct scsi_host_sg_pool scsi_sg_pools[] = {
        SP(8),
        SP(16),
        SP(32),
@@ -92,10 +92,12 @@ int scsi_insert_special_req(struct scsi_request *sreq, int at_head)
         */
        sreq->sr_request->flags &= ~REQ_DONTPREP;
        blk_insert_request(sreq->sr_device->request_queue, sreq->sr_request,
-                          at_head, sreq, 0);
+                          at_head, sreq);
        return 0;
 }
 
+static void scsi_run_queue(struct request_queue *q);
+
 /*
  * Function:    scsi_queue_insert()
  *
@@ -119,18 +121,14 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
 {
        struct Scsi_Host *host = cmd->device->host;
        struct scsi_device *device = cmd->device;
+       struct request_queue *q = device->request_queue;
+       unsigned long flags;
 
        SCSI_LOG_MLQUEUE(1,
                 printk("Inserting command %p into mlqueue\n", cmd));
 
        /*
-        * We are inserting the command into the ml queue.  First, we
-        * cancel the timer, so it doesn't time out.
-        */
-       scsi_delete_timer(cmd);
-
-       /*
-        * Next, set the appropriate busy bit for the device/host.
+        * Set the appropriate busy bit for the device/host.
         *
         * If the host/device isn't busy, assume that something actually
         * completed, and that we should be able to queue a command now.
@@ -160,17 +158,22 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
        scsi_device_unbusy(device);
 
        /*
-        * Insert this command at the head of the queue for it's device.
-        * It will go before all other commands that are already in the queue.
+        * Requeue this command.  It will go before all other commands
+        * that are already in the queue.
         *
         * NOTE: there is magic here about the way the queue is plugged if
         * we have no outstanding commands.
         * 
-        * Although this *doesn't* plug the queue, it does call the request
+        * Although we *don't* plug the queue, we call the request
         * function.  The SCSI request function detects the blocked condition
         * and plugs the queue appropriately.
-        */
-       blk_insert_request(device->request_queue, cmd->request, 1, cmd, 1);
+         */
+       spin_lock_irqsave(q->queue_lock, flags);
+       blk_requeue_request(q, cmd->request);
+       spin_unlock_irqrestore(q->queue_lock, flags);
+
+       scsi_run_queue(q);
+
        return 0;
 }
 
@@ -298,7 +301,6 @@ static int scsi_init_cmd_errh(struct scsi_cmnd *cmd)
 {
        cmd->owner = SCSI_OWNER_MIDLEVEL;
        cmd->serial_number = 0;
-       cmd->serial_number_at_timeout = 0;
        cmd->abort_reason = 0;
 
        memset(cmd->sense_buffer, 0, sizeof cmd->sense_buffer);
@@ -320,7 +322,6 @@ static int scsi_init_cmd_errh(struct scsi_cmnd *cmd)
        memcpy(cmd->data_cmnd, cmd->cmnd, sizeof(cmd->cmnd));
        cmd->buffer = cmd->request_buffer;
        cmd->bufflen = cmd->request_bufflen;
-       cmd->internal_timeout = NORMAL_TIMEOUT;
        cmd->abort_reason = 0;
 
        return 1;
@@ -487,8 +488,13 @@ static void scsi_run_queue(struct request_queue *q)
  */
 static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
 {
+       unsigned long flags;
+
        cmd->request->flags &= ~REQ_DONTPREP;
-       blk_insert_request(q, cmd->request, 1, cmd, 1);
+
+       spin_lock_irqsave(q->queue_lock, flags);
+       blk_requeue_request(q, cmd->request);
+       spin_unlock_irqrestore(q->queue_lock, flags);
 
        scsi_run_queue(q);
 }
@@ -626,7 +632,7 @@ static void scsi_free_sgtable(struct scatterlist *sgl, int index)
 {
        struct scsi_host_sg_pool *sgp;
 
-       BUG_ON(index > SG_MEMPOOL_NR);
+       BUG_ON(index >= SG_MEMPOOL_NR);
 
        sgp = scsi_sg_pools + index;
        mempool_free(sgl, sgp->pool);
@@ -943,10 +949,8 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
         * if sg table allocation fails, requeue request later.
         */
        sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC);
-       if (unlikely(!sgpnt)) {
-               req->flags |= REQ_SPECIAL;
+       if (unlikely(!sgpnt))
                return BLKPREP_DEFER;
-       }
 
        cmd->request_buffer = (char *) sgpnt;
        cmd->request_bufflen = req->nr_sectors << 9;