aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-10-12 11:07:04 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-10-23 23:21:08 -0400
commit04629b7bde553e3703577779f53cb0ba1eddd2c0 (patch)
tree0ad137523361599cdd4c16daad11d6bab2893511 /drivers/target
parent6c76bf951cb099f5573954b1f56c1121c3a41c72 (diff)
target: Remove unnecessary se_task members
This is a squashed version of the following unnecessary se_task structure member removal patches: target: remove the task_execute_queue field in se_task Instead of using a separate flag we can simply do list_emptry checks on t_execute_list if we make sure to always use list_del_init to remove a task from the list. Also factor some duplicate code into a new __transport_remove_task_from_execute_queue helper. target: remove the read-only task_no field in se_task The task_no field never was initialized and only used in debug printks, so kill it. target: remove the task_padded_sg field in se_task This field is only check in one place and not actually needed there. Rationale: - transport_do_task_sg_chain asserts that we have task_sg_chaining set early on - we only make use of the sg_prev_nents field we calculate based on it if there is another sg list that gets chained onto this one, which never happens for the last (or only) task. 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.c7
-rw-r--r--drivers/target/target_core_transport.c59
2 files changed, 26 insertions, 40 deletions
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index b5c18648fa2..b8a780fff36 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -226,11 +226,8 @@ static void core_tmr_drain_task_list(
226 /* 226 /*
227 * Remove from task execute list before processing drain_task_list 227 * Remove from task execute list before processing drain_task_list
228 */ 228 */
229 if (atomic_read(&task->task_execute_queue) != 0) { 229 if (!list_empty(&task->t_execute_list))
230 list_del(&task->t_execute_list); 230 __transport_remove_task_from_execute_queue(task, dev);
231 atomic_set(&task->task_execute_queue, 0);
232 atomic_dec(&dev->execute_tasks);
233 }
234 } 231 }
235 spin_unlock_irqrestore(&dev->execute_task_lock, flags); 232 spin_unlock_irqrestore(&dev->execute_task_lock, flags);
236 233
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 165a60c875a..4a787a0ab06 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -915,38 +915,36 @@ static void transport_add_tasks_from_cmd(struct se_cmd *cmd)
915 915
916 spin_lock_irqsave(&dev->execute_task_lock, flags); 916 spin_lock_irqsave(&dev->execute_task_lock, flags);
917 list_for_each_entry(task, &cmd->t_task_list, t_list) { 917 list_for_each_entry(task, &cmd->t_task_list, t_list) {
918 if (atomic_read(&task->task_execute_queue)) 918 if (!list_empty(&task->t_execute_list))
919 continue; 919 continue;
920 /* 920 /*
921 * __transport_add_task_to_execute_queue() handles the 921 * __transport_add_task_to_execute_queue() handles the
922 * SAM Task Attribute emulation if enabled 922 * SAM Task Attribute emulation if enabled
923 */ 923 */
924 __transport_add_task_to_execute_queue(task, task_prev, dev); 924 __transport_add_task_to_execute_queue(task, task_prev, dev);
925 atomic_set(&task->task_execute_queue, 1);
926 task_prev = task; 925 task_prev = task;
927 } 926 }
928 spin_unlock_irqrestore(&dev->execute_task_lock, flags); 927 spin_unlock_irqrestore(&dev->execute_task_lock, flags);
929} 928}
930 929
931/* transport_remove_task_from_execute_queue(): 930void __transport_remove_task_from_execute_queue(struct se_task *task,
932 * 931 struct se_device *dev)
933 * 932{
934 */ 933 list_del_init(&task->t_execute_list);
934 atomic_dec(&dev->execute_tasks);
935}
936
935void transport_remove_task_from_execute_queue( 937void transport_remove_task_from_execute_queue(
936 struct se_task *task, 938 struct se_task *task,
937 struct se_device *dev) 939 struct se_device *dev)
938{ 940{
939 unsigned long flags; 941 unsigned long flags;
940 942
941 if (atomic_read(&task->task_execute_queue) == 0) { 943 if (WARN_ON(list_empty(&task->t_execute_list)))
942 dump_stack();
943 return; 944 return;
944 }
945 945
946 spin_lock_irqsave(&dev->execute_task_lock, flags); 946 spin_lock_irqsave(&dev->execute_task_lock, flags);
947 list_del(&task->t_execute_list); 947 __transport_remove_task_from_execute_queue(task, dev);
948 atomic_set(&task->task_execute_queue, 0);
949 atomic_dec(&dev->execute_tasks);
950 spin_unlock_irqrestore(&dev->execute_task_lock, flags); 948 spin_unlock_irqrestore(&dev->execute_task_lock, flags);
951} 949}
952 950
@@ -1787,8 +1785,7 @@ static int transport_stop_tasks_for_cmd(struct se_cmd *cmd)
1787 spin_lock_irqsave(&cmd->t_state_lock, flags); 1785 spin_lock_irqsave(&cmd->t_state_lock, flags);
1788 list_for_each_entry_safe(task, task_tmp, 1786 list_for_each_entry_safe(task, task_tmp,
1789 &cmd->t_task_list, t_list) { 1787 &cmd->t_task_list, t_list) {
1790 pr_debug("task_no[%d] - Processing task %p\n", 1788 pr_debug("Processing task %p\n", task);
1791 task->task_no, task);
1792 /* 1789 /*
1793 * If the struct se_task has not been sent and is not active, 1790 * If the struct se_task has not been sent and is not active,
1794 * remove the struct se_task from the execution queue. 1791 * remove the struct se_task from the execution queue.
@@ -1799,8 +1796,7 @@ static int transport_stop_tasks_for_cmd(struct se_cmd *cmd)
1799 transport_remove_task_from_execute_queue(task, 1796 transport_remove_task_from_execute_queue(task,
1800 cmd->se_dev); 1797 cmd->se_dev);
1801 1798
1802 pr_debug("task_no[%d] - Removed from execute queue\n", 1799 pr_debug("Task %p removed from execute queue\n", task);
1803 task->task_no);
1804 spin_lock_irqsave(&cmd->t_state_lock, flags); 1800 spin_lock_irqsave(&cmd->t_state_lock, flags);
1805 continue; 1801 continue;
1806 } 1802 }
@@ -1814,17 +1810,15 @@ static int transport_stop_tasks_for_cmd(struct se_cmd *cmd)
1814 spin_unlock_irqrestore(&cmd->t_state_lock, 1810 spin_unlock_irqrestore(&cmd->t_state_lock,
1815 flags); 1811 flags);
1816 1812
1817 pr_debug("task_no[%d] - Waiting to complete\n", 1813 pr_debug("Task %p waiting to complete\n", task);
1818 task->task_no);
1819 wait_for_completion(&task->task_stop_comp); 1814 wait_for_completion(&task->task_stop_comp);
1820 pr_debug("task_no[%d] - Stopped successfully\n", 1815 pr_debug("Task %p stopped successfully\n", task);
1821 task->task_no);
1822 1816
1823 spin_lock_irqsave(&cmd->t_state_lock, flags); 1817 spin_lock_irqsave(&cmd->t_state_lock, flags);
1824 atomic_dec(&cmd->t_task_cdbs_left); 1818 atomic_dec(&cmd->t_task_cdbs_left);
1825 task->task_flags &= ~(TF_ACTIVE | TF_REQUEST_STOP); 1819 task->task_flags &= ~(TF_ACTIVE | TF_REQUEST_STOP);
1826 } else { 1820 } else {
1827 pr_debug("task_no[%d] - Did nothing\n", task->task_no); 1821 pr_debug("Task %p - did nothing\n", task);
1828 ret++; 1822 ret++;
1829 } 1823 }
1830 1824
@@ -2347,9 +2341,7 @@ check_depth:
2347 } 2341 }
2348 task = list_first_entry(&dev->execute_task_list, 2342 task = list_first_entry(&dev->execute_task_list,
2349 struct se_task, t_execute_list); 2343 struct se_task, t_execute_list);
2350 list_del(&task->t_execute_list); 2344 __transport_remove_task_from_execute_queue(task, dev);
2351 atomic_set(&task->task_execute_queue, 0);
2352 atomic_dec(&dev->execute_tasks);
2353 spin_unlock_irq(&dev->execute_task_lock); 2345 spin_unlock_irq(&dev->execute_task_lock);
2354 2346
2355 atomic_dec(&dev->depth_left); 2347 atomic_dec(&dev->depth_left);
@@ -2681,9 +2673,9 @@ static int transport_get_sense_data(struct se_cmd *cmd)
2681 2673
2682 sense_buffer = dev->transport->get_sense_buffer(task); 2674 sense_buffer = dev->transport->get_sense_buffer(task);
2683 if (!sense_buffer) { 2675 if (!sense_buffer) {
2684 pr_err("ITT[0x%08x]_TASK[%d]: Unable to locate" 2676 pr_err("ITT[0x%08x]_TASK[%p]: Unable to locate"
2685 " sense buffer for task with sense\n", 2677 " sense buffer for task with sense\n",
2686 cmd->se_tfo->get_task_tag(cmd), task->task_no); 2678 cmd->se_tfo->get_task_tag(cmd), task);
2687 continue; 2679 continue;
2688 } 2680 }
2689 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2681 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
@@ -3897,15 +3889,13 @@ void transport_do_task_sg_chain(struct se_cmd *cmd)
3897 /* 3889 /*
3898 * For the padded tasks, use the extra SGL vector allocated 3890 * For the padded tasks, use the extra SGL vector allocated
3899 * in transport_allocate_data_tasks() for the sg_prev_nents 3891 * in transport_allocate_data_tasks() for the sg_prev_nents
3900 * offset into sg_chain() above.. The last task of a 3892 * offset into sg_chain() above.
3901 * multi-task list, or a single task will not have 3893 *
3902 * task->task_sg_padded set.. 3894 * We do not need the padding for the last task (or a single
3895 * task), but in that case we will never use the sg_prev_nents
3896 * value below which would be incorrect.
3903 */ 3897 */
3904 if (task->task_padded_sg) 3898 sg_prev_nents = (task->task_sg_nents + 1);
3905 sg_prev_nents = (task->task_sg_nents + 1);
3906 else
3907 sg_prev_nents = task->task_sg_nents;
3908
3909 sg_prev = task->task_sg; 3899 sg_prev = task->task_sg;
3910 } 3900 }
3911 /* 3901 /*
@@ -3992,7 +3982,6 @@ static int transport_allocate_data_tasks(
3992 */ 3982 */
3993 if (cmd->se_tfo->task_sg_chaining && (i < (task_count - 1))) { 3983 if (cmd->se_tfo->task_sg_chaining && (i < (task_count - 1))) {
3994 task_sg_nents_padded = (task->task_sg_nents + 1); 3984 task_sg_nents_padded = (task->task_sg_nents + 1);
3995 task->task_padded_sg = 1;
3996 } else 3985 } else
3997 task_sg_nents_padded = task->task_sg_nents; 3986 task_sg_nents_padded = task->task_sg_nents;
3998 3987