aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2011-02-16 16:04:37 -0500
committerJames Bottomley <James.Bottomley@suse.de>2011-02-24 12:41:12 -0500
commit289324b0c6007171d67bf1ab0827355ae3374773 (patch)
tree6a6af0500e8acab0455d7b0d2391b0096f94b4f7 /drivers
parenta79af8a64d395bd89de8695a5ea5e1a7f01f02a8 (diff)
[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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index a631e58894f1..b4218390941e 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1782,13 +1782,48 @@ iscsi_conn_attr(data_digest, ISCSI_PARAM_DATADGST_EN);
1782iscsi_conn_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN); 1782iscsi_conn_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN);
1783iscsi_conn_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN); 1783iscsi_conn_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN);
1784iscsi_conn_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT); 1784iscsi_conn_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT);
1785iscsi_conn_attr(port, ISCSI_PARAM_CONN_PORT);
1786iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN); 1785iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN);
1787iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS); 1786iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS);
1788iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS);
1789iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); 1787iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO);
1790iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); 1788iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO);
1791 1789
1790#define iscsi_conn_ep_attr_show(param) \
1791static 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) \
1821static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, \
1822 show_conn_ep_param_##param, NULL);
1823
1824iscsi_conn_ep_attr(address, ISCSI_PARAM_CONN_ADDRESS);
1825iscsi_conn_ep_attr(port, ISCSI_PARAM_CONN_PORT);
1826
1792/* 1827/*
1793 * iSCSI session attrs 1828 * iSCSI session attrs
1794 */ 1829 */