All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper
@ 2015-03-07  5:27 Nicholas A. Bellinger
  2015-03-07  5:27 ` [PATCH 2/3] iscsi-target: Expose per endpoint dynamic_sessions attribute Nicholas A. Bellinger
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nicholas A. Bellinger @ 2015-03-07  5:27 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

This patch adds a new helper function that can be used by fabric driver
TPG attributes for dumping the list of active sessions with a dynamically
generated se_node_acl. (generate_node_acl=1).

It prints one se_node_acl->initiatorname per line, up to PAGE_SIZE which
is due to the current limitiation of single page attribute output within
sysfs and configfs code.

Note that if a session is referencing a explicit NodeACL, the InitiatorName
will not appear within dynamic_sessions output.

Reported-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_transport.c       | 24 ++++++++++++++++++++++++
 include/target/target_core_fabric.h          |  1 +
 include/target/target_core_fabric_configfs.h |  5 +++++
 3 files changed, 30 insertions(+)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 0adc0f6..e06c136 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -404,6 +404,30 @@ void target_put_session(struct se_session *se_sess)
 }
 EXPORT_SYMBOL(target_put_session);
 
+ssize_t target_show_dynamic_sessions(struct se_portal_group *se_tpg, char *page)
+{
+	struct se_session *se_sess;
+	ssize_t len = 0;
+
+	spin_lock_bh(&se_tpg->session_lock);
+	list_for_each_entry(se_sess, &se_tpg->tpg_sess_list, sess_list) {
+		if (!se_sess->se_node_acl)
+			continue;
+		if (!se_sess->se_node_acl->dynamic_node_acl)
+			continue;
+		if (strlen(se_sess->se_node_acl->initiatorname) + 1 + len > PAGE_SIZE)
+			break;
+
+		len += snprintf(page + len, PAGE_SIZE - len, "%s\n",
+				se_sess->se_node_acl->initiatorname);
+		len += 1; /* Include NULL terminator */
+	}
+	spin_unlock_bh(&se_tpg->session_lock);
+
+	return len;
+}
+EXPORT_SYMBOL(target_show_dynamic_sessions);
+
 static void target_complete_nacl(struct kref *kref)
 {
 	struct se_node_acl *nacl = container_of(kref,
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index 22a4e98e..2f4a250 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -95,6 +95,7 @@ void	transport_register_session(struct se_portal_group *,
 		struct se_node_acl *, struct se_session *, void *);
 void	target_get_session(struct se_session *);
 void	target_put_session(struct se_session *);
+ssize_t	target_show_dynamic_sessions(struct se_portal_group *, char *);
 void	transport_free_session(struct se_session *);
 void	target_put_nacl(struct se_node_acl *);
 void	transport_deregister_session_configfs(struct se_session *);
diff --git a/include/target/target_core_fabric_configfs.h b/include/target/target_core_fabric_configfs.h
index b32a149..7a0649c 100644
--- a/include/target/target_core_fabric_configfs.h
+++ b/include/target/target_core_fabric_configfs.h
@@ -90,6 +90,11 @@ static struct target_fabric_tpg_attribute _fabric##_tpg_##_name =	\
 	_fabric##_tpg_store_##_name);
 
 
+#define TF_TPG_BASE_ATTR_RO(_fabric, _name)				\
+static struct target_fabric_tpg_attribute _fabric##_tpg_##_name =	\
+	__CONFIGFS_EATTR_RO(_name,					\
+	_fabric##_tpg_show_##_name);
+
 CONFIGFS_EATTR_STRUCT(target_fabric_wwn, target_fabric_configfs);
 #define TF_WWN_ATTR(_fabric, _name, _mode)				\
 static struct target_fabric_wwn_attribute _fabric##_wwn_##_name =	\
-- 
1.9.1


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

* [PATCH 2/3] iscsi-target: Expose per endpoint dynamic_sessions attribute
  2015-03-07  5:27 [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper Nicholas A. Bellinger
@ 2015-03-07  5:27 ` Nicholas A. Bellinger
  2015-03-07  5:27 ` [PATCH 3/3] tcm_qla2xxx: " Nicholas A. Bellinger
  2015-03-08 20:38 ` [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper Christophe Vu-Brugier
  2 siblings, 0 replies; 5+ messages in thread
From: Nicholas A. Bellinger @ 2015-03-07  5:27 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

This patch exposes a new ../iscsi/$IQN/$TPGT/dynamic_sessions attribute
to dump the currently active sessions by iSCSI InitiatorName that have
been created with dynamically generated se_node_acls.

This information is useful so that user-space can optionally perform
dynamic -> explicit NodeACL conversion based on $INITIATOR_WWPN.

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 drivers/target/iscsi/iscsi_target_configfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index 48384b6..95a67f6 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -1410,8 +1410,18 @@ out:
 
 TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR);
 
+static ssize_t lio_target_tpg_show_dynamic_sessions(
+	struct se_portal_group *se_tpg,
+	char *page)
+{
+	return target_show_dynamic_sessions(se_tpg, page);
+}
+
+TF_TPG_BASE_ATTR_RO(lio_target, dynamic_sessions);
+
 static struct configfs_attribute *lio_target_tpg_attrs[] = {
 	&lio_target_tpg_enable.attr,
+	&lio_target_tpg_dynamic_sessions.attr,
 	NULL,
 };
 
-- 
1.9.1


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

* [PATCH 3/3] tcm_qla2xxx: Expose per endpoint dynamic_sessions attribute
  2015-03-07  5:27 [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper Nicholas A. Bellinger
  2015-03-07  5:27 ` [PATCH 2/3] iscsi-target: Expose per endpoint dynamic_sessions attribute Nicholas A. Bellinger
@ 2015-03-07  5:27 ` Nicholas A. Bellinger
  2015-03-10  4:50   ` Saurav Kashyap
  2015-03-08 20:38 ` [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper Christophe Vu-Brugier
  2 siblings, 1 reply; 5+ messages in thread
From: Nicholas A. Bellinger @ 2015-03-07  5:27 UTC (permalink / raw)
  To: target-devel; +Cc: linux-scsi, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

This patch exposes a new ../qla2xxx*/$WWPN/$TPGT/dynamic_sessions
attribute to dump the currently active sessions by FC initiator WWPN
that have been created with dynamically generated se_node_acls.

This information is useful so that user-space can optionally perform
dynamic -> explicit NodeACL conversion based on $INITIATOR_WWPN.

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 99f43b7..c4f66f5 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1082,8 +1082,18 @@ static ssize_t tcm_qla2xxx_tpg_store_enable(
 
 TF_TPG_BASE_ATTR(tcm_qla2xxx, enable, S_IRUGO | S_IWUSR);
 
+static ssize_t tcm_qla2xxx_tpg_show_dynamic_sessions(
+	struct se_portal_group *se_tpg,
+	char *page)
+{
+	return target_show_dynamic_sessions(se_tpg, page);
+}
+
+TF_TPG_BASE_ATTR_RO(tcm_qla2xxx, dynamic_sessions);
+
 static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = {
 	&tcm_qla2xxx_tpg_enable.attr,
+	&tcm_qla2xxx_tpg_dynamic_sessions.attr,
 	NULL,
 };
 
-- 
1.9.1


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

* Re: [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper
  2015-03-07  5:27 [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper Nicholas A. Bellinger
  2015-03-07  5:27 ` [PATCH 2/3] iscsi-target: Expose per endpoint dynamic_sessions attribute Nicholas A. Bellinger
  2015-03-07  5:27 ` [PATCH 3/3] tcm_qla2xxx: " Nicholas A. Bellinger
@ 2015-03-08 20:38 ` Christophe Vu-Brugier
  2 siblings, 0 replies; 5+ messages in thread
From: Christophe Vu-Brugier @ 2015-03-08 20:38 UTC (permalink / raw)
  To: Nicholas A. Bellinger; +Cc: target-devel, linux-scsi, Nicholas Bellinger

Hi Nicholas,

On Sat,  7 Mar 2015 05:27:07 +0000, Nicholas A. Bellinger wrote :
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> This patch adds a new helper function that can be used by fabric
> driver TPG attributes for dumping the list of active sessions with a
> dynamically generated se_node_acl. (generate_node_acl=1).
> 
> It prints one se_node_acl->initiatorname per line, up to PAGE_SIZE
> which is due to the current limitiation of single page attribute
                                   ^
                              limitation

> output within sysfs and configfs code.
> 
> Note that if a session is referencing a explicit NodeACL, the
> InitiatorName will not appear within dynamic_sessions output.
> 
> Reported-by: Andy Grover <agrover@redhat.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
>  drivers/target/target_core_transport.c       | 24
> ++++++++++++++++++++++++ include/target/target_core_fabric.h
> |  1 + include/target/target_core_fabric_configfs.h |  5 +++++
>  3 files changed, 30 insertions(+)
> 
> diff --git a/drivers/target/target_core_transport.c
> b/drivers/target/target_core_transport.c index 0adc0f6..e06c136 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -404,6 +404,30 @@ void target_put_session(struct se_session
> *se_sess) }
>  EXPORT_SYMBOL(target_put_session);
>  
> +ssize_t target_show_dynamic_sessions(struct se_portal_group *se_tpg,
> char *page) +{
> +	struct se_session *se_sess;
> +	ssize_t len = 0;
> +
> +	spin_lock_bh(&se_tpg->session_lock);
> +	list_for_each_entry(se_sess, &se_tpg->tpg_sess_list,
> sess_list) {
> +		if (!se_sess->se_node_acl)
> +			continue;
> +		if (!se_sess->se_node_acl->dynamic_node_acl)
> +			continue;
> +		if (strlen(se_sess->se_node_acl->initiatorname) + 1
> + len > PAGE_SIZE)
> +			break;
> +
> +		len += snprintf(page + len, PAGE_SIZE - len, "%s\n",
> +				se_sess->se_node_acl->initiatorname);
> +		len += 1; /* Include NULL terminator */

I don't understand why a NUL character is needed to separate the
initiator names. Maybe you want to put a NUL character at the end of
the string but I am not sure it is necessary (for instance
lio_target_nacl_show_info() does not do that).

With best regards,

> +	}
> +	spin_unlock_bh(&se_tpg->session_lock);
> +
> +	return len;
> +}
> +EXPORT_SYMBOL(target_show_dynamic_sessions);
> +
>  static void target_complete_nacl(struct kref *kref)
>  {
>  	struct se_node_acl *nacl = container_of(kref,
> diff --git a/include/target/target_core_fabric.h
> b/include/target/target_core_fabric.h index 22a4e98e..2f4a250 100644
> --- a/include/target/target_core_fabric.h
> +++ b/include/target/target_core_fabric.h
> @@ -95,6 +95,7 @@ void	transport_register_session(struct
> se_portal_group *, struct se_node_acl *, struct se_session *, void *);
>  void	target_get_session(struct se_session *);
>  void	target_put_session(struct se_session *);
> +ssize_t	target_show_dynamic_sessions(struct se_portal_group
> *, char *); void	transport_free_session(struct se_session *);
>  void	target_put_nacl(struct se_node_acl *);
>  void	transport_deregister_session_configfs(struct se_session
> *); diff --git a/include/target/target_core_fabric_configfs.h
> b/include/target/target_core_fabric_configfs.h index b32a149..7a0649c
> 100644 --- a/include/target/target_core_fabric_configfs.h
> +++ b/include/target/target_core_fabric_configfs.h
> @@ -90,6 +90,11 @@ static struct target_fabric_tpg_attribute
> _fabric##_tpg_##_name =	\ _fabric##_tpg_store_##_name);
>  
>  
> +#define TF_TPG_BASE_ATTR_RO(_fabric,
> _name)				\ +static struct
> target_fabric_tpg_attribute _fabric##_tpg_##_name =	\
> +
> __CONFIGFS_EATTR_RO(_name,					\
> +	_fabric##_tpg_show_##_name);
> +
>  CONFIGFS_EATTR_STRUCT(target_fabric_wwn, target_fabric_configfs);
>  #define TF_WWN_ATTR(_fabric, _name,
> _mode)				\ static struct
> target_fabric_wwn_attribute _fabric##_wwn_##_name =	\


-- 
Christophe Vu-Brugier

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

* Re: [PATCH 3/3] tcm_qla2xxx: Expose per endpoint dynamic_sessions attribute
  2015-03-07  5:27 ` [PATCH 3/3] tcm_qla2xxx: " Nicholas A. Bellinger
@ 2015-03-10  4:50   ` Saurav Kashyap
  0 siblings, 0 replies; 5+ messages in thread
From: Saurav Kashyap @ 2015-03-10  4:50 UTC (permalink / raw)
  To: Nicholas A. Bellinger, target-devel; +Cc: linux-scsi, Nicholas Bellinger

Acked-by: Saurav Kashyap <saurav.kashyap@qlogic.com>

Thanks,
~Saurav

>From: Nicholas Bellinger <nab@linux-iscsi.org>
>
>This patch exposes a new ../qla2xxx*/$WWPN/$TPGT/dynamic_sessions
>attribute to dump the currently active sessions by FC initiator WWPN
>that have been created with dynamically generated se_node_acls.
>
>This information is useful so that user-space can optionally perform
>dynamic -> explicit NodeACL conversion based on $INITIATOR_WWPN.
>
>Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
>---
> drivers/scsi/qla2xxx/tcm_qla2xxx.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
>diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
>b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
>index 99f43b7..c4f66f5 100644
>--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
>+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
>@@ -1082,8 +1082,18 @@ static ssize_t tcm_qla2xxx_tpg_store_enable(
> 
> TF_TPG_BASE_ATTR(tcm_qla2xxx, enable, S_IRUGO | S_IWUSR);
> 
>+static ssize_t tcm_qla2xxx_tpg_show_dynamic_sessions(
>+	struct se_portal_group *se_tpg,
>+	char *page)
>+{
>+	return target_show_dynamic_sessions(se_tpg, page);
>+}
>+
>+TF_TPG_BASE_ATTR_RO(tcm_qla2xxx, dynamic_sessions);
>+
> static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = {
> 	&tcm_qla2xxx_tpg_enable.attr,
>+	&tcm_qla2xxx_tpg_dynamic_sessions.attr,
> 	NULL,
> };
> 
>-- 
>1.9.1
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2015-03-10  4:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-07  5:27 [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper Nicholas A. Bellinger
2015-03-07  5:27 ` [PATCH 2/3] iscsi-target: Expose per endpoint dynamic_sessions attribute Nicholas A. Bellinger
2015-03-07  5:27 ` [PATCH 3/3] tcm_qla2xxx: " Nicholas A. Bellinger
2015-03-10  4:50   ` Saurav Kashyap
2015-03-08 20:38 ` [PATCH 1/3] target: Add target_show_dynamic_sessions attribute helper Christophe Vu-Brugier

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.