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(). Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx> Cc: Himanshu Madhani <himanshu.madhani@xxxxxxxxxx> Cc: Giridhar Malavali <giridhar.malavali@xxxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> --- drivers/target/target_core_device.c | 7 +++++++ drivers/target/target_core_tmr.c | 13 ++++++++++++- drivers/target/target_core_transport.c | 13 ++++++++----- include/target/target_core_base.h | 2 ++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 9d55e9fe7857..9ee8d387202a 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -160,6 +160,13 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u64 unpacked_lun) struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; unsigned long flags; + if (se_cmd->se_cmd_flags & SCF_IGNORE_TMR_LUN) { + se_cmd->se_lun = NULL; + se_cmd->se_dev = NULL; + se_tmr->tmr_dev = NULL; + return 0; + } + rcu_read_lock(); deve = target_nacl_find_deve(nacl, unpacked_lun); if (deve) { diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 311dc3c2f1dc..6f9ec58e02c7 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 */ @@ -178,6 +185,10 @@ void core_tmr_abort_task( if (!__target_check_io_state(se_cmd, se_sess, 0)) continue; + if (!dev && transport_lookup_tmr_lun(tmr->task_cmd, + se_cmd->orig_fe_lun) < 0) + continue; + list_del_init(&se_cmd->se_cmd_list); spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 1cadc9eefa21..4938e1dde45a 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1584,18 +1584,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. **/ @@ -1613,6 +1613,8 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, 0, DMA_NONE, TCM_SIMPLE_TAG, sense); + if (flags & TARGET_SCF_IGNORE_TMR_LUN) + se_cmd->se_cmd_flags |= SCF_IGNORE_TMR_LUN; /* * FIXME: Currently expect caller to handle se_cmd->se_tmr_req * allocation failure. @@ -3060,7 +3062,8 @@ void transport_send_task_abort(struct se_cmd *cmd) static void target_tmr_work(struct work_struct *work) { struct se_cmd *cmd = container_of(work, struct se_cmd, work); - struct se_device *dev = cmd->se_dev; + struct se_device *dev = + cmd->se_cmd_flags & SCF_IGNORE_TMR_LUN ? NULL : cmd->se_dev; struct se_tmr_req *tmr = cmd->se_tmr_req; unsigned long flags; int ret; diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index fc52207e8076..7255cfbef17b 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -139,6 +139,7 @@ enum se_cmd_flags_table { SCF_ACK_KREF = 0x00400000, SCF_USE_CPUID = 0x00800000, SCF_TASK_ATTR_SET = 0x01000000, + SCF_IGNORE_TMR_LUN = 0x02000000, }; /* @@ -186,6 +187,7 @@ enum target_sc_flags_table { TARGET_SCF_ACK_KREF = 0x02, TARGET_SCF_UNKNOWN_SIZE = 0x04, TARGET_SCF_USE_CPUID = 0x08, + TARGET_SCF_IGNORE_TMR_LUN = 0x16, }; /* fabric independent task management function values */ -- 2.11.0 ��.n��������+%������w��{.n����j�����{ay�ʇڙ���f���h������_�(�階�ݢj"��������G����?���&��