[SCSI] target: Fix task->task_execute_queue=1 clear bug + LUN_RESET OOPs
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 20 May 2011 03:19:12 +0000 (20:19 -0700)
committerJames Bottomley <jbottomley@parallels.com>
Tue, 24 May 2011 17:01:05 +0000 (13:01 -0400)
This patch fixes a bug where task->task_execute_queue=1 was not being
cleared once se_task had been removed from se_device->execute_task_list,
resulting in an OOPs in core_tmr_lun_reset() for the task->task_active=0
case where transport_remove_task_from_execute_queue() was incorrectly
being called.

This patch fixes two cases in transport_get_task_from_execute_queue()
and transport_remove_task_from_execute_queue() to properly clear
task->task_execute_queue=0 once list_del(&task->t_execute_list) has
been called.

It also adds an explict check in transport_remove_task_from_execute_queue()
to dump_stack + return if called with task->task_execute_queue=0.

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <jbottomley@parallels.com>
drivers/target/target_core_transport.c

index 7c87b042375adffb8e8a341a9b8fada639e4645c..623963b8c1b78b9c39d7abcc75c947ca122a6f8c 100644 (file)
@@ -1194,6 +1194,7 @@ transport_get_task_from_execute_queue(struct se_device *dev)
                break;
 
        list_del(&task->t_execute_list);
+       atomic_set(&task->task_execute_queue, 0);
        atomic_dec(&dev->execute_tasks);
 
        return task;
@@ -1209,8 +1210,14 @@ void transport_remove_task_from_execute_queue(
 {
        unsigned long flags;
 
+       if (atomic_read(&task->task_execute_queue) == 0) {
+               dump_stack();
+               return;
+       }
+
        spin_lock_irqsave(&dev->execute_task_lock, flags);
        list_del(&task->t_execute_list);
+       atomic_set(&task->task_execute_queue, 0);
        atomic_dec(&dev->execute_tasks);
        spin_unlock_irqrestore(&dev->execute_task_lock, flags);
 }