Skip to contentSkip to conversation

scsi_transport_iscsi.c contexts

PATCH In review Nicholas A. Bellinger 2 participants 7 messages Apr 28, 2005 – Apr 30, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi_transport_iscsi.c contexts

This patch against 2.6.12-rc3 is the first step for scsi_transport_iscsi getting iSCSI Keys defined in RFC 3720 Section 12 and other values not defined in this section as keys, but need to be exported out via sysfs into the correct connection/session contexts.

Currently, scsi_transport_iscsi.[c,h] assume that all values are on a per session basis. These changes have been tested with the upcoming iSCSI transport class enabled release of iscsi-initiator-core (1.6.2.0-rc2), and should hopefully be 'breakage-free' with sfnet.

Comments?

Signature · 28 lines
Nicholas A. Bellinger <[email protected]>

-----------------------------------------------------------------------

Pretty straight forward changes to:

drivers/scsi/scsi_transport_iscsi.c

Added a connection_attrib[] member to iscsi_internal.

Made max_recv_data_segment_len, header_digest, data_digest, ip_address
and port per connection.

Added of_marker, if_marker, of_markint and if_markint from RFC 3720
Appendix A.  Also per connection.

Also moved around the various CPP macros for creating the class device
functions.  This should be much more reable now.

include/scsi/scsi_transport_iscsi.h

Added a struct iscsi_connection_class.

Added struct iscsi_connection_class to struct iscsi_session_class.

Split out the connection/session accessor macros.

Some reorginization of struct iscsi_function_template.
drivers/scsi/scsi_transport_iscsi.c +212 -134
diff -urN linux-2.6.12-rc3/drivers/scsi/scsi_transport_iscsi.c linux-2.6.12-rc3-iscsi/drivers/scsi/scsi_transport_iscsi.c
@@ -3,6 +3,8 @@
  *
  * Copyright (C) IBM Corporation, 2004
  * Copyright (C) Mike Christie, 2004
+ * Copyright (C) PyX Technologies, 2005
+ * Copyright (C) Nicholas A. Bellinger <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +27,8 @@
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_transport_iscsi.h>
 
-#define ISCSI_SESSION_ATTRS 20
+#define ISCSI_CONNECTION_ATTRS 9
+#define ISCSI_SESSION_ATTRS 15
 #define ISCSI_HOST_ATTRS 2
 
 struct iscsi_internal {
@@ -34,6 +37,7 @@
 	/*
 	 * We do not have any private or other attrs.
 	 */
+	struct class_device_attribute *connection_attrs[ISCSI_CONNECTION_ATTRS + 1];
 	struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
 	struct class_device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1];
 };
@@ -51,68 +55,119 @@
 			       NULL,
 			       NULL,
 			       NULL);
+
 /*
- * iSCSI target and session attrs
+ * Format specification attributes
  */
-#define iscsi_session_show_fn(field, format)				\
+#define iscsi_show_fn(type, field, format)				\
 									\
 static ssize_t								\
-show_session_##field(struct class_device *cdev, char *buf)		\
+iscsi_show_##type##_##field(struct class_device *cdev, char *buf)	\
 {									\
 	struct scsi_target *starget = transport_class_to_starget(cdev);	\
 	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
 	struct iscsi_internal *i = to_iscsi_internal(shost->transportt); \
 									\
 	if (i->fnt->get_##field)					\
-		i->fnt->get_##field(starget);				\
-	return snprintf(buf, 20, format"\n", iscsi_##field(starget));	\
+		 i->fnt->get_##field(starget);				\
+	return snprintf(buf, 20, format"\n", iscsi_##field(starget));   \
 }
 
+#define iscsi_connection_rd_attr(field, format)				\
+	iscsi_show_fn(connection, field, format)			\
+static CLASS_DEVICE_ATTR(field, S_IRUGO, iscsi_show_connection_##field, NULL);
+
 #define iscsi_session_rd_attr(field, format)				\
-	iscsi_session_show_fn(field, format)				\
-static CLASS_DEVICE_ATTR(field, S_IRUGO, show_session_##field, NULL);
+	iscsi_show_fn(session, field, format)				\
+static CLASS_DEVICE_ATTR(field, S_IRUGO, iscsi_show_session_##field, NULL);
 
-iscsi_session_rd_attr(tpgt, "%hu");
-iscsi_session_rd_attr(tsih, "%2x");
-iscsi_session_rd_attr(max_recv_data_segment_len, "%u");
-iscsi_session_rd_attr(max_burst_len, "%u");
-iscsi_session_rd_attr(first_burst_len, "%u");
-iscsi_session_rd_attr(def_time2wait, "%hu");
-iscsi_session_rd_attr(def_time2retain, "%hu");
-iscsi_session_rd_attr(max_outstanding_r2t, "%hu");
-iscsi_session_rd_attr(erl, "%d");
+/*
+ * Boolean attributes
+ */
+#define iscsi_show_bool_fn(type, field)                                 \
+                                                                        \
+static ssize_t                                                          \
+iscsi_show_##type##_bool_##field(struct class_device *cdev, char *buf)	\
+{                                                                       \
+        struct scsi_target *starget = transport_class_to_starget(cdev); \
+        struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);    \
+        struct iscsi_internal *i = to_iscsi_internal(shost->transportt); \
+                                                                        \
+        if (i->fnt->get_##field)                                        \
+                i->fnt->get_##field(starget);                           \
+                                                                        \
+        if (iscsi_##field(starget))                                     \
+                return sprintf(buf, "Yes\n");                           \
+        return sprintf(buf, "No\n");                                    \
+}
+
+#define iscsi_connection_rd_bool_attr(field)				\
+        iscsi_show_bool_fn(connection, field)				\
+static CLASS_DEVICE_ATTR(field, S_IRUGO, iscsi_show_connection_bool_##field, NULL);
 
+#define iscsi_session_rd_bool_attr(field)				\
+        iscsi_show_bool_fn(session, field)				\
+static CLASS_DEVICE_ATTR(field, S_IRUGO, iscsi_show_session_bool_##field, NULL);
 
-#define iscsi_session_show_bool_fn(field)				\
+/*
+ * This is used for iSCSI names. Normally, we follow
+ * the transport class convention of having the lld
+ * set the field, but in these cases the value is
+ * too large.
+ */
+#define iscsi_show_str_fn(type, field)					\
 									\
 static ssize_t								\
-show_session_bool_##field(struct class_device *cdev, char *buf)		\
-{									\
-	struct scsi_target *starget = transport_class_to_starget(cdev);	\
-	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
-	struct iscsi_internal *i = to_iscsi_internal(shost->transportt); \
-									\
-	if (i->fnt->get_##field)					\
-		i->fnt->get_##field(starget);				\
-									\
-	if (iscsi_##field(starget))					\
-		return sprintf(buf, "Yes\n");				\
-	return sprintf(buf, "No\n");					\
+iscsi_show_##type##_str_##field(struct class_device *cdev, char *buf)	\
+{                                                                       \
+        ssize_t ret = 0;                                                \
+        struct scsi_target *starget = transport_class_to_starget(cdev); \
+        struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);    \
+        struct iscsi_internal *i = to_iscsi_internal(shost->transportt); \
+                                                                        \
+        if (i->fnt->get_##field)                                        \
+                ret = i->fnt->get_##field(starget, buf, PAGE_SIZE);     \
+        return ret;                                                     \
 }
 
-#define iscsi_session_rd_bool_attr(field)				\
-	iscsi_session_show_bool_fn(field)				\
-static CLASS_DEVICE_ATTR(field, S_IRUGO, show_session_bool_##field, NULL);
+#define iscsi_connection_rd_str_attr(field)				\
+        iscsi_show_str_fn(connection, field)				\
+static CLASS_DEVICE_ATTR(field, S_IRUGO, iscsi_show_connection_str_##field, NULL);
 
-iscsi_session_rd_bool_attr(initial_r2t);
-iscsi_session_rd_bool_attr(immediate_data);
-iscsi_session_rd_bool_attr(data_pdu_in_order);
-iscsi_session_rd_bool_attr(data_sequence_in_order);
+#define iscsi_session_rd_str_attr(field)				\
+        iscsi_show_str_fn(session, field)				\
+static CLASS_DEVICE_ATTR(field, S_IRUGO, iscsi_show_session_str_##field, NULL);
 
-#define iscsi_session_show_digest_fn(field)				\
+/*
+ * Again, this is used for iSCSI names. Normally, we follow
+ * the transport class convention of having the lld set
+ * the field, but in these cases the value is too large.
+ */
+#define iscsi_host_show_str_fn(field)                                   \
+                                                                        \
+static ssize_t                                                          \
+iscsi_show_host_str_##field(struct class_device *cdev, char *buf)	\
+{                                                                       \
+        int ret = 0;                                                    \
+        struct Scsi_Host *shost = transport_class_to_shost(cdev);       \
+        struct iscsi_internal *i = to_iscsi_internal(shost->transportt); \
+                                                                        \
+        if (i->fnt->get_##field)                                        \
+                ret = i->fnt->get_##field(shost, buf, PAGE_SIZE);       \
+        return ret;                                                     \
+}
+
+#define iscsi_host_rd_str_attr(field)                                   \
+        iscsi_host_show_str_fn(field)                                   \
+static CLASS_DEVICE_ATTR(field, S_IRUGO, iscsi_show_host_str_##field, NULL);
+
+/*
+ * Special case for Digests
+ */
+#define iscsi_show_connection_digest_fn(field)				\
 									\
 static ssize_t								\
-show_##field(struct class_device *cdev, char *buf)			\
+iscsi_show_connection_##field(struct class_device *cdev, char *buf)	\
 {									\
 	struct scsi_target *starget = transport_class_to_starget(cdev);	\
 	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
@@ -126,121 +181,93 @@
 	return sprintf(buf, "None\n");					\
 }
 
-#define iscsi_session_rd_digest_attr(field)				\
-	iscsi_session_show_digest_fn(field)				\
-static CLASS_DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
-
-iscsi_session_rd_digest_attr(header_digest);
-iscsi_session_rd_digest_attr(data_digest);
-
-static ssize_t
-show_port(struct class_device *cdev, char *buf)
-{
-	struct scsi_target *starget = transport_class_to_starget(cdev);
-	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
-	struct iscsi_internal *i = to_iscsi_internal(shost->transportt);
-
-	if (i->fnt->get_port)
-		i->fnt->get_port(starget);
-
-	return snprintf(buf, 20, "%hu\n", ntohs(iscsi_port(starget)));
-}
-static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
-
-static ssize_t
-show_ip_address(struct class_device *cdev, char *buf)
-{
-	struct scsi_target *starget = transport_class_to_starget(cdev);
-	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
-	struct iscsi_internal *i = to_iscsi_internal(shost->transportt);
-
-	if (i->fnt->get_ip_address)
-		i->fnt->get_ip_address(starget);
-
-	if (iscsi_addr_type(starget) == AF_INET)
-		return sprintf(buf, "%u.%u.%u.%u\n",
-			       NIPQUAD(iscsi_sin_addr(starget)));
-	else if(iscsi_addr_type(starget) == AF_INET6)
-		return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
-			       NIP6(iscsi_sin6_addr(starget)));
-	return -EINVAL;
-}
-static CLASS_DEVICE_ATTR(ip_address, S_IRUGO, show_ip_address, NULL);
-
-static ssize_t
-show_isid(struct class_device *cdev, char *buf)
-{
-	struct scsi_target *starget = transport_class_to_starget(cdev);
-	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
-	struct iscsi_internal *i = to_iscsi_internal(shost->transportt);
-
-	if (i->fnt->get_isid)
-		i->fnt->get_isid(starget);
-
-	return sprintf(buf, "%02x%02x%02x%02x%02x%02x\n",
-		       iscsi_isid(starget)[0], iscsi_isid(starget)[1],
-		       iscsi_isid(starget)[2], iscsi_isid(starget)[3],
-		       iscsi_isid(starget)[4], iscsi_isid(starget)[5]);
-}
-static CLASS_DEVICE_ATTR(isid, S_IRUGO, show_isid, NULL);
+#define iscsi_connection_rd_digest_attr(field)				\
+	iscsi_show_connection_digest_fn(field)				\
+static CLASS_DEVICE_ATTR(field, S_IRUGO, iscsi_show_connection_##field, NULL);
 
 /*
- * This is used for iSCSI names. Normally, we follow
- * the transport class convention of having the lld
- * set the field, but in these cases the value is
- * too large.
+ * Special case for iSCSI Port
  */
-#define iscsi_session_show_str_fn(field)				\
+#define iscsi_show_connection_port_fn()					\
 									\
 static ssize_t								\
-show_session_str_##field(struct class_device *cdev, char *buf)		\
+iscsi_show_connection_port(struct class_device *cdev, char *buf)	\
 {									\
-	ssize_t ret = 0;						\
 	struct scsi_target *starget = transport_class_to_starget(cdev);	\
 	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
 	struct iscsi_internal *i = to_iscsi_internal(shost->transportt); \
 									\
-	if (i->fnt->get_##field)					\
-		ret = i->fnt->get_##field(starget, buf, PAGE_SIZE);	\
-	return ret;							\
+	if (i->fnt->get_port)						\
+		i->fnt->get_port(starget);				\
+									\
+	return snprintf(buf, 20, "%hu\n", ntohs(iscsi_port(starget)));	\
 }
 
-#define iscsi_session_rd_str_attr(field)				\
-	iscsi_session_show_str_fn(field)				\
-static CLASS_DEVICE_ATTR(field, S_IRUGO, show_session_str_##field, NULL);
-
-iscsi_session_rd_str_attr(target_name);
-iscsi_session_rd_str_attr(target_alias);
+#define iscsi_connection_rd_port()					\
+	iscsi_show_connection_port_fn()					\
+static CLASS_DEVICE_ATTR(port, S_IRUGO, iscsi_show_connection_port, NULL);
 
 /*
- * iSCSI host attrs
+ * Special case for iSCSI IP Address - Connection Only
  */
+#define iscsi_show_connection_ip_address_fn()				\
+									\
+static ssize_t								\
+iscsi_show_connection_ip_address(struct class_device *cdev, char *buf)	\
+{									\
+	struct scsi_target *starget = transport_class_to_starget(cdev);	\
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
+	struct iscsi_internal *i = to_iscsi_internal(shost->transportt); \
+									\
+	if (i->fnt->get_ip_address)					\
+		i->fnt->get_ip_address(starget);			\
+									\
+	if (iscsi_addr_type(starget) == AF_INET)			\
+		return sprintf(buf, "%u.%u.%u.%u\n",			\
+			       NIPQUAD(iscsi_sin_addr(starget)));	\
+	else if(iscsi_addr_type(starget) == AF_INET6)			\
+		return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", \
+			       NIP6(iscsi_sin6_addr(starget)));		\
+	return -EINVAL;							\
+}								
+
+#define iscsi_connection_rd_ip_address()				\
+	iscsi_show_connection_ip_address_fn()				\
+static CLASS_DEVICE_ATTR(ip_address, S_IRUGO, iscsi_show_connection_ip_address, NULL);
 
 /*
- * Again, this is used for iSCSI names. Normally, we follow
- * the transport class convention of having the lld set
- * the field, but in these cases the value is too large.
+ * Special case for iSCSI Initiator ISID - Session Wide
  */
-#define iscsi_host_show_str_fn(field)					\
+#define iscsi_show_session_isid_fn()					\
 									\
 static ssize_t								\
-show_host_str_##field(struct class_device *cdev, char *buf)		\
+iscsi_show_session_isid(struct class_device *cdev, char *buf)		\
 {									\
-	int ret = 0;							\
-	struct Scsi_Host *shost = transport_class_to_shost(cdev);	\
+	struct scsi_target *starget = transport_class_to_starget(cdev);	\
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);	\
 	struct iscsi_internal *i = to_iscsi_internal(shost->transportt); \
 									\
-	if (i->fnt->get_##field)					\
-		ret = i->fnt->get_##field(shost, buf, PAGE_SIZE);	\
-	return ret;							\
+	if (i->fnt->get_isid)						\
+		i->fnt->get_isid(starget);				\
+									\
+	return sprintf(buf, "%02x%02x%02x%02x%02x%02x\n",		\
+		       iscsi_isid(starget)[0], iscsi_isid(starget)[1],	\
+		       iscsi_isid(starget)[2], iscsi_isid(starget)[3],	\
+		       iscsi_isid(starget)[4], iscsi_isid(starget)[5]);	\
 }
 
-#define iscsi_host_rd_str_attr(field)					\
-	iscsi_host_show_str_fn(field)					\
-static CLASS_DEVICE_ATTR(field, S_IRUGO, show_host_str_##field, NULL);
+#define iscsi_session_rd_isid()						\
+	iscsi_show_session_isid_fn()					\
+static CLASS_DEVICE_ATTR(isid, S_IRUGO, iscsi_show_session_isid, NULL);
 
-iscsi_host_rd_str_attr(initiator_name);
-iscsi_host_rd_str_attr(initiator_alias);
+/*
+ * Used in iscsi_register_transport()
+ */
+#define SETUP_CONNECTION_RD_ATTR(field)					\
+	if (i->fnt->show_##field) {					\
+		i->connection_attrs[count] = &class_device_attr_##field; \
+		count++;						\
+	}
 
 #define SETUP_SESSION_RD_ATTR(field)					\
 	if (i->fnt->show_##field) {					\
@@ -254,6 +281,48 @@
 		count++;						\
 	}
 
+/*
+ * iSCSI keys - RFC 3720 Section 12 - Connection Only
+ */
+iscsi_connection_rd_attr(max_recv_data_segment_len, "%u");
+iscsi_connection_rd_ip_address();
+iscsi_connection_rd_port();
+iscsi_connection_rd_digest_attr(header_digest);
+iscsi_connection_rd_digest_attr(data_digest);
+
+/*
+ * iSCSI Keys - RFC 3720 Appendix A - Connection Only
+ */
+iscsi_connection_rd_attr(of_markint, "%hu");
+iscsi_connection_rd_attr(if_markint, "%hu");
+iscsi_connection_rd_bool_attr(of_marker);
+iscsi_connection_rd_bool_attr(if_marker);
+
+/*
+ * iSCSI Keys - RFC 3270 Section 12 - Session Wide
+ */
+iscsi_session_rd_isid();
+iscsi_session_rd_attr(tpgt, "%hu");
+iscsi_session_rd_attr(tsih, "%2x"); /* Not actually negoitated, returned in login PDU */
+iscsi_session_rd_attr(max_burst_len, "%u");
+iscsi_session_rd_attr(first_burst_len, "%u");
+iscsi_session_rd_attr(def_time2wait, "%hu");
+iscsi_session_rd_attr(def_time2retain, "%hu");
+iscsi_session_rd_attr(max_outstanding_r2t, "%hu");
+iscsi_session_rd_attr(erl, "%d");
+iscsi_session_rd_bool_attr(initial_r2t);
+iscsi_session_rd_bool_attr(immediate_data);
+iscsi_session_rd_bool_attr(data_pdu_in_order);
+iscsi_session_rd_bool_attr(data_sequence_in_order);
+iscsi_session_rd_str_attr(target_name);
+iscsi_session_rd_str_attr(target_alias);
+
+/*
+ * Still Session Wide - Defines as Host Attribute due to length limitiations.
+ */
+iscsi_host_rd_str_attr(initiator_name);
+iscsi_host_rd_str_attr(initiator_alias);
+
 static int iscsi_host_match(struct attribute_container *cont,
 			  struct device *dev)
 {
@@ -311,18 +380,27 @@
 	transport_container_register(&i->t.target_attrs);
 	i->t.target_size = sizeof(struct iscsi_class_session);
 
-	SETUP_SESSION_RD_ATTR(tsih);
+	SETUP_CONNECTION_RD_ATTR(max_recv_data_segment_len);
+	SETUP_CONNECTION_RD_ATTR(header_digest);
+	SETUP_CONNECTION_RD_ATTR(data_digest);
+	SETUP_CONNECTION_RD_ATTR(of_marker);
+	SETUP_CONNECTION_RD_ATTR(if_marker);
+	SETUP_CONNECTION_RD_ATTR(of_markint);
+	SETUP_CONNECTION_RD_ATTR(if_markint);
+	SETUP_CONNECTION_RD_ATTR(ip_address);
+	SETUP_CONNECTION_RD_ATTR(port);
+
+	BUG_ON(count > ISCSI_CONNECTION_ATTRS);
+	i->connection_attrs[count] = NULL;	
+
+	count = 0;
 	SETUP_SESSION_RD_ATTR(isid);
-	SETUP_SESSION_RD_ATTR(header_digest);
-	SETUP_SESSION_RD_ATTR(data_digest);
+	SETUP_SESSION_RD_ATTR(tsih);
 	SETUP_SESSION_RD_ATTR(target_name);
 	SETUP_SESSION_RD_ATTR(target_alias);
-	SETUP_SESSION_RD_ATTR(port);
 	SETUP_SESSION_RD_ATTR(tpgt);
-	SETUP_SESSION_RD_ATTR(ip_address);
 	SETUP_SESSION_RD_ATTR(initial_r2t);
 	SETUP_SESSION_RD_ATTR(immediate_data);
-	SETUP_SESSION_RD_ATTR(max_recv_data_segment_len);
 	SETUP_SESSION_RD_ATTR(max_burst_len);
 	SETUP_SESSION_RD_ATTR(first_burst_len);
 	SETUP_SESSION_RD_ATTR(def_time2wait);
include/scsi/scsi_transport_iscsi.h +71 -33

184 lines not on this page · raw message

#1 lore raw
Quoted 39 lines · Nicholas A. Bellinger

This patch against 2.6.12-rc3 is the first step for scsi_transport_iscsi getting iSCSI Keys defined in RFC 3720 Section 12 and other values not defined in this section as keys, but need to be exported out via sysfs into the correct connection/session contexts.

Currently, scsi_transport_iscsi.[c,h] assume that all values are on a per session basis. These changes have been tested with the upcoming iSCSI transport class enabled release of iscsi-initiator-core (1.6.2.0-rc2), and should hopefully be 'breakage-free' with sfnet.

Comments?

------------------------------------------------------------------------

diff -urN linux-2.6.12-rc3/drivers/scsi/scsi_transport_iscsi.c linux-2.6.12-rc3-iscsi/drivers/scsi/scsi_transport_iscsi.c

drivers/scsi/scsi_transport_iscsi.c +4 -1
@@ -3,6 +3,8 @@
  *
  * Copyright (C) IBM Corporation, 2004
  * Copyright (C) Mike Christie, 2004
+ * Copyright (C) PyX Technologies, 2005
+ * Copyright (C) Nicholas A. Bellinger <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +27,8 @@
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_transport_iscsi.h>
 
-#define ISCSI_SESSION_ATTRS 20
+#define ISCSI_CONNECTION_ATTRS 9
+#define ISCSI_SESSION_ATTRS 15
 #define ISCSI_HOST_ATTRS 2
 
 struct iscsi_internal {

drivers/scsi/scsi_transport_iscsi.c line 40

Quoted 4 lines
drivers/scsi/scsi_transport_iscsi.c +1 -0
@@ -34,6 +37,7 @@
 	/*
 	 * We do not have any private or other attrs.
 	 */
+	struct class_device_attribute *connection_attrs[ISCSI_CONNECTION_ATTRS + 1];

How are these attrs getting set up? By the LLD? Patch does not work for me; nothing shows up btw.

The reason all the settings are stuck on the session was becuase we couldn't come to an agreement on the layout. We wanted to do something like this:

/sys/class/iscsi_session/iscsi_connection

or even

/sys/class/iscsi_session
/sys/class/iscsi_connection

with some symlinks to glue them together for the latter (I could probably do a better picture but you get the idea right). It depends on if people allowed us to stick kobjects in structs to make the dirs (could use a attribute group too I guess) or if they wanted seperate devices. It might make some sense to figure out the layout while seperating things out.

#2 lore raw
Quoted 38 lines · Mike Christie
Quoted 37 lines · Nicholas A. Bellinger

This patch against 2.6.12-rc3 is the first step for scsi_transport_iscsi getting iSCSI Keys defined in RFC 3720 Section 12 and other values not defined in this section as keys, but need to be exported out via sysfs into the correct connection/session contexts.

Currently, scsi_transport_iscsi.[c,h] assume that all values are on a per session basis. These changes have been tested with the upcoming iSCSI transport class enabled release of iscsi-initiator-core (1.6.2.0-rc2), and should hopefully be 'breakage-free' with sfnet.

Comments?

------------------------------------------------------------------------

diff -urN linux-2.6.12-rc3/drivers/scsi/scsi_transport_iscsi.c linux-2.6.12-rc3-iscsi/drivers/scsi/scsi_transport_iscsi.c

drivers/scsi/scsi_transport_iscsi.c +4 -1
@@ -3,6 +3,8 @@
  *
  * Copyright (C) IBM Corporation, 2004
  * Copyright (C) Mike Christie, 2004
+ * Copyright (C) PyX Technologies, 2005
+ * Copyright (C) Nicholas A. Bellinger <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +27,8 @@
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_transport_iscsi.h>
 
-#define ISCSI_SESSION_ATTRS 20
+#define ISCSI_CONNECTION_ATTRS 9
+#define ISCSI_SESSION_ATTRS 15
 #define ISCSI_HOST_ATTRS 2
 
Quoted 10 lines

drivers/scsi/scsi_transport_iscsi.c line 40

Quoted 6 lines
drivers/scsi/scsi_transport_iscsi.c +1 -0
 struct iscsi_internal {
@@ -34,6 +37,7 @@
 	/*
 	 * We do not have any private or other attrs.
 	 */
+	struct class_device_attribute *connection_attrs[ISCSI_CONNECTION_ATTRS + 1];

How are these attrs getting set up? By the LLD? Patch does not work for me; nothing shows up btw.

Whoops, I forgot to mention that the includes of the local scsi_transport_scsi.h in linux-iscsi-4.0.1.11 need to be changed from "scsi_transport_iscsi.h" to <scsi/scsi_transport_iscsi.h>. I assume this was failing because of the changes to struct iscsi_function_template in the patch.

Quoted 10 lines

The reason all the settings are stuck on the session was becuase we couldn't come to an agreement on the layout. We wanted to do something like this:

/sys/class/iscsi_session/iscsi_connection

or even

/sys/class/iscsi_session
/sys/class/iscsi_connection

I am still thinking on this one. First and foremost I think that we need to get move towards a single class for iSCSI Initiators instead of what is currently registered (/sys/class/iscsi_transport
and /sys/class/iscsi_host). Let me keep working on this some more and I will draft up a prosposal in the near future. Any futher input is welcomed. :-)

Quoted 6 lines

with some symlinks to glue them together for the latter (I could probably do a better picture but you get the idea right). It depends on if people allowed us to stick kobjects in structs to make the dirs (could use a attribute group too I guess) or if they wanted seperate devices. It might make some sense to figure out the layout while seperating things out.

The other thing I think we should considering is only registering iscsi_session and iscsi_connection classes to the iscsi_host (or whaterver the class is going to be called) when those entities actually exist within the said iSCSI stack, and unregistering them once they go away. iscsi-initiator-core already does something along these lines in iscsi_initiator_sysfs.c, and anchors everything released to a specific Scsi Host to a 'iSCSI Channel'.

Signature · 1 line
Nicholas A. Bellinger <[email protected]>
#3 lore raw
Quoted 72 lines · Nicholas A. Bellinger
Quoted 39 lines · Mike Christie
Quoted 37 lines · Nicholas A. Bellinger

This patch against 2.6.12-rc3 is the first step for scsi_transport_iscsi getting iSCSI Keys defined in RFC 3720 Section 12 and other values not defined in this section as keys, but need to be exported out via sysfs into the correct connection/session contexts.

Currently, scsi_transport_iscsi.[c,h] assume that all values are on a per session basis. These changes have been tested with the upcoming iSCSI transport class enabled release of iscsi-initiator-core (1.6.2.0-rc2), and should hopefully be 'breakage-free' with sfnet.

Comments?

------------------------------------------------------------------------

diff -urN linux-2.6.12-rc3/drivers/scsi/scsi_transport_iscsi.c linux-2.6.12-rc3-iscsi/drivers/scsi/scsi_transport_iscsi.c

drivers/scsi/scsi_transport_iscsi.c +4 -1
@@ -3,6 +3,8 @@
 *
 * Copyright (C) IBM Corporation, 2004
 * Copyright (C) Mike Christie, 2004
+ * Copyright (C) PyX Technologies, 2005
+ * Copyright (C) Nicholas A. Bellinger <[email protected]>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
@@ -25,7 +27,8 @@
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_transport_iscsi.h>
 
-#define ISCSI_SESSION_ATTRS 20
+#define ISCSI_CONNECTION_ATTRS 9
+#define ISCSI_SESSION_ATTRS 15
 #define ISCSI_HOST_ATTRS 2
 
Quoted 10 lines

drivers/scsi/scsi_transport_iscsi.c line 40

Quoted 6 lines
drivers/scsi/scsi_transport_iscsi.c +1 -0
 struct iscsi_internal {
@@ -34,6 +37,7 @@
 	/*
 	 * We do not have any private or other attrs.
 	 */
+	struct class_device_attribute *connection_attrs[ISCSI_CONNECTION_ATTRS + 1];

How are these attrs getting set up? By the LLD? Patch does not work for me; nothing shows up btw.

Whoops, I forgot to mention that the includes of the local scsi_transport_scsi.h in linux-iscsi-4.0.1.11 need to be changed from "scsi_transport_iscsi.h" to <scsi/scsi_transport_iscsi.h>. I assume this was failing because of the changes to struct iscsi_function_template in the patch.

Quoted 10 lines

The reason all the settings are stuck on the session was becuase we couldn't come to an agreement on the layout. We wanted to do something like this:

/sys/class/iscsi_session/iscsi_connection

or even

/sys/class/iscsi_session
/sys/class/iscsi_connection

Quoted 7 lines

I am still thinking on this one. First and foremost I think that we need to get move towards a single class for iSCSI Initiators instead of what is currently registered (/sys/class/iscsi_transport
and /sys/class/iscsi_host). Let me keep working on this some more and I will draft up a prosposal in the near future. Any futher input is welcomed. :-)

get everyone to agree (or force them) on how to set the initiarname and alias and the iscsi_host can be chopped. the iscsi_host is only there becuase sfnet used a /etc file and I think you can set the initiatorname on some HW cards from a BIOS/OF prompt (or you will not have control over it) so if they ever end up on the same box and wanted to konw what each one ended up as you could.

#4 lore raw
Quoted 20 lines · Mike Christie
Quoted 12 lines
Quoted 10 lines

The reason all the settings are stuck on the session was becuase we couldn't come to an agreement on the layout. We wanted to do something like this:

/sys/class/iscsi_session/iscsi_connection

or even

/sys/class/iscsi_session
/sys/class/iscsi_connection

Quoted 7 lines

I am still thinking on this one. First and foremost I think that we need to get move towards a single class for iSCSI Initiators instead of what is currently registered (/sys/class/iscsi_transport
and /sys/class/iscsi_host). Let me keep working on this some more and I will draft up a prosposal in the near future. Any futher input is welcomed. :-)

Quoted 6 lines

get everyone to agree (or force them) on how to set the initiarname and alias and the iscsi_host can be chopped. the iscsi_host is only there becuase sfnet used a /etc file and I think you can set the initiatorname on some HW cards from a BIOS/OF prompt (or you will not have control over it) so if they ever end up on the same box and wanted to konw what each one ended up as you could.

Ok, one possible solution is when the iSCSI Template structure gets registered with the iSCSI Transport, the LLD can tell the transport what values are already defined. I think this point really goes back to previous points about different class attributes need to be dynamicly registered within the iSCSI Stack when certain events occur.

Considering the following:

1) iscsi_attach_transport() is called when the iSCSI Stack is loaded:

/sys/class/iscsi_transport/

a) Initiator[Name,Alias] is not set.

The stack will set this value later.

b) Initiator[Name,Alais] is set.

Assume that ->get_initiator_[name,alias]() will return values from hardware

2) struct iscsi_channel_class *iscsi_attach_channel(struct scsi_transport_template)

/sys/class/iscsi_transport/iscsi_$CHANNEL_ID.

Note that for management purposes that $CHANNEL_ID needs to be a value that does not change. ie: not the SCSI Host ID.

This registers ALL of the sysfs attributes for both session and connection contexts. These values are read/write as these are values that are used as the defaults when sessions/connections are started on said iSCSI Channel.

3) struct iscsi_session_class *iscsi_attach_session(struct iscsi_channel_class)

/sys/class/iscsi_transport/iscsi_$CHANNEL_ID/

This contains the read only attributes that where negoitated after successful session establishment. Note that some of these values need to be write as well. (InitiatorAlias can be changed after the session is up)

4) struct iscsi_connection_class *iscsi_attach_connection(struct iscsi_session_class *, unsigned short cid)

/sys/class/iscsi_transport/iscsi_$CHANNEL_ID/session/connection_$CID

This contains the read only attributes that where negoitated after successful connection establishment. Note that some of these values need to be write as well. (MaxRecvDataSegmentLength can be changed after the connection up).

Of course the names would probable get changed around a bit, but I think you get the idea.

Signature · 1 line
Nicholas A. Bellinger <[email protected]>
#5 lore raw
Quoted 30 lines · Nicholas A. Bellinger
Quoted 20 lines · Mike Christie
Quoted 12 lines
Quoted 10 lines

The reason all the settings are stuck on the session was becuase we couldn't come to an agreement on the layout. We wanted to do something like this:

/sys/class/iscsi_session/iscsi_connection

or even

/sys/class/iscsi_session
/sys/class/iscsi_connection

Quoted 7 lines

I am still thinking on this one. First and foremost I think that we need to get move towards a single class for iSCSI Initiators instead of what is currently registered (/sys/class/iscsi_transport
and /sys/class/iscsi_host). Let me keep working on this some more and I will draft up a prosposal in the near future. Any futher input is welcomed. :-)

Quoted 6 lines

get everyone to agree (or force them) on how to set the initiarname and alias and the iscsi_host can be chopped. the iscsi_host is only there becuase sfnet used a /etc file and I think you can set the initiatorname on some HW cards from a BIOS/OF prompt (or you will not have control over it) so if they ever end up on the same box and wanted to konw what each one ended up as you could.

Quoted 5 lines

Ok, one possible solution is when the iSCSI Template structure gets registered with the iSCSI Transport, the LLD can tell the transport what
values are already defined. I think this point really goes back to
previous points about different class attributes need to be dynamicly registered within the iSCSI Stack when certain events occur.

I am not arguing with that. We sent a patch to break the session stuff from the target (sfnet did not need the channel abstraction) and from there to add a connection beneath it is a matter of getting hold of the correct kobject to stick things under (when you use the transport class/container stuff it is not as simple as before though).

We are also not using sysfs for creation anymore though. Maybe we need to discuss that point too. We are using netlinks for this so open-iscsi/linux-iscsi/whatever-name-it-is-called-today:) and pyx have some confliting points.

As far as filesystem based creation stuff goes it also seems our sysfs masters may prefer configfs for things like software iscsi, dm or bonding where userspace is driving the device creation and not the kernel. Do the scsi maintainers care about this?

Quoted 7 lines

Considering the following:

1) iscsi_attach_transport() is called when the iSCSI Stack is loaded:

/sys/class/iscsi_transport/

Quoted 9 lines

a) Initiator[Name,Alias] is not set.

The stack will set this value later.

b) Initiator[Name,Alais] is set.

Assume that ->get_initiator_[name,alias]() will return values from hardware

this is unrelated to sysfs or netlinks, but will this be able to support two stacks running at the same time with different initiator names? It looks like it will be shared across drivers so it would need /sys/class/iscsi_transport%SOME_STACK_ENUM
I am jsut wondering becuase whether we should use one name for all drivers vs each driver using its own has come up several times on the sfnet list.

#6 lore raw
Quoted 50 lines · Mike Christie
Quoted 30 lines · Nicholas A. Bellinger
Quoted 20 lines · Mike Christie
Quoted 12 lines
Quoted 10 lines

The reason all the settings are stuck on the session was becuase we couldn't come to an agreement on the layout. We wanted to do something like this:

/sys/class/iscsi_session/iscsi_connection

or even

/sys/class/iscsi_session
/sys/class/iscsi_connection

Quoted 7 lines

I am still thinking on this one. First and foremost I think that we need to get move towards a single class for iSCSI Initiators instead of what is currently registered (/sys/class/iscsi_transport
and /sys/class/iscsi_host). Let me keep working on this some more and I will draft up a prosposal in the near future. Any futher input is welcomed. :-)

Quoted 6 lines

get everyone to agree (or force them) on how to set the initiarname and alias and the iscsi_host can be chopped. the iscsi_host is only there becuase sfnet used a /etc file and I think you can set the initiatorname on some HW cards from a BIOS/OF prompt (or you will not have control over it) so if they ever end up on the same box and wanted to konw what each one ended up as you could.

Quoted 5 lines

Ok, one possible solution is when the iSCSI Template structure gets registered with the iSCSI Transport, the LLD can tell the transport what
values are already defined. I think this point really goes back to
previous points about different class attributes need to be dynamicly registered within the iSCSI Stack when certain events occur.

I am not arguing with that. We sent a patch to break the session stuff from the target (sfnet did not need the channel abstraction) and from there to add a connection beneath it is a matter of getting hold of the correct kobject to stick things under (when you use the transport class/container stuff it is not as simple as before though).

We are also not using sysfs for creation anymore though. Maybe we need to discuss that point too. We are using netlinks for this so open-iscsi/linux-iscsi/whatever-name-it-is-called-today:) and pyx have some confliting points.

Quoted 5 lines

As far as filesystem based creation stuff goes it also seems our sysfs masters may prefer configfs for things like software iscsi, dm or bonding where userspace is driving the device creation and not the kernel. Do the scsi maintainers care about this?

One clarifcation for that last paragraph. I mean configfs for just the creation part. And sysfs would still be used to export info to userspace.

Or netlink for all or parts or some other fun combo :)