]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] remove a timer race in scsi_queue_insert()
authorTejun Heo <htejun@gmail.com>
Fri, 13 May 2005 15:46:08 +0000 (00:46 +0900)
committerJames Bottomley <jejb@mulgrave.(none)>
Fri, 20 May 2005 17:53:54 +0000 (12:53 -0500)
scsi_queue_insert() has four callers.  Three callers call with
timer disabled and one (the second invocation in
scsi_dispatch_cmd()) calls with timer activated.
scsi_queue_insert() used to always call scsi_delete_timer()
and ignore the return value.  This results in race with timer
expiration.  Remove scsi_delete_timer() call from
scsi_queue_insert() and make the caller delete timer and check
the return value.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/scsi.c
drivers/scsi/scsi_lib.c

index 05d2bd075fd4e27a6f954e2b0662c400733790f9..0d730f646bce895a2f7ef3cabd72a1335311b3d2 100644 (file)
@@ -638,10 +638,12 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
        }
        spin_unlock_irqrestore(host->host_lock, flags);
        if (rtn) {
-               atomic_inc(&cmd->device->iodone_cnt);
-               scsi_queue_insert(cmd,
-                               (rtn == SCSI_MLQUEUE_DEVICE_BUSY) ?
-                                rtn : SCSI_MLQUEUE_HOST_BUSY);
+               if (scsi_delete_timer(cmd)) {
+                       atomic_inc(&cmd->device->iodone_cnt);
+                       scsi_queue_insert(cmd,
+                                         (rtn == SCSI_MLQUEUE_DEVICE_BUSY) ?
+                                         rtn : SCSI_MLQUEUE_HOST_BUSY);
+               }
                SCSI_LOG_MLQUEUE(3,
                    printk("queuecommand : request rejected\n"));
        }
index c3bb28c3feefe71aa95ab12691ea106bcc3c7163..9f996499fa9d2b44dbdf9431040a47bce15855c5 100644 (file)
@@ -128,13 +128,7 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
                 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.