提交 d8c37e7b 编写于 作者: T Tejun Heo 提交者: James Bottomley

[SCSI] remove a timer race in scsi_queue_insert()

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: NTejun Heo <htejun@gmail.com>
Signed-off-by: NJames Bottomley <James.Bottomley@SteelEye.com>
上级 5b8ef842
...@@ -638,10 +638,12 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) ...@@ -638,10 +638,12 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
} }
spin_unlock_irqrestore(host->host_lock, flags); spin_unlock_irqrestore(host->host_lock, flags);
if (rtn) { if (rtn) {
if (scsi_delete_timer(cmd)) {
atomic_inc(&cmd->device->iodone_cnt); atomic_inc(&cmd->device->iodone_cnt);
scsi_queue_insert(cmd, scsi_queue_insert(cmd,
(rtn == SCSI_MLQUEUE_DEVICE_BUSY) ? (rtn == SCSI_MLQUEUE_DEVICE_BUSY) ?
rtn : SCSI_MLQUEUE_HOST_BUSY); rtn : SCSI_MLQUEUE_HOST_BUSY);
}
SCSI_LOG_MLQUEUE(3, SCSI_LOG_MLQUEUE(3,
printk("queuecommand : request rejected\n")); printk("queuecommand : request rejected\n"));
} }
......
...@@ -128,13 +128,7 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason) ...@@ -128,13 +128,7 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
printk("Inserting command %p into mlqueue\n", cmd)); printk("Inserting command %p into mlqueue\n", cmd));
/* /*
* We are inserting the command into the ml queue. First, we * Set the appropriate busy bit for the device/host.
* cancel the timer, so it doesn't time out.
*/
scsi_delete_timer(cmd);
/*
* Next, set the appropriate busy bit for the device/host.
* *
* If the host/device isn't busy, assume that something actually * If the host/device isn't busy, assume that something actually
* completed, and that we should be able to queue a command now. * completed, and that we should be able to queue a command now.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册