Skip to content

Commit fbbd492

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: target/core: Simplify the code for aborting SCSI commands
Instead of allowing the code that aborts a SCSI command to finish before all iSCSI data frames have been received, make that code wait until all iSCSI data frames have been received. Introduce a new member variable in the target driver template to communicate that information from the iSCSI target driver to the target core. This change allows to leave out the check whether or not it is already safe to send the TASK_ABORTED reply from transport_send_task_abort(). Cc: Nicholas Bellinger <nab@linux-iscsi.org> Cc: Mike Christie <mchristi@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: David Disseldorp <ddiss@suse.de> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent a014c36 commit fbbd492

3 files changed

Lines changed: 11 additions & 20 deletions

File tree

‎drivers/target/iscsi/iscsi_target_configfs.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,4 +1591,6 @@ const struct target_core_fabric_ops iscsi_ops = {
15911591
.tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs,
15921592
.tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs,
15931593
.tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs,
1594+
1595+
.write_pending_must_be_called = true,
15941596
};

‎drivers/target/target_core_transport.c‎

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,7 +2584,8 @@ transport_generic_new_cmd(struct se_cmd *cmd)
25842584
* Determine if frontend context caller is requesting the stopping of
25852585
* this command for frontend exceptions.
25862586
*/
2587-
if (cmd->transport_state & CMD_T_STOP) {
2587+
if (cmd->transport_state & CMD_T_STOP &&
2588+
!cmd->se_tfo->write_pending_must_be_called) {
25882589
pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08llx\n",
25892590
__func__, __LINE__, cmd->tag);
25902591

@@ -3297,25 +3298,6 @@ void transport_send_task_abort(struct se_cmd *cmd)
32973298
}
32983299
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
32993300

3300-
/*
3301-
* If there are still expected incoming fabric WRITEs, we wait
3302-
* until until they have completed before sending a TASK_ABORTED
3303-
* response. This response with TASK_ABORTED status will be
3304-
* queued back to fabric module by transport_check_aborted_status().
3305-
*/
3306-
if (cmd->data_direction == DMA_TO_DEVICE) {
3307-
if (cmd->se_tfo->write_pending_status(cmd) != 0) {
3308-
spin_lock_irqsave(&cmd->t_state_lock, flags);
3309-
if (cmd->se_cmd_flags & SCF_SEND_DELAYED_TAS) {
3310-
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
3311-
goto send_abort;
3312-
}
3313-
cmd->se_cmd_flags |= SCF_SEND_DELAYED_TAS;
3314-
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
3315-
return;
3316-
}
3317-
}
3318-
send_abort:
33193301
cmd->scsi_status = SAM_STAT_TASK_ABORTED;
33203302

33213303
transport_lun_remove_cmd(cmd);

‎include/target/target_core_fabric.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ struct target_core_fabric_ops {
111111
struct configfs_attribute **tfc_tpg_nacl_attrib_attrs;
112112
struct configfs_attribute **tfc_tpg_nacl_auth_attrs;
113113
struct configfs_attribute **tfc_tpg_nacl_param_attrs;
114+
115+
/*
116+
* Set this member variable to true if the SCSI transport protocol
117+
* (e.g. iSCSI) requires that the Data-Out buffer is transferred in
118+
* its entirety before a command is aborted.
119+
*/
120+
bool write_pending_must_be_called;
114121
};
115122

116123
int target_register_template(const struct target_core_fabric_ops *fo);

0 commit comments

Comments
 (0)