All callers that never have the session_reinstatement flag set can trivially be converted to transport_put_cmd. Opencode the session reinstatement code in transport_generic_free_cmd, which was the only caller ever asking for it. Signed-off-by: Christoph Hellwig <hch@xxxxxx> Index: lio-core/drivers/target/target_core_transport.c =================================================================== --- lio-core.orig/drivers/target/target_core_transport.c 2011-09-13 14:57:33.149089111 -0400 +++ lio-core/drivers/target/target_core_transport.c 2011-09-13 15:01:36.615589705 -0400 @@ -88,8 +88,6 @@ static u32 transport_allocate_tasks(stru enum dma_data_direction data_direction, struct scatterlist *sgl, unsigned int nents); static int transport_generic_get_mem(struct se_cmd *cmd); -static int transport_generic_remove(struct se_cmd *cmd, - int session_reinstatement); static bool transport_put_cmd(struct se_cmd *cmd); static void transport_remove_cmd_from_queue(struct se_cmd *cmd, struct se_queue_obj *qobj); @@ -601,7 +599,7 @@ void transport_cmd_finish_abort(struct s if (transport_cmd_check_stop_to_fabric(cmd)) return; if (remove) - transport_generic_remove(cmd, 0); + transport_put_cmd(cmd); } void transport_cmd_finish_abort_tmr(struct se_cmd *cmd) @@ -611,7 +609,7 @@ void transport_cmd_finish_abort_tmr(stru if (transport_cmd_check_stop_to_fabric(cmd)) return; - transport_generic_remove(cmd, 0); + transport_put_cmd(cmd); } static void transport_add_cmd_to_queue( @@ -2093,7 +2091,7 @@ static void transport_generic_request_ti unsigned long flags; /* - * Reset cmd->t_se_count to allow transport_generic_remove() + * Reset cmd->t_se_count to allow transport_put_cmd() * to allow last call to free memory resources. */ spin_lock_irqsave(&cmd->t_state_lock, flags); @@ -2104,7 +2102,7 @@ static void transport_generic_request_ti } spin_unlock_irqrestore(&cmd->t_state_lock, flags); - transport_generic_remove(cmd, 0); + transport_put_cmd(cmd); } static inline u32 transport_lba_21(unsigned char *cdb) @@ -3793,24 +3791,6 @@ out_busy: return false; } -static int -transport_generic_remove(struct se_cmd *cmd, int session_reinstatement) -{ - unsigned long flags; - - if (!transport_put_cmd(cmd)) { - if (session_reinstatement) { - spin_lock_irqsave(&cmd->t_state_lock, flags); - transport_all_task_dev_remove_state(cmd); - spin_unlock_irqrestore(&cmd->t_state_lock, - flags); - } - return 1; - } - - return 0; -} - /* * transport_generic_map_mem_to_cmd - Use fabric-alloced pages instead of * allocating in the core. @@ -4400,7 +4380,13 @@ void transport_generic_free_cmd( transport_free_dev_tasks(cmd); - transport_generic_remove(cmd, session_reinstatement); + if (!transport_put_cmd(cmd) && session_reinstatement) { + unsigned long flags; + + spin_lock_irqsave(&cmd->t_state_lock, flags); + transport_all_task_dev_remove_state(cmd); + spin_unlock_irqrestore(&cmd->t_state_lock, flags); + } } } EXPORT_SYMBOL(transport_generic_free_cmd); @@ -5078,7 +5064,7 @@ static void transport_processing_shutdow transport_lun_remove_cmd(cmd); if (transport_cmd_check_stop(cmd, 1, 0)) - transport_generic_remove(cmd, 0); + transport_put_cmd(cmd); } spin_lock_irqsave(&dev->execute_task_lock, flags); @@ -5106,7 +5092,7 @@ static void transport_processing_shutdow transport_lun_remove_cmd(cmd); if (transport_cmd_check_stop(cmd, 1, 0)) - transport_generic_remove(cmd, 0); + transport_put_cmd(cmd); } spin_lock_irqsave(&dev->execute_task_lock, flags); @@ -5129,7 +5115,7 @@ static void transport_processing_shutdow } else { transport_lun_remove_cmd(cmd); if (transport_cmd_check_stop(cmd, 1, 0)) - transport_generic_remove(cmd, 0); + transport_put_cmd(cmd); } } } @@ -5203,7 +5189,7 @@ get_cmd: transport_generic_complete_ok(cmd); break; case TRANSPORT_REMOVE: - transport_generic_remove(cmd, 0); + transport_put_cmd(cmd); break; case TRANSPORT_FREE_CMD_INTR: transport_generic_free_cmd(cmd, 0, 0); -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html