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

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>

authored by

Bart Van Assche and committed by
Martin K. Petersen
fbbd4923 a014c364

+11 -20
+2
drivers/target/iscsi/iscsi_target_configfs.c
··· 1591 1591 .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs, 1592 1592 .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs, 1593 1593 .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs, 1594 + 1595 + .write_pending_must_be_called = true, 1594 1596 };
+2 -20
drivers/target/target_core_transport.c
··· 2584 2584 * Determine if frontend context caller is requesting the stopping of 2585 2585 * this command for frontend exceptions. 2586 2586 */ 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) { 2588 2589 pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08llx\n", 2589 2590 __func__, __LINE__, cmd->tag); 2590 2591 ··· 3298 3297 } 3299 3298 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 3300 3299 3301 - /* 3302 - * If there are still expected incoming fabric WRITEs, we wait 3303 - * until until they have completed before sending a TASK_ABORTED 3304 - * response. This response with TASK_ABORTED status will be 3305 - * queued back to fabric module by transport_check_aborted_status(). 3306 - */ 3307 - if (cmd->data_direction == DMA_TO_DEVICE) { 3308 - if (cmd->se_tfo->write_pending_status(cmd) != 0) { 3309 - spin_lock_irqsave(&cmd->t_state_lock, flags); 3310 - if (cmd->se_cmd_flags & SCF_SEND_DELAYED_TAS) { 3311 - spin_unlock_irqrestore(&cmd->t_state_lock, flags); 3312 - goto send_abort; 3313 - } 3314 - cmd->se_cmd_flags |= SCF_SEND_DELAYED_TAS; 3315 - spin_unlock_irqrestore(&cmd->t_state_lock, flags); 3316 - return; 3317 - } 3318 - } 3319 - send_abort: 3320 3300 cmd->scsi_status = SAM_STAT_TASK_ABORTED; 3321 3301 3322 3302 transport_lun_remove_cmd(cmd);
+7
include/target/target_core_fabric.h
··· 111 111 struct configfs_attribute **tfc_tpg_nacl_attrib_attrs; 112 112 struct configfs_attribute **tfc_tpg_nacl_auth_attrs; 113 113 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; 114 121 }; 115 122 116 123 int target_register_template(const struct target_core_fabric_ops *fo);