On Thu, 2017-02-09 at 17:28 -0800, Bart Van Assche wrote: > target_submit_tmr() only supports the I_T_L nexus for SCSI abort > and other task management functions. Make it possible for target > drivers to specify I_T nexus for SCSI abort by passing the > TARGET_SCF_IGNORE_TMR_LUN flag to target_submit_tmr(). > > Note: although several SCSI transport layers require in-order > processing of TMFs per session, using schedule_work() does not > introduce any new potential reordering. Since TMFs that originate > from a single session can be queued onto different backend > device workqueues there is already a potential for reordering. > > Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx> > Reviewed-by: Hannes Reinecke <hare@xxxxxxxx> > Reviewed-by: Christoph Hellwig <hch@xxxxxx> > Cc: Himanshu Madhani <himanshu.madhani@xxxxxxxxxx> > Cc: Giridhar Malavali <giridhar.malavali@xxxxxxxxxx> > --- > drivers/target/target_core_tmr.c | 9 ++++++++- > drivers/target/target_core_transport.c | 23 +++++++++++++++++------ > include/target/target_core_base.h | 1 + > 3 files changed, 26 insertions(+), 7 deletions(-) > > diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c > index 311dc3c2f1dc..3330775aa47a 100644 > --- a/drivers/target/target_core_tmr.c > +++ b/drivers/target/target_core_tmr.c > @@ -149,6 +149,13 @@ static bool __target_check_io_state(struct se_cmd *se_cmd, > return kref_get_unless_zero(&se_cmd->cmd_kref); > } > > +/** > + * core_tmr_abort_task - abort a SCSI command > + * @dev: LUN specified in task management function or NULL if no LUN has been > + * specified. > + * @tmr: Task management function. > + * @se_sess: Session a.k.a. I_T nexus. > + */ > void core_tmr_abort_task( > struct se_device *dev, > struct se_tmr_req *tmr, > @@ -161,7 +168,7 @@ void core_tmr_abort_task( > spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); > list_for_each_entry(se_cmd, &se_sess->sess_cmd_list, se_cmd_list) { > > - if (dev != se_cmd->se_dev) > + if (dev && dev != se_cmd->se_dev) > continue; > > /* skip task management functions, including tmr->task_cmd */ > diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c > index 22190003534d..4e233c0f5f68 100644 > --- a/drivers/target/target_core_transport.c > +++ b/drivers/target/target_core_transport.c > @@ -1577,18 +1577,18 @@ static void target_complete_tmr_failure(struct work_struct *work) > } > > /** > - * target_submit_tmr - lookup unpacked lun and submit uninitialized se_cmd > - * for TMR CDBs > + * target_submit_tmr - submit a SCSI task management function to the target core > * > * @se_cmd: command descriptor to submit > * @se_sess: associated se_sess for endpoint > * @sense: pointer to SCSI sense buffer > - * @unpacked_lun: unpacked LUN to reference for struct se_lun > + * @unpacked_lun: LUN the TMR applies to. Ignored if TARGET_SCF_IGNORE_TMR_LUN > + * has been set in @flags. > * @fabric_context: fabric context for TMR req > * @tm_type: Type of TM request > * @gfp: gfp type for caller > * @tag: referenced task tag for TMR_ABORT_TASK > - * @flags: submit cmd flags > + * @flags: submit cmd flags (TARGET_SCF_*). > * > * Callable from all contexts. > **/ > @@ -1624,7 +1624,14 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, > return ret; > } > > - ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun); > + if (flags & TARGET_SCF_IGNORE_TMR_LUN) { > + WARN_ON_ONCE(tm_type != TMR_ABORT_TASK); > + se_cmd->se_lun = NULL; > + se_cmd->se_dev = NULL; > + se_cmd->se_tmr_req->tmr_dev = NULL; > + } else { > + ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun); > + } > if (ret) { > /* > * For callback during failure handling, push this work off > @@ -1634,6 +1641,7 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, > schedule_work(&se_cmd->work); > return 0; > } > + WARN_ON_ONCE(tm_type != TMR_ABORT_TASK && !se_cmd->se_dev); > transport_generic_handle_tmr(se_cmd); > return 0; > } > @@ -3147,7 +3155,10 @@ int transport_generic_handle_tmr( > } > > INIT_WORK(&cmd->work, target_tmr_work); > - queue_work(cmd->se_dev->tmr_wq, &cmd->work); > + if (cmd->se_dev) > + queue_work(cmd->se_dev->tmr_wq, &cmd->work); > + else > + schedule_work(&cmd->work); > return 0; > } > EXPORT_SYMBOL(transport_generic_handle_tmr); The -v4 patch was using doing a lun lookup from within core_tmr_abort_task() when !se_tmr->tmr_dev that could trigger a deadlock. But this patch doesn't seem to do any lookup at all for TARGET_SCF_IGNORE_TMR_LUN when !se_tmr->tmr_dev..? Is that correct..? -- 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