]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
[SCSI] iscsi class: add callout to get iscsi_endpoint values
authorMike Christie <michaelc@cs.wisc.edu>
Wed, 16 Feb 2011 21:04:37 +0000 (15:04 -0600)
committerJames Bottomley <James.Bottomley@suse.de>
Thu, 24 Feb 2011 17:41:12 +0000 (12:41 -0500)
For drivers using the ep callbacks the addr and port
are attached to the endpoint instead of the conn.
This adds a callout to the iscsi_transport to get
ep values. It also adds locking around the get
param call to make sure that ep_disconnect does
not free the LLD's ep interconnect structs from
under us (the ep has a refcount so it will not
go away but the LLD may have structs from other
subsystems that are not allocated in the ep so
we need to protect them from getting freed).

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/scsi_transport_iscsi.c
include/scsi/scsi_transport_iscsi.h

index a631e58894f1c4fb85acd533fcf5afe5630eeda5..b4218390941e1cbd1ee6fd45dfcef8fd82b76cfb 100644 (file)
@@ -1782,13 +1782,48 @@ iscsi_conn_attr(data_digest, ISCSI_PARAM_DATADGST_EN);
 iscsi_conn_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN);
 iscsi_conn_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN);
 iscsi_conn_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT);
-iscsi_conn_attr(port, ISCSI_PARAM_CONN_PORT);
 iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN);
 iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS);
-iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS);
 iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO);
 iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO);
 
+#define iscsi_conn_ep_attr_show(param)                                 \
+static ssize_t show_conn_ep_param_##param(struct device *dev,          \
+                                         struct device_attribute *attr,\
+                                         char *buf)                    \
+{                                                                      \
+       struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent);   \
+       struct iscsi_transport *t = conn->transport;                    \
+       struct iscsi_endpoint *ep;                                      \
+       ssize_t rc;                                                     \
+                                                                       \
+       /*                                                              \
+        * Need to make sure ep_disconnect does not free the LLD's      \
+        * interconnect resources while we are trying to read them.     \
+        */                                                             \
+       mutex_lock(&conn->ep_mutex);                                    \
+       ep = conn->ep;                                                  \
+       if (!ep && t->ep_connect) {                                     \
+               mutex_unlock(&conn->ep_mutex);                          \
+               return -ENOTCONN;                                       \
+       }                                                               \
+                                                                       \
+       if (ep)                                                         \
+               rc = t->get_ep_param(ep, param, buf);                   \
+       else                                                            \
+               rc = t->get_conn_param(conn, param, buf);               \
+       mutex_unlock(&conn->ep_mutex);                                  \
+       return rc;                                                      \
+}
+
+#define iscsi_conn_ep_attr(field, param)                               \
+       iscsi_conn_ep_attr_show(param)                                  \
+static ISCSI_CLASS_ATTR(conn, field, S_IRUGO,                          \
+                       show_conn_ep_param_##param, NULL);
+
+iscsi_conn_ep_attr(address, ISCSI_PARAM_CONN_ADDRESS);
+iscsi_conn_ep_attr(port, ISCSI_PARAM_CONN_PORT);
+
 /*
  * iSCSI session attrs
  */
index 00e5bf7c9de6b88926d7e003f97a4080ec614611..bf8f529656755704970e4da850dd8624c1e159e7 100644 (file)
@@ -101,6 +101,8 @@ struct iscsi_transport {
        void (*destroy_conn) (struct iscsi_cls_conn *conn);
        int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param,
                          char *buf, int buflen);
+       int (*get_ep_param) (struct iscsi_endpoint *ep, enum iscsi_param param,
+                            char *buf);
        int (*get_conn_param) (struct iscsi_cls_conn *conn,
                               enum iscsi_param param, char *buf);
        int (*get_session_param) (struct iscsi_cls_session *session,