Commit 289324b0c6007171d67bf1ab0827355ae3374773

Authored by Mike Christie
Committed by James Bottomley
1 parent a79af8a64d

[SCSI] iscsi class: add callout to get iscsi_endpoint values

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>

Showing 2 changed files with 39 additions and 2 deletions Side-by-side Diff

drivers/scsi/scsi_transport_iscsi.c
... ... @@ -1782,12 +1782,47 @@
1782 1782 iscsi_conn_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN);
1783 1783 iscsi_conn_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN);
1784 1784 iscsi_conn_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT);
1785   -iscsi_conn_attr(port, ISCSI_PARAM_CONN_PORT);
1786 1785 iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN);
1787 1786 iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS);
1788   -iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS);
1789 1787 iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO);
1790 1788 iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO);
  1789 +
  1790 +#define iscsi_conn_ep_attr_show(param) \
  1791 +static ssize_t show_conn_ep_param_##param(struct device *dev, \
  1792 + struct device_attribute *attr,\
  1793 + char *buf) \
  1794 +{ \
  1795 + struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \
  1796 + struct iscsi_transport *t = conn->transport; \
  1797 + struct iscsi_endpoint *ep; \
  1798 + ssize_t rc; \
  1799 + \
  1800 + /* \
  1801 + * Need to make sure ep_disconnect does not free the LLD's \
  1802 + * interconnect resources while we are trying to read them. \
  1803 + */ \
  1804 + mutex_lock(&conn->ep_mutex); \
  1805 + ep = conn->ep; \
  1806 + if (!ep && t->ep_connect) { \
  1807 + mutex_unlock(&conn->ep_mutex); \
  1808 + return -ENOTCONN; \
  1809 + } \
  1810 + \
  1811 + if (ep) \
  1812 + rc = t->get_ep_param(ep, param, buf); \
  1813 + else \
  1814 + rc = t->get_conn_param(conn, param, buf); \
  1815 + mutex_unlock(&conn->ep_mutex); \
  1816 + return rc; \
  1817 +}
  1818 +
  1819 +#define iscsi_conn_ep_attr(field, param) \
  1820 + iscsi_conn_ep_attr_show(param) \
  1821 +static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, \
  1822 + show_conn_ep_param_##param, NULL);
  1823 +
  1824 +iscsi_conn_ep_attr(address, ISCSI_PARAM_CONN_ADDRESS);
  1825 +iscsi_conn_ep_attr(port, ISCSI_PARAM_CONN_PORT);
1791 1826  
1792 1827 /*
1793 1828 * iSCSI session attrs
include/scsi/scsi_transport_iscsi.h
... ... @@ -101,6 +101,8 @@
101 101 void (*destroy_conn) (struct iscsi_cls_conn *conn);
102 102 int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param,
103 103 char *buf, int buflen);
  104 + int (*get_ep_param) (struct iscsi_endpoint *ep, enum iscsi_param param,
  105 + char *buf);
104 106 int (*get_conn_param) (struct iscsi_cls_conn *conn,
105 107 enum iscsi_param param, char *buf);
106 108 int (*get_session_param) (struct iscsi_cls_session *session,