Skip to content

Commit

Permalink
target: make the se_task task_state_active a normal bool
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and Nicholas Bellinger committed Dec 14, 2011
1 parent 41e16e9 commit 1880807
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion drivers/target/target_core_tmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static void core_tmr_drain_task_list(
continue;

list_move_tail(&task->t_state_list, &drain_task_list);
atomic_set(&task->task_state_active, 0);
task->t_state_active = false;
/*
* Remove from task execute list before processing drain_task_list
*/
Expand Down
41 changes: 20 additions & 21 deletions drivers/target/target_core_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,18 @@ static void transport_all_task_dev_remove_state(struct se_cmd *cmd)
if (task->task_flags & TF_ACTIVE)
continue;

if (!atomic_read(&task->task_state_active))
continue;

spin_lock_irqsave(&dev->execute_task_lock, flags);
list_del(&task->t_state_list);
pr_debug("Removed ITT: 0x%08x dev: %p task[%p]\n",
cmd->se_tfo->get_task_tag(cmd), dev, task);
spin_unlock_irqrestore(&dev->execute_task_lock, flags);
if (task->t_state_active) {
pr_debug("Removed ITT: 0x%08x dev: %p task[%p]\n",
cmd->se_tfo->get_task_tag(cmd), dev, task);

atomic_set(&task->task_state_active, 0);
atomic_dec(&cmd->t_task_cdbs_ex_left);
list_del(&task->t_state_list);
atomic_dec(&cmd->t_task_cdbs_ex_left);
task->t_state_active = false;
}
spin_unlock_irqrestore(&dev->execute_task_lock, flags);
}

}

/* transport_cmd_check_stop():
Expand Down Expand Up @@ -813,7 +813,7 @@ static void __transport_add_task_to_execute_queue(
head_of_queue = transport_add_task_check_sam_attr(task, task_prev, dev);
atomic_inc(&dev->execute_tasks);

if (atomic_read(&task->task_state_active))
if (task->t_state_active)
return;
/*
* Determine if this task needs to go to HEAD_OF_QUEUE for the
Expand All @@ -827,7 +827,7 @@ static void __transport_add_task_to_execute_queue(
else
list_add_tail(&task->t_state_list, &dev->state_task_list);

atomic_set(&task->task_state_active, 1);
task->t_state_active = true;

pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n",
task->task_se_cmd->se_tfo->get_task_tag(task->task_se_cmd),
Expand All @@ -842,17 +842,16 @@ static void transport_add_tasks_to_state_queue(struct se_cmd *cmd)

spin_lock_irqsave(&cmd->t_state_lock, flags);
list_for_each_entry(task, &cmd->t_task_list, t_list) {
if (atomic_read(&task->task_state_active))
continue;

spin_lock(&dev->execute_task_lock);
list_add_tail(&task->t_state_list, &dev->state_task_list);
atomic_set(&task->task_state_active, 1);

pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n",
task->task_se_cmd->se_tfo->get_task_tag(
task->task_se_cmd), task, dev);

if (!task->t_state_active) {
list_add_tail(&task->t_state_list,
&dev->state_task_list);
task->t_state_active = true;

pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n",
task->task_se_cmd->se_tfo->get_task_tag(
task->task_se_cmd), task, dev);
}
spin_unlock(&dev->execute_task_lock);
}
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
Expand Down
2 changes: 1 addition & 1 deletion include/target/target_core_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,10 @@ struct se_task {
u16 task_flags;
u8 task_scsi_status;
enum dma_data_direction task_data_direction;
atomic_t task_state_active;
struct list_head t_list;
struct list_head t_execute_list;
struct list_head t_state_list;
bool t_state_active;
struct completion task_stop_comp;
} ____cacheline_aligned;

Expand Down

0 comments on commit 1880807

Please sign in to comment.