All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] qla2xxx: Patches for target-pending branch
@ 2016-02-04 16:45 Himanshu Madhani
  2016-02-04 16:45 ` [PATCH 1/4] qla2xxx: Fix stale pointer access Himanshu Madhani
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-04 16:45 UTC (permalink / raw)
  To: target-devel, nab; +Cc: giridhar.malavali, linux-scsi, himanshu.madhani

Hi Nic, 

Please apply following patches to target-pending branch at your earliest
convenience.

Thanks,
Himanshu

Quinn Tran (3):
  qla2xxx: Fix stale pointer access.
  qla2xxx: Add DebugFS node for target sess list.
  qla2xxx: Add DebugFS node to show irq vector's cpuid

Swapnil Nagle (1):
  qla2xxx: Use ATIO type to send correct tmr response

 drivers/scsi/qla2xxx/qla_def.h    |    3 +
 drivers/scsi/qla2xxx/qla_dfs.c    |  104 +++++++++++++++++++++++++++++++++++++
 drivers/scsi/qla2xxx/qla_init.c   |   10 ++--
 drivers/scsi/qla2xxx/qla_isr.c    |   20 ++++++-
 drivers/scsi/qla2xxx/qla_mid.c    |    4 +-
 drivers/scsi/qla2xxx/qla_os.c     |    6 ++
 drivers/scsi/qla2xxx/qla_target.c |   58 +++++++++++++-------
 drivers/scsi/qla2xxx/qla_tmpl.c   |   16 ++++++
 8 files changed, 192 insertions(+), 29 deletions(-)

-- 
1.7.7


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/4] qla2xxx: Fix stale pointer access.
  2016-02-04 16:45 [PATCH 0/4] qla2xxx: Patches for target-pending branch Himanshu Madhani
@ 2016-02-04 16:45 ` Himanshu Madhani
  2016-02-04 16:45 ` [PATCH 2/4] qla2xxx: Use ATIO type to send correct tmr response Himanshu Madhani
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-04 16:45 UTC (permalink / raw)
  To: target-devel, nab; +Cc: giridhar.malavali, linux-scsi, himanshu.madhani

From: Quinn Tran <quinn.tran@qlogic.com>

[ Upstream Commit 84e32a06f4f8756ce9ec3c8dc7e97896575f0771 ]

Commit 84e32a0 ("qla2xxx: Use pci_enable_msix_range() instead of
pci_enable_msix()") introduced a regression when target mode is enabled.
In qla24xx_enable_msix(), ha->max_rsp_queues was incorrectly set
to a value higher than the number of response queues allocated causing
an invalid dereference. Specifically here in qla2x00_init_rings():
    *rsp->in_ptr = 0;

Add additional check to make sure the pointer is valid. following
call stack will be seen

---- 8< ----
RIP: 0010:[<ffffffffa02ccadc>]  [<ffffffffa02ccadc>] qla2x00_init_rings+0xdc/0x320 [qla2xxx]
RSP: 0018:ffff880429447dd8  EFLAGS: 00010082
....
Call Trace:
[<ffffffffa02ceb40>] qla2x00_abort_isp+0x170/0x6b0 [qla2xxx]
[<ffffffffa02c6f77>] qla2x00_do_dpc+0x357/0x7f0 [qla2xxx]
[<ffffffffa02c6c20>] ? qla2x00_relogin+0x260/0x260 [qla2xxx]
[<ffffffff8107d2c9>] kthread+0xc9/0xe0
[<ffffffff8107d200>] ? flush_kthread_worker+0x90/0x90
[<ffffffff8172cc6f>] ret_from_fork+0x3f/0x70
[<ffffffff8107d200>] ? flush_kthread_worker+0x90/0x90
---- 8< ----

Cc: <stable@vger.kernel.org>
Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
---
 drivers/scsi/qla2xxx/qla_init.c |   10 +++++-----
 drivers/scsi/qla2xxx/qla_isr.c  |    4 ++--
 drivers/scsi/qla2xxx/qla_mid.c  |    4 ++--
 drivers/scsi/qla2xxx/qla_os.c   |    6 ++++++
 drivers/scsi/qla2xxx/qla_tmpl.c |   16 ++++++++++++++++
 5 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 52a8765..692a757 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -2204,7 +2204,7 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
 	/* Clear outstanding commands array. */
 	for (que = 0; que < ha->max_req_queues; que++) {
 		req = ha->req_q_map[que];
-		if (!req)
+		if (!req || !test_bit(que, ha->req_qid_map))
 			continue;
 		req->out_ptr = (void *)(req->ring + req->length);
 		*req->out_ptr = 0;
@@ -2221,7 +2221,7 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
 
 	for (que = 0; que < ha->max_rsp_queues; que++) {
 		rsp = ha->rsp_q_map[que];
-		if (!rsp)
+		if (!rsp || !test_bit(que, ha->rsp_qid_map))
 			continue;
 		rsp->in_ptr = (void *)(rsp->ring + rsp->length);
 		*rsp->in_ptr = 0;
@@ -4981,7 +4981,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
 
 	for (i = 1; i < ha->max_rsp_queues; i++) {
 		rsp = ha->rsp_q_map[i];
-		if (rsp) {
+		if (rsp && test_bit(i, ha->rsp_qid_map)) {
 			rsp->options &= ~BIT_0;
 			ret = qla25xx_init_rsp_que(base_vha, rsp);
 			if (ret != QLA_SUCCESS)
@@ -4996,8 +4996,8 @@ qla25xx_init_queues(struct qla_hw_data *ha)
 	}
 	for (i = 1; i < ha->max_req_queues; i++) {
 		req = ha->req_q_map[i];
-		if (req) {
-		/* Clear outstanding commands array. */
+		if (req && test_bit(i, ha->req_qid_map)) {
+			/* Clear outstanding commands array. */
 			req->options &= ~BIT_0;
 			ret = qla25xx_init_req_que(base_vha, req);
 			if (ret != QLA_SUCCESS)
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index d4d65eb..4af9547 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -3063,9 +3063,9 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
 		    "MSI-X: Failed to enable support "
 		    "-- %d/%d\n Retry with %d vectors.\n",
 		    ha->msix_count, ret, ret);
+		ha->msix_count = ret;
+		ha->max_rsp_queues = ha->msix_count - 1;
 	}
-	ha->msix_count = ret;
-	ha->max_rsp_queues = ha->msix_count - 1;
 	ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) *
 				ha->msix_count, GFP_KERNEL);
 	if (!ha->msix_entries) {
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index c5dd594..cf7ba52 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -600,7 +600,7 @@ qla25xx_delete_queues(struct scsi_qla_host *vha)
 	/* Delete request queues */
 	for (cnt = 1; cnt < ha->max_req_queues; cnt++) {
 		req = ha->req_q_map[cnt];
-		if (req) {
+		if (req && test_bit(cnt, ha->req_qid_map)) {
 			ret = qla25xx_delete_req_que(vha, req);
 			if (ret != QLA_SUCCESS) {
 				ql_log(ql_log_warn, vha, 0x00ea,
@@ -614,7 +614,7 @@ qla25xx_delete_queues(struct scsi_qla_host *vha)
 	/* Delete response queues */
 	for (cnt = 1; cnt < ha->max_rsp_queues; cnt++) {
 		rsp = ha->rsp_q_map[cnt];
-		if (rsp) {
+		if (rsp && test_bit(cnt, ha->rsp_qid_map)) {
 			ret = qla25xx_delete_rsp_que(vha, rsp);
 			if (ret != QLA_SUCCESS) {
 				ql_log(ql_log_warn, vha, 0x00eb,
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index f1788db..f6c7ce3 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -409,6 +409,9 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
 	int cnt;
 
 	for (cnt = 0; cnt < ha->max_req_queues; cnt++) {
+		if (!test_bit(cnt, ha->req_qid_map))
+			continue;
+
 		req = ha->req_q_map[cnt];
 		qla2x00_free_req_que(ha, req);
 	}
@@ -416,6 +419,9 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
 	ha->req_q_map = NULL;
 
 	for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) {
+		if (!test_bit(cnt, ha->rsp_qid_map))
+			continue;
+
 		rsp = ha->rsp_q_map[cnt];
 		qla2x00_free_rsp_que(ha, rsp);
 	}
diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index ddbe2e7..c3e6225 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -395,6 +395,10 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
 	if (ent->t263.queue_type == T263_QUEUE_TYPE_REQ) {
 		for (i = 0; i < vha->hw->max_req_queues; i++) {
 			struct req_que *req = vha->hw->req_q_map[i];
+
+			if (!test_bit(i, vha->hw->req_qid_map))
+				continue;
+
 			if (req || !buf) {
 				length = req ?
 				    req->length : REQUEST_ENTRY_CNT_24XX;
@@ -408,6 +412,10 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
 	} else if (ent->t263.queue_type == T263_QUEUE_TYPE_RSP) {
 		for (i = 0; i < vha->hw->max_rsp_queues; i++) {
 			struct rsp_que *rsp = vha->hw->rsp_q_map[i];
+
+			if (!test_bit(i, vha->hw->rsp_qid_map))
+				continue;
+
 			if (rsp || !buf) {
 				length = rsp ?
 				    rsp->length : RESPONSE_ENTRY_CNT_MQ;
@@ -634,6 +642,10 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
 	if (ent->t274.queue_type == T274_QUEUE_TYPE_REQ_SHAD) {
 		for (i = 0; i < vha->hw->max_req_queues; i++) {
 			struct req_que *req = vha->hw->req_q_map[i];
+
+			if (!test_bit(i, vha->hw->req_qid_map))
+				continue;
+
 			if (req || !buf) {
 				qla27xx_insert16(i, buf, len);
 				qla27xx_insert16(1, buf, len);
@@ -645,6 +657,10 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
 	} else if (ent->t274.queue_type == T274_QUEUE_TYPE_RSP_SHAD) {
 		for (i = 0; i < vha->hw->max_rsp_queues; i++) {
 			struct rsp_que *rsp = vha->hw->rsp_q_map[i];
+
+			if (!test_bit(i, vha->hw->rsp_qid_map))
+				continue;
+
 			if (rsp || !buf) {
 				qla27xx_insert16(i, buf, len);
 				qla27xx_insert16(1, buf, len);
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/4] qla2xxx: Use ATIO type to send correct tmr response
  2016-02-04 16:45 [PATCH 0/4] qla2xxx: Patches for target-pending branch Himanshu Madhani
  2016-02-04 16:45 ` [PATCH 1/4] qla2xxx: Fix stale pointer access Himanshu Madhani
@ 2016-02-04 16:45 ` Himanshu Madhani
  2016-02-04 16:45 ` [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list Himanshu Madhani
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-04 16:45 UTC (permalink / raw)
  To: target-devel, nab; +Cc: giridhar.malavali, linux-scsi, himanshu.madhani

From: Swapnil Nagle <swapnil.nagle@purestorage.com>

The function value inside se_cmd can change if the TMR is cancelled.
Use original ATIO Type to correctly determine CTIO response.

Signed-off-by: Swapnil Nagle <swapnil.nagle@purestroage.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
---
 drivers/scsi/qla2xxx/qla_target.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 74eb776..46c6679 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -1756,7 +1756,7 @@ void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *mcmd)
 		qlt_send_notify_ack(vha, &mcmd->orig_iocb.imm_ntfy,
 		    0, 0, 0, 0, 0, 0);
 	else {
-		if (mcmd->se_cmd.se_tmr_req->function == TMR_ABORT_TASK)
+		if (mcmd->orig_iocb.atio.u.raw.entry_type == ABTS_RECV_24XX)
 			qlt_24xx_send_abts_resp(vha, &mcmd->orig_iocb.abts,
 			    mcmd->fc_tm_rsp, false);
 		else
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-04 16:45 [PATCH 0/4] qla2xxx: Patches for target-pending branch Himanshu Madhani
  2016-02-04 16:45 ` [PATCH 1/4] qla2xxx: Fix stale pointer access Himanshu Madhani
  2016-02-04 16:45 ` [PATCH 2/4] qla2xxx: Use ATIO type to send correct tmr response Himanshu Madhani
@ 2016-02-04 16:45 ` Himanshu Madhani
  2016-02-04 18:16   ` Bart Van Assche
  2016-02-07  4:40   ` Nicholas A. Bellinger
  2016-02-04 16:45 ` [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid Himanshu Madhani
  2016-02-07  4:31 ` [PATCH 0/4] qla2xxx: Patches for target-pending branch Nicholas A. Bellinger
  4 siblings, 2 replies; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-04 16:45 UTC (permalink / raw)
  To: target-devel, nab; +Cc: giridhar.malavali, linux-scsi, himanshu.madhani

From: Quinn Tran <quinn.tran@qlogic.com>

 #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
 qla2xxx_31
 Port ID   Port Name                Handle
 ff:fc:01  21:fd:00:05:33:c7:ec:16  0
 01:0e:00  21:00:00:24:ff:7b:8a:e4  1
 01:0f:00  21:00:00:24:ff:7b:8a:e5  2
 ....

Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
---
 drivers/scsi/qla2xxx/qla_def.h    |    1 +
 drivers/scsi/qla2xxx/qla_dfs.c    |   55 ++++++++++++++++++++++++++++++++++++
 drivers/scsi/qla2xxx/qla_target.c |   56 ++++++++++++++++++++++++------------
 3 files changed, 93 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 9872f34..e6c5bcf 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2929,6 +2929,7 @@ struct qlt_hw_data {
 
 	uint8_t tgt_node_name[WWN_SIZE];
 
+	struct dentry *dfs_tgt_sess;
 	struct list_head q_full_list;
 	uint32_t num_pend_cmds;
 	uint32_t num_qfull_cmds_alloc;
diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index cd8b96a..34272fd 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -13,6 +13,47 @@ static struct dentry *qla2x00_dfs_root;
 static atomic_t qla2x00_dfs_root_count;
 
 static int
+qla2x00_dfs_tgt_sess_show(struct seq_file *s, void *unused)
+{
+	scsi_qla_host_t *vha = s->private;
+	struct qla_hw_data *ha = vha->hw;
+	unsigned long flags;
+	struct qla_tgt_sess *sess = NULL;
+	struct qla_tgt *tgt= vha->vha_tgt.qla_tgt;
+
+	seq_printf(s, "%s\n",vha->host_str);
+	if (tgt) {
+		seq_printf(s, "Port ID   Port Name                Handle\n");
+
+		spin_lock_irqsave(&ha->tgt.sess_lock, flags);
+		list_for_each_entry(sess, &tgt->sess_list, sess_list_entry) {
+			seq_printf(s, "%02x:%02x:%02x  %8phC  %d\n",
+					   sess->s_id.b.domain,sess->s_id.b.area,
+					   sess->s_id.b.al_pa,	sess->port_name,
+					   sess->loop_id);
+		}
+		spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
+	}
+
+	return 0;
+}
+
+static int
+qla2x00_dfs_tgt_sess_open(struct inode *inode, struct file *file)
+{
+	scsi_qla_host_t *vha = inode->i_private;
+	return single_open(file, qla2x00_dfs_tgt_sess_show, vha);
+}
+
+
+static const struct file_operations dfs_tgt_sess_ops = {
+	.open		= qla2x00_dfs_tgt_sess_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int
 qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)
 {
 	struct scsi_qla_host *vha = s->private;
@@ -248,6 +289,15 @@ create_nodes:
 		    "Unable to create debugfs fce node.\n");
 		goto out;
 	}
+
+	ha->tgt.dfs_tgt_sess = debugfs_create_file("tgt_sess",
+		S_IRUSR, ha->dfs_dir, vha, &dfs_tgt_sess_ops);
+	if (!ha->tgt.dfs_tgt_sess) {
+		ql_log(ql_log_warn, vha, 0xffff,
+			"Unable to create debugFS tgt_sess node.\n");
+		goto out;
+	}
+
 out:
 	return 0;
 }
@@ -257,6 +307,11 @@ qla2x00_dfs_remove(scsi_qla_host_t *vha)
 {
 	struct qla_hw_data *ha = vha->hw;
 
+	if (ha->tgt.dfs_tgt_sess) {
+		debugfs_remove(ha->tgt.dfs_tgt_sess);
+		ha->tgt.dfs_tgt_sess = NULL;
+	}
+
 	if (ha->dfs_fw_resource_cnt) {
 		debugfs_remove(ha->dfs_fw_resource_cnt);
 		ha->dfs_fw_resource_cnt = NULL;
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 46c6679..a754aa4 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -641,7 +641,8 @@ void qlt_unreg_sess(struct qla_tgt_sess *sess)
 {
 	struct scsi_qla_host *vha = sess->vha;
 
-	vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
+	if (sess->se_sess)
+		vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
 
 	if (!list_empty(&sess->del_list_entry))
 		list_del_init(&sess->del_list_entry);
@@ -856,8 +857,12 @@ static void qlt_del_sess_work_fn(struct delayed_work *work)
 			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);
+			if (sess->se_sess) {
+				ha->tgt.tgt_ops->shutdown_sess(sess);
+				ha->tgt.tgt_ops->put_sess(sess);
+			} else {
+				qlt_unreg_sess(sess);
+			}
 		} else {
 			schedule_delayed_work(&tgt->sess_del_work,
 			    sess->expires - elapsed);
@@ -905,6 +910,19 @@ static struct qla_tgt_sess *qlt_create_sess(
 			if (sess->deleted)
 				qlt_undelete_sess(sess);
 
+			if (!sess->se_sess) {
+				be_sid[0] = sess->s_id.b.domain;
+				be_sid[1] = sess->s_id.b.area;
+				be_sid[2] = sess->s_id.b.al_pa;
+
+				if (ha->tgt.tgt_ops->check_initiator_node_acl
+				    (vha, &sess->port_name[0], sess, &be_sid[0],
+				     sess->loop_id) < 0) {
+					spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
+					return NULL;
+				}
+			}
+
 			kref_get(&sess->se_sess->sess_kref);
 			ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id,
 						(fcport->flags & FCF_CONF_COMP_SUPPORTED));
@@ -951,22 +969,6 @@ static struct qla_tgt_sess *qlt_create_sess(
 	be_sid[0] = sess->s_id.b.domain;
 	be_sid[1] = sess->s_id.b.area;
 	be_sid[2] = sess->s_id.b.al_pa;
-	/*
-	 * Determine if this fc_port->port_name is allowed to access
-	 * target mode using explict NodeACLs+MappedLUNs, or using
-	 * TPG demo mode.  If this is successful a target mode FC nexus
-	 * is created.
-	 */
-	if (ha->tgt.tgt_ops->check_initiator_node_acl(vha,
-	    &fcport->port_name[0], sess, &be_sid[0], fcport->loop_id) < 0) {
-		kfree(sess);
-		return NULL;
-	}
-	/*
-	 * Take an extra reference to ->sess_kref here to handle qla_tgt_sess
-	 * access across ->tgt.sess_lock reaquire.
-	 */
-	kref_get(&sess->se_sess->sess_kref);
 
 	sess->conf_compl_supported = (fcport->flags & FCF_CONF_COMP_SUPPORTED);
 	BUILD_BUG_ON(sizeof(sess->port_name) != sizeof(fcport->port_name));
@@ -985,6 +987,22 @@ static struct qla_tgt_sess *qlt_create_sess(
 	    fcport->loop_id, sess->s_id.b.domain, sess->s_id.b.area,
 	    sess->s_id.b.al_pa, sess->conf_compl_supported ?  "" : "not ");
 
+	/*
+	 * Determine if this fc_port->port_name is allowed to access
+	 * target mode using explict NodeACLs+MappedLUNs, or using
+	 * TPG demo mode.  If this is successful a target mode FC nexus
+	 * is created.
+	 */
+	if (ha->tgt.tgt_ops->check_initiator_node_acl(vha,
+	    &fcport->port_name[0], sess, &be_sid[0], fcport->loop_id) < 0)
+		return NULL;
+	else
+		/*
+		 * Take an extra reference to ->sess_kref here to handle qla_tgt_sess
+		 * access across ->tgt.sess_lock reaquire.
+		 */
+		kref_get(&sess->se_sess->sess_kref);
+
 	return sess;
 }
 
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid
  2016-02-04 16:45 [PATCH 0/4] qla2xxx: Patches for target-pending branch Himanshu Madhani
                   ` (2 preceding siblings ...)
  2016-02-04 16:45 ` [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list Himanshu Madhani
@ 2016-02-04 16:45 ` Himanshu Madhani
  2016-02-04 18:20   ` Bart Van Assche
  2016-02-07  4:31 ` [PATCH 0/4] qla2xxx: Patches for target-pending branch Nicholas A. Bellinger
  4 siblings, 1 reply; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-04 16:45 UTC (permalink / raw)
  To: target-devel, nab; +Cc: giridhar.malavali, linux-scsi, himanshu.madhani

From: Quinn Tran <quinn.tran@qlogic.com>

> cat /sys/kernel/debug/qla2xxx/*/irq_cpuid
qla2xxx_81
            IRQ Name  Vector  CPUID
   qla2xxx (default)  150     9
     qla2xxx (rsp_q)  151     9
    qla2xxx (atio_q)  152     9

Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
---
 drivers/scsi/qla2xxx/qla_def.h |    2 +
 drivers/scsi/qla2xxx/qla_dfs.c |   49 ++++++++++++++++++++++++++++++++++++++++
 drivers/scsi/qla2xxx/qla_isr.c |   16 +++++++++++++
 3 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index e6c5bcf..c6cc519 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2722,6 +2722,7 @@ struct qla_msix_entry {
 	int have_irq;
 	uint32_t vector;
 	uint16_t entry;
+	const char *name;
 	struct rsp_que *rsp;
 	struct irq_affinity_notify irq_notify;
 	int cpuid;
@@ -3377,6 +3378,7 @@ struct qla_hw_data {
 	struct dentry *dfs_fce;
 	struct dentry *dfs_tgt_counters;
 	struct dentry *dfs_fw_resource_cnt;
+	struct dentry *dfs_irq_cpuid;
 
 	dma_addr_t	fce_dma;
 	void		*fce;
diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index 34272fd..4ff17f6 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -13,6 +13,41 @@ static struct dentry *qla2x00_dfs_root;
 static atomic_t qla2x00_dfs_root_count;
 
 static int
+qla2x00_dfs_irq_cpuid_show(struct seq_file *s, void *unused)
+{
+	scsi_qla_host_t *vha = s->private;
+	struct qla_hw_data *ha = vha->hw;
+	struct qla_msix_entry *qentry;
+	int i;
+
+	seq_printf(s, "%s\n",vha->host_str);
+	seq_printf(s, "%20s  Vector  CPUID\n","IRQ Name");
+
+	for (i = 0; i < ha->msix_count; i++) {
+		qentry = &ha->msix_entries[i];
+		if (qentry->have_irq)
+			seq_printf(s, "%20s  %3d      %d\n", qentry->name,
+			    qentry->vector, qentry->cpuid);
+	}
+
+	return 0;
+}
+
+static int
+qla2x00_dfs_irq_cpuid_open(struct inode *inode, struct file *file)
+{
+	scsi_qla_host_t *vha = inode->i_private;
+	return single_open(file, qla2x00_dfs_irq_cpuid_show, vha);
+}
+
+static const struct file_operations dfs_irq_cpuid_ops = {
+	.open		= qla2x00_dfs_irq_cpuid_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int
 qla2x00_dfs_tgt_sess_show(struct seq_file *s, void *unused)
 {
 	scsi_qla_host_t *vha = s->private;
@@ -298,6 +333,15 @@ create_nodes:
 		goto out;
 	}
 
+	ha->dfs_irq_cpuid = debugfs_create_file("irq_cpuid",
+		S_IRUSR, ha->dfs_dir, vha, &dfs_irq_cpuid_ops);
+	if (!ha->dfs_irq_cpuid) {
+		ql_log(ql_log_warn, vha, 0xffff,
+			"Unable to create debugFS irq_cpuid node.\n");
+		goto out;
+	}
+
+
 out:
 	return 0;
 }
@@ -307,6 +351,11 @@ qla2x00_dfs_remove(scsi_qla_host_t *vha)
 {
 	struct qla_hw_data *ha = vha->hw;
 
+	if (ha->dfs_irq_cpuid) {
+		debugfs_remove(ha->dfs_irq_cpuid);
+		ha->dfs_irq_cpuid = NULL;
+	}
+
 	if (ha->tgt.dfs_tgt_sess) {
 		debugfs_remove(ha->tgt.dfs_tgt_sess);
 		ha->tgt.dfs_tgt_sess = NULL;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 4af9547..d527189 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -3102,6 +3102,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
 			goto msix_register_fail;
 		qentry->have_irq = 1;
 		qentry->rsp = rsp;
+		qentry->name = msix_entries[i].name;
 		rsp->msix = qentry;
 
 		/* Register for CPU affinity notification. */
@@ -3128,7 +3129,22 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
 			0, qla83xx_msix_entries[ATIO_VECTOR].name, rsp);
 		qentry->have_irq = 1;
 		qentry->rsp = rsp;
+		qentry->name = qla83xx_msix_entries[ATIO_VECTOR].name;
+		qentry->irq_notify.notify  = qla_irq_affinity_notify;
+		qentry->irq_notify.release = qla_irq_affinity_release;
 		rsp->msix = qentry;
+
+		/* Register for CPU affinity notification. */
+		irq_set_affinity_notifier(qentry->vector, &qentry->irq_notify);
+
+		/* Schedule work (ie. trigger a notification) to read cpu
+		 * mask for this specific irq.
+		 * kref_get is required because
+		* irq_affinity_notify() will do
+		* kref_put().
+		*/
+		kref_get(&qentry->irq_notify.kref);
+		schedule_work(&qentry->irq_notify.work);
 	}
 
 msix_register_fail:
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-04 16:45 ` [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list Himanshu Madhani
@ 2016-02-04 18:16   ` Bart Van Assche
  2016-02-05 17:26     ` Himanshu Madhani
  2016-02-07  4:44     ` Nicholas A. Bellinger
  2016-02-07  4:40   ` Nicholas A. Bellinger
  1 sibling, 2 replies; 21+ messages in thread
From: Bart Van Assche @ 2016-02-04 18:16 UTC (permalink / raw)
  To: Himanshu Madhani, target-devel, nab
  Cc: giridhar.malavali, linux-scsi, Quinn Tran

On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
> From: Quinn Tran <quinn.tran@qlogic.com>
>
>   #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
>   qla2xxx_31
>   Port ID   Port Name                Handle
>   ff:fc:01  21:fd:00:05:33:c7:ec:16  0
>   01:0e:00  21:00:00:24:ff:7b:8a:e4  1
>   01:0f:00  21:00:00:24:ff:7b:8a:e5  2
>   ....

Hello Quinn and Himanshu,

The above information is not only useful to people who are debugging the 
QLogic target driver but also to end users who want to check which 
initiator ports have already logged in to a target port. Hence my 
proposal to move this information from debugfs to another location (e.g. 
configfs or sysfs). Users of other target drivers are probably also 
interested in seeing which sessions are active. How about adding the 
functionality for reporting session information per target port in the 
LIO core in such a way that some attributes are available for all target 
drivers (e.g. initiator port name, SCSI command statistics) and such 
that target drivers can define additional attributes to exported for 
each session (e.g. port ID, handle, ...).

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid
  2016-02-04 16:45 ` [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid Himanshu Madhani
@ 2016-02-04 18:20   ` Bart Van Assche
  2016-02-05 18:49     ` Quinn Tran
  0 siblings, 1 reply; 21+ messages in thread
From: Bart Van Assche @ 2016-02-04 18:20 UTC (permalink / raw)
  To: Himanshu Madhani, target-devel, nab
  Cc: giridhar.malavali, linux-scsi, Quinn Tran

On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
> From: Quinn Tran <quinn.tran@qlogic.com>
>
>> cat /sys/kernel/debug/qla2xxx/*/irq_cpuid
> qla2xxx_81
>              IRQ Name  Vector  CPUID
>     qla2xxx (default)  150     9
>       qla2xxx (rsp_q)  151     9
>      qla2xxx (atio_q)  152     9

Hello Quinn and Himanshu,

Do you think it would be possible to generate this information via a 
user-space script from /proc/interrupts and /proc/irq/<n>/smp_affinity?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-04 18:16   ` Bart Van Assche
@ 2016-02-05 17:26     ` Himanshu Madhani
  2016-02-05 20:00       ` Bart Van Assche
  2016-02-07  4:44     ` Nicholas A. Bellinger
  1 sibling, 1 reply; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-05 17:26 UTC (permalink / raw)
  To: Bart Van Assche, target-devel, nab
  Cc: Giridhar Malavali, linux-scsi, Quinn Tran

Hi Bart, 


On 2/4/16, 10:16 AM, "Bart Van Assche" <bart.vanassche@sandisk.com> wrote:

>On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
>> From: Quinn Tran <quinn.tran@qlogic.com>
>>
>>   #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
>>   qla2xxx_31
>>   Port ID   Port Name                Handle
>>   ff:fc:01  21:fd:00:05:33:c7:ec:16  0
>>   01:0e:00  21:00:00:24:ff:7b:8a:e4  1
>>   01:0f:00  21:00:00:24:ff:7b:8a:e5  2
>>   ....
>
>Hello Quinn and Himanshu,
>
>The above information is not only useful to people who are debugging the
>QLogic target driver but also to end users who want to check which
>initiator ports have already logged in to a target port. Hence my
>proposal to move this information from debugfs to another location (e.g.
>configfs or sysfs). Users of other target drivers are probably also
>interested in seeing which sessions are active. How about adding the
>functionality for reporting session information per target port in the
>LIO core in such a way that some attributes are available for all target
>drivers (e.g. initiator port name, SCSI command statistics) and such
>that target drivers can define additional attributes to exported for
>each session (e.g. port ID, handle, ...).

We had initially implemented this as a sysfs hook, but knowing that sysfs
is not encouraged, we decided to put this information via debugfs. Would it
make more sense if we send a sysfs patch?


>
>Thanks,
>
>Bart.

Thanks,
- Himanshu

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid
  2016-02-04 18:20   ` Bart Van Assche
@ 2016-02-05 18:49     ` Quinn Tran
  2016-02-05 19:42       ` Bart Van Assche
  0 siblings, 1 reply; 21+ messages in thread
From: Quinn Tran @ 2016-02-05 18:49 UTC (permalink / raw)
  To: Bart Van Assche, Himanshu Madhani, target-devel, nab
  Cc: Giridhar Malavali, linux-scsi

Bart,

Currently, the data from the 2 mentioned “/proc” entry points were not able to give us the host_id/port & the vector information.

The 2 alternatives are i) change the driver code to register host id along with the vector and add script to combine the infos,  ii) 1 code change that gives us the summary.

We choose path 2 for the ease of usage.

Regards,
Quinn Tran






On 2/4/16, 10:20 AM, "Bart Van Assche" <bart.vanassche@sandisk.com> wrote:

>On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
>> From: Quinn Tran <quinn.tran@qlogic.com>
>>
>>> cat /sys/kernel/debug/qla2xxx/*/irq_cpuid
>> qla2xxx_81
>>              IRQ Name  Vector  CPUID
>>     qla2xxx (default)  150     9
>>       qla2xxx (rsp_q)  151     9
>>      qla2xxx (atio_q)  152     9
>
>Hello Quinn and Himanshu,
>
>Do you think it would be possible to generate this information via a 
>user-space script from /proc/interrupts and /proc/irq/<n>/smp_affinity?
>
>Thanks,
>
>Bart.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid
  2016-02-05 18:49     ` Quinn Tran
@ 2016-02-05 19:42       ` Bart Van Assche
  2016-02-05 21:52         ` Quinn Tran
  0 siblings, 1 reply; 21+ messages in thread
From: Bart Van Assche @ 2016-02-05 19:42 UTC (permalink / raw)
  To: Quinn Tran, Himanshu Madhani, target-devel, nab
  Cc: Giridhar Malavali, linux-scsi

On 02/05/2016 10:49 AM, Quinn Tran wrote:
> On 2/4/16, 10:20 AM, "Bart Van Assche" <bart.vanassche@sandisk.com> wrote:
>> On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
>>> From: Quinn Tran <quinn.tran@qlogic.com>
>>>
>>>> cat /sys/kernel/debug/qla2xxx/*/irq_cpuid
>>> qla2xxx_81
>>>               IRQ Name  Vector  CPUID
>>>      qla2xxx (default)  150     9
>>>        qla2xxx (rsp_q)  151     9
>>>       qla2xxx (atio_q)  152     9
>>
>> Hello Quinn and Himanshu,
>>
>> Do you think it would be possible to generate this information via a
>> user-space script from /proc/interrupts and /proc/irq/<n>/smp_affinity?
>>
>> Thanks,
>>
>> Bart.
>
> Bart,
> 
> Currently, the data from the 2 mentioned “/proc” entry points were not able to give us the host_id/port & the vector information.
> 
> The 2 alternatives are i) change the driver code to register host id along with the vector and add script to combine the infos,  ii) 1 code change that gives us the summary.
> 
> We choose path 2 for the ease of usage.

Hello Quinn,

Please have another look at /proc/interrupts and
/proc/irq/<n>/smp_affinity. The information that is exported through
this patch is already available there. This is why I think this patch
should be dropped. All you need is something like the shell script below.

Sample output (nn = NUMA node; num = IRQ vector):

==== IRQs
nn cpu num count name
0  6   105  1753 PCI-MSI-edge      qla2xxx (rsp_q)                 
1  1   104  8781 PCI-MSI-edge      qla2xxx (default)               
1  1   107  1629 PCI-MSI-edge      qla2xxx (rsp_q)                 

The shell script that produced the above output:

ppi() {
    { echo "$(<"/sys/devices/system/cpu/cpu$1/topology/physical_package_id")" || echo '?'; } 2>/dev/null
}

echo "==== IRQs"
printf "%-2s %-3s %-3s %12s %-50s\n" nn cpu num count name
cat /proc/interrupts |
  while read line; do
    num="$(echo "$line" | sed -n 's/^[[:blank:]]*\([0-9]*\):\([0-9[:blank:]]*\)\(.*\)/\1/p')"
    [ -z "$num" ] && continue
    count=0
    for c in $(echo "$line" | sed -n 's/^[[:blank:]]*\([0-9]*\):\([0-9[:blank:]]*\)\(.*\)/\2/p'); do
	count=$((count+c))
    done
    name="$(echo "$line" | sed -n 's/^[[:blank:]]*\([0-9]*\):\([0-9[:blank:]]*\)\(.*\)/\3/p')"
    if [ -r "/proc/irq/$num/smp_affinity_list" ]; then
	al="$(<"/proc/irq/$num/smp_affinity_list")"
	cpu="${al/-*}" 
	cpu="${cpu/,*}"
	ppi="$(ppi "$cpu")"
    else
	cpu="?"
	ppi="?"
    fi
    printf "%-2s %-3d %-3d %12d %-50s\n" "$ppi" "$cpu" "$num" "$count" "$name"
  done |
  sort -n -k1,3

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-05 17:26     ` Himanshu Madhani
@ 2016-02-05 20:00       ` Bart Van Assche
  2016-02-05 20:17         ` Giridhar Malavali
  0 siblings, 1 reply; 21+ messages in thread
From: Bart Van Assche @ 2016-02-05 20:00 UTC (permalink / raw)
  To: Himanshu Madhani, target-devel, nab
  Cc: Giridhar Malavali, linux-scsi, Quinn Tran, Christoph Hellwig

On 02/05/2016 09:26 AM, Himanshu Madhani wrote:
> On 2/4/16, 10:16 AM, "Bart Van Assche" <bart.vanassche@sandisk.com> wrote:
>> On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
>>> From: Quinn Tran <quinn.tran@qlogic.com>
>>>
>>>    #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
>>>    qla2xxx_31
>>>    Port ID   Port Name                Handle
>>>    ff:fc:01  21:fd:00:05:33:c7:ec:16  0
>>>    01:0e:00  21:00:00:24:ff:7b:8a:e4  1
>>>    01:0f:00  21:00:00:24:ff:7b:8a:e5  2
>>>    ....
>>
>> Hello Quinn and Himanshu,
>>
>> The above information is not only useful to people who are debugging the
>> QLogic target driver but also to end users who want to check which
>> initiator ports have already logged in to a target port. Hence my
>> proposal to move this information from debugfs to another location (e.g.
>> configfs or sysfs). Users of other target drivers are probably also
>> interested in seeing which sessions are active. How about adding the
>> functionality for reporting session information per target port in the
>> LIO core in such a way that some attributes are available for all target
>> drivers (e.g. initiator port name, SCSI command statistics) and such
>> that target drivers can define additional attributes to exported for
>> each session (e.g. port ID, handle, ...).
>
> We had initially implemented this as a sysfs hook, but knowing that sysfs
> is not encouraged, we decided to put this information via debugfs. Would it
> make more sense if we send a sysfs patch?

Hello Himanshu,

Let's try to reach agreement about the approach first before starting to 
rework this patch.

Five years ago I explained in a message that I posted on the linux-scsi 
mailing list why LIO should use sysfs to export information that changes 
dynamically (see also http://thread.gmane.org/gmane.linux.scsi/65615/). 
I think this patch shows that there is a real need to have detailed 
session information from LIO target drivers in user space. We need one 
directory per session instead of exporting all session information 
through a single file. sysfs is the right filesystem to export such 
information because configfs directories should be created by the user 
and not from inside the kernel. If no agreement can be reached about 
this over e-mail my proposal is to discuss this further at the 2016 
LSF/MM summit.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-05 20:00       ` Bart Van Assche
@ 2016-02-05 20:17         ` Giridhar Malavali
  0 siblings, 0 replies; 21+ messages in thread
From: Giridhar Malavali @ 2016-02-05 20:17 UTC (permalink / raw)
  To: Bart Van Assche, Himanshu Madhani, target-devel, nab
  Cc: linux-scsi, Quinn Tran, Christoph Hellwig

[-- Attachment #1: Type: text/plain, Size: 2768 bytes --]



On 2/5/16, 12:00 PM, "Bart Van Assche" <bart.vanassche@sandisk.com> wrote:

>On 02/05/2016 09:26 AM, Himanshu Madhani wrote:
>> On 2/4/16, 10:16 AM, "Bart Van Assche" <bart.vanassche@sandisk.com>
>>wrote:
>>> On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
>>>> From: Quinn Tran <quinn.tran@qlogic.com>
>>>>
>>>>    #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
>>>>    qla2xxx_31
>>>>    Port ID   Port Name                Handle
>>>>    ff:fc:01  21:fd:00:05:33:c7:ec:16  0
>>>>    01:0e:00  21:00:00:24:ff:7b:8a:e4  1
>>>>    01:0f:00  21:00:00:24:ff:7b:8a:e5  2
>>>>    ....
>>>
>>> Hello Quinn and Himanshu,
>>>
>>> The above information is not only useful to people who are debugging
>>>the
>>> QLogic target driver but also to end users who want to check which
>>> initiator ports have already logged in to a target port. Hence my
>>> proposal to move this information from debugfs to another location
>>>(e.g.
>>> configfs or sysfs). Users of other target drivers are probably also
>>> interested in seeing which sessions are active. How about adding the
>>> functionality for reporting session information per target port in the
>>> LIO core in such a way that some attributes are available for all
>>>target
>>> drivers (e.g. initiator port name, SCSI command statistics) and such
>>> that target drivers can define additional attributes to exported for
>>> each session (e.g. port ID, handle, ...).
>>
>> We had initially implemented this as a sysfs hook, but knowing that
>>sysfs
>> is not encouraged, we decided to put this information via debugfs.
>>Would it
>> make more sense if we send a sysfs patch?
>
>Hello Himanshu,
>
>Let's try to reach agreement about the approach first before starting to
>rework this patch.
>
>Five years ago I explained in a message that I posted on the linux-scsi
>mailing list why LIO should use sysfs to export information that changes
>dynamically (see also http://thread.gmane.org/gmane.linux.scsi/65615/).
>I think this patch shows that there is a real need to have detailed
>session information from LIO target drivers in user space. We need one
>directory per session instead of exporting all session information
>through a single file. sysfs is the right filesystem to export such
>information because configfs directories should be created by the user
>and not from inside the kernel. If no agreement can be reached about
>this over e-mail my proposal is to discuss this further at the 2016
>LSF/MM summit.

Bart, 

I see lot of target customers requesting for such information and having
something that can be created inside kernel space will be helpful. Let us
discuss further at 2016 LSF/MM summit.

‹ Giri



>
>Thanks,
>
>Bart.


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 5732 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid
  2016-02-05 19:42       ` Bart Van Assche
@ 2016-02-05 21:52         ` Quinn Tran
  0 siblings, 0 replies; 21+ messages in thread
From: Quinn Tran @ 2016-02-05 21:52 UTC (permalink / raw)
  To: Bart Van Assche, Himanshu Madhani, target-devel, nab
  Cc: Giridhar Malavali, linux-scsi

Bart,

Thanks for sharing the script.  Will drop the patch.

Regards,
Quinn Tran






On 2/5/16, 11:42 AM, "Bart Van Assche" <bart.vanassche@sandisk.com> wrote:

>On 02/05/2016 10:49 AM, Quinn Tran wrote:
>> On 2/4/16, 10:20 AM, "Bart Van Assche" <bart.vanassche@sandisk.com> wrote:
>>> On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
>>>> From: Quinn Tran <quinn.tran@qlogic.com>
>>>>
>>>>> cat /sys/kernel/debug/qla2xxx/*/irq_cpuid
>>>> qla2xxx_81
>>>>               IRQ Name  Vector  CPUID
>>>>      qla2xxx (default)  150     9
>>>>        qla2xxx (rsp_q)  151     9
>>>>       qla2xxx (atio_q)  152     9
>>>
>>> Hello Quinn and Himanshu,
>>>
>>> Do you think it would be possible to generate this information via a
>>> user-space script from /proc/interrupts and /proc/irq/<n>/smp_affinity?
>>>
>>> Thanks,
>>>
>>> Bart.
>>
>> Bart,
>> 
>> Currently, the data from the 2 mentioned “/proc” entry points were not able to give us the host_id/port & the vector information.
>> 
>> The 2 alternatives are i) change the driver code to register host id along with the vector and add script to combine the infos,  ii) 1 code change that gives us the summary.
>> 
>> We choose path 2 for the ease of usage.
>
>Hello Quinn,
>
>Please have another look at /proc/interrupts and
>/proc/irq/<n>/smp_affinity. The information that is exported through
>this patch is already available there. This is why I think this patch
>should be dropped. All you need is something like the shell script below.
>
>Sample output (nn = NUMA node; num = IRQ vector):
>
>==== IRQs
>nn cpu num count name
>0  6   105  1753 PCI-MSI-edge      qla2xxx (rsp_q)                 
>1  1   104  8781 PCI-MSI-edge      qla2xxx (default)               
>1  1   107  1629 PCI-MSI-edge      qla2xxx (rsp_q)                 
>
>The shell script that produced the above output:
>
>ppi() {
>    { echo "$(<"/sys/devices/system/cpu/cpu$1/topology/physical_package_id")" || echo '?'; } 2>/dev/null
>}
>
>echo "==== IRQs"
>printf "%-2s %-3s %-3s %12s %-50s\n" nn cpu num count name
>cat /proc/interrupts |
>  while read line; do
>    num="$(echo "$line" | sed -n 's/^[[:blank:]]*\([0-9]*\):\([0-9[:blank:]]*\)\(.*\)/\1/p')"
>    [ -z "$num" ] && continue
>    count=0
>    for c in $(echo "$line" | sed -n 's/^[[:blank:]]*\([0-9]*\):\([0-9[:blank:]]*\)\(.*\)/\2/p'); do
>	count=$((count+c))
>    done
>    name="$(echo "$line" | sed -n 's/^[[:blank:]]*\([0-9]*\):\([0-9[:blank:]]*\)\(.*\)/\3/p')"
>    if [ -r "/proc/irq/$num/smp_affinity_list" ]; then
>	al="$(<"/proc/irq/$num/smp_affinity_list")"
>	cpu="${al/-*}" 
>	cpu="${cpu/,*}"
>	ppi="$(ppi "$cpu")"
>    else
>	cpu="?"
>	ppi="?"
>    fi
>    printf "%-2s %-3d %-3d %12d %-50s\n" "$ppi" "$cpu" "$num" "$count" "$name"
>  done |
>  sort -n -k1,3
>
>Thanks,
>
>Bart.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/4] qla2xxx: Patches for target-pending branch
  2016-02-04 16:45 [PATCH 0/4] qla2xxx: Patches for target-pending branch Himanshu Madhani
                   ` (3 preceding siblings ...)
  2016-02-04 16:45 ` [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid Himanshu Madhani
@ 2016-02-07  4:31 ` Nicholas A. Bellinger
  4 siblings, 0 replies; 21+ messages in thread
From: Nicholas A. Bellinger @ 2016-02-07  4:31 UTC (permalink / raw)
  To: Himanshu Madhani; +Cc: target-devel, giridhar.malavali, linux-scsi

Hi Himanshu & Co,

On Thu, 2016-02-04 at 11:45 -0500, Himanshu Madhani wrote:
> Hi Nic, 
> 
> Please apply following patches to target-pending branch at your earliest
> convenience.
> 
> Thanks,
> Himanshu
> 
> Quinn Tran (3):
>   qla2xxx: Fix stale pointer access.
>   qla2xxx: Add DebugFS node for target sess list.
>   qla2xxx: Add DebugFS node to show irq vector's cpuid
> 
> Swapnil Nagle (1):
>   qla2xxx: Use ATIO type to send correct tmr response
> 
>  drivers/scsi/qla2xxx/qla_def.h    |    3 +
>  drivers/scsi/qla2xxx/qla_dfs.c    |  104 +++++++++++++++++++++++++++++++++++++
>  drivers/scsi/qla2xxx/qla_init.c   |   10 ++--
>  drivers/scsi/qla2xxx/qla_isr.c    |   20 ++++++-
>  drivers/scsi/qla2xxx/qla_mid.c    |    4 +-
>  drivers/scsi/qla2xxx/qla_os.c     |    6 ++
>  drivers/scsi/qla2xxx/qla_target.c |   58 +++++++++++++-------
>  drivers/scsi/qla2xxx/qla_tmpl.c   |   16 ++++++
>  8 files changed, 192 insertions(+), 29 deletions(-)
> 

Applied #1 + #2 to target-pending/master.

Commenting on the others inline.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-04 16:45 ` [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list Himanshu Madhani
  2016-02-04 18:16   ` Bart Van Assche
@ 2016-02-07  4:40   ` Nicholas A. Bellinger
  2016-02-07  5:00     ` Nicholas A. Bellinger
  2016-02-08 17:43     ` Himanshu Madhani
  1 sibling, 2 replies; 21+ messages in thread
From: Nicholas A. Bellinger @ 2016-02-07  4:40 UTC (permalink / raw)
  To: Himanshu Madhani; +Cc: target-devel, giridhar.malavali, linux-scsi, Quinn Tran

Hi Himanshu & Quinn,

On Thu, 2016-02-04 at 11:45 -0500, Himanshu Madhani wrote:
> From: Quinn Tran <quinn.tran@qlogic.com>
> 
>  #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
>  qla2xxx_31
>  Port ID   Port Name                Handle
>  ff:fc:01  21:fd:00:05:33:c7:ec:16  0
>  01:0e:00  21:00:00:24:ff:7b:8a:e4  1
>  01:0f:00  21:00:00:24:ff:7b:8a:e5  2
>  ....
> 
> Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
> Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
> ---
>  drivers/scsi/qla2xxx/qla_def.h    |    1 +
>  drivers/scsi/qla2xxx/qla_dfs.c    |   55 ++++++++++++++++++++++++++++++++++++
>  drivers/scsi/qla2xxx/qla_target.c |   56 ++++++++++++++++++++++++------------
>  3 files changed, 93 insertions(+), 19 deletions(-)
> 

So looking at this patch beyond the debugfs part, it does change where
->check_initiator_node_acl() gets call during qlt_create_sess().

I assume this is related to new debugfs attribute, and these changes
(plus others in qlt_del_sess_work_fn) are not bug-fixes on their own,
correct..?

Aside from that, I don't have an objection to merge as v4.6 for-next
code if QLogic finds it useful for debugging.

> diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
> index 9872f34..e6c5bcf 100644
> --- a/drivers/scsi/qla2xxx/qla_def.h
> +++ b/drivers/scsi/qla2xxx/qla_def.h
> @@ -2929,6 +2929,7 @@ struct qlt_hw_data {
>  
>  	uint8_t tgt_node_name[WWN_SIZE];
>  
> +	struct dentry *dfs_tgt_sess;
>  	struct list_head q_full_list;
>  	uint32_t num_pend_cmds;
>  	uint32_t num_qfull_cmds_alloc;
> diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
> index cd8b96a..34272fd 100644
> --- a/drivers/scsi/qla2xxx/qla_dfs.c
> +++ b/drivers/scsi/qla2xxx/qla_dfs.c
> @@ -13,6 +13,47 @@ static struct dentry *qla2x00_dfs_root;
>  static atomic_t qla2x00_dfs_root_count;
>  
>  static int
> +qla2x00_dfs_tgt_sess_show(struct seq_file *s, void *unused)
> +{
> +	scsi_qla_host_t *vha = s->private;
> +	struct qla_hw_data *ha = vha->hw;
> +	unsigned long flags;
> +	struct qla_tgt_sess *sess = NULL;
> +	struct qla_tgt *tgt= vha->vha_tgt.qla_tgt;
> +
> +	seq_printf(s, "%s\n",vha->host_str);
> +	if (tgt) {
> +		seq_printf(s, "Port ID   Port Name                Handle\n");
> +
> +		spin_lock_irqsave(&ha->tgt.sess_lock, flags);
> +		list_for_each_entry(sess, &tgt->sess_list, sess_list_entry) {
> +			seq_printf(s, "%02x:%02x:%02x  %8phC  %d\n",
> +					   sess->s_id.b.domain,sess->s_id.b.area,
> +					   sess->s_id.b.al_pa,	sess->port_name,
> +					   sess->loop_id);
> +		}
> +		spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +qla2x00_dfs_tgt_sess_open(struct inode *inode, struct file *file)
> +{
> +	scsi_qla_host_t *vha = inode->i_private;
> +	return single_open(file, qla2x00_dfs_tgt_sess_show, vha);
> +}
> +
> +
> +static const struct file_operations dfs_tgt_sess_ops = {
> +	.open		= qla2x00_dfs_tgt_sess_open,
> +	.read		= seq_read,
> +	.llseek		= seq_lseek,
> +	.release	= single_release,
> +};
> +
> +static int
>  qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)
>  {
>  	struct scsi_qla_host *vha = s->private;
> @@ -248,6 +289,15 @@ create_nodes:
>  		    "Unable to create debugfs fce node.\n");
>  		goto out;
>  	}
> +
> +	ha->tgt.dfs_tgt_sess = debugfs_create_file("tgt_sess",
> +		S_IRUSR, ha->dfs_dir, vha, &dfs_tgt_sess_ops);
> +	if (!ha->tgt.dfs_tgt_sess) {
> +		ql_log(ql_log_warn, vha, 0xffff,
> +			"Unable to create debugFS tgt_sess node.\n");
> +		goto out;
> +	}
> +
>  out:
>  	return 0;
>  }
> @@ -257,6 +307,11 @@ qla2x00_dfs_remove(scsi_qla_host_t *vha)
>  {
>  	struct qla_hw_data *ha = vha->hw;
>  
> +	if (ha->tgt.dfs_tgt_sess) {
> +		debugfs_remove(ha->tgt.dfs_tgt_sess);
> +		ha->tgt.dfs_tgt_sess = NULL;
> +	}
> +
>  	if (ha->dfs_fw_resource_cnt) {
>  		debugfs_remove(ha->dfs_fw_resource_cnt);
>  		ha->dfs_fw_resource_cnt = NULL;
> diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
> index 46c6679..a754aa4 100644
> --- a/drivers/scsi/qla2xxx/qla_target.c
> +++ b/drivers/scsi/qla2xxx/qla_target.c
> @@ -641,7 +641,8 @@ void qlt_unreg_sess(struct qla_tgt_sess *sess)
>  {
>  	struct scsi_qla_host *vha = sess->vha;
>  
> -	vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
> +	if (sess->se_sess)
> +		vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
>  
>  	if (!list_empty(&sess->del_list_entry))
>  		list_del_init(&sess->del_list_entry);
> @@ -856,8 +857,12 @@ static void qlt_del_sess_work_fn(struct delayed_work *work)
>  			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);
> +			if (sess->se_sess) {
> +				ha->tgt.tgt_ops->shutdown_sess(sess);
> +				ha->tgt.tgt_ops->put_sess(sess);
> +			} else {
> +				qlt_unreg_sess(sess);
> +			}
>  		} else {
>  			schedule_delayed_work(&tgt->sess_del_work,
>  			    sess->expires - elapsed);
> @@ -905,6 +910,19 @@ static struct qla_tgt_sess *qlt_create_sess(
>  			if (sess->deleted)
>  				qlt_undelete_sess(sess);
>  
> +			if (!sess->se_sess) {
> +				be_sid[0] = sess->s_id.b.domain;
> +				be_sid[1] = sess->s_id.b.area;
> +				be_sid[2] = sess->s_id.b.al_pa;
> +
> +				if (ha->tgt.tgt_ops->check_initiator_node_acl
> +				    (vha, &sess->port_name[0], sess, &be_sid[0],
> +				     sess->loop_id) < 0) {
> +					spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
> +					return NULL;
> +				}
> +			}
> +
>  			kref_get(&sess->se_sess->sess_kref);
>  			ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id,
>  						(fcport->flags & FCF_CONF_COMP_SUPPORTED));
> @@ -951,22 +969,6 @@ static struct qla_tgt_sess *qlt_create_sess(
>  	be_sid[0] = sess->s_id.b.domain;
>  	be_sid[1] = sess->s_id.b.area;
>  	be_sid[2] = sess->s_id.b.al_pa;
> -	/*
> -	 * Determine if this fc_port->port_name is allowed to access
> -	 * target mode using explict NodeACLs+MappedLUNs, or using
> -	 * TPG demo mode.  If this is successful a target mode FC nexus
> -	 * is created.
> -	 */
> -	if (ha->tgt.tgt_ops->check_initiator_node_acl(vha,
> -	    &fcport->port_name[0], sess, &be_sid[0], fcport->loop_id) < 0) {
> -		kfree(sess);
> -		return NULL;
> -	}
> -	/*
> -	 * Take an extra reference to ->sess_kref here to handle qla_tgt_sess
> -	 * access across ->tgt.sess_lock reaquire.
> -	 */
> -	kref_get(&sess->se_sess->sess_kref);
>  
>  	sess->conf_compl_supported = (fcport->flags & FCF_CONF_COMP_SUPPORTED);
>  	BUILD_BUG_ON(sizeof(sess->port_name) != sizeof(fcport->port_name));
> @@ -985,6 +987,22 @@ static struct qla_tgt_sess *qlt_create_sess(
>  	    fcport->loop_id, sess->s_id.b.domain, sess->s_id.b.area,
>  	    sess->s_id.b.al_pa, sess->conf_compl_supported ?  "" : "not ");
>  
> +	/*
> +	 * Determine if this fc_port->port_name is allowed to access
> +	 * target mode using explict NodeACLs+MappedLUNs, or using
> +	 * TPG demo mode.  If this is successful a target mode FC nexus
> +	 * is created.
> +	 */
> +	if (ha->tgt.tgt_ops->check_initiator_node_acl(vha,
> +	    &fcport->port_name[0], sess, &be_sid[0], fcport->loop_id) < 0)
> +		return NULL;
> +	else
> +		/*
> +		 * Take an extra reference to ->sess_kref here to handle qla_tgt_sess
> +		 * access across ->tgt.sess_lock reaquire.
> +		 */
> +		kref_get(&sess->se_sess->sess_kref);
> +
>  	return sess;
>  }
>  

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-04 18:16   ` Bart Van Assche
  2016-02-05 17:26     ` Himanshu Madhani
@ 2016-02-07  4:44     ` Nicholas A. Bellinger
  1 sibling, 0 replies; 21+ messages in thread
From: Nicholas A. Bellinger @ 2016-02-07  4:44 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Himanshu Madhani, target-devel, giridhar.malavali, linux-scsi,
	Quinn Tran

On Thu, 2016-02-04 at 10:16 -0800, Bart Van Assche wrote:
> On 02/04/2016 08:45 AM, Himanshu Madhani wrote:
> > From: Quinn Tran <quinn.tran@qlogic.com>
> >
> >   #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
> >   qla2xxx_31
> >   Port ID   Port Name                Handle
> >   ff:fc:01  21:fd:00:05:33:c7:ec:16  0
> >   01:0e:00  21:00:00:24:ff:7b:8a:e4  1
> >   01:0f:00  21:00:00:24:ff:7b:8a:e5  2
> >   ....
> 
> Hello Quinn and Himanshu,
> 
> The above information is not only useful to people who are debugging the 
> QLogic target driver but also to end users who want to check which 
> initiator ports have already logged in to a target port. Hence my 
> proposal to move this information from debugfs to another location (e.g. 
> configfs or sysfs). Users of other target drivers are probably also 
> interested in seeing which sessions are active. 

We already have that.  For explicit NodeACLS, see:

   /sys/kernel/config/target/$FABRIC/$T_WWPN/$TPGT/acls/$I_WWPN/info

and for demo-mode dynamically generated se_node_acl, see:

   /sys/kernel/config/target/$FABRIC/$T_WWPN/$TPGT/dynamic_sessions

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-07  4:40   ` Nicholas A. Bellinger
@ 2016-02-07  5:00     ` Nicholas A. Bellinger
  2016-02-09 18:01       ` Himanshu Madhani
  2016-02-08 17:43     ` Himanshu Madhani
  1 sibling, 1 reply; 21+ messages in thread
From: Nicholas A. Bellinger @ 2016-02-07  5:00 UTC (permalink / raw)
  To: Himanshu Madhani; +Cc: target-devel, giridhar.malavali, linux-scsi, Quinn Tran

On Sat, 2016-02-06 at 20:40 -0800, Nicholas A. Bellinger wrote:
> Hi Himanshu & Quinn,
> 
> On Thu, 2016-02-04 at 11:45 -0500, Himanshu Madhani wrote:
> > From: Quinn Tran <quinn.tran@qlogic.com>
> > 
> >  #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
> >  qla2xxx_31
> >  Port ID   Port Name                Handle
> >  ff:fc:01  21:fd:00:05:33:c7:ec:16  0
> >  01:0e:00  21:00:00:24:ff:7b:8a:e4  1
> >  01:0f:00  21:00:00:24:ff:7b:8a:e5  2
> >  ....
> > 
> > Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
> > Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
> > ---
> >  drivers/scsi/qla2xxx/qla_def.h    |    1 +
> >  drivers/scsi/qla2xxx/qla_dfs.c    |   55 ++++++++++++++++++++++++++++++++++++
> >  drivers/scsi/qla2xxx/qla_target.c |   56 ++++++++++++++++++++++++------------
> >  3 files changed, 93 insertions(+), 19 deletions(-)
> > 
> 
> So looking at this patch beyond the debugfs part, it does change where
> ->check_initiator_node_acl() gets call during qlt_create_sess().
> 
> I assume this is related to new debugfs attribute, and these changes
> (plus others in qlt_del_sess_work_fn) are not bug-fixes on their own,
> correct..?
> 
> Aside from that, I don't have an objection to merge as v4.6 for-next
> code if QLogic finds it useful for debugging.
> 

Btw, this patch has a conflict with target-pending/queue-next wrt to
removal of be_sid + loopid from tgt_ops->check_initiator_node_acl(),
which is part of the target_alloc_session() conversion for v4.6.

Here's the updated version that's been applied to queue-next:

https://git.kernel.org/cgit/linux/kernel/git/nab/target-pending.git/commit/?h=queue-next&id=cfd527d9db57ceac8a1e211b77c3357259df48cc

Please verify that it looks + works as expected.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-07  4:40   ` Nicholas A. Bellinger
  2016-02-07  5:00     ` Nicholas A. Bellinger
@ 2016-02-08 17:43     ` Himanshu Madhani
  2016-02-09  5:49       ` Nicholas A. Bellinger
  1 sibling, 1 reply; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-08 17:43 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: target-devel, Giridhar Malavali, linux-scsi, Quinn Tran

Hi Nic, 


On 2/6/16, 8:40 PM, "Nicholas A. Bellinger" <nab@linux-iscsi.org> wrote:

>Hi Himanshu & Quinn,
>
>On Thu, 2016-02-04 at 11:45 -0500, Himanshu Madhani wrote:
>> From: Quinn Tran <quinn.tran@qlogic.com>
>> 
>>  #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
>>  qla2xxx_31
>>  Port ID   Port Name                Handle
>>  ff:fc:01  21:fd:00:05:33:c7:ec:16  0
>>  01:0e:00  21:00:00:24:ff:7b:8a:e4  1
>>  01:0f:00  21:00:00:24:ff:7b:8a:e5  2
>>  ....
>> 
>> Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
>> Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
>> ---
>>  drivers/scsi/qla2xxx/qla_def.h    |    1 +
>>  drivers/scsi/qla2xxx/qla_dfs.c    |   55
>>++++++++++++++++++++++++++++++++++++
>>  drivers/scsi/qla2xxx/qla_target.c |   56
>>++++++++++++++++++++++++------------
>>  3 files changed, 93 insertions(+), 19 deletions(-)
>> 
>
>So looking at this patch beyond the debugfs part, it does change where
>->check_initiator_node_acl() gets call during qlt_create_sess().
>
>I assume this is related to new debugfs attribute, and these changes
>(plus others in qlt_del_sess_work_fn) are not bug-fixes on their own,
>correct..?
>
>Aside from that, I don't have an objection to merge as v4.6 for-next
>code if QLogic finds it useful for debugging.

Yes. The changes in this patch are strictly for making information
available via debugFS
and not bug-fixes on their own. This information has been requested by few
customer who
finds this information useful for debugging and in addition they use this
information in
their configuration scripts as well.


>
>
>
>> diff --git a/drivers/scsi/qla2xxx/qla_def.h
>>b/drivers/scsi/qla2xxx/qla_def.h
>> index 9872f34..e6c5bcf 100644
>> --- a/drivers/scsi/qla2xxx/qla_def.h
>> +++ b/drivers/scsi/qla2xxx/qla_def.h
>> @@ -2929,6 +2929,7 @@ struct qlt_hw_data {
>>  
>>  	uint8_t tgt_node_name[WWN_SIZE];
>>  
>> +	struct dentry *dfs_tgt_sess;
>>  	struct list_head q_full_list;
>>  	uint32_t num_pend_cmds;
>>  	uint32_t num_qfull_cmds_alloc;
>> diff --git a/drivers/scsi/qla2xxx/qla_dfs.c
>>b/drivers/scsi/qla2xxx/qla_dfs.c
>> index cd8b96a..34272fd 100644
>> --- a/drivers/scsi/qla2xxx/qla_dfs.c
>> +++ b/drivers/scsi/qla2xxx/qla_dfs.c
>> @@ -13,6 +13,47 @@ static struct dentry *qla2x00_dfs_root;
>>  static atomic_t qla2x00_dfs_root_count;
>>  
>>  static int
>> +qla2x00_dfs_tgt_sess_show(struct seq_file *s, void *unused)
>> +{
>> +	scsi_qla_host_t *vha = s->private;
>> +	struct qla_hw_data *ha = vha->hw;
>> +	unsigned long flags;
>> +	struct qla_tgt_sess *sess = NULL;
>> +	struct qla_tgt *tgt= vha->vha_tgt.qla_tgt;
>> +
>> +	seq_printf(s, "%s\n",vha->host_str);
>> +	if (tgt) {
>> +		seq_printf(s, "Port ID   Port Name                Handle\n");
>> +
>> +		spin_lock_irqsave(&ha->tgt.sess_lock, flags);
>> +		list_for_each_entry(sess, &tgt->sess_list, sess_list_entry) {
>> +			seq_printf(s, "%02x:%02x:%02x  %8phC  %d\n",
>> +					   sess->s_id.b.domain,sess->s_id.b.area,
>> +					   sess->s_id.b.al_pa,	sess->port_name,
>> +					   sess->loop_id);
>> +		}
>> +		spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int
>> +qla2x00_dfs_tgt_sess_open(struct inode *inode, struct file *file)
>> +{
>> +	scsi_qla_host_t *vha = inode->i_private;
>> +	return single_open(file, qla2x00_dfs_tgt_sess_show, vha);
>> +}
>> +
>> +
>> +static const struct file_operations dfs_tgt_sess_ops = {
>> +	.open		= qla2x00_dfs_tgt_sess_open,
>> +	.read		= seq_read,
>> +	.llseek		= seq_lseek,
>> +	.release	= single_release,
>> +};
>> +
>> +static int
>>  qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)
>>  {
>>  	struct scsi_qla_host *vha = s->private;
>> @@ -248,6 +289,15 @@ create_nodes:
>>  		    "Unable to create debugfs fce node.\n");
>>  		goto out;
>>  	}
>> +
>> +	ha->tgt.dfs_tgt_sess = debugfs_create_file("tgt_sess",
>> +		S_IRUSR, ha->dfs_dir, vha, &dfs_tgt_sess_ops);
>> +	if (!ha->tgt.dfs_tgt_sess) {
>> +		ql_log(ql_log_warn, vha, 0xffff,
>> +			"Unable to create debugFS tgt_sess node.\n");
>> +		goto out;
>> +	}
>> +
>>  out:
>>  	return 0;
>>  }
>> @@ -257,6 +307,11 @@ qla2x00_dfs_remove(scsi_qla_host_t *vha)
>>  {
>>  	struct qla_hw_data *ha = vha->hw;
>>  
>> +	if (ha->tgt.dfs_tgt_sess) {
>> +		debugfs_remove(ha->tgt.dfs_tgt_sess);
>> +		ha->tgt.dfs_tgt_sess = NULL;
>> +	}
>> +
>>  	if (ha->dfs_fw_resource_cnt) {
>>  		debugfs_remove(ha->dfs_fw_resource_cnt);
>>  		ha->dfs_fw_resource_cnt = NULL;
>> diff --git a/drivers/scsi/qla2xxx/qla_target.c
>>b/drivers/scsi/qla2xxx/qla_target.c
>> index 46c6679..a754aa4 100644
>> --- a/drivers/scsi/qla2xxx/qla_target.c
>> +++ b/drivers/scsi/qla2xxx/qla_target.c
>> @@ -641,7 +641,8 @@ void qlt_unreg_sess(struct qla_tgt_sess *sess)
>>  {
>>  	struct scsi_qla_host *vha = sess->vha;
>>  
>> -	vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
>> +	if (sess->se_sess)
>> +		vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
>>  
>>  	if (!list_empty(&sess->del_list_entry))
>>  		list_del_init(&sess->del_list_entry);
>> @@ -856,8 +857,12 @@ static void qlt_del_sess_work_fn(struct
>>delayed_work *work)
>>  			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);
>> +			if (sess->se_sess) {
>> +				ha->tgt.tgt_ops->shutdown_sess(sess);
>> +				ha->tgt.tgt_ops->put_sess(sess);
>> +			} else {
>> +				qlt_unreg_sess(sess);
>> +			}
>>  		} else {
>>  			schedule_delayed_work(&tgt->sess_del_work,
>>  			    sess->expires - elapsed);
>> @@ -905,6 +910,19 @@ static struct qla_tgt_sess *qlt_create_sess(
>>  			if (sess->deleted)
>>  				qlt_undelete_sess(sess);
>>  
>> +			if (!sess->se_sess) {
>> +				be_sid[0] = sess->s_id.b.domain;
>> +				be_sid[1] = sess->s_id.b.area;
>> +				be_sid[2] = sess->s_id.b.al_pa;
>> +
>> +				if (ha->tgt.tgt_ops->check_initiator_node_acl
>> +				    (vha, &sess->port_name[0], sess, &be_sid[0],
>> +				     sess->loop_id) < 0) {
>> +					spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
>> +					return NULL;
>> +				}
>> +			}
>> +
>>  			kref_get(&sess->se_sess->sess_kref);
>>  			ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id,
>>  						(fcport->flags & FCF_CONF_COMP_SUPPORTED));
>> @@ -951,22 +969,6 @@ static struct qla_tgt_sess *qlt_create_sess(
>>  	be_sid[0] = sess->s_id.b.domain;
>>  	be_sid[1] = sess->s_id.b.area;
>>  	be_sid[2] = sess->s_id.b.al_pa;
>> -	/*
>> -	 * Determine if this fc_port->port_name is allowed to access
>> -	 * target mode using explict NodeACLs+MappedLUNs, or using
>> -	 * TPG demo mode.  If this is successful a target mode FC nexus
>> -	 * is created.
>> -	 */
>> -	if (ha->tgt.tgt_ops->check_initiator_node_acl(vha,
>> -	    &fcport->port_name[0], sess, &be_sid[0], fcport->loop_id) < 0) {
>> -		kfree(sess);
>> -		return NULL;
>> -	}
>> -	/*
>> -	 * Take an extra reference to ->sess_kref here to handle qla_tgt_sess
>> -	 * access across ->tgt.sess_lock reaquire.
>> -	 */
>> -	kref_get(&sess->se_sess->sess_kref);
>>  
>>  	sess->conf_compl_supported = (fcport->flags &
>>FCF_CONF_COMP_SUPPORTED);
>>  	BUILD_BUG_ON(sizeof(sess->port_name) != sizeof(fcport->port_name));
>> @@ -985,6 +987,22 @@ static struct qla_tgt_sess *qlt_create_sess(
>>  	    fcport->loop_id, sess->s_id.b.domain, sess->s_id.b.area,
>>  	    sess->s_id.b.al_pa, sess->conf_compl_supported ?  "" : "not ");
>>  
>> +	/*
>> +	 * Determine if this fc_port->port_name is allowed to access
>> +	 * target mode using explict NodeACLs+MappedLUNs, or using
>> +	 * TPG demo mode.  If this is successful a target mode FC nexus
>> +	 * is created.
>> +	 */
>> +	if (ha->tgt.tgt_ops->check_initiator_node_acl(vha,
>> +	    &fcport->port_name[0], sess, &be_sid[0], fcport->loop_id) < 0)
>> +		return NULL;
>> +	else
>> +		/*
>> +		 * Take an extra reference to ->sess_kref here to handle qla_tgt_sess
>> +		 * access across ->tgt.sess_lock reaquire.
>> +		 */
>> +		kref_get(&sess->se_sess->sess_kref);
>> +
>>  	return sess;
>>  }
>>  
>
>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-08 17:43     ` Himanshu Madhani
@ 2016-02-09  5:49       ` Nicholas A. Bellinger
  2016-02-09 21:30         ` Himanshu Madhani
  0 siblings, 1 reply; 21+ messages in thread
From: Nicholas A. Bellinger @ 2016-02-09  5:49 UTC (permalink / raw)
  To: Himanshu Madhani; +Cc: target-devel, Giridhar Malavali, linux-scsi, Quinn Tran

On Mon, 2016-02-08 at 17:43 +0000, Himanshu Madhani wrote:
> >
> >So looking at this patch beyond the debugfs part, it does change where
> >->check_initiator_node_acl() gets call during qlt_create_sess().
> >
> >I assume this is related to new debugfs attribute, and these changes
> >(plus others in qlt_del_sess_work_fn) are not bug-fixes on their own,
> >correct..?
> >
> >Aside from that, I don't have an objection to merge as v4.6 for-next
> >code if QLogic finds it useful for debugging.
> 
> Yes. The changes in this patch are strictly for making information
> available via debugFS and not bug-fixes on their own.

Thanks for clarifying.

> This information has been requested by few customer who
> finds this information useful for debugging and in addition they use this
> information in their configuration scripts as well.

So I've got no particular objection to people adding debugfs
informational attributes for whatever to aid debugging of their drivers.

That said, the same information can too be exposed as a tcm_qla2xxx
struct se_node_acl->acl_group configfs attribute, and for demo-mode
sessions via a tcm_qla2xxx provided dynamic_sessions configfs attribute
handler.

I'd be happy to add expose this under tcm_qla2xxx configfs for v4.6 code
if you'd like, otherwise I'm OK with the patch in queue-next as-is if
you find it useful.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-07  5:00     ` Nicholas A. Bellinger
@ 2016-02-09 18:01       ` Himanshu Madhani
  0 siblings, 0 replies; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-09 18:01 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: target-devel, Giridhar Malavali, linux-scsi, Quinn Tran

[-- Attachment #1: Type: text/plain, Size: 1987 bytes --]



On 2/6/16, 9:00 PM, "Nicholas A. Bellinger" <nab@linux-iscsi.org> wrote:

>On Sat, 2016-02-06 at 20:40 -0800, Nicholas A. Bellinger wrote:
>> Hi Himanshu & Quinn,
>> 
>> On Thu, 2016-02-04 at 11:45 -0500, Himanshu Madhani wrote:
>> > From: Quinn Tran <quinn.tran@qlogic.com>
>> > 
>> >  #cat  /sys/kernel/debug/qla2xxx/qla2xxx_31/tgt_sess
>> >  qla2xxx_31
>> >  Port ID   Port Name                Handle
>> >  ff:fc:01  21:fd:00:05:33:c7:ec:16  0
>> >  01:0e:00  21:00:00:24:ff:7b:8a:e4  1
>> >  01:0f:00  21:00:00:24:ff:7b:8a:e5  2
>> >  ....
>> > 
>> > Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
>> > Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
>> > ---
>> >  drivers/scsi/qla2xxx/qla_def.h    |    1 +
>> >  drivers/scsi/qla2xxx/qla_dfs.c    |   55
>>++++++++++++++++++++++++++++++++++++
>> >  drivers/scsi/qla2xxx/qla_target.c |   56
>>++++++++++++++++++++++++------------
>> >  3 files changed, 93 insertions(+), 19 deletions(-)
>> > 
>> 
>> So looking at this patch beyond the debugfs part, it does change where
>> ->check_initiator_node_acl() gets call during qlt_create_sess().
>> 
>> I assume this is related to new debugfs attribute, and these changes
>> (plus others in qlt_del_sess_work_fn) are not bug-fixes on their own,
>> correct..?
>> 
>> Aside from that, I don't have an objection to merge as v4.6 for-next
>> code if QLogic finds it useful for debugging.
>> 
>
>Btw, this patch has a conflict with target-pending/queue-next wrt to
>removal of be_sid + loopid from tgt_ops->check_initiator_node_acl(),
>which is part of the target_alloc_session() conversion for v4.6.
>
>Here's the updated version that's been applied to queue-next:
>
>https://git.kernel.org/cgit/linux/kernel/git/nab/target-pending.git/commit
>/?h=queue-next&id=cfd527d9db57ceac8a1e211b77c3357259df48cc
>
>Please verify that it looks + works as expected.
>

This Patch looks good. Tested successfully on my setup.

>


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 5416 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list.
  2016-02-09  5:49       ` Nicholas A. Bellinger
@ 2016-02-09 21:30         ` Himanshu Madhani
  0 siblings, 0 replies; 21+ messages in thread
From: Himanshu Madhani @ 2016-02-09 21:30 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: target-devel, Giridhar Malavali, linux-scsi, Quinn Tran


On 2/8/16, 9:49 PM, "Nicholas A. Bellinger" <nab@linux-iscsi.org> wrote:

>On Mon, 2016-02-08 at 17:43 +0000, Himanshu Madhani wrote:
>> >
>> >So looking at this patch beyond the debugfs part, it does change where
>> >->check_initiator_node_acl() gets call during qlt_create_sess().
>> >
>> >I assume this is related to new debugfs attribute, and these changes
>> >(plus others in qlt_del_sess_work_fn) are not bug-fixes on their own,
>> >correct..?
>> >
>> >Aside from that, I don't have an objection to merge as v4.6 for-next
>> >code if QLogic finds it useful for debugging.
>> 
>> Yes. The changes in this patch are strictly for making information
>> available via debugFS and not bug-fixes on their own.
>
>Thanks for clarifying.
>
>> This information has been requested by few customer who
>> finds this information useful for debugging and in addition they use
>>this
>> information in their configuration scripts as well.
>
>So I've got no particular objection to people adding debugfs
>informational attributes for whatever to aid debugging of their drivers.
>
>That said, the same information can too be exposed as a tcm_qla2xxx
>struct se_node_acl->acl_group configfs attribute, and for demo-mode
>sessions via a tcm_qla2xxx provided dynamic_sessions configfs attribute
>handler.
>
>I'd be happy to add expose this under tcm_qla2xxx configfs for v4.6 code
>if you'd like, otherwise I'm OK with the patch in queue-next as-is if
>you find it useful.
>

I really like your idea of exposing this information via configFS. Please
go ahead and make updates on exposing this information via
se_node_acl->acl_group
Configfs attribute. We can ask our customer to explore configfs to retrieve
information. However, We would also like to keep this information in
debugFS for now.

>

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-02-09 21:30 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-04 16:45 [PATCH 0/4] qla2xxx: Patches for target-pending branch Himanshu Madhani
2016-02-04 16:45 ` [PATCH 1/4] qla2xxx: Fix stale pointer access Himanshu Madhani
2016-02-04 16:45 ` [PATCH 2/4] qla2xxx: Use ATIO type to send correct tmr response Himanshu Madhani
2016-02-04 16:45 ` [PATCH 3/4] qla2xxx: Add DebugFS node for target sess list Himanshu Madhani
2016-02-04 18:16   ` Bart Van Assche
2016-02-05 17:26     ` Himanshu Madhani
2016-02-05 20:00       ` Bart Van Assche
2016-02-05 20:17         ` Giridhar Malavali
2016-02-07  4:44     ` Nicholas A. Bellinger
2016-02-07  4:40   ` Nicholas A. Bellinger
2016-02-07  5:00     ` Nicholas A. Bellinger
2016-02-09 18:01       ` Himanshu Madhani
2016-02-08 17:43     ` Himanshu Madhani
2016-02-09  5:49       ` Nicholas A. Bellinger
2016-02-09 21:30         ` Himanshu Madhani
2016-02-04 16:45 ` [PATCH 4/4] qla2xxx: Add DebugFS node to show irq vector's cpuid Himanshu Madhani
2016-02-04 18:20   ` Bart Van Assche
2016-02-05 18:49     ` Quinn Tran
2016-02-05 19:42       ` Bart Van Assche
2016-02-05 21:52         ` Quinn Tran
2016-02-07  4:31 ` [PATCH 0/4] qla2xxx: Patches for target-pending branch Nicholas A. Bellinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.