target/core: Make ABORT and LUN RESET handling synchronous
PATCH 11/17 target/core: Make ABORT and LUN RESET handling synchronous
Instead of invoking target driver callback functions from the context that handles an abort or LUN RESET task management function, only set the abort flag from that context and perform the actual abort handling from the context of the regular command processing flow. This approach has the following advantages:
- The task management function code becomes much easier to read and to verify since the number of potential race conditions against the command processing flow is strongly reduced.
- It is no longer needed to store the command state into the command itself since that information is no longer needed from the context where a task management function is processed.
Notes:
- With this patch applied for SCSI commands the CMD_T_ABORTED flag is checked at two stages by the target core during command execution:
just before local execution of a command starts (see also target_execute_cmd()) and also just before the response is sent (see also target_complete_cmd()).
- The SCF_SEND_DELAYED_TAS has been removed. This flag was used to make the second transport_check_aborted_status() call send the command status back to the initiator. The new approach is that the CMD_T_ABORTED flag is checked from inside target_complete_cmd(). If that flag is set when that function is called, appropriate action is taken - either send the TASK ABORTED status back to the initiator or abort the command without sending a response.
--- drivers/target/target_core_internal.h | 2 - drivers/target/target_core_tmr.c | 49 ++-- drivers/target/target_core_transport.c | 304 ++++++++++--------------- include/target/target_core_base.h | 1 - include/target/target_core_fabric.h | 1 + 5 files changed, 153 insertions(+), 204 deletions(-)
drivers/target/target_core_internal.h +0 -2
@@ -138,7 +138,6 @@ int init_se_kmem_caches(void);void release_se_kmem_caches (void );u32 scsi_get_new_index (scsi_index_t );void transport_subsystem_check_init (void ); -int transport_cmd_finish_abort (struct se_cmd *);unsigned char *transport_dump_cmd_direction (struct se_cmd *);void transport_dump_dev_state (struct se_device *,char *,int *); void transport_dump_dev_info(struct se_device *, struct se_lun *,
@@ -148,7 +147,6 @@ int transport_dump_vpd_assoc(struct t10_vpd *, unsigned char *, int);int transport_dump_vpd_ident_type (struct t10_vpd *,unsigned char *,int );int transport_dump_vpd_ident (struct t10_vpd *,unsigned char *,int );void transport_clear_lun_ref (struct se_lun *); -void transport_send_task_abort (struct se_cmd *);sense_reason_t target_cmd_size_check (struct se_cmd *cmd,unsigned int size);void target_qf_do_work (struct work_struct *work);bool target_check_wce (struct se_device *dev);
drivers/target/target_core_tmr.c +28 -21
71 lines not on this page · raw message
drivers/target/target_core_transport.c +124 -180
418 lines not on this page · raw message
include/target/target_core_base.h +0 -1
@@ -134,7 +134,6 @@ enum se_cmd_flags_table {SCF_SENT_CHECK_CONDITION =0x00000800 ,SCF_OVERFLOW_BIT =0x00001000 ,SCF_UNDERFLOW_BIT =0x00002000 , -SCF_SEND_DELAYED_TAS =0x00004000 ,SCF_ALUA_NON_OPTIMIZED =0x00008000 ,SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC =0x00020000 , SCF_COMPARE_AND_WRITE = 0x00080000,
include/target/target_core_fabric.h +1 -0
@@ -149,6 +149,7 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,int transport_handle_cdb_direct (struct se_cmd *);sense_reason_t transport_generic_new_cmd (struct se_cmd *); +void target_put_cmd_and_wait (struct se_cmd *cmd);void target_execute_cmd (struct se_cmd *cmd);int transport_generic_free_cmd (struct se_cmd *,int );
Signature · 1 line
2.18.0