Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: target: Fold core_tmr_handle_tas_abort() into transport_cmd_finish_abort()

For the two calls to transport_cmd_finish_abort() outside
core_tmr_handle_tas_abort() it is guaranteed that CMD_T_TAS is not set. Use
this property to fold core_tmr_handle_tas_abort() into
transport_cmd_finish_abort(). This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
65422d70 709d5651

+11 -17
+1 -1
drivers/target/target_core_internal.h
··· 138 138 void release_se_kmem_caches(void); 139 139 u32 scsi_get_new_index(scsi_index_t); 140 140 void transport_subsystem_check_init(void); 141 - int transport_cmd_finish_abort(struct se_cmd *, int); 141 + int transport_cmd_finish_abort(struct se_cmd *); 142 142 unsigned char *transport_dump_cmd_direction(struct se_cmd *); 143 143 void transport_dump_dev_state(struct se_device *, char *, int *); 144 144 void transport_dump_dev_info(struct se_device *, struct se_lun *,
+3 -13
drivers/target/target_core_tmr.c
··· 75 75 kfree(tmr); 76 76 } 77 77 78 - static int core_tmr_handle_tas_abort(struct se_cmd *cmd, int tas) 79 - { 80 - bool send_tas = cmd->transport_state & CMD_T_TAS; 81 - 82 - if (send_tas) 83 - transport_send_task_abort(cmd); 84 - 85 - return transport_cmd_finish_abort(cmd, !send_tas); 86 - } 87 - 88 78 static int target_check_cdb_and_preempt(struct list_head *list, 89 79 struct se_cmd *cmd) 90 80 { ··· 173 183 cancel_work_sync(&se_cmd->work); 174 184 transport_wait_for_tasks(se_cmd); 175 185 176 - if (!transport_cmd_finish_abort(se_cmd, true)) 186 + if (!transport_cmd_finish_abort(se_cmd)) 177 187 target_put_sess_cmd(se_cmd); 178 188 179 189 printk("ABORT_TASK: Sending TMR_FUNCTION_COMPLETE for" ··· 271 281 cancel_work_sync(&cmd->work); 272 282 transport_wait_for_tasks(cmd); 273 283 274 - if (!transport_cmd_finish_abort(cmd, 1)) 284 + if (!transport_cmd_finish_abort(cmd)) 275 285 target_put_sess_cmd(cmd); 276 286 } 277 287 } ··· 360 370 cancel_work_sync(&cmd->work); 361 371 transport_wait_for_tasks(cmd); 362 372 363 - if (!core_tmr_handle_tas_abort(cmd, tas)) 373 + if (!transport_cmd_finish_abort(cmd)) 364 374 target_put_sess_cmd(cmd); 365 375 } 366 376 }
+7 -3
drivers/target/target_core_transport.c
··· 688 688 percpu_ref_put(&lun->lun_ref); 689 689 } 690 690 691 - int transport_cmd_finish_abort(struct se_cmd *cmd, int remove) 691 + int transport_cmd_finish_abort(struct se_cmd *cmd) 692 692 { 693 + bool send_tas = cmd->transport_state & CMD_T_TAS; 693 694 bool ack_kref = (cmd->se_cmd_flags & SCF_ACK_KREF); 694 695 int ret = 0; 696 + 697 + if (send_tas) 698 + transport_send_task_abort(cmd); 695 699 696 700 if (cmd->se_cmd_flags & SCF_SE_LUN_CMD) 697 701 transport_lun_remove_cmd(cmd); ··· 703 699 * Allow the fabric driver to unmap any resources before 704 700 * releasing the descriptor via TFO->release_cmd() 705 701 */ 706 - if (remove) 702 + if (!send_tas) 707 703 cmd->se_tfo->aborted_task(cmd); 708 704 709 705 if (transport_cmd_check_stop_to_fabric(cmd)) 710 706 return 1; 711 - if (remove && ack_kref) 707 + if (!send_tas && ack_kref) 712 708 ret = target_put_sess_cmd(cmd); 713 709 714 710 return ret;