On Wed, 2017-02-08 at 14:24 -0800, Bart Van Assche wrote: > Whether or not a session is being torn down does not affect whether > or not SCSI commands are in the task set. Hence remove the "tearing > down" checks from the TMF code. The CMD_T_FABRIC_STOP test is left > out because it overlaps with the CMD_T_COMPLETE and kref tests. The > TRANSPORT_ISTATE_PROCESSING check is left out because it is now > safe to wait for a command that is in that state. > > Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx> > Reviewed-by: Hannes Reinecke <hare@xxxxxxxx> > Cc: Christoph Hellwig <hch@xxxxxx> > Cc: Andy Grover <agrover@xxxxxxxxxx> > Cc: David Disseldorp <ddiss@xxxxxxx> > --- > drivers/target/target_core_tmr.c | 30 ++++++------------------------ > 1 file changed, 6 insertions(+), 24 deletions(-) > > diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c > index 398526704001..e4c8ebbcb20c 100644 > --- a/drivers/target/target_core_tmr.c > +++ b/drivers/target/target_core_tmr.c > @@ -98,9 +98,8 @@ static bool __target_check_io_state(struct se_cmd *se_cmd, > assert_spin_locked(&sess->sess_cmd_lock); > WARN_ON_ONCE(!irqs_disabled()); > /* > - * If command already reached CMD_T_COMPLETE state within > - * target_complete_cmd() or CMD_T_FABRIC_STOP due to shutdown, > - * this se_cmd has been passed to fabric driver and will > + * If a command has already reached the CMD_T_COMPLETE state, > + * it has already been passed to the fabric driver and will > * not be aborted. > * > * Otherwise, obtain a local se_cmd->cmd_kref now for TMR > @@ -108,15 +107,9 @@ static bool __target_check_io_state(struct se_cmd *se_cmd, > * long as se_cmd->cmd_kref is still active unless zero. > */ > spin_lock(&se_cmd->t_state_lock); > - if (se_cmd->transport_state & (CMD_T_COMPLETE | CMD_T_FABRIC_STOP)) { > - pr_debug("Attempted to abort io tag: %llu already complete or" > - " fabric stop, skipping\n", se_cmd->tag); > - spin_unlock(&se_cmd->t_state_lock); > - return false; > - } > - if (sess->sess_tearing_down) { > - pr_debug("Attempted to abort io tag: %llu already shutdown," > - " skipping\n", se_cmd->tag); > + if (se_cmd->transport_state & CMD_T_COMPLETE) { > + pr_debug("Response for command with tag %llu is being sent to initiator, skipping\n", > + se_cmd->tag); > spin_unlock(&se_cmd->t_state_lock); > return false; > } The removal of this breaks the second order case I've mentioned at the top of patch #18. That is, while CMD_T_ABORTED is going on, fabric drivers must be able to handle a session reinstatement that forces all se_cmd descriptors into a quiesce state. Getting rid of CMD_T_FABRIC_STOP here prevents session shutdown code from knowing when commands are actively being CMD_T_ABORTED. > @@ -235,18 +228,7 @@ static void core_tmr_drain_tmr_list( > > spin_lock(&sess->sess_cmd_lock); > spin_lock(&cmd->t_state_lock); > - if (!(cmd->transport_state & CMD_T_ACTIVE) || > - (cmd->transport_state & CMD_T_FABRIC_STOP)) { > - spin_unlock(&cmd->t_state_lock); > - spin_unlock(&sess->sess_cmd_lock); > - continue; > - } > - if (cmd->t_state == TRANSPORT_ISTATE_PROCESSING) { > - spin_unlock(&cmd->t_state_lock); > - spin_unlock(&sess->sess_cmd_lock); > - continue; > - } > - if (sess->sess_tearing_down) { > + if (!(cmd->transport_state & CMD_T_ACTIVE)) { > spin_unlock(&cmd->t_state_lock); > spin_unlock(&sess->sess_cmd_lock); > continue; Likewise here. There are cases when a TMR cannot be aborted. Like once it's been stopped during session shutdown quiesce, and once it's already been queued into se_device->tmr_wq (eg: TRANSPORT_ISTATE_PROCESSING) it must be allowed to proceed. -- 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