Commit 6d2fa9e1 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending

Pull SCSI target updates from Nicholas Bellinger:
 "Lots of activity this round on performance improvements in target-core
  while benchmarking the prototype scsi-mq initiator code with
  vhost-scsi fabric ports, along with a number of iscsi/iser-target
  improvements and hardening fixes for exception path cases post v3.10
  merge.

  The highlights include:

   - Make persistent reservations APTPL buffer allocated on-demand, and
     drop per t10_reservation buffer.  (grover)
   - Make virtual LUN=0 a NULLIO device, and skip allocation of NULLIO
     device pages (grover)
   - Add transport_cmd_check_stop write_pending bit to avoid extra
     access of ->t_state_lock is WRITE I/O submission fast-path.  (nab)
   - Drop unnecessary CMD_T_DEV_ACTIVE check from
     transport_lun_remove_cmd to avoid extra access of ->t_state_lock in
     release fast-path.  (nab)
   - Avoid extra t_state_lock access in __target_execute_cmd fast-path
     (nab)
   - Drop unnecessary vhost-scsi wait_for_tasks=true usage +
     ->t_state_lock access in release fast-path.  (nab)
   - Convert vhost-scsi to use modern se_cmd->cmd_kref
     TARGET_SCF_ACK_KREF usage (nab)
   - Add tracepoints for SCSI commands being processed (roland)
   - Refactoring of iscsi-target handling of ISCSI_OP_NOOP +
     ISCSI_OP_TEXT to be transport independent (nab)
   - Add iscsi-target SendTargets=$IQN support for in-band discovery
     (nab)
   - Add iser-target support for in-band discovery (nab + Or)
   - Add iscsi-target demo-mode TPG authentication context support (nab)
   - Fix isert_put_reject payload buffer post (nab)
   - Fix iscsit_add_reject* usage for iser (nab)
   - Fix iscsit_sequence_cmd reject handling for iser (nab)
   - Fix ISCSI_OP_SCSI_TMFUNC handling for iser (nab)
   - Fix session reset bug with RDMA_CM_EVENT_DISCONNECTED (nab)

  The last five iscsi/iser-target items are CC'ed to stable, as they do
  address issues present in v3.10 code.  They are certainly larger than
  I'd like for stable patch set, but are important to ensure proper
  REJECT exception handling in iser-target for 3.10.y"

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (51 commits)
  iser-target: Ignore non TEXT + LOGOUT opcodes for discovery
  target: make queue_tm_rsp() return void
  target: remove unused codes from enum tcm_tmrsp_table
  iscsi-target: kstrtou* configfs attribute parameter cleanups
  iscsi-target: Fix tfc_tpg_auth_cit configfs length overflow
  iscsi-target: Fix tfc_tpg_nacl_auth_cit configfs length overflow
  iser-target: Add support for ISCSI_OP_TEXT opcode + payload handling
  iser-target: Rename sense_buf_[dma,len] to pdu_[dma,len]
  iser-target: Add vendor_err debug output
  target: Add (obsolete) checking for PMI/LBA fields in READ CAPACITY(10)
  target: Return correct sense data for IO past the end of a device
  target: Add tracepoints for SCSI commands being processed
  iser-target: Fix session reset bug with RDMA_CM_EVENT_DISCONNECTED
  iscsi-target: Fix ISCSI_OP_SCSI_TMFUNC handling for iser
  iscsi-target: Fix iscsit_sequence_cmd reject handling for iser
  iscsi-target: Fix iscsit_add_reject* usage for iser
  iser-target: Fix isert_put_reject payload buffer post
  iscsi-target: missing kfree() on error path
  iscsi-target: Drop left-over iscsi_conn->bad_hdr
  target: Make core_scsi3_update_and_write_aptpl return sense_reason_t
  ...
parents 0fb3767b ca40d24e
This diff is collapsed.
...@@ -61,8 +61,8 @@ struct isert_cmd { ...@@ -61,8 +61,8 @@ struct isert_cmd {
uint32_t write_stag; uint32_t write_stag;
uint64_t read_va; uint64_t read_va;
uint64_t write_va; uint64_t write_va;
u64 sense_buf_dma; u64 pdu_buf_dma;
u32 sense_buf_len; u32 pdu_buf_len;
u32 read_va_off; u32 read_va_off;
u32 write_va_off; u32 write_va_off;
u32 rdma_wr_num; u32 rdma_wr_num;
...@@ -102,6 +102,7 @@ struct isert_conn { ...@@ -102,6 +102,7 @@ struct isert_conn {
struct ib_qp *conn_qp; struct ib_qp *conn_qp;
struct isert_device *conn_device; struct isert_device *conn_device;
struct work_struct conn_logout_work; struct work_struct conn_logout_work;
struct mutex conn_mutex;
wait_queue_head_t conn_wait; wait_queue_head_t conn_wait;
wait_queue_head_t conn_wait_comp_err; wait_queue_head_t conn_wait_comp_err;
struct kref conn_kref; struct kref conn_kref;
......
...@@ -3011,7 +3011,7 @@ static u8 tcm_to_srp_tsk_mgmt_status(const int tcm_mgmt_status) ...@@ -3011,7 +3011,7 @@ static u8 tcm_to_srp_tsk_mgmt_status(const int tcm_mgmt_status)
* Callback function called by the TCM core. Must not block since it can be * Callback function called by the TCM core. Must not block since it can be
* invoked on the context of the IB completion handler. * invoked on the context of the IB completion handler.
*/ */
static int srpt_queue_response(struct se_cmd *cmd) static void srpt_queue_response(struct se_cmd *cmd)
{ {
struct srpt_rdma_ch *ch; struct srpt_rdma_ch *ch;
struct srpt_send_ioctx *ioctx; struct srpt_send_ioctx *ioctx;
...@@ -3022,8 +3022,6 @@ static int srpt_queue_response(struct se_cmd *cmd) ...@@ -3022,8 +3022,6 @@ static int srpt_queue_response(struct se_cmd *cmd)
int resp_len; int resp_len;
u8 srp_tm_status; u8 srp_tm_status;
ret = 0;
ioctx = container_of(cmd, struct srpt_send_ioctx, cmd); ioctx = container_of(cmd, struct srpt_send_ioctx, cmd);
ch = ioctx->ch; ch = ioctx->ch;
BUG_ON(!ch); BUG_ON(!ch);
...@@ -3049,7 +3047,7 @@ static int srpt_queue_response(struct se_cmd *cmd) ...@@ -3049,7 +3047,7 @@ static int srpt_queue_response(struct se_cmd *cmd)
|| WARN_ON_ONCE(state == SRPT_STATE_CMD_RSP_SENT))) { || WARN_ON_ONCE(state == SRPT_STATE_CMD_RSP_SENT))) {
atomic_inc(&ch->req_lim_delta); atomic_inc(&ch->req_lim_delta);
srpt_abort_cmd(ioctx); srpt_abort_cmd(ioctx);
goto out; return;
} }
dir = ioctx->cmd.data_direction; dir = ioctx->cmd.data_direction;
...@@ -3061,7 +3059,7 @@ static int srpt_queue_response(struct se_cmd *cmd) ...@@ -3061,7 +3059,7 @@ static int srpt_queue_response(struct se_cmd *cmd)
if (ret) { if (ret) {
printk(KERN_ERR "xfer_data failed for tag %llu\n", printk(KERN_ERR "xfer_data failed for tag %llu\n",
ioctx->tag); ioctx->tag);
goto out; return;
} }
} }
...@@ -3082,9 +3080,17 @@ static int srpt_queue_response(struct se_cmd *cmd) ...@@ -3082,9 +3080,17 @@ static int srpt_queue_response(struct se_cmd *cmd)
srpt_set_cmd_state(ioctx, SRPT_STATE_DONE); srpt_set_cmd_state(ioctx, SRPT_STATE_DONE);
target_put_sess_cmd(ioctx->ch->sess, &ioctx->cmd); target_put_sess_cmd(ioctx->ch->sess, &ioctx->cmd);
} }
}
out: static int srpt_queue_data_in(struct se_cmd *cmd)
return ret; {
srpt_queue_response(cmd);
return 0;
}
static void srpt_queue_tm_rsp(struct se_cmd *cmd)
{
srpt_queue_response(cmd);
} }
static int srpt_queue_status(struct se_cmd *cmd) static int srpt_queue_status(struct se_cmd *cmd)
...@@ -3097,7 +3103,8 @@ static int srpt_queue_status(struct se_cmd *cmd) ...@@ -3097,7 +3103,8 @@ static int srpt_queue_status(struct se_cmd *cmd)
(SCF_TRANSPORT_TASK_SENSE | SCF_EMULATED_TASK_SENSE)) (SCF_TRANSPORT_TASK_SENSE | SCF_EMULATED_TASK_SENSE))
WARN_ON(cmd->scsi_status != SAM_STAT_CHECK_CONDITION); WARN_ON(cmd->scsi_status != SAM_STAT_CHECK_CONDITION);
ioctx->queue_status_only = true; ioctx->queue_status_only = true;
return srpt_queue_response(cmd); srpt_queue_response(cmd);
return 0;
} }
static void srpt_refresh_port_work(struct work_struct *work) static void srpt_refresh_port_work(struct work_struct *work)
...@@ -3930,9 +3937,9 @@ static struct target_core_fabric_ops srpt_template = { ...@@ -3930,9 +3937,9 @@ static struct target_core_fabric_ops srpt_template = {
.set_default_node_attributes = srpt_set_default_node_attrs, .set_default_node_attributes = srpt_set_default_node_attrs,
.get_task_tag = srpt_get_task_tag, .get_task_tag = srpt_get_task_tag,
.get_cmd_state = srpt_get_tcm_cmd_state, .get_cmd_state = srpt_get_tcm_cmd_state,
.queue_data_in = srpt_queue_response, .queue_data_in = srpt_queue_data_in,
.queue_status = srpt_queue_status, .queue_status = srpt_queue_status,
.queue_tm_rsp = srpt_queue_response, .queue_tm_rsp = srpt_queue_tm_rsp,
/* /*
* Setup function pointers for generic logic in * Setup function pointers for generic logic in
* target_core_fabric_configfs.c * target_core_fabric_configfs.c
......
...@@ -544,102 +544,6 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id, ...@@ -544,102 +544,6 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id,
return res; return res;
} }
static bool qlt_check_fcport_exist(struct scsi_qla_host *vha,
struct qla_tgt_sess *sess)
{
struct qla_hw_data *ha = vha->hw;
struct qla_port_24xx_data *pmap24;
bool res, found = false;
int rc, i;
uint16_t loop_id = 0xFFFF; /* to eliminate compiler's warning */
uint16_t entries;
void *pmap;
int pmap_len;
fc_port_t *fcport;
int global_resets;
unsigned long flags;
retry:
global_resets = atomic_read(&ha->tgt.qla_tgt->tgt_global_resets_count);
rc = qla2x00_get_node_name_list(vha, &pmap, &pmap_len);
if (rc != QLA_SUCCESS) {
res = false;
goto out;
}
pmap24 = pmap;
entries = pmap_len/sizeof(*pmap24);
for (i = 0; i < entries; ++i) {
if (!memcmp(sess->port_name, pmap24[i].port_name, WWN_SIZE)) {
loop_id = le16_to_cpu(pmap24[i].loop_id);
found = true;
break;
}
}
kfree(pmap);
if (!found) {
res = false;
goto out;
}
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf046,
"qlt_check_fcport_exist(): loop_id %d", loop_id);
fcport = kzalloc(sizeof(*fcport), GFP_KERNEL);
if (fcport == NULL) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf047,
"qla_target(%d): Allocation of tmp FC port failed",
vha->vp_idx);
res = false;
goto out;
}
fcport->loop_id = loop_id;
rc = qla2x00_get_port_database(vha, fcport, 0);
if (rc != QLA_SUCCESS) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf048,
"qla_target(%d): Failed to retrieve fcport "
"information -- get_port_database() returned %x "
"(loop_id=0x%04x)", vha->vp_idx, rc, loop_id);
res = false;
goto out_free_fcport;
}
if (global_resets !=
atomic_read(&ha->tgt.qla_tgt->tgt_global_resets_count)) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf002,
"qla_target(%d): global reset during session discovery"
" (counter was %d, new %d), retrying",
vha->vp_idx, global_resets,
atomic_read(&ha->tgt.qla_tgt->tgt_global_resets_count));
goto retry;
}
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf003,
"Updating sess %p s_id %x:%x:%x, loop_id %d) to d_id %x:%x:%x, "
"loop_id %d", sess, sess->s_id.b.domain, sess->s_id.b.al_pa,
sess->s_id.b.area, sess->loop_id, fcport->d_id.b.domain,
fcport->d_id.b.al_pa, fcport->d_id.b.area, fcport->loop_id);
spin_lock_irqsave(&ha->hardware_lock, flags);
ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id,
(fcport->flags & FCF_CONF_COMP_SUPPORTED));
spin_unlock_irqrestore(&ha->hardware_lock, flags);
res = true;
out_free_fcport:
kfree(fcport);
out:
return res;
}
/* ha->hardware_lock supposed to be held on entry */ /* ha->hardware_lock supposed to be held on entry */
static void qlt_undelete_sess(struct qla_tgt_sess *sess) static void qlt_undelete_sess(struct qla_tgt_sess *sess)
{ {
...@@ -663,43 +567,13 @@ static void qlt_del_sess_work_fn(struct delayed_work *work) ...@@ -663,43 +567,13 @@ static void qlt_del_sess_work_fn(struct delayed_work *work)
sess = list_entry(tgt->del_sess_list.next, typeof(*sess), sess = list_entry(tgt->del_sess_list.next, typeof(*sess),
del_list_entry); del_list_entry);
if (time_after_eq(jiffies, sess->expires)) { if (time_after_eq(jiffies, sess->expires)) {
bool cancel;
qlt_undelete_sess(sess); qlt_undelete_sess(sess);
spin_unlock_irqrestore(&ha->hardware_lock, flags); ql_dbg(ql_dbg_tgt_mgt, vha, 0xf004,
cancel = qlt_check_fcport_exist(vha, sess); "Timeout: sess %p about to be deleted\n",
sess);
if (cancel) { ha->tgt.tgt_ops->shutdown_sess(sess);
if (sess->deleted) { ha->tgt.tgt_ops->put_sess(sess);
/*
* sess was again deleted while we were
* discovering it
*/
spin_lock_irqsave(&ha->hardware_lock,
flags);
continue;
}
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf049,
"qla_target(%d): cancel deletion of "
"session for port %02x:%02x:%02x:%02x:%02x:"
"%02x:%02x:%02x (loop ID %d), because "
" it isn't deleted by firmware",
vha->vp_idx, sess->port_name[0],
sess->port_name[1], sess->port_name[2],
sess->port_name[3], sess->port_name[4],
sess->port_name[5], sess->port_name[6],
sess->port_name[7], sess->loop_id);
} else {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf004,
"Timeout: sess %p about to be deleted\n",
sess);
ha->tgt.tgt_ops->shutdown_sess(sess);
ha->tgt.tgt_ops->put_sess(sess);
}
spin_lock_irqsave(&ha->hardware_lock, flags);
} else { } else {
schedule_delayed_work(&tgt->sess_del_work, schedule_delayed_work(&tgt->sess_del_work,
jiffies - sess->expires); jiffies - sess->expires);
...@@ -884,9 +758,8 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -884,9 +758,8 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport)
sess->loop_id); sess->loop_id);
sess->local = 0; sess->local = 0;
} }
spin_unlock_irqrestore(&ha->hardware_lock, flags);
ha->tgt.tgt_ops->put_sess(sess); ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
} }
void qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport) void qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport)
...@@ -2706,7 +2579,9 @@ static void qlt_do_work(struct work_struct *work) ...@@ -2706,7 +2579,9 @@ static void qlt_do_work(struct work_struct *work)
/* /*
* Drop extra session reference from qla_tgt_handle_cmd_for_atio*( * Drop extra session reference from qla_tgt_handle_cmd_for_atio*(
*/ */
spin_lock_irqsave(&ha->hardware_lock, flags);
ha->tgt.tgt_ops->put_sess(sess); ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
return; return;
out_term: out_term:
...@@ -2718,9 +2593,9 @@ static void qlt_do_work(struct work_struct *work) ...@@ -2718,9 +2593,9 @@ static void qlt_do_work(struct work_struct *work)
spin_lock_irqsave(&ha->hardware_lock, flags); spin_lock_irqsave(&ha->hardware_lock, flags);
qlt_send_term_exchange(vha, NULL, &cmd->atio, 1); qlt_send_term_exchange(vha, NULL, &cmd->atio, 1);
kmem_cache_free(qla_tgt_cmd_cachep, cmd); kmem_cache_free(qla_tgt_cmd_cachep, cmd);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
if (sess) if (sess)
ha->tgt.tgt_ops->put_sess(sess); ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
} }
/* ha->hardware_lock supposed to be held on entry */ /* ha->hardware_lock supposed to be held on entry */
...@@ -4169,16 +4044,16 @@ static void qlt_abort_work(struct qla_tgt *tgt, ...@@ -4169,16 +4044,16 @@ static void qlt_abort_work(struct qla_tgt *tgt,
rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess); rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess);
if (rc != 0) if (rc != 0)
goto out_term; goto out_term;
spin_unlock_irqrestore(&ha->hardware_lock, flags);
ha->tgt.tgt_ops->put_sess(sess); ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
return; return;
out_term: out_term:
qlt_24xx_send_abts_resp(vha, &prm->abts, FCP_TMF_REJECTED, false); qlt_24xx_send_abts_resp(vha, &prm->abts, FCP_TMF_REJECTED, false);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
if (sess) if (sess)
ha->tgt.tgt_ops->put_sess(sess); ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
} }
static void qlt_tmr_work(struct qla_tgt *tgt, static void qlt_tmr_work(struct qla_tgt *tgt,
...@@ -4226,16 +4101,16 @@ static void qlt_tmr_work(struct qla_tgt *tgt, ...@@ -4226,16 +4101,16 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
rc = qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0); rc = qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0);
if (rc != 0) if (rc != 0)
goto out_term; goto out_term;
spin_unlock_irqrestore(&ha->hardware_lock, flags);
ha->tgt.tgt_ops->put_sess(sess); ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
return; return;
out_term: out_term:
qlt_send_term_exchange(vha, NULL, &prm->tm_iocb2, 1); qlt_send_term_exchange(vha, NULL, &prm->tm_iocb2, 1);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
if (sess) if (sess)
ha->tgt.tgt_ops->put_sess(sess); ha->tgt.tgt_ops->put_sess(sess);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
} }
static void qlt_sess_work_fn(struct work_struct *work) static void qlt_sess_work_fn(struct work_struct *work)
......
...@@ -703,7 +703,7 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) ...@@ -703,7 +703,7 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd)
return qlt_xmit_response(cmd, xmit_type, se_cmd->scsi_status); return qlt_xmit_response(cmd, xmit_type, se_cmd->scsi_status);
} }
static int tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd) static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
{ {
struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; struct se_tmr_req *se_tmr = se_cmd->se_tmr_req;
struct qla_tgt_mgmt_cmd *mcmd = container_of(se_cmd, struct qla_tgt_mgmt_cmd *mcmd = container_of(se_cmd,
...@@ -735,8 +735,6 @@ static int tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd) ...@@ -735,8 +735,6 @@ static int tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
* CTIO response packet. * CTIO response packet.
*/ */
qlt_xmit_tm_rsp(mcmd); qlt_xmit_tm_rsp(mcmd);
return 0;
} }
/* Local pointer to allocated TCM configfs fabric module */ /* Local pointer to allocated TCM configfs fabric module */
...@@ -799,12 +797,14 @@ static void tcm_qla2xxx_put_session(struct se_session *se_sess) ...@@ -799,12 +797,14 @@ static void tcm_qla2xxx_put_session(struct se_session *se_sess)
static void tcm_qla2xxx_put_sess(struct qla_tgt_sess *sess) static void tcm_qla2xxx_put_sess(struct qla_tgt_sess *sess)
{ {
tcm_qla2xxx_put_session(sess->se_sess); assert_spin_locked(&sess->vha->hw->hardware_lock);
kref_put(&sess->se_sess->sess_kref, tcm_qla2xxx_release_session);
} }
static void tcm_qla2xxx_shutdown_sess(struct qla_tgt_sess *sess) static void tcm_qla2xxx_shutdown_sess(struct qla_tgt_sess *sess)
{ {
tcm_qla2xxx_shutdown_session(sess->se_sess); assert_spin_locked(&sess->vha->hw->hardware_lock);
target_sess_cmd_list_set_waiting(sess->se_sess);
} }
static struct se_node_acl *tcm_qla2xxx_make_nodeacl( static struct se_node_acl *tcm_qla2xxx_make_nodeacl(
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ extern struct iscsi_np *iscsit_add_np(struct __kernel_sockaddr_storage *, ...@@ -15,7 +15,7 @@ extern struct iscsi_np *iscsit_add_np(struct __kernel_sockaddr_storage *,
extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *, extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *,
struct iscsi_portal_group *); struct iscsi_portal_group *);
extern int iscsit_del_np(struct iscsi_np *); extern int iscsit_del_np(struct iscsi_np *);
extern int iscsit_add_reject_from_cmd(u8, int, int, unsigned char *, struct iscsi_cmd *); extern int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8, unsigned char *);
extern void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *); extern void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *);
extern int iscsit_logout_closesession(struct iscsi_cmd *, struct iscsi_conn *); extern int iscsit_logout_closesession(struct iscsi_cmd *, struct iscsi_conn *);
extern int iscsit_logout_closeconnection(struct iscsi_cmd *, struct iscsi_conn *); extern int iscsit_logout_closeconnection(struct iscsi_cmd *, struct iscsi_conn *);
......
...@@ -132,7 +132,8 @@ enum cmd_flags_table { ...@@ -132,7 +132,8 @@ enum cmd_flags_table {
ICF_CONTIG_MEMORY = 0x00000020, ICF_CONTIG_MEMORY = 0x00000020,
ICF_ATTACHED_TO_RQUEUE = 0x00000040, ICF_ATTACHED_TO_RQUEUE = 0x00000040,
ICF_OOO_CMDSN = 0x00000080, ICF_OOO_CMDSN = 0x00000080,
ICF_REJECT_FAIL_CONN = 0x00000100, IFC_SENDTARGETS_ALL = 0x00000100,
IFC_SENDTARGETS_SINGLE = 0x00000200,
}; };
/* struct iscsi_cmd->i_state */ /* struct iscsi_cmd->i_state */
...@@ -366,6 +367,8 @@ struct iscsi_cmd { ...@@ -366,6 +367,8 @@ struct iscsi_cmd {
u8 maxcmdsn_inc; u8 maxcmdsn_inc;
/* Immediate Unsolicited Dataout */ /* Immediate Unsolicited Dataout */
u8 unsolicited_data; u8 unsolicited_data;
/* Reject reason code */
u8 reject_reason;
/* CID contained in logout PDU when opcode == ISCSI_INIT_LOGOUT_CMND */ /* CID contained in logout PDU when opcode == ISCSI_INIT_LOGOUT_CMND */
u16 logout_cid; u16 logout_cid;
/* Command flags */ /* Command flags */
...@@ -427,6 +430,8 @@ struct iscsi_cmd { ...@@ -427,6 +430,8 @@ struct iscsi_cmd {
u32 tx_size; u32 tx_size;
/* Buffer used for various purposes */ /* Buffer used for various purposes */
void *buf_ptr; void *buf_ptr;
/* Used by SendTargets=[iqn.,eui.] discovery */
void *text_in_ptr;
/* See include/linux/dma-mapping.h */ /* See include/linux/dma-mapping.h */
enum dma_data_direction data_direction; enum dma_data_direction data_direction;
/* iSCSI PDU Header + CRC */ /* iSCSI PDU Header + CRC */
...@@ -446,7 +451,6 @@ struct iscsi_cmd { ...@@ -446,7 +451,6 @@ struct iscsi_cmd {
struct list_head datain_list; struct list_head datain_list;
/* R2T List */ /* R2T List */
struct list_head cmd_r2t_list; struct list_head cmd_r2t_list;
struct completion reject_comp;
/* Timer for DataOUT */ /* Timer for DataOUT */
struct timer_list dataout_timer; struct timer_list dataout_timer;
/* Iovecs for SCSI data payload RX/TX w/ kernel level sockets */ /* Iovecs for SCSI data payload RX/TX w/ kernel level sockets */
...@@ -528,8 +532,6 @@ struct iscsi_conn { ...@@ -528,8 +532,6 @@ struct iscsi_conn {
u32 of_marker; u32 of_marker;
/* Used for calculating OFMarker offset to next PDU */ /* Used for calculating OFMarker offset to next PDU */
u32 of_marker_offset; u32 of_marker_offset;
/* Complete Bad PDU for sending reject */
unsigned char bad_hdr[ISCSI_HDR_LEN];
#define IPV6_ADDRESS_SPACE 48 #define IPV6_ADDRESS_SPACE 48
unsigned char login_ip[IPV6_ADDRESS_SPACE]; unsigned char login_ip[IPV6_ADDRESS_SPACE];
unsigned char local_ip[IPV6_ADDRESS_SPACE]; unsigned char local_ip[IPV6_ADDRESS_SPACE];
...@@ -809,6 +811,7 @@ struct iscsi_portal_group { ...@@ -809,6 +811,7 @@ struct iscsi_portal_group {
struct mutex tpg_access_lock; struct mutex tpg_access_lock;
struct mutex np_login_lock; struct mutex np_login_lock;
struct iscsi_tpg_attrib tpg_attrib; struct iscsi_tpg_attrib tpg_attrib;
struct iscsi_node_auth tpg_demo_auth;
/* Pointer to default list of iSCSI parameters for TPG */ /* Pointer to default list of iSCSI parameters for TPG */
struct iscsi_param_list *param_list; struct iscsi_param_list *param_list;
struct iscsi_tiqn *tpg_tiqn; struct iscsi_tiqn *tpg_tiqn;
......
...@@ -746,13 +746,12 @@ int iscsit_check_post_dataout( ...@@ -746,13 +746,12 @@ int iscsit_check_post_dataout(
if (!conn->sess->sess_ops->ErrorRecoveryLevel) { if (!conn->sess->sess_ops->ErrorRecoveryLevel) {
pr_err("Unable to recover from DataOUT CRC" pr_err("Unable to recover from DataOUT CRC"
" failure while ERL=0, closing session.\n"); " failure while ERL=0, closing session.\n");
iscsit_add_reject_from_cmd(ISCSI_REASON_DATA_DIGEST_ERROR, iscsit_reject_cmd(cmd, ISCSI_REASON_DATA_DIGEST_ERROR,
1, 0, buf, cmd); buf);
return DATAOUT_CANNOT_RECOVER; return DATAOUT_CANNOT_RECOVER;
} }
iscsit_add_reject_from_cmd(ISCSI_REASON_DATA_DIGEST_ERROR, iscsit_reject_cmd(cmd, ISCSI_REASON_DATA_DIGEST_ERROR, buf);
0, 0, buf, cmd);
return iscsit_dataout_post_crc_failed(cmd, buf); return iscsit_dataout_post_crc_failed(cmd, buf);
} }
} }
...@@ -909,6 +908,7 @@ void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep) ...@@ -909,6 +908,7 @@ void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep)
wait_for_completion(&conn->conn_wait_comp); wait_for_completion(&conn->conn_wait_comp);
complete(&conn->conn_post_wait_comp); complete(&conn->conn_post_wait_comp);
} }
EXPORT_SYMBOL(iscsit_cause_connection_reinstatement);
void iscsit_fall_back_to_erl0(struct iscsi_session *sess) void iscsit_fall_back_to_erl0(struct iscsi_session *sess)
{ {
......
...@@ -162,9 +162,8 @@ static int iscsit_handle_r2t_snack( ...@@ -162,9 +162,8 @@ static int iscsit_handle_r2t_snack(
" protocol error.\n", cmd->init_task_tag, begrun, " protocol error.\n", cmd->init_task_tag, begrun,
(begrun + runlength), cmd->acked_data_sn); (begrun + runlength), cmd->acked_data_sn);
return iscsit_add_reject_from_cmd( return iscsit_reject_cmd(cmd,
ISCSI_REASON_PROTOCOL_ERROR, ISCSI_REASON_PROTOCOL_ERROR, buf);
1, 0, buf, cmd);
} }
if (runlength) { if (runlength) {
...@@ -173,8 +172,8 @@ static int iscsit_handle_r2t_snack( ...@@ -173,8 +172,8 @@ static int iscsit_handle_r2t_snack(
" with BegRun: 0x%08x, RunLength: 0x%08x, exceeds" " with BegRun: 0x%08x, RunLength: 0x%08x, exceeds"
" current R2TSN: 0x%08x, protocol error.\n", " current R2TSN: 0x%08x, protocol error.\n",
cmd->init_task_tag, begrun, runlength, cmd->r2t_sn); cmd->init_task_tag, begrun, runlength, cmd->r2t_sn);
return iscsit_add_reject_from_cmd( return iscsit_reject_cmd(cmd,
ISCSI_REASON_BOOKMARK_INVALID, 1, 0, buf, cmd); ISCSI_REASON_BOOKMARK_INVALID, buf);
} }
last_r2tsn = (begrun + runlength); last_r2tsn = (begrun + runlength);
} else } else
...@@ -433,8 +432,7 @@ static int iscsit_handle_recovery_datain( ...@@ -433,8 +432,7 @@ static int iscsit_handle_recovery_datain(
" protocol error.\n", cmd->init_task_tag, begrun, " protocol error.\n", cmd->init_task_tag, begrun,
(begrun + runlength), cmd->acked_data_sn); (begrun + runlength), cmd->acked_data_sn);
return iscsit_add_reject_from_cmd(ISCSI_REASON_PROTOCOL_ERROR, return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf);
1, 0, buf, cmd);
} }
/* /*
...@@ -445,14 +443,14 @@ static int iscsit_handle_recovery_datain( ...@@ -445,14 +443,14 @@ static int iscsit_handle_recovery_datain(
pr_err("Initiator requesting BegRun: 0x%08x, RunLength" pr_err("Initiator requesting BegRun: 0x%08x, RunLength"
": 0x%08x greater than maximum DataSN: 0x%08x.\n", ": 0x%08x greater than maximum DataSN: 0x%08x.\n",
begrun, runlength, (cmd->data_sn - 1)); begrun, runlength, (cmd->data_sn - 1));
return iscsit_add_reject_from_cmd(ISCSI_REASON_BOOKMARK_INVALID, return iscsit_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_INVALID,
1, 0, buf, cmd); buf);
} }
dr = iscsit_allocate_datain_req(); dr = iscsit_allocate_datain_req();
if (!dr) if (!dr)
return iscsit_add_reject_from_cmd(ISCSI_REASON_BOOKMARK_NO_RESOURCES, return iscsit_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_NO_RESOURCES,
1, 0, buf, cmd); buf);
dr->data_sn = dr->begrun = begrun; dr->data_sn = dr->begrun = begrun;
dr->runlength = runlength; dr->runlength = runlength;
...@@ -1090,7 +1088,7 @@ int iscsit_handle_ooo_cmdsn( ...@@ -1090,7 +1088,7 @@ int iscsit_handle_ooo_cmdsn(
ooo_cmdsn = iscsit_allocate_ooo_cmdsn(); ooo_cmdsn = iscsit_allocate_ooo_cmdsn();
if (!ooo_cmdsn) if (!ooo_cmdsn)
return CMDSN_ERROR_CANNOT_RECOVER; return -ENOMEM;
ooo_cmdsn->cmd = cmd; ooo_cmdsn->cmd = cmd;
ooo_cmdsn->batch_count = (batch) ? ooo_cmdsn->batch_count = (batch) ?
...@@ -1101,10 +1099,10 @@ int iscsit_handle_ooo_cmdsn( ...@@ -1101,10 +1099,10 @@ int iscsit_handle_ooo_cmdsn(
if (iscsit_attach_ooo_cmdsn(sess, ooo_cmdsn) < 0) { if (iscsit_attach_ooo_cmdsn(sess, ooo_cmdsn) < 0) {
kmem_cache_free(lio_ooo_cache, ooo_cmdsn); kmem_cache_free(lio_ooo_cache, ooo_cmdsn);
return CMDSN_ERROR_CANNOT_RECOVER; return -ENOMEM;
} }
return CMDSN_HIGHER_THAN_EXP; return 0;
} }
static int iscsit_set_dataout_timeout_values( static int iscsit_set_dataout_timeout_values(
......
...@@ -112,6 +112,7 @@ static u32 iscsi_handle_authentication( ...@@ -112,6 +112,7 @@ static u32 iscsi_handle_authentication(
struct iscsi_session *sess = conn->sess; struct iscsi_session *sess = conn->sess;
struct iscsi_node_auth *auth; struct iscsi_node_auth *auth;
struct iscsi_node_acl *iscsi_nacl; struct iscsi_node_acl *iscsi_nacl;
struct iscsi_portal_group *iscsi_tpg;
struct se_node_acl *se_nacl; struct se_node_acl *se_nacl;
if (!sess->sess_ops->SessionType) { if (!sess->sess_ops->SessionType) {
...@@ -132,7 +133,17 @@ static u32 iscsi_handle_authentication( ...@@ -132,7 +133,17 @@ static u32 iscsi_handle_authentication(
return -1; return -1;
} }
auth = ISCSI_NODE_AUTH(iscsi_nacl); if (se_nacl->dynamic_node_acl) {
iscsi_tpg = container_of(se_nacl->se_tpg,
struct iscsi_portal_group, tpg_se_tpg);
auth = &iscsi_tpg->tpg_demo_auth;
} else {
iscsi_nacl = container_of(se_nacl, struct iscsi_node_acl,
se_node_acl);
auth = ISCSI_NODE_AUTH(iscsi_nacl);
}
} else { } else {
/* /*
* For SessionType=Discovery * For SessionType=Discovery
......
...@@ -1799,9 +1799,6 @@ void iscsi_set_connection_parameters( ...@@ -1799,9 +1799,6 @@ void iscsi_set_connection_parameters(
* this key is not sent over the wire. * this key is not sent over the wire.
*/ */
if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) { if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
if (param_list->iser == true)
continue;
ops->MaxXmitDataSegmentLength = ops->MaxXmitDataSegmentLength =
simple_strtoul(param->value, &tmpptr, 0); simple_strtoul(param->value, &tmpptr, 0);
pr_debug("MaxXmitDataSegmentLength: %s\n", pr_debug("MaxXmitDataSegmentLength: %s\n",
......
...@@ -178,7 +178,6 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) ...@@ -178,7 +178,6 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask)
INIT_LIST_HEAD(&cmd->i_conn_node); INIT_LIST_HEAD(&cmd->i_conn_node);
INIT_LIST_HEAD(&cmd->datain_list); INIT_LIST_HEAD(&cmd->datain_list);
INIT_LIST_HEAD(&cmd->cmd_r2t_list); INIT_LIST_HEAD(&cmd->cmd_r2t_list);
init_completion(&cmd->reject_comp);
spin_lock_init(&cmd->datain_lock); spin_lock_init(&cmd->datain_lock);
spin_lock_init(&cmd->dataout_timeout_lock); spin_lock_init(&cmd->dataout_timeout_lock);
spin_lock_init(&cmd->istate_lock); spin_lock_init(&cmd->istate_lock);
...@@ -284,13 +283,12 @@ static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cm ...@@ -284,13 +283,12 @@ static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cm
* Commands may be received out of order if MC/S is in use. * Commands may be received out of order if MC/S is in use.
* Ensure they are executed in CmdSN order. * Ensure they are executed in CmdSN order.
*/ */
int iscsit_sequence_cmd( int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
struct iscsi_conn *conn, unsigned char *buf, __be32 cmdsn)
struct iscsi_cmd *cmd,
__be32 cmdsn)
{ {
int ret; int ret, cmdsn_ret;
int cmdsn_ret; bool reject = false;
u8 reason = ISCSI_REASON_BOOKMARK_NO_RESOURCES;
mutex_lock(&conn->sess->cmdsn_mutex); mutex_lock(&conn->sess->cmdsn_mutex);
...@@ -300,9 +298,19 @@ int iscsit_sequence_cmd( ...@@ -300,9 +298,19 @@ int iscsit_sequence_cmd(
ret = iscsit_execute_cmd(cmd, 0); ret = iscsit_execute_cmd(cmd, 0);
if ((ret >= 0) && !list_empty(&conn->sess->sess_ooo_cmdsn_list)) if ((ret >= 0) && !list_empty(&conn->sess->sess_ooo_cmdsn_list))
iscsit_execute_ooo_cmdsns(conn->sess); iscsit_execute_ooo_cmdsns(conn->sess);
else if (ret < 0) {
reject = true;
ret = CMDSN_ERROR_CANNOT_RECOVER;
}
break; break;
case CMDSN_HIGHER_THAN_EXP: case CMDSN_HIGHER_THAN_EXP:
ret = iscsit_handle_ooo_cmdsn(conn->sess, cmd, be32_to_cpu(cmdsn)); ret = iscsit_handle_ooo_cmdsn(conn->sess, cmd, be32_to_cpu(cmdsn));
if (ret < 0) {
reject = true;
ret = CMDSN_ERROR_CANNOT_RECOVER;
break;
}
ret = CMDSN_HIGHER_THAN_EXP;
break; break;
case CMDSN_LOWER_THAN_EXP: case CMDSN_LOWER_THAN_EXP:
cmd->i_state = ISTATE_REMOVE; cmd->i_state = ISTATE_REMOVE;
...@@ -310,11 +318,16 @@ int iscsit_sequence_cmd( ...@@ -310,11 +318,16 @@ int iscsit_sequence_cmd(
ret = cmdsn_ret; ret = cmdsn_ret;
break; break;
default: default:
reason = ISCSI_REASON_PROTOCOL_ERROR;
reject = true;
ret = cmdsn_ret; ret = cmdsn_ret;
break; break;
} }
mutex_unlock(&conn->sess->cmdsn_mutex); mutex_unlock(&conn->sess->cmdsn_mutex);
if (reject)
iscsit_reject_cmd(cmd, reason, buf);
return ret; return ret;
} }
EXPORT_SYMBOL(iscsit_sequence_cmd); EXPORT_SYMBOL(iscsit_sequence_cmd);
...@@ -681,6 +694,7 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) ...@@ -681,6 +694,7 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd)
kfree(cmd->seq_list); kfree(cmd->seq_list);
kfree(cmd->tmr_req); kfree(cmd->tmr_req);
kfree(cmd->iov_data); kfree(cmd->iov_data);
kfree(cmd->text_in_ptr);
kmem_cache_free(lio_cmd_cache, cmd); kmem_cache_free(lio_cmd_cache, cmd);
} }
......
...@@ -13,7 +13,8 @@ extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t); ...@@ -13,7 +13,8 @@ extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t);
extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32); extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32);
extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *); extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *);
extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32); extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32);
int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, __be32 cmdsn); extern int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
unsigned char * ,__be32 cmdsn);
extern int iscsit_check_unsolicited_dataout(struct iscsi_cmd *, unsigned char *); extern int iscsit_check_unsolicited_dataout(struct iscsi_cmd *, unsigned char *);
extern struct iscsi_cmd *iscsit_find_cmd_from_itt(struct iscsi_conn *, itt_t); extern struct iscsi_cmd *iscsit_find_cmd_from_itt(struct iscsi_conn *, itt_t);
extern struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *, extern struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *,
......
...@@ -786,7 +786,7 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd) ...@@ -786,7 +786,7 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd)
return 0; return 0;
} }
static int tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd) static void tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd)
{ {
struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; struct se_tmr_req *se_tmr = se_cmd->se_tmr_req;
struct tcm_loop_tmr *tl_tmr = se_tmr->fabric_tmr_ptr; struct tcm_loop_tmr *tl_tmr = se_tmr->fabric_tmr_ptr;
...@@ -796,7 +796,6 @@ static int tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd) ...@@ -796,7 +796,6 @@ static int tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd)
*/ */
atomic_set(&tl_tmr->tmr_complete, 1); atomic_set(&tl_tmr->tmr_complete, 1);
wake_up(&tl_tmr->tl_tmr_wait); wake_up(&tl_tmr->tl_tmr_wait);
return 0;
} }
static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba) static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba)
......
...@@ -1842,9 +1842,8 @@ static int sbp_queue_status(struct se_cmd *se_cmd) ...@@ -1842,9 +1842,8 @@ static int sbp_queue_status(struct se_cmd *se_cmd)
return sbp_send_sense(req); return sbp_send_sense(req);
} }
static int sbp_queue_tm_rsp(struct se_cmd *se_cmd) static void sbp_queue_tm_rsp(struct se_cmd *se_cmd)
{ {
return 0;
} }
static int sbp_check_stop_free(struct se_cmd *se_cmd) static int sbp_check_stop_free(struct se_cmd *se_cmd)
......
...@@ -983,7 +983,6 @@ static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev, ...@@ -983,7 +983,6 @@ static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev,
struct se_node_acl *se_nacl; struct se_node_acl *se_nacl;
struct t10_pr_registration *pr_reg; struct t10_pr_registration *pr_reg;
char i_buf[PR_REG_ISID_ID_LEN]; char i_buf[PR_REG_ISID_ID_LEN];
int prf_isid;
memset(i_buf, 0, PR_REG_ISID_ID_LEN); memset(i_buf, 0, PR_REG_ISID_ID_LEN);
...@@ -992,12 +991,11 @@ static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev, ...@@ -992,12 +991,11 @@ static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev,
return sprintf(page, "No SPC-3 Reservation holder\n"); return sprintf(page, "No SPC-3 Reservation holder\n");
se_nacl = pr_reg->pr_reg_nacl; se_nacl = pr_reg->pr_reg_nacl;
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
PR_REG_ISID_ID_LEN);
return sprintf(page, "SPC-3 Reservation: %s Initiator: %s%s\n", return sprintf(page, "SPC-3 Reservation: %s Initiator: %s%s\n",
se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(), se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
se_nacl->initiatorname, (prf_isid) ? &i_buf[0] : ""); se_nacl->initiatorname, i_buf);
} }
static ssize_t target_core_dev_pr_show_spc2_res(struct se_device *dev, static ssize_t target_core_dev_pr_show_spc2_res(struct se_device *dev,
...@@ -1116,7 +1114,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( ...@@ -1116,7 +1114,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
unsigned char buf[384]; unsigned char buf[384];
char i_buf[PR_REG_ISID_ID_LEN]; char i_buf[PR_REG_ISID_ID_LEN];
ssize_t len = 0; ssize_t len = 0;
int reg_count = 0, prf_isid; int reg_count = 0;
len += sprintf(page+len, "SPC-3 PR Registrations:\n"); len += sprintf(page+len, "SPC-3 PR Registrations:\n");
...@@ -1127,12 +1125,11 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( ...@@ -1127,12 +1125,11 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
memset(buf, 0, 384); memset(buf, 0, 384);
memset(i_buf, 0, PR_REG_ISID_ID_LEN); memset(i_buf, 0, PR_REG_ISID_ID_LEN);
tfo = pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; tfo = pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo;
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], core_pr_dump_initiator_port(pr_reg, i_buf,
PR_REG_ISID_ID_LEN); PR_REG_ISID_ID_LEN);
sprintf(buf, "%s Node: %s%s Key: 0x%016Lx PRgen: 0x%08x\n", sprintf(buf, "%s Node: %s%s Key: 0x%016Lx PRgen: 0x%08x\n",
tfo->get_fabric_name(), tfo->get_fabric_name(),
pr_reg->pr_reg_nacl->initiatorname, (prf_isid) ? pr_reg->pr_reg_nacl->initiatorname, i_buf, pr_reg->pr_res_key,
&i_buf[0] : "", pr_reg->pr_res_key,
pr_reg->pr_res_generation); pr_reg->pr_res_generation);
if (len + strlen(buf) >= PAGE_SIZE) if (len + strlen(buf) >= PAGE_SIZE)
......
...@@ -1410,7 +1410,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) ...@@ -1410,7 +1410,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
INIT_LIST_HEAD(&dev->t10_alua.tg_pt_gps_list); INIT_LIST_HEAD(&dev->t10_alua.tg_pt_gps_list);
spin_lock_init(&dev->t10_alua.tg_pt_gps_lock); spin_lock_init(&dev->t10_alua.tg_pt_gps_lock);
dev->t10_pr.pr_aptpl_buf_len = PR_APTPL_BUF_LEN;
dev->t10_wwn.t10_dev = dev; dev->t10_wwn.t10_dev = dev;
dev->t10_alua.t10_dev = dev; dev->t10_alua.t10_dev = dev;
...@@ -1545,7 +1544,7 @@ int core_dev_setup_virtual_lun0(void) ...@@ -1545,7 +1544,7 @@ int core_dev_setup_virtual_lun0(void)
{ {
struct se_hba *hba; struct se_hba *hba;
struct se_device *dev; struct se_device *dev;
char buf[16]; char buf[] = "rd_pages=8,rd_nullio=1";
int ret; int ret;
hba = core_alloc_hba("rd_mcp", 0, HBA_FLAGS_INTERNAL_USE); hba = core_alloc_hba("rd_mcp", 0, HBA_FLAGS_INTERNAL_USE);
...@@ -1558,8 +1557,6 @@ int core_dev_setup_virtual_lun0(void) ...@@ -1558,8 +1557,6 @@ int core_dev_setup_virtual_lun0(void)
goto out_free_hba; goto out_free_hba;
} }
memset(buf, 0, 16);
sprintf(buf, "rd_pages=8");
hba->transport->set_configfs_dev_params(dev, buf, sizeof(buf)); hba->transport->set_configfs_dev_params(dev, buf, sizeof(buf));
ret = target_configure_device(dev); ret = target_configure_device(dev);
......
...@@ -965,6 +965,19 @@ TF_CIT_SETUP(tpg_attrib, &target_fabric_tpg_attrib_item_ops, NULL, NULL); ...@@ -965,6 +965,19 @@ TF_CIT_SETUP(tpg_attrib, &target_fabric_tpg_attrib_item_ops, NULL, NULL);
/* End of tfc_tpg_attrib_cit */ /* End of tfc_tpg_attrib_cit */
/* Start of tfc_tpg_auth_cit */
CONFIGFS_EATTR_OPS(target_fabric_tpg_auth, se_portal_group, tpg_auth_group);
static struct configfs_item_operations target_fabric_tpg_auth_item_ops = {
.show_attribute = target_fabric_tpg_auth_attr_show,
.store_attribute = target_fabric_tpg_auth_attr_store,
};
TF_CIT_SETUP(tpg_auth, &target_fabric_tpg_auth_item_ops, NULL, NULL);
/* End of tfc_tpg_attrib_cit */
/* Start of tfc_tpg_param_cit */ /* Start of tfc_tpg_param_cit */
CONFIGFS_EATTR_OPS(target_fabric_tpg_param, se_portal_group, tpg_param_group); CONFIGFS_EATTR_OPS(target_fabric_tpg_param, se_portal_group, tpg_param_group);
...@@ -1030,8 +1043,9 @@ static struct config_group *target_fabric_make_tpg( ...@@ -1030,8 +1043,9 @@ static struct config_group *target_fabric_make_tpg(
se_tpg->tpg_group.default_groups[1] = &se_tpg->tpg_np_group; se_tpg->tpg_group.default_groups[1] = &se_tpg->tpg_np_group;
se_tpg->tpg_group.default_groups[2] = &se_tpg->tpg_acl_group; se_tpg->tpg_group.default_groups[2] = &se_tpg->tpg_acl_group;
se_tpg->tpg_group.default_groups[3] = &se_tpg->tpg_attrib_group; se_tpg->tpg_group.default_groups[3] = &se_tpg->tpg_attrib_group;
se_tpg->tpg_group.default_groups[4] = &se_tpg->tpg_param_group; se_tpg->tpg_group.default_groups[4] = &se_tpg->tpg_auth_group;
se_tpg->tpg_group.default_groups[5] = NULL; se_tpg->tpg_group.default_groups[5] = &se_tpg->tpg_param_group;
se_tpg->tpg_group.default_groups[6] = NULL;
config_group_init_type_name(&se_tpg->tpg_group, name, config_group_init_type_name(&se_tpg->tpg_group, name,
&TF_CIT_TMPL(tf)->tfc_tpg_base_cit); &TF_CIT_TMPL(tf)->tfc_tpg_base_cit);
...@@ -1043,6 +1057,8 @@ static struct config_group *target_fabric_make_tpg( ...@@ -1043,6 +1057,8 @@ static struct config_group *target_fabric_make_tpg(
&TF_CIT_TMPL(tf)->tfc_tpg_nacl_cit); &TF_CIT_TMPL(tf)->tfc_tpg_nacl_cit);
config_group_init_type_name(&se_tpg->tpg_attrib_group, "attrib", config_group_init_type_name(&se_tpg->tpg_attrib_group, "attrib",
&TF_CIT_TMPL(tf)->tfc_tpg_attrib_cit); &TF_CIT_TMPL(tf)->tfc_tpg_attrib_cit);
config_group_init_type_name(&se_tpg->tpg_auth_group, "auth",
&TF_CIT_TMPL(tf)->tfc_tpg_auth_cit);
config_group_init_type_name(&se_tpg->tpg_param_group, "param", config_group_init_type_name(&se_tpg->tpg_param_group, "param",
&TF_CIT_TMPL(tf)->tfc_tpg_param_cit); &TF_CIT_TMPL(tf)->tfc_tpg_param_cit);
...@@ -1202,6 +1218,7 @@ int target_fabric_setup_cits(struct target_fabric_configfs *tf) ...@@ -1202,6 +1218,7 @@ int target_fabric_setup_cits(struct target_fabric_configfs *tf)
target_fabric_setup_tpg_np_cit(tf); target_fabric_setup_tpg_np_cit(tf);
target_fabric_setup_tpg_np_base_cit(tf); target_fabric_setup_tpg_np_base_cit(tf);
target_fabric_setup_tpg_attrib_cit(tf); target_fabric_setup_tpg_attrib_cit(tf);
target_fabric_setup_tpg_auth_cit(tf);
target_fabric_setup_tpg_param_cit(tf); target_fabric_setup_tpg_param_cit(tf);
target_fabric_setup_tpg_nacl_cit(tf); target_fabric_setup_tpg_nacl_cit(tf);
target_fabric_setup_tpg_nacl_base_cit(tf); target_fabric_setup_tpg_nacl_base_cit(tf);
......
This diff is collapsed.
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
extern struct kmem_cache *t10_pr_reg_cache; extern struct kmem_cache *t10_pr_reg_cache;
extern int core_pr_dump_initiator_port(struct t10_pr_registration *, extern void core_pr_dump_initiator_port(struct t10_pr_registration *,
char *, u32); char *, u32);
extern sense_reason_t target_scsi2_reservation_release(struct se_cmd *); extern sense_reason_t target_scsi2_reservation_release(struct se_cmd *);
extern sense_reason_t target_scsi2_reservation_reserve(struct se_cmd *); extern sense_reason_t target_scsi2_reservation_reserve(struct se_cmd *);
......
...@@ -139,6 +139,11 @@ static int rd_build_device_space(struct rd_dev *rd_dev) ...@@ -139,6 +139,11 @@ static int rd_build_device_space(struct rd_dev *rd_dev)
rd_dev->rd_page_count); rd_dev->rd_page_count);
return -EINVAL; return -EINVAL;
} }
/* Don't need backing pages for NULLIO */
if (rd_dev->rd_flags & RDF_NULLIO)
return 0;
total_sg_needed = rd_dev->rd_page_count; total_sg_needed = rd_dev->rd_page_count;
sg_tables = (total_sg_needed / max_sg_per_table) + 1; sg_tables = (total_sg_needed / max_sg_per_table) + 1;
......
...@@ -38,11 +38,27 @@ static sense_reason_t ...@@ -38,11 +38,27 @@ static sense_reason_t
sbc_emulate_readcapacity(struct se_cmd *cmd) sbc_emulate_readcapacity(struct se_cmd *cmd)
{ {
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
unsigned char *cdb = cmd->t_task_cdb;
unsigned long long blocks_long = dev->transport->get_blocks(dev); unsigned long long blocks_long = dev->transport->get_blocks(dev);
unsigned char *rbuf; unsigned char *rbuf;
unsigned char buf[8]; unsigned char buf[8];
u32 blocks; u32 blocks;
/*
* SBC-2 says:
* If the PMI bit is set to zero and the LOGICAL BLOCK
* ADDRESS field is not set to zero, the device server shall
* terminate the command with CHECK CONDITION status with
* the sense key set to ILLEGAL REQUEST and the additional
* sense code set to INVALID FIELD IN CDB.
*
* In SBC-3, these fields are obsolete, but some SCSI
* compliance tests actually check this, so we might as well
* follow SBC-2.
*/
if (!(cdb[8] & 1) && !!(cdb[2] | cdb[3] | cdb[4] | cdb[5]))
return TCM_INVALID_CDB_FIELD;
if (blocks_long >= 0x00000000ffffffff) if (blocks_long >= 0x00000000ffffffff)
blocks = 0xffffffff; blocks = 0xffffffff;
else else
...@@ -581,7 +597,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -581,7 +597,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
pr_err("cmd exceeds last lba %llu " pr_err("cmd exceeds last lba %llu "
"(lba %llu, sectors %u)\n", "(lba %llu, sectors %u)\n",
end_lba, cmd->t_task_lba, sectors); end_lba, cmd->t_task_lba, sectors);
return TCM_INVALID_CDB_FIELD; return TCM_ADDRESS_OUT_OF_RANGE;
} }
size = sbc_get_size(cmd, sectors); size = sbc_get_size(cmd, sectors);
......
...@@ -85,13 +85,8 @@ void core_tmr_release_req( ...@@ -85,13 +85,8 @@ void core_tmr_release_req(
static void core_tmr_handle_tas_abort( static void core_tmr_handle_tas_abort(
struct se_node_acl *tmr_nacl, struct se_node_acl *tmr_nacl,
struct se_cmd *cmd, struct se_cmd *cmd,
int tas, int tas)
int fe_count)
{ {
if (!fe_count) {
transport_cmd_finish_abort(cmd, 1);
return;
}
/* /*
* TASK ABORTED status (TAS) bit support * TASK ABORTED status (TAS) bit support
*/ */
...@@ -253,7 +248,6 @@ static void core_tmr_drain_state_list( ...@@ -253,7 +248,6 @@ static void core_tmr_drain_state_list(
LIST_HEAD(drain_task_list); LIST_HEAD(drain_task_list);
struct se_cmd *cmd, *next; struct se_cmd *cmd, *next;
unsigned long flags; unsigned long flags;
int fe_count;
/* /*
* Complete outstanding commands with TASK_ABORTED SAM status. * Complete outstanding commands with TASK_ABORTED SAM status.
...@@ -329,12 +323,10 @@ static void core_tmr_drain_state_list( ...@@ -329,12 +323,10 @@ static void core_tmr_drain_state_list(
spin_lock_irqsave(&cmd->t_state_lock, flags); spin_lock_irqsave(&cmd->t_state_lock, flags);
target_stop_cmd(cmd, &flags); target_stop_cmd(cmd, &flags);
fe_count = atomic_read(&cmd->t_fe_count);
cmd->transport_state |= CMD_T_ABORTED; cmd->transport_state |= CMD_T_ABORTED;
spin_unlock_irqrestore(&cmd->t_state_lock, flags); spin_unlock_irqrestore(&cmd->t_state_lock, flags);
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count); core_tmr_handle_tas_abort(tmr_nacl, cmd, tas);
} }
} }
......
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
#include "target_core_pr.h" #include "target_core_pr.h"
#include "target_core_ua.h" #include "target_core_ua.h"
#define CREATE_TRACE_POINTS
#include <trace/events/target.h>
static struct workqueue_struct *target_completion_wq; static struct workqueue_struct *target_completion_wq;
static struct kmem_cache *se_sess_cache; static struct kmem_cache *se_sess_cache;
struct kmem_cache *se_ua_cache; struct kmem_cache *se_ua_cache;
...@@ -446,11 +449,15 @@ static void target_remove_from_state_list(struct se_cmd *cmd) ...@@ -446,11 +449,15 @@ static void target_remove_from_state_list(struct se_cmd *cmd)
spin_unlock_irqrestore(&dev->execute_task_lock, flags); spin_unlock_irqrestore(&dev->execute_task_lock, flags);
} }
static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists) static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists,
bool write_pending)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&cmd->t_state_lock, flags); spin_lock_irqsave(&cmd->t_state_lock, flags);
if (write_pending)
cmd->t_state = TRANSPORT_WRITE_PENDING;
/* /*
* Determine if IOCTL context caller in requesting the stopping of this * Determine if IOCTL context caller in requesting the stopping of this
* command for LUN shutdown purposes. * command for LUN shutdown purposes.
...@@ -515,7 +522,7 @@ static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists) ...@@ -515,7 +522,7 @@ static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists)
static int transport_cmd_check_stop_to_fabric(struct se_cmd *cmd) static int transport_cmd_check_stop_to_fabric(struct se_cmd *cmd)
{ {
return transport_cmd_check_stop(cmd, true); return transport_cmd_check_stop(cmd, true, false);
} }
static void transport_lun_remove_cmd(struct se_cmd *cmd) static void transport_lun_remove_cmd(struct se_cmd *cmd)
...@@ -526,13 +533,6 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd) ...@@ -526,13 +533,6 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd)
if (!lun) if (!lun)
return; return;
spin_lock_irqsave(&cmd->t_state_lock, flags);
if (cmd->transport_state & CMD_T_DEV_ACTIVE) {
cmd->transport_state &= ~CMD_T_DEV_ACTIVE;
target_remove_from_state_list(cmd);
}
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
spin_lock_irqsave(&lun->lun_cmd_lock, flags); spin_lock_irqsave(&lun->lun_cmd_lock, flags);
if (!list_empty(&cmd->se_lun_node)) if (!list_empty(&cmd->se_lun_node))
list_del_init(&cmd->se_lun_node); list_del_init(&cmd->se_lun_node);
...@@ -1092,7 +1092,6 @@ sense_reason_t ...@@ -1092,7 +1092,6 @@ sense_reason_t
target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb) target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb)
{ {
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
unsigned long flags;
sense_reason_t ret; sense_reason_t ret;
/* /*
...@@ -1127,6 +1126,8 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb) ...@@ -1127,6 +1126,8 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb)
*/ */
memcpy(cmd->t_task_cdb, cdb, scsi_command_size(cdb)); memcpy(cmd->t_task_cdb, cdb, scsi_command_size(cdb));
trace_target_sequencer_start(cmd);
/* /*
* Check for an existing UNIT ATTENTION condition * Check for an existing UNIT ATTENTION condition
*/ */
...@@ -1152,9 +1153,7 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb) ...@@ -1152,9 +1153,7 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb)
if (ret) if (ret)
return ret; return ret;
spin_lock_irqsave(&cmd->t_state_lock, flags);
cmd->se_cmd_flags |= SCF_SUPPORTED_SAM_OPCODE; cmd->se_cmd_flags |= SCF_SUPPORTED_SAM_OPCODE;
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
spin_lock(&cmd->se_lun->lun_sep_lock); spin_lock(&cmd->se_lun->lun_sep_lock);
if (cmd->se_lun->lun_sep) if (cmd->se_lun->lun_sep)
...@@ -1552,7 +1551,8 @@ void transport_generic_request_failure(struct se_cmd *cmd, ...@@ -1552,7 +1551,8 @@ void transport_generic_request_failure(struct se_cmd *cmd,
cmd->orig_fe_lun, 0x2C, cmd->orig_fe_lun, 0x2C,
ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS); ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS);
ret = cmd->se_tfo->queue_status(cmd); trace_target_cmd_complete(cmd);
ret = cmd->se_tfo-> queue_status(cmd);
if (ret == -EAGAIN || ret == -ENOMEM) if (ret == -EAGAIN || ret == -ENOMEM)
goto queue_full; goto queue_full;
goto check_stop; goto check_stop;
...@@ -1583,10 +1583,6 @@ static void __target_execute_cmd(struct se_cmd *cmd) ...@@ -1583,10 +1583,6 @@ static void __target_execute_cmd(struct se_cmd *cmd)
{ {
sense_reason_t ret; sense_reason_t ret;
spin_lock_irq(&cmd->t_state_lock);
cmd->transport_state |= (CMD_T_BUSY|CMD_T_SENT);
spin_unlock_irq(&cmd->t_state_lock);
if (cmd->execute_cmd) { if (cmd->execute_cmd) {
ret = cmd->execute_cmd(cmd); ret = cmd->execute_cmd(cmd);
if (ret) { if (ret) {
...@@ -1693,11 +1689,17 @@ void target_execute_cmd(struct se_cmd *cmd) ...@@ -1693,11 +1689,17 @@ void target_execute_cmd(struct se_cmd *cmd)
} }
cmd->t_state = TRANSPORT_PROCESSING; cmd->t_state = TRANSPORT_PROCESSING;
cmd->transport_state |= CMD_T_ACTIVE; cmd->transport_state |= CMD_T_ACTIVE|CMD_T_BUSY|CMD_T_SENT;
spin_unlock_irq(&cmd->t_state_lock); spin_unlock_irq(&cmd->t_state_lock);
if (!target_handle_task_attr(cmd)) if (target_handle_task_attr(cmd)) {
__target_execute_cmd(cmd); spin_lock_irq(&cmd->t_state_lock);
cmd->transport_state &= ~CMD_T_BUSY|CMD_T_SENT;
spin_unlock_irq(&cmd->t_state_lock);
return;
}
__target_execute_cmd(cmd);
} }
EXPORT_SYMBOL(target_execute_cmd); EXPORT_SYMBOL(target_execute_cmd);
...@@ -1770,6 +1772,7 @@ static void transport_complete_qf(struct se_cmd *cmd) ...@@ -1770,6 +1772,7 @@ static void transport_complete_qf(struct se_cmd *cmd)
transport_complete_task_attr(cmd); transport_complete_task_attr(cmd);
if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) {
trace_target_cmd_complete(cmd);
ret = cmd->se_tfo->queue_status(cmd); ret = cmd->se_tfo->queue_status(cmd);
if (ret) if (ret)
goto out; goto out;
...@@ -1777,6 +1780,7 @@ static void transport_complete_qf(struct se_cmd *cmd) ...@@ -1777,6 +1780,7 @@ static void transport_complete_qf(struct se_cmd *cmd)
switch (cmd->data_direction) { switch (cmd->data_direction) {
case DMA_FROM_DEVICE: case DMA_FROM_DEVICE:
trace_target_cmd_complete(cmd);
ret = cmd->se_tfo->queue_data_in(cmd); ret = cmd->se_tfo->queue_data_in(cmd);
break; break;
case DMA_TO_DEVICE: case DMA_TO_DEVICE:
...@@ -1787,6 +1791,7 @@ static void transport_complete_qf(struct se_cmd *cmd) ...@@ -1787,6 +1791,7 @@ static void transport_complete_qf(struct se_cmd *cmd)
} }
/* Fall through for DMA_TO_DEVICE */ /* Fall through for DMA_TO_DEVICE */
case DMA_NONE: case DMA_NONE:
trace_target_cmd_complete(cmd);
ret = cmd->se_tfo->queue_status(cmd); ret = cmd->se_tfo->queue_status(cmd);
break; break;
default: default:
...@@ -1865,6 +1870,7 @@ static void target_complete_ok_work(struct work_struct *work) ...@@ -1865,6 +1870,7 @@ static void target_complete_ok_work(struct work_struct *work)
} }
spin_unlock(&cmd->se_lun->lun_sep_lock); spin_unlock(&cmd->se_lun->lun_sep_lock);
trace_target_cmd_complete(cmd);
ret = cmd->se_tfo->queue_data_in(cmd); ret = cmd->se_tfo->queue_data_in(cmd);
if (ret == -EAGAIN || ret == -ENOMEM) if (ret == -EAGAIN || ret == -ENOMEM)
goto queue_full; goto queue_full;
...@@ -1893,6 +1899,7 @@ static void target_complete_ok_work(struct work_struct *work) ...@@ -1893,6 +1899,7 @@ static void target_complete_ok_work(struct work_struct *work)
} }
/* Fall through for DMA_TO_DEVICE */ /* Fall through for DMA_TO_DEVICE */
case DMA_NONE: case DMA_NONE:
trace_target_cmd_complete(cmd);
ret = cmd->se_tfo->queue_status(cmd); ret = cmd->se_tfo->queue_status(cmd);
if (ret == -EAGAIN || ret == -ENOMEM) if (ret == -EAGAIN || ret == -ENOMEM)
goto queue_full; goto queue_full;
...@@ -1956,11 +1963,7 @@ static int transport_release_cmd(struct se_cmd *cmd) ...@@ -1956,11 +1963,7 @@ static int transport_release_cmd(struct se_cmd *cmd)
* If this cmd has been setup with target_get_sess_cmd(), drop * If this cmd has been setup with target_get_sess_cmd(), drop
* the kref and call ->release_cmd() in kref callback. * the kref and call ->release_cmd() in kref callback.
*/ */
if (cmd->check_release != 0) return target_put_sess_cmd(cmd->se_sess, cmd);
return target_put_sess_cmd(cmd->se_sess, cmd);
cmd->se_tfo->release_cmd(cmd);
return 1;
} }
/** /**
...@@ -1971,21 +1974,6 @@ static int transport_release_cmd(struct se_cmd *cmd) ...@@ -1971,21 +1974,6 @@ static int transport_release_cmd(struct se_cmd *cmd)
*/ */
static int transport_put_cmd(struct se_cmd *cmd) static int transport_put_cmd(struct se_cmd *cmd)
{ {
unsigned long flags;
spin_lock_irqsave(&cmd->t_state_lock, flags);
if (atomic_read(&cmd->t_fe_count) &&
!atomic_dec_and_test(&cmd->t_fe_count)) {
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
return 0;
}
if (cmd->transport_state & CMD_T_DEV_ACTIVE) {
cmd->transport_state &= ~CMD_T_DEV_ACTIVE;
target_remove_from_state_list(cmd);
}
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_free_pages(cmd); transport_free_pages(cmd);
return transport_release_cmd(cmd); return transport_release_cmd(cmd);
} }
...@@ -2103,9 +2091,6 @@ transport_generic_new_cmd(struct se_cmd *cmd) ...@@ -2103,9 +2091,6 @@ transport_generic_new_cmd(struct se_cmd *cmd)
if (ret < 0) if (ret < 0)
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
} }
atomic_inc(&cmd->t_fe_count);
/* /*
* If this command is not a write we can execute it right here, * If this command is not a write we can execute it right here,
* for write buffers we need to notify the fabric driver first * for write buffers we need to notify the fabric driver first
...@@ -2116,12 +2101,7 @@ transport_generic_new_cmd(struct se_cmd *cmd) ...@@ -2116,12 +2101,7 @@ transport_generic_new_cmd(struct se_cmd *cmd)
target_execute_cmd(cmd); target_execute_cmd(cmd);
return 0; return 0;
} }
transport_cmd_check_stop(cmd, false, true);
spin_lock_irq(&cmd->t_state_lock);
cmd->t_state = TRANSPORT_WRITE_PENDING;
spin_unlock_irq(&cmd->t_state_lock);
transport_cmd_check_stop(cmd, false);
ret = cmd->se_tfo->write_pending(cmd); ret = cmd->se_tfo->write_pending(cmd);
if (ret == -EAGAIN || ret == -ENOMEM) if (ret == -EAGAIN || ret == -ENOMEM)
...@@ -2202,8 +2182,6 @@ int target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd, ...@@ -2202,8 +2182,6 @@ int target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd,
goto out; goto out;
} }
list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list); list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list);
se_cmd->check_release = 1;
out: out:
spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
return ret; return ret;
...@@ -2319,7 +2297,7 @@ static int transport_lun_wait_for_tasks(struct se_cmd *cmd, struct se_lun *lun) ...@@ -2319,7 +2297,7 @@ static int transport_lun_wait_for_tasks(struct se_cmd *cmd, struct se_lun *lun)
pr_debug("ConfigFS ITT[0x%08x] - CMD_T_STOP, skipping\n", pr_debug("ConfigFS ITT[0x%08x] - CMD_T_STOP, skipping\n",
cmd->se_tfo->get_task_tag(cmd)); cmd->se_tfo->get_task_tag(cmd));
spin_unlock_irqrestore(&cmd->t_state_lock, flags); spin_unlock_irqrestore(&cmd->t_state_lock, flags);
transport_cmd_check_stop(cmd, false); transport_cmd_check_stop(cmd, false, false);
return -EPERM; return -EPERM;
} }
cmd->transport_state |= CMD_T_LUN_FE_STOP; cmd->transport_state |= CMD_T_LUN_FE_STOP;
...@@ -2427,7 +2405,7 @@ static void __transport_clear_lun_from_sessions(struct se_lun *lun) ...@@ -2427,7 +2405,7 @@ static void __transport_clear_lun_from_sessions(struct se_lun *lun)
spin_unlock_irqrestore(&cmd->t_state_lock, spin_unlock_irqrestore(&cmd->t_state_lock,
cmd_flags); cmd_flags);
transport_cmd_check_stop(cmd, false); transport_cmd_check_stop(cmd, false, false);
complete(&cmd->transport_lun_fe_stop_comp); complete(&cmd->transport_lun_fe_stop_comp);
spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags); spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags);
continue; continue;
...@@ -2778,6 +2756,7 @@ transport_send_check_condition_and_sense(struct se_cmd *cmd, ...@@ -2778,6 +2756,7 @@ transport_send_check_condition_and_sense(struct se_cmd *cmd,
cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER;
after_reason: after_reason:
trace_target_cmd_complete(cmd);
return cmd->se_tfo->queue_status(cmd); return cmd->se_tfo->queue_status(cmd);
} }
EXPORT_SYMBOL(transport_send_check_condition_and_sense); EXPORT_SYMBOL(transport_send_check_condition_and_sense);
...@@ -2794,6 +2773,7 @@ int transport_check_aborted_status(struct se_cmd *cmd, int send_status) ...@@ -2794,6 +2773,7 @@ int transport_check_aborted_status(struct se_cmd *cmd, int send_status)
cmd->t_task_cdb[0], cmd->se_tfo->get_task_tag(cmd)); cmd->t_task_cdb[0], cmd->se_tfo->get_task_tag(cmd));
cmd->se_cmd_flags |= SCF_SENT_DELAYED_TAS; cmd->se_cmd_flags |= SCF_SENT_DELAYED_TAS;
trace_target_cmd_complete(cmd);
cmd->se_tfo->queue_status(cmd); cmd->se_tfo->queue_status(cmd);
return 1; return 1;
...@@ -2831,6 +2811,7 @@ void transport_send_task_abort(struct se_cmd *cmd) ...@@ -2831,6 +2811,7 @@ void transport_send_task_abort(struct se_cmd *cmd)
" ITT: 0x%08x\n", cmd->t_task_cdb[0], " ITT: 0x%08x\n", cmd->t_task_cdb[0],
cmd->se_tfo->get_task_tag(cmd)); cmd->se_tfo->get_task_tag(cmd));
trace_target_cmd_complete(cmd);
cmd->se_tfo->queue_status(cmd); cmd->se_tfo->queue_status(cmd);
} }
......
...@@ -161,7 +161,7 @@ int ft_write_pending(struct se_cmd *); ...@@ -161,7 +161,7 @@ int ft_write_pending(struct se_cmd *);
int ft_write_pending_status(struct se_cmd *); int ft_write_pending_status(struct se_cmd *);
u32 ft_get_task_tag(struct se_cmd *); u32 ft_get_task_tag(struct se_cmd *);
int ft_get_cmd_state(struct se_cmd *); int ft_get_cmd_state(struct se_cmd *);
int ft_queue_tm_resp(struct se_cmd *); void ft_queue_tm_resp(struct se_cmd *);
/* /*
* other internal functions. * other internal functions.
......
...@@ -394,14 +394,14 @@ static void ft_send_tm(struct ft_cmd *cmd) ...@@ -394,14 +394,14 @@ static void ft_send_tm(struct ft_cmd *cmd)
/* /*
* Send status from completed task management request. * Send status from completed task management request.
*/ */
int ft_queue_tm_resp(struct se_cmd *se_cmd) void ft_queue_tm_resp(struct se_cmd *se_cmd)
{ {
struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd); struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd);
struct se_tmr_req *tmr = se_cmd->se_tmr_req; struct se_tmr_req *tmr = se_cmd->se_tmr_req;
enum fcp_resp_rsp_codes code; enum fcp_resp_rsp_codes code;
if (cmd->aborted) if (cmd->aborted)
return 0; return;
switch (tmr->response) { switch (tmr->response) {
case TMR_FUNCTION_COMPLETE: case TMR_FUNCTION_COMPLETE:
code = FCP_TMF_CMPL; code = FCP_TMF_CMPL;
...@@ -413,10 +413,7 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd) ...@@ -413,10 +413,7 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd)
code = FCP_TMF_REJECTED; code = FCP_TMF_REJECTED;
break; break;
case TMR_TASK_DOES_NOT_EXIST: case TMR_TASK_DOES_NOT_EXIST:
case TMR_TASK_STILL_ALLEGIANT:
case TMR_TASK_FAILOVER_NOT_SUPPORTED:
case TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED: case TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED:
case TMR_FUNCTION_AUTHORIZATION_FAILED:
default: default:
code = FCP_TMF_FAILED; code = FCP_TMF_FAILED;
break; break;
...@@ -424,7 +421,6 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd) ...@@ -424,7 +421,6 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd)
pr_debug("tmr fn %d resp %d fcp code %d\n", pr_debug("tmr fn %d resp %d fcp code %d\n",
tmr->function, tmr->response, code); tmr->function, tmr->response, code);
ft_send_resp_code(cmd, code); ft_send_resp_code(cmd, code);
return 0;
} }
static void ft_send_work(struct work_struct *work); static void ft_send_work(struct work_struct *work);
......
...@@ -1467,9 +1467,8 @@ static int usbg_get_cmd_state(struct se_cmd *se_cmd) ...@@ -1467,9 +1467,8 @@ static int usbg_get_cmd_state(struct se_cmd *se_cmd)
return 0; return 0;
} }
static int usbg_queue_tm_rsp(struct se_cmd *se_cmd) static void usbg_queue_tm_rsp(struct se_cmd *se_cmd)
{ {
return 0;
} }
static const char *usbg_check_wwn(const char *name) static const char *usbg_check_wwn(const char *name)
......
...@@ -448,7 +448,19 @@ static u32 tcm_vhost_tpg_get_inst_index(struct se_portal_group *se_tpg) ...@@ -448,7 +448,19 @@ static u32 tcm_vhost_tpg_get_inst_index(struct se_portal_group *se_tpg)
static void tcm_vhost_release_cmd(struct se_cmd *se_cmd) static void tcm_vhost_release_cmd(struct se_cmd *se_cmd)
{ {
return; struct tcm_vhost_cmd *tv_cmd = container_of(se_cmd,
struct tcm_vhost_cmd, tvc_se_cmd);
if (tv_cmd->tvc_sgl_count) {
u32 i;
for (i = 0; i < tv_cmd->tvc_sgl_count; i++)
put_page(sg_page(&tv_cmd->tvc_sgl[i]));
kfree(tv_cmd->tvc_sgl);
}
tcm_vhost_put_inflight(tv_cmd->inflight);
kfree(tv_cmd);
} }
static int tcm_vhost_shutdown_session(struct se_session *se_sess) static int tcm_vhost_shutdown_session(struct se_session *se_sess)
...@@ -518,9 +530,9 @@ static int tcm_vhost_queue_status(struct se_cmd *se_cmd) ...@@ -518,9 +530,9 @@ static int tcm_vhost_queue_status(struct se_cmd *se_cmd)
return 0; return 0;
} }
static int tcm_vhost_queue_tm_rsp(struct se_cmd *se_cmd) static void tcm_vhost_queue_tm_rsp(struct se_cmd *se_cmd)
{ {
return 0; return;
} }
static void tcm_vhost_free_evt(struct vhost_scsi *vs, struct tcm_vhost_evt *evt) static void tcm_vhost_free_evt(struct vhost_scsi *vs, struct tcm_vhost_evt *evt)
...@@ -560,19 +572,13 @@ static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *cmd) ...@@ -560,19 +572,13 @@ static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *cmd)
struct se_cmd *se_cmd = &cmd->tvc_se_cmd; struct se_cmd *se_cmd = &cmd->tvc_se_cmd;
/* TODO locking against target/backend threads? */ /* TODO locking against target/backend threads? */
transport_generic_free_cmd(se_cmd, 1); transport_generic_free_cmd(se_cmd, 0);
if (cmd->tvc_sgl_count) { }
u32 i;
for (i = 0; i < cmd->tvc_sgl_count; i++)
put_page(sg_page(&cmd->tvc_sgl[i]));
kfree(cmd->tvc_sgl);
}
tcm_vhost_put_inflight(cmd->inflight);
kfree(cmd); static int vhost_scsi_check_stop_free(struct se_cmd *se_cmd)
{
return target_put_sess_cmd(se_cmd->se_sess, se_cmd);
} }
static void static void
...@@ -856,7 +862,7 @@ static void tcm_vhost_submission_work(struct work_struct *work) ...@@ -856,7 +862,7 @@ static void tcm_vhost_submission_work(struct work_struct *work)
cmd->tvc_cdb, &cmd->tvc_sense_buf[0], cmd->tvc_cdb, &cmd->tvc_sense_buf[0],
cmd->tvc_lun, cmd->tvc_exp_data_len, cmd->tvc_lun, cmd->tvc_exp_data_len,
cmd->tvc_task_attr, cmd->tvc_data_direction, cmd->tvc_task_attr, cmd->tvc_data_direction,
0, sg_ptr, cmd->tvc_sgl_count, TARGET_SCF_ACK_KREF, sg_ptr, cmd->tvc_sgl_count,
sg_bidi_ptr, sg_no_bidi); sg_bidi_ptr, sg_no_bidi);
if (rc < 0) { if (rc < 0) {
transport_send_check_condition_and_sense(se_cmd, transport_send_check_condition_and_sense(se_cmd,
...@@ -2028,6 +2034,7 @@ static struct target_core_fabric_ops tcm_vhost_ops = { ...@@ -2028,6 +2034,7 @@ static struct target_core_fabric_ops tcm_vhost_ops = {
.tpg_release_fabric_acl = tcm_vhost_release_fabric_acl, .tpg_release_fabric_acl = tcm_vhost_release_fabric_acl,
.tpg_get_inst_index = tcm_vhost_tpg_get_inst_index, .tpg_get_inst_index = tcm_vhost_tpg_get_inst_index,
.release_cmd = tcm_vhost_release_cmd, .release_cmd = tcm_vhost_release_cmd,
.check_stop_free = vhost_scsi_check_stop_free,
.shutdown_session = tcm_vhost_shutdown_session, .shutdown_session = tcm_vhost_shutdown_session,
.close_session = tcm_vhost_close_session, .close_session = tcm_vhost_close_session,
.sess_get_index = tcm_vhost_sess_get_index, .sess_get_index = tcm_vhost_sess_get_index,
......
...@@ -34,8 +34,6 @@ extern void iscsit_put_transport(struct iscsit_transport *); ...@@ -34,8 +34,6 @@ extern void iscsit_put_transport(struct iscsit_transport *);
/* /*
* From iscsi_target.c * From iscsi_target.c
*/ */
extern int iscsit_add_reject_from_cmd(u8, int, int, unsigned char *,
struct iscsi_cmd *);
extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *, extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *,
unsigned char *); unsigned char *);
extern void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *); extern void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *);
...@@ -45,18 +43,26 @@ extern int iscsit_check_dataout_hdr(struct iscsi_conn *, unsigned char *, ...@@ -45,18 +43,26 @@ extern int iscsit_check_dataout_hdr(struct iscsi_conn *, unsigned char *,
struct iscsi_cmd **); struct iscsi_cmd **);
extern int iscsit_check_dataout_payload(struct iscsi_cmd *, struct iscsi_data *, extern int iscsit_check_dataout_payload(struct iscsi_cmd *, struct iscsi_data *,
bool); bool);
extern int iscsit_handle_nop_out(struct iscsi_conn *, struct iscsi_cmd *, extern int iscsit_setup_nop_out(struct iscsi_conn *, struct iscsi_cmd *,
unsigned char *); struct iscsi_nopout *);
extern int iscsit_process_nop_out(struct iscsi_conn *, struct iscsi_cmd *,
struct iscsi_nopout *);
extern int iscsit_handle_logout_cmd(struct iscsi_conn *, struct iscsi_cmd *, extern int iscsit_handle_logout_cmd(struct iscsi_conn *, struct iscsi_cmd *,
unsigned char *); unsigned char *);
extern int iscsit_handle_task_mgt_cmd(struct iscsi_conn *, struct iscsi_cmd *, extern int iscsit_handle_task_mgt_cmd(struct iscsi_conn *, struct iscsi_cmd *,
unsigned char *); unsigned char *);
extern int iscsit_setup_text_cmd(struct iscsi_conn *, struct iscsi_cmd *,
struct iscsi_text *);
extern int iscsit_process_text_cmd(struct iscsi_conn *, struct iscsi_cmd *,
struct iscsi_text *);
extern void iscsit_build_rsp_pdu(struct iscsi_cmd *, struct iscsi_conn *, extern void iscsit_build_rsp_pdu(struct iscsi_cmd *, struct iscsi_conn *,
bool, struct iscsi_scsi_rsp *); bool, struct iscsi_scsi_rsp *);
extern void iscsit_build_nopin_rsp(struct iscsi_cmd *, struct iscsi_conn *, extern void iscsit_build_nopin_rsp(struct iscsi_cmd *, struct iscsi_conn *,
struct iscsi_nopin *, bool); struct iscsi_nopin *, bool);
extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *, extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *,
struct iscsi_tm_rsp *); struct iscsi_tm_rsp *);
extern int iscsit_build_text_rsp(struct iscsi_cmd *, struct iscsi_conn *,
struct iscsi_text_rsp *);
extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *, extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *,
struct iscsi_reject *); struct iscsi_reject *);
extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *, extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *,
...@@ -66,6 +72,10 @@ extern int iscsit_logout_post_handler(struct iscsi_cmd *, struct iscsi_conn *); ...@@ -66,6 +72,10 @@ extern int iscsit_logout_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
* From iscsi_target_device.c * From iscsi_target_device.c
*/ */
extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *); extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *);
/*
* From iscsi_target_erl0.c
*/
extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int);
/* /*
* From iscsi_target_erl1.c * From iscsi_target_erl1.c
*/ */
...@@ -80,4 +90,5 @@ extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *); ...@@ -80,4 +90,5 @@ extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
* From iscsi_target_util.c * From iscsi_target_util.c
*/ */
extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t); extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t);
extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *, __be32); extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *,
unsigned char *, __be32);
...@@ -218,14 +218,11 @@ enum tcm_tmreq_table { ...@@ -218,14 +218,11 @@ enum tcm_tmreq_table {
/* fabric independent task management response values */ /* fabric independent task management response values */
enum tcm_tmrsp_table { enum tcm_tmrsp_table {
TMR_FUNCTION_COMPLETE = 0, TMR_FUNCTION_COMPLETE = 1,
TMR_TASK_DOES_NOT_EXIST = 1, TMR_TASK_DOES_NOT_EXIST = 2,
TMR_LUN_DOES_NOT_EXIST = 2, TMR_LUN_DOES_NOT_EXIST = 3,
TMR_TASK_STILL_ALLEGIANT = 3, TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED = 4,
TMR_TASK_FAILOVER_NOT_SUPPORTED = 4, TMR_FUNCTION_REJECTED = 5,
TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED = 5,
TMR_FUNCTION_AUTHORIZATION_FAILED = 6,
TMR_FUNCTION_REJECTED = 255,
}; };
/* /*
...@@ -339,8 +336,6 @@ struct t10_pr_registration { ...@@ -339,8 +336,6 @@ struct t10_pr_registration {
/* Used during APTPL metadata reading */ /* Used during APTPL metadata reading */
#define PR_APTPL_MAX_TPORT_LEN 256 #define PR_APTPL_MAX_TPORT_LEN 256
unsigned char pr_tport[PR_APTPL_MAX_TPORT_LEN]; unsigned char pr_tport[PR_APTPL_MAX_TPORT_LEN];
/* For writing out live meta data */
unsigned char *pr_aptpl_buf;
u16 pr_aptpl_rpti; u16 pr_aptpl_rpti;
u16 pr_reg_tpgt; u16 pr_reg_tpgt;
/* Reservation effects all target ports */ /* Reservation effects all target ports */
...@@ -374,9 +369,7 @@ struct t10_reservation { ...@@ -374,9 +369,7 @@ struct t10_reservation {
/* Activate Persistence across Target Power Loss enabled /* Activate Persistence across Target Power Loss enabled
* for SCSI device */ * for SCSI device */
int pr_aptpl_active; int pr_aptpl_active;
/* Used by struct t10_reservation->pr_aptpl_buf_len */
#define PR_APTPL_BUF_LEN 8192 #define PR_APTPL_BUF_LEN 8192
u32 pr_aptpl_buf_len;
u32 pr_generation; u32 pr_generation;
spinlock_t registration_lock; spinlock_t registration_lock;
spinlock_t aptpl_reg_lock; spinlock_t aptpl_reg_lock;
...@@ -424,8 +417,6 @@ struct se_cmd { ...@@ -424,8 +417,6 @@ struct se_cmd {
int sam_task_attr; int sam_task_attr;
/* Transport protocol dependent state, see transport_state_table */ /* Transport protocol dependent state, see transport_state_table */
enum transport_state_table t_state; enum transport_state_table t_state;
/* Used to signal cmd->se_tfo->check_release_cmd() usage per cmd */
unsigned check_release:1;
unsigned cmd_wait_set:1; unsigned cmd_wait_set:1;
unsigned unknown_data_length:1; unsigned unknown_data_length:1;
/* See se_cmd_flags_table */ /* See se_cmd_flags_table */
...@@ -458,7 +449,6 @@ struct se_cmd { ...@@ -458,7 +449,6 @@ struct se_cmd {
unsigned char *t_task_cdb; unsigned char *t_task_cdb;
unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE]; unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];
unsigned long long t_task_lba; unsigned long long t_task_lba;
atomic_t t_fe_count;
unsigned int transport_state; unsigned int transport_state;
#define CMD_T_ABORTED (1 << 0) #define CMD_T_ABORTED (1 << 0)
#define CMD_T_ACTIVE (1 << 1) #define CMD_T_ACTIVE (1 << 1)
...@@ -802,11 +792,12 @@ struct se_portal_group { ...@@ -802,11 +792,12 @@ struct se_portal_group {
struct target_core_fabric_ops *se_tpg_tfo; struct target_core_fabric_ops *se_tpg_tfo;
struct se_wwn *se_tpg_wwn; struct se_wwn *se_tpg_wwn;
struct config_group tpg_group; struct config_group tpg_group;
struct config_group *tpg_default_groups[6]; struct config_group *tpg_default_groups[7];
struct config_group tpg_lun_group; struct config_group tpg_lun_group;
struct config_group tpg_np_group; struct config_group tpg_np_group;
struct config_group tpg_acl_group; struct config_group tpg_acl_group;
struct config_group tpg_attrib_group; struct config_group tpg_attrib_group;
struct config_group tpg_auth_group;
struct config_group tpg_param_group; struct config_group tpg_param_group;
}; };
......
...@@ -23,6 +23,7 @@ struct target_fabric_configfs_template { ...@@ -23,6 +23,7 @@ struct target_fabric_configfs_template {
struct config_item_type tfc_tpg_np_cit; struct config_item_type tfc_tpg_np_cit;
struct config_item_type tfc_tpg_np_base_cit; struct config_item_type tfc_tpg_np_base_cit;
struct config_item_type tfc_tpg_attrib_cit; struct config_item_type tfc_tpg_attrib_cit;
struct config_item_type tfc_tpg_auth_cit;
struct config_item_type tfc_tpg_param_cit; struct config_item_type tfc_tpg_param_cit;
struct config_item_type tfc_tpg_nacl_cit; struct config_item_type tfc_tpg_nacl_cit;
struct config_item_type tfc_tpg_nacl_base_cit; struct config_item_type tfc_tpg_nacl_base_cit;
......
...@@ -61,7 +61,7 @@ struct target_core_fabric_ops { ...@@ -61,7 +61,7 @@ struct target_core_fabric_ops {
int (*get_cmd_state)(struct se_cmd *); int (*get_cmd_state)(struct se_cmd *);
int (*queue_data_in)(struct se_cmd *); int (*queue_data_in)(struct se_cmd *);
int (*queue_status)(struct se_cmd *); int (*queue_status)(struct se_cmd *);
int (*queue_tm_rsp)(struct se_cmd *); void (*queue_tm_rsp)(struct se_cmd *);
/* /*
* fabric module calls for target_core_fabric_configfs.c * fabric module calls for target_core_fabric_configfs.c
*/ */
......
...@@ -62,6 +62,17 @@ static struct target_fabric_tpg_attrib_attribute _fabric##_tpg_attrib_##_name = ...@@ -62,6 +62,17 @@ static struct target_fabric_tpg_attrib_attribute _fabric##_tpg_attrib_##_name =
_fabric##_tpg_attrib_show_##_name, \ _fabric##_tpg_attrib_show_##_name, \
_fabric##_tpg_attrib_store_##_name); _fabric##_tpg_attrib_store_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_tpg_auth, se_portal_group);
#define TF_TPG_AUTH_ATTR(_fabric, _name, _mode) \
static struct target_fabric_tpg_auth_attribute _fabric##_tpg_auth_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_tpg_auth_show_##_name, \
_fabric##_tpg_auth_store_##_name);
#define TF_TPG_AUTH_ATTR_RO(_fabric, _name) \
static struct target_fabric_tpg_auth_attribute _fabric##_tpg_auth_##_name = \
__CONFIGFS_EATTR_RO(_name, \
_fabric##_tpg_auth_show_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_tpg_param, se_portal_group); CONFIGFS_EATTR_STRUCT(target_fabric_tpg_param, se_portal_group);
#define TF_TPG_PARAM_ATTR(_fabric, _name, _mode) \ #define TF_TPG_PARAM_ATTR(_fabric, _name, _mode) \
......
#undef TRACE_SYSTEM
#define TRACE_SYSTEM target
#if !defined(_TRACE_TARGET_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_TARGET_H
#include <linux/tracepoint.h>
#include <linux/trace_seq.h>
#include <scsi/scsi.h>
#include <scsi/scsi_tcq.h>
#include <target/target_core_base.h>
/* cribbed verbatim from <trace/event/scsi.h> */
#define scsi_opcode_name(opcode) { opcode, #opcode }
#define show_opcode_name(val) \
__print_symbolic(val, \
scsi_opcode_name(TEST_UNIT_READY), \
scsi_opcode_name(REZERO_UNIT), \
scsi_opcode_name(REQUEST_SENSE), \
scsi_opcode_name(FORMAT_UNIT), \
scsi_opcode_name(READ_BLOCK_LIMITS), \
scsi_opcode_name(REASSIGN_BLOCKS), \
scsi_opcode_name(INITIALIZE_ELEMENT_STATUS), \
scsi_opcode_name(READ_6), \
scsi_opcode_name(WRITE_6), \
scsi_opcode_name(SEEK_6), \
scsi_opcode_name(READ_REVERSE), \
scsi_opcode_name(WRITE_FILEMARKS), \
scsi_opcode_name(SPACE), \
scsi_opcode_name(INQUIRY), \
scsi_opcode_name(RECOVER_BUFFERED_DATA), \
scsi_opcode_name(MODE_SELECT), \
scsi_opcode_name(RESERVE), \
scsi_opcode_name(RELEASE), \
scsi_opcode_name(COPY), \
scsi_opcode_name(ERASE), \
scsi_opcode_name(MODE_SENSE), \
scsi_opcode_name(START_STOP), \
scsi_opcode_name(RECEIVE_DIAGNOSTIC), \
scsi_opcode_name(SEND_DIAGNOSTIC), \
scsi_opcode_name(ALLOW_MEDIUM_REMOVAL), \
scsi_opcode_name(SET_WINDOW), \
scsi_opcode_name(READ_CAPACITY), \
scsi_opcode_name(READ_10), \
scsi_opcode_name(WRITE_10), \
scsi_opcode_name(SEEK_10), \
scsi_opcode_name(POSITION_TO_ELEMENT), \
scsi_opcode_name(WRITE_VERIFY), \
scsi_opcode_name(VERIFY), \
scsi_opcode_name(SEARCH_HIGH), \
scsi_opcode_name(SEARCH_EQUAL), \
scsi_opcode_name(SEARCH_LOW), \
scsi_opcode_name(SET_LIMITS), \
scsi_opcode_name(PRE_FETCH), \
scsi_opcode_name(READ_POSITION), \
scsi_opcode_name(SYNCHRONIZE_CACHE), \
scsi_opcode_name(LOCK_UNLOCK_CACHE), \
scsi_opcode_name(READ_DEFECT_DATA), \
scsi_opcode_name(MEDIUM_SCAN), \
scsi_opcode_name(COMPARE), \
scsi_opcode_name(COPY_VERIFY), \
scsi_opcode_name(WRITE_BUFFER), \
scsi_opcode_name(READ_BUFFER), \
scsi_opcode_name(UPDATE_BLOCK), \
scsi_opcode_name(READ_LONG), \
scsi_opcode_name(WRITE_LONG), \
scsi_opcode_name(CHANGE_DEFINITION), \
scsi_opcode_name(WRITE_SAME), \
scsi_opcode_name(UNMAP), \
scsi_opcode_name(READ_TOC), \
scsi_opcode_name(LOG_SELECT), \
scsi_opcode_name(LOG_SENSE), \
scsi_opcode_name(XDWRITEREAD_10), \
scsi_opcode_name(MODE_SELECT_10), \
scsi_opcode_name(RESERVE_10), \
scsi_opcode_name(RELEASE_10), \
scsi_opcode_name(MODE_SENSE_10), \
scsi_opcode_name(PERSISTENT_RESERVE_IN), \
scsi_opcode_name(PERSISTENT_RESERVE_OUT), \
scsi_opcode_name(VARIABLE_LENGTH_CMD), \
scsi_opcode_name(REPORT_LUNS), \
scsi_opcode_name(MAINTENANCE_IN), \
scsi_opcode_name(MAINTENANCE_OUT), \
scsi_opcode_name(MOVE_MEDIUM), \
scsi_opcode_name(EXCHANGE_MEDIUM), \
scsi_opcode_name(READ_12), \
scsi_opcode_name(WRITE_12), \
scsi_opcode_name(WRITE_VERIFY_12), \
scsi_opcode_name(SEARCH_HIGH_12), \
scsi_opcode_name(SEARCH_EQUAL_12), \
scsi_opcode_name(SEARCH_LOW_12), \
scsi_opcode_name(READ_ELEMENT_STATUS), \
scsi_opcode_name(SEND_VOLUME_TAG), \
scsi_opcode_name(WRITE_LONG_2), \
scsi_opcode_name(READ_16), \
scsi_opcode_name(WRITE_16), \
scsi_opcode_name(VERIFY_16), \
scsi_opcode_name(WRITE_SAME_16), \
scsi_opcode_name(SERVICE_ACTION_IN), \
scsi_opcode_name(SAI_READ_CAPACITY_16), \
scsi_opcode_name(SAI_GET_LBA_STATUS), \
scsi_opcode_name(MI_REPORT_TARGET_PGS), \
scsi_opcode_name(MO_SET_TARGET_PGS), \
scsi_opcode_name(READ_32), \
scsi_opcode_name(WRITE_32), \
scsi_opcode_name(WRITE_SAME_32), \
scsi_opcode_name(ATA_16), \
scsi_opcode_name(ATA_12))
#define show_task_attribute_name(val) \
__print_symbolic(val, \
{ MSG_SIMPLE_TAG, "SIMPLE" }, \
{ MSG_HEAD_TAG, "HEAD" }, \
{ MSG_ORDERED_TAG, "ORDERED" }, \
{ MSG_ACA_TAG, "ACA" } )
#define show_scsi_status_name(val) \
__print_symbolic(val, \
{ SAM_STAT_GOOD, "GOOD" }, \
{ SAM_STAT_CHECK_CONDITION, "CHECK CONDITION" }, \
{ SAM_STAT_CONDITION_MET, "CONDITION MET" }, \
{ SAM_STAT_BUSY, "BUSY" }, \
{ SAM_STAT_INTERMEDIATE, "INTERMEDIATE" }, \
{ SAM_STAT_INTERMEDIATE_CONDITION_MET, "INTERMEDIATE CONDITION MET" }, \
{ SAM_STAT_RESERVATION_CONFLICT, "RESERVATION CONFLICT" }, \
{ SAM_STAT_COMMAND_TERMINATED, "COMMAND TERMINATED" }, \
{ SAM_STAT_TASK_SET_FULL, "TASK SET FULL" }, \
{ SAM_STAT_ACA_ACTIVE, "ACA ACTIVE" }, \
{ SAM_STAT_TASK_ABORTED, "TASK ABORTED" } )
TRACE_EVENT(target_sequencer_start,
TP_PROTO(struct se_cmd *cmd),
TP_ARGS(cmd),
TP_STRUCT__entry(
__field( unsigned int, unpacked_lun )
__field( unsigned int, opcode )
__field( unsigned int, data_length )
__field( unsigned int, task_attribute )
__array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE )
__string( initiator, cmd->se_sess->se_node_acl->initiatorname )
),
TP_fast_assign(
__entry->unpacked_lun = cmd->se_lun->unpacked_lun;
__entry->opcode = cmd->t_task_cdb[0];
__entry->data_length = cmd->data_length;
__entry->task_attribute = cmd->sam_task_attr;
memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE);
__assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname);
),
TP_printk("%s -> LUN %03u %s data_length %6u CDB %s (TA:%s C:%02x)",
__get_str(initiator), __entry->unpacked_lun,
show_opcode_name(__entry->opcode),
__entry->data_length, __print_hex(__entry->cdb, 16),
show_task_attribute_name(__entry->task_attribute),
scsi_command_size(__entry->cdb) <= 16 ?
__entry->cdb[scsi_command_size(__entry->cdb) - 1] :
__entry->cdb[1]
)
);
TRACE_EVENT(target_cmd_complete,
TP_PROTO(struct se_cmd *cmd),
TP_ARGS(cmd),
TP_STRUCT__entry(
__field( unsigned int, unpacked_lun )
__field( unsigned int, opcode )
__field( unsigned int, data_length )
__field( unsigned int, task_attribute )
__field( unsigned char, scsi_status )
__field( unsigned char, sense_length )
__array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE )
__array( unsigned char, sense_data, 18 )
__string(initiator, cmd->se_sess->se_node_acl->initiatorname)
),
TP_fast_assign(
__entry->unpacked_lun = cmd->se_lun->unpacked_lun;
__entry->opcode = cmd->t_task_cdb[0];
__entry->data_length = cmd->data_length;
__entry->task_attribute = cmd->sam_task_attr;
__entry->scsi_status = cmd->scsi_status;
__entry->sense_length = cmd->scsi_status == SAM_STAT_CHECK_CONDITION ?
min(18, ((u8 *) cmd->sense_buffer)[SPC_ADD_SENSE_LEN_OFFSET] + 8) : 0;
memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE);
memcpy(__entry->sense_data, cmd->sense_buffer, __entry->sense_length);
__assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname);
),
TP_printk("%s <- LUN %03u status %s (sense len %d%s%s) %s data_length %6u CDB %s (TA:%s C:%02x)",
__get_str(initiator), __entry->unpacked_lun,
show_scsi_status_name(__entry->scsi_status),
__entry->sense_length, __entry->sense_length ? " / " : "",
__print_hex(__entry->sense_data, __entry->sense_length),
show_opcode_name(__entry->opcode),
__entry->data_length, __print_hex(__entry->cdb, 16),
show_task_attribute_name(__entry->task_attribute),
scsi_command_size(__entry->cdb) <= 16 ?
__entry->cdb[scsi_command_size(__entry->cdb) - 1] :
__entry->cdb[1]
)
);
#endif /* _TRACE_TARGET_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment