aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-11-23 06:54:36 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2011-12-14 06:27:02 -0500
commit1880807adb21d741f08b747956c90bf4a6f95fbf (patch)
treefb3815bf85679116bb455ded1a678049950a3d9f /drivers/target
parent41e16e981679124c78c30f046d4f0b71d86ff1b2 (diff)
target: make the se_task task_state_active a normal bool
There is no need to make task_state_active an atomic_t given that it is always set under the execute_task_lock so we can make it a simple bool. Also rename it to t_state_active to be closer to the list it guards, and make sure all checks before the list addion/removal actually happen under execute_task_lock. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_tmr.c2
-rw-r--r--drivers/target/target_core_transport.c41
2 files changed, 21 insertions, 22 deletions
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index fc9d74890319..b4c9bb783c46 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -221,7 +221,7 @@ static void core_tmr_drain_task_list(
221 continue; 221 continue;
222 222
223 list_move_tail(&task->t_state_list, &drain_task_list); 223 list_move_tail(&task->t_state_list, &drain_task_list);
224 atomic_set(&task->task_state_active, 0); 224 task->t_state_active = false;
225 /* 225 /*
226 * Remove from task execute list before processing drain_task_list 226 * Remove from task execute list before processing drain_task_list
227 */ 227 */
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index ae112ac91c47..511836eb2953 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -421,18 +421,18 @@ static void transport_all_task_dev_remove_state(struct se_cmd *cmd)
421 if (task->task_flags & TF_ACTIVE) 421 if (task->task_flags & TF_ACTIVE)
422 continue; 422 continue;
423 423
424 if (!atomic_read(&task->task_state_active))
425 continue;
426
427 spin_lock_irqsave(&dev->execute_task_lock, flags); 424 spin_lock_irqsave(&dev->execute_task_lock, flags);
428 list_del(&task->t_state_list); 425 if (task->t_state_active) {
429 pr_debug("Removed ITT: 0x%08x dev: %p task[%p]\n", 426 pr_debug("Removed ITT: 0x%08x dev: %p task[%p]\n",
430 cmd->se_tfo->get_task_tag(cmd), dev, task); 427 cmd->se_tfo->get_task_tag(cmd), dev, task);
431 spin_unlock_irqrestore(&dev->execute_task_lock, flags);
432 428
433 atomic_set(&task->task_state_active, 0); 429 list_del(&task->t_state_list);
434 atomic_dec(&cmd->t_task_cdbs_ex_left); 430 atomic_dec(&cmd->t_task_cdbs_ex_left);
431 task->t_state_active = false;
432 }
433 spin_unlock_irqrestore(&dev->execute_task_lock, flags);
435 } 434 }
435
436} 436}
437 437
438/* transport_cmd_check_stop(): 438/* transport_cmd_check_stop():
@@ -813,7 +813,7 @@ static void __transport_add_task_to_execute_queue(
813 head_of_queue = transport_add_task_check_sam_attr(task, task_prev, dev); 813 head_of_queue = transport_add_task_check_sam_attr(task, task_prev, dev);
814 atomic_inc(&dev->execute_tasks); 814 atomic_inc(&dev->execute_tasks);
815 815
816 if (atomic_read(&task->task_state_active)) 816 if (task->t_state_active)
817 return; 817 return;
818 /* 818 /*
819 * Determine if this task needs to go to HEAD_OF_QUEUE for the 819 * Determine if this task needs to go to HEAD_OF_QUEUE for the
@@ -827,7 +827,7 @@ static void __transport_add_task_to_execute_queue(
827 else 827 else
828 list_add_tail(&task->t_state_list, &dev->state_task_list); 828 list_add_tail(&task->t_state_list, &dev->state_task_list);
829 829
830 atomic_set(&task->task_state_active, 1); 830 task->t_state_active = true;
831 831
832 pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n", 832 pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n",
833 task->task_se_cmd->se_tfo->get_task_tag(task->task_se_cmd), 833 task->task_se_cmd->se_tfo->get_task_tag(task->task_se_cmd),
@@ -842,17 +842,16 @@ static void transport_add_tasks_to_state_queue(struct se_cmd *cmd)
842 842
843 spin_lock_irqsave(&cmd->t_state_lock, flags); 843 spin_lock_irqsave(&cmd->t_state_lock, flags);
844 list_for_each_entry(task, &cmd->t_task_list, t_list) { 844 list_for_each_entry(task, &cmd->t_task_list, t_list) {
845 if (atomic_read(&task->task_state_active))
846 continue;
847
848 spin_lock(&dev->execute_task_lock); 845 spin_lock(&dev->execute_task_lock);
849 list_add_tail(&task->t_state_list, &dev->state_task_list); 846 if (!task->t_state_active) {
850 atomic_set(&task->task_state_active, 1); 847 list_add_tail(&task->t_state_list,
851 848 &dev->state_task_list);
852 pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n", 849 task->t_state_active = true;
853 task->task_se_cmd->se_tfo->get_task_tag( 850
854 task->task_se_cmd), task, dev); 851 pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n",
855 852 task->task_se_cmd->se_tfo->get_task_tag(
853 task->task_se_cmd), task, dev);
854 }
856 spin_unlock(&dev->execute_task_lock); 855 spin_unlock(&dev->execute_task_lock);
857 } 856 }
858 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 857 spin_unlock_irqrestore(&cmd->t_state_lock, flags);