diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2011-07-25 14:48:45 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-08-27 10:36:14 -0400 |
commit | f27fb2ef7bd88c9c5f67befe4d85e2155aa0e1a8 (patch) | |
tree | 6c313f71cc2c0701a4e873e8231571c442b131e2 /drivers/scsi | |
parent | b78dbba0053c6f14384d55b929d21b85d03c38bb (diff) |
[SCSI] iscsi class: sysfs group is_visible callout for iscsi host attrs
The iscsi class currently does not support writable sysfs
attrs for LLD sysfs settings. This patch converts the
iscsi class and driver's host attrs to use the attribute
container sysfs group and the sysfs group's is_visible callout
to be able to support readable or writable sysfs attrs.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/be2iscsi/be_iscsi.c | 9 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_main.c | 2 | ||||
-rw-r--r-- | drivers/scsi/bnx2i/bnx2i_iscsi.c | 11 | ||||
-rw-r--r-- | drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | 3 | ||||
-rw-r--r-- | drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 3 | ||||
-rw-r--r-- | drivers/scsi/cxgbi/libcxgbi.c | 10 | ||||
-rw-r--r-- | drivers/scsi/iscsi_tcp.c | 13 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_os.c | 12 | ||||
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 58 |
9 files changed, 85 insertions, 36 deletions
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index ecd19bb3b207..feadaa288080 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c | |||
@@ -737,6 +737,15 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep) | |||
737 | mode_t be2iscsi_attr_is_visible(int param_type, int param) | 737 | mode_t be2iscsi_attr_is_visible(int param_type, int param) |
738 | { | 738 | { |
739 | switch (param_type) { | 739 | switch (param_type) { |
740 | case ISCSI_HOST_PARAM: | ||
741 | switch (param) { | ||
742 | case ISCSI_HOST_PARAM_HWADDRESS: | ||
743 | case ISCSI_HOST_PARAM_IPADDRESS: | ||
744 | case ISCSI_HOST_PARAM_INITIATOR_NAME: | ||
745 | return S_IRUGO; | ||
746 | default: | ||
747 | return 0; | ||
748 | } | ||
740 | case ISCSI_PARAM: | 749 | case ISCSI_PARAM: |
741 | switch (param) { | 750 | switch (param) { |
742 | case ISCSI_PARAM_MAX_RECV_DLENGTH: | 751 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 93a3c708411a..72ac64bbceaf 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c | |||
@@ -4364,8 +4364,6 @@ struct iscsi_transport beiscsi_iscsi_transport = { | |||
4364 | .name = DRV_NAME, | 4364 | .name = DRV_NAME, |
4365 | .caps = CAP_RECOVERY_L0 | CAP_HDRDGST | CAP_TEXT_NEGO | | 4365 | .caps = CAP_RECOVERY_L0 | CAP_HDRDGST | CAP_TEXT_NEGO | |
4366 | CAP_MULTI_R2T | CAP_DATADGST | CAP_DATA_PATH_OFFLOAD, | 4366 | CAP_MULTI_R2T | CAP_DATADGST | CAP_DATA_PATH_OFFLOAD, |
4367 | .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS | | ||
4368 | ISCSI_HOST_INITIATOR_NAME, | ||
4369 | .create_session = beiscsi_session_create, | 4367 | .create_session = beiscsi_session_create, |
4370 | .destroy_session = beiscsi_session_destroy, | 4368 | .destroy_session = beiscsi_session_destroy, |
4371 | .create_conn = beiscsi_conn_create, | 4369 | .create_conn = beiscsi_conn_create, |
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 2db3399d2734..d1e697190970 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c | |||
@@ -2180,6 +2180,15 @@ static int bnx2i_nl_set_path(struct Scsi_Host *shost, struct iscsi_path *params) | |||
2180 | static mode_t bnx2i_attr_is_visible(int param_type, int param) | 2180 | static mode_t bnx2i_attr_is_visible(int param_type, int param) |
2181 | { | 2181 | { |
2182 | switch (param_type) { | 2182 | switch (param_type) { |
2183 | case ISCSI_HOST_PARAM: | ||
2184 | switch (param) { | ||
2185 | case ISCSI_HOST_PARAM_NETDEV_NAME: | ||
2186 | case ISCSI_HOST_PARAM_HWADDRESS: | ||
2187 | case ISCSI_HOST_PARAM_IPADDRESS: | ||
2188 | return S_IRUGO; | ||
2189 | default: | ||
2190 | return 0; | ||
2191 | } | ||
2183 | case ISCSI_PARAM: | 2192 | case ISCSI_PARAM: |
2184 | switch (param) { | 2193 | switch (param) { |
2185 | case ISCSI_PARAM_MAX_RECV_DLENGTH: | 2194 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
@@ -2251,8 +2260,6 @@ struct iscsi_transport bnx2i_iscsi_transport = { | |||
2251 | CAP_MULTI_R2T | CAP_DATADGST | | 2260 | CAP_MULTI_R2T | CAP_DATADGST | |
2252 | CAP_DATA_PATH_OFFLOAD | | 2261 | CAP_DATA_PATH_OFFLOAD | |
2253 | CAP_TEXT_NEGO, | 2262 | CAP_TEXT_NEGO, |
2254 | .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS | | ||
2255 | ISCSI_HOST_NETDEV_NAME, | ||
2256 | .create_session = bnx2i_session_create, | 2263 | .create_session = bnx2i_session_create, |
2257 | .destroy_session = bnx2i_session_destroy, | 2264 | .destroy_session = bnx2i_session_destroy, |
2258 | .create_conn = bnx2i_conn_create, | 2265 | .create_conn = bnx2i_conn_create, |
diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c index 50d4e3f05038..f76185b010da 100644 --- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c +++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | |||
@@ -106,9 +106,6 @@ static struct iscsi_transport cxgb3i_iscsi_transport = { | |||
106 | .caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST | 106 | .caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST |
107 | | CAP_DATADGST | CAP_DIGEST_OFFLOAD | | 107 | | CAP_DATADGST | CAP_DIGEST_OFFLOAD | |
108 | CAP_PADDING_OFFLOAD | CAP_TEXT_NEGO, | 108 | CAP_PADDING_OFFLOAD | CAP_TEXT_NEGO, |
109 | .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS | | ||
110 | ISCSI_HOST_INITIATOR_NAME | | ||
111 | ISCSI_HOST_NETDEV_NAME, | ||
112 | .attr_is_visible = cxgbi_attr_is_visible, | 109 | .attr_is_visible = cxgbi_attr_is_visible, |
113 | .get_host_param = cxgbi_get_host_param, | 110 | .get_host_param = cxgbi_get_host_param, |
114 | .set_host_param = cxgbi_set_host_param, | 111 | .set_host_param = cxgbi_set_host_param, |
diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c index 72f19ef7e016..628a6983a20b 100644 --- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | |||
@@ -107,9 +107,6 @@ static struct iscsi_transport cxgb4i_iscsi_transport = { | |||
107 | .caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST | | 107 | .caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST | |
108 | CAP_DATADGST | CAP_DIGEST_OFFLOAD | | 108 | CAP_DATADGST | CAP_DIGEST_OFFLOAD | |
109 | CAP_PADDING_OFFLOAD | CAP_TEXT_NEGO, | 109 | CAP_PADDING_OFFLOAD | CAP_TEXT_NEGO, |
110 | .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS | | ||
111 | ISCSI_HOST_INITIATOR_NAME | | ||
112 | ISCSI_HOST_NETDEV_NAME, | ||
113 | .attr_is_visible = cxgbi_attr_is_visible, | 110 | .attr_is_visible = cxgbi_attr_is_visible, |
114 | .get_host_param = cxgbi_get_host_param, | 111 | .get_host_param = cxgbi_get_host_param, |
115 | .set_host_param = cxgbi_set_host_param, | 112 | .set_host_param = cxgbi_set_host_param, |
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index f9c2ca0d8083..67ded44557e1 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c | |||
@@ -2569,6 +2569,16 @@ EXPORT_SYMBOL_GPL(cxgbi_iscsi_cleanup); | |||
2569 | mode_t cxgbi_attr_is_visible(int param_type, int param) | 2569 | mode_t cxgbi_attr_is_visible(int param_type, int param) |
2570 | { | 2570 | { |
2571 | switch (param_type) { | 2571 | switch (param_type) { |
2572 | case ISCSI_HOST_PARAM: | ||
2573 | switch (param) { | ||
2574 | case ISCSI_HOST_PARAM_NETDEV_NAME: | ||
2575 | case ISCSI_HOST_PARAM_HWADDRESS: | ||
2576 | case ISCSI_HOST_PARAM_IPADDRESS: | ||
2577 | case ISCSI_HOST_PARAM_INITIATOR_NAME: | ||
2578 | return S_IRUGO; | ||
2579 | default: | ||
2580 | return 0; | ||
2581 | } | ||
2572 | case ISCSI_PARAM: | 2582 | case ISCSI_PARAM: |
2573 | switch (param) { | 2583 | switch (param) { |
2574 | case ISCSI_PARAM_MAX_RECV_DLENGTH: | 2584 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 6ab212211760..23e706673d06 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -875,6 +875,16 @@ static void iscsi_sw_tcp_session_destroy(struct iscsi_cls_session *cls_session) | |||
875 | static mode_t iscsi_sw_tcp_attr_is_visible(int param_type, int param) | 875 | static mode_t iscsi_sw_tcp_attr_is_visible(int param_type, int param) |
876 | { | 876 | { |
877 | switch (param_type) { | 877 | switch (param_type) { |
878 | case ISCSI_HOST_PARAM: | ||
879 | switch (param) { | ||
880 | case ISCSI_HOST_PARAM_NETDEV_NAME: | ||
881 | case ISCSI_HOST_PARAM_HWADDRESS: | ||
882 | case ISCSI_HOST_PARAM_IPADDRESS: | ||
883 | case ISCSI_HOST_PARAM_INITIATOR_NAME: | ||
884 | return S_IRUGO; | ||
885 | default: | ||
886 | return 0; | ||
887 | } | ||
878 | case ISCSI_PARAM: | 888 | case ISCSI_PARAM: |
879 | switch (param) { | 889 | switch (param) { |
880 | case ISCSI_PARAM_MAX_RECV_DLENGTH: | 890 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
@@ -955,9 +965,6 @@ static struct iscsi_transport iscsi_sw_tcp_transport = { | |||
955 | .name = "tcp", | 965 | .name = "tcp", |
956 | .caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST | 966 | .caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST |
957 | | CAP_DATADGST, | 967 | | CAP_DATADGST, |
958 | .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS | | ||
959 | ISCSI_HOST_INITIATOR_NAME | | ||
960 | ISCSI_HOST_NETDEV_NAME, | ||
961 | /* session management */ | 968 | /* session management */ |
962 | .create_session = iscsi_sw_tcp_session_create, | 969 | .create_session = iscsi_sw_tcp_session_create, |
963 | .destroy_session = iscsi_sw_tcp_session_destroy, | 970 | .destroy_session = iscsi_sw_tcp_session_destroy, |
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index df6da3cb124d..a9da3152ee51 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
@@ -138,9 +138,6 @@ static struct iscsi_transport qla4xxx_iscsi_transport = { | |||
138 | .name = DRIVER_NAME, | 138 | .name = DRIVER_NAME, |
139 | .caps = CAP_FW_DB | CAP_SENDTARGETS_OFFLOAD | | 139 | .caps = CAP_FW_DB | CAP_SENDTARGETS_OFFLOAD | |
140 | CAP_DATA_PATH_OFFLOAD, | 140 | CAP_DATA_PATH_OFFLOAD, |
141 | .host_param_mask = ISCSI_HOST_HWADDRESS | | ||
142 | ISCSI_HOST_IPADDRESS | | ||
143 | ISCSI_HOST_INITIATOR_NAME, | ||
144 | .tgt_dscvr = qla4xxx_tgt_dscvr, | 141 | .tgt_dscvr = qla4xxx_tgt_dscvr, |
145 | .attr_is_visible = ql4_attr_is_visible, | 142 | .attr_is_visible = ql4_attr_is_visible, |
146 | .get_conn_param = qla4xxx_conn_get_param, | 143 | .get_conn_param = qla4xxx_conn_get_param, |
@@ -156,6 +153,15 @@ static struct scsi_transport_template *qla4xxx_scsi_transport; | |||
156 | static mode_t ql4_attr_is_visible(int param_type, int param) | 153 | static mode_t ql4_attr_is_visible(int param_type, int param) |
157 | { | 154 | { |
158 | switch (param_type) { | 155 | switch (param_type) { |
156 | case ISCSI_HOST_PARAM: | ||
157 | switch (param) { | ||
158 | case ISCSI_HOST_PARAM_HWADDRESS: | ||
159 | case ISCSI_HOST_PARAM_IPADDRESS: | ||
160 | case ISCSI_HOST_PARAM_INITIATOR_NAME: | ||
161 | return S_IRUGO; | ||
162 | default: | ||
163 | return 0; | ||
164 | } | ||
159 | case ISCSI_PARAM: | 165 | case ISCSI_PARAM: |
160 | switch (param) { | 166 | switch (param) { |
161 | case ISCSI_PARAM_CONN_ADDRESS: | 167 | case ISCSI_PARAM_CONN_ADDRESS: |
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index a8dd85dc77b1..2e9b68215593 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -32,8 +32,6 @@ | |||
32 | #include <scsi/iscsi_if.h> | 32 | #include <scsi/iscsi_if.h> |
33 | #include <scsi/scsi_cmnd.h> | 33 | #include <scsi/scsi_cmnd.h> |
34 | 34 | ||
35 | #define ISCSI_HOST_ATTRS 4 | ||
36 | |||
37 | #define ISCSI_TRANSPORT_VERSION "2.0-870" | 35 | #define ISCSI_TRANSPORT_VERSION "2.0-870" |
38 | 36 | ||
39 | static int dbg_session; | 37 | static int dbg_session; |
@@ -74,7 +72,6 @@ struct iscsi_internal { | |||
74 | struct list_head list; | 72 | struct list_head list; |
75 | struct device dev; | 73 | struct device dev; |
76 | 74 | ||
77 | struct device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; | ||
78 | struct transport_container conn_cont; | 75 | struct transport_container conn_cont; |
79 | struct transport_container session_cont; | 76 | struct transport_container session_cont; |
80 | }; | 77 | }; |
@@ -2301,13 +2298,42 @@ iscsi_host_attr(hwaddress, ISCSI_HOST_PARAM_HWADDRESS); | |||
2301 | iscsi_host_attr(ipaddress, ISCSI_HOST_PARAM_IPADDRESS); | 2298 | iscsi_host_attr(ipaddress, ISCSI_HOST_PARAM_IPADDRESS); |
2302 | iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); | 2299 | iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); |
2303 | 2300 | ||
2304 | #define SETUP_HOST_RD_ATTR(field, param_flag) \ | 2301 | static struct attribute *iscsi_host_attrs[] = { |
2305 | do { \ | 2302 | &dev_attr_host_netdev.attr, |
2306 | if (tt->host_param_mask & param_flag) { \ | 2303 | &dev_attr_host_hwaddress.attr, |
2307 | priv->host_attrs[count] = &dev_attr_host_##field; \ | 2304 | &dev_attr_host_ipaddress.attr, |
2308 | count++; \ | 2305 | &dev_attr_host_initiatorname.attr, |
2309 | } \ | 2306 | NULL, |
2310 | } while (0) | 2307 | }; |
2308 | |||
2309 | static mode_t iscsi_host_attr_is_visible(struct kobject *kobj, | ||
2310 | struct attribute *attr, int i) | ||
2311 | { | ||
2312 | struct device *cdev = container_of(kobj, struct device, kobj); | ||
2313 | struct Scsi_Host *shost = transport_class_to_shost(cdev); | ||
2314 | struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); | ||
2315 | int param; | ||
2316 | |||
2317 | if (attr == &dev_attr_host_netdev.attr) | ||
2318 | param = ISCSI_HOST_PARAM_NETDEV_NAME; | ||
2319 | else if (attr == &dev_attr_host_hwaddress.attr) | ||
2320 | param = ISCSI_HOST_PARAM_HWADDRESS; | ||
2321 | else if (attr == &dev_attr_host_ipaddress.attr) | ||
2322 | param = ISCSI_HOST_PARAM_IPADDRESS; | ||
2323 | else if (attr == &dev_attr_host_initiatorname.attr) | ||
2324 | param = ISCSI_HOST_PARAM_INITIATOR_NAME; | ||
2325 | else { | ||
2326 | WARN_ONCE(1, "Invalid host attr"); | ||
2327 | return 0; | ||
2328 | } | ||
2329 | |||
2330 | return priv->iscsi_transport->attr_is_visible(ISCSI_HOST_PARAM, param); | ||
2331 | } | ||
2332 | |||
2333 | static struct attribute_group iscsi_host_group = { | ||
2334 | .attrs = iscsi_host_attrs, | ||
2335 | .is_visible = iscsi_host_attr_is_visible, | ||
2336 | }; | ||
2311 | 2337 | ||
2312 | static int iscsi_session_match(struct attribute_container *cont, | 2338 | static int iscsi_session_match(struct attribute_container *cont, |
2313 | struct device *dev) | 2339 | struct device *dev) |
@@ -2379,7 +2405,7 @@ iscsi_register_transport(struct iscsi_transport *tt) | |||
2379 | { | 2405 | { |
2380 | struct iscsi_internal *priv; | 2406 | struct iscsi_internal *priv; |
2381 | unsigned long flags; | 2407 | unsigned long flags; |
2382 | int count = 0, err; | 2408 | int err; |
2383 | 2409 | ||
2384 | BUG_ON(!tt); | 2410 | BUG_ON(!tt); |
2385 | 2411 | ||
@@ -2406,20 +2432,12 @@ iscsi_register_transport(struct iscsi_transport *tt) | |||
2406 | goto unregister_dev; | 2432 | goto unregister_dev; |
2407 | 2433 | ||
2408 | /* host parameters */ | 2434 | /* host parameters */ |
2409 | priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; | ||
2410 | priv->t.host_attrs.ac.class = &iscsi_host_class.class; | 2435 | priv->t.host_attrs.ac.class = &iscsi_host_class.class; |
2411 | priv->t.host_attrs.ac.match = iscsi_host_match; | 2436 | priv->t.host_attrs.ac.match = iscsi_host_match; |
2437 | priv->t.host_attrs.ac.grp = &iscsi_host_group; | ||
2412 | priv->t.host_size = sizeof(struct iscsi_cls_host); | 2438 | priv->t.host_size = sizeof(struct iscsi_cls_host); |
2413 | transport_container_register(&priv->t.host_attrs); | 2439 | transport_container_register(&priv->t.host_attrs); |
2414 | 2440 | ||
2415 | SETUP_HOST_RD_ATTR(netdev, ISCSI_HOST_NETDEV_NAME); | ||
2416 | SETUP_HOST_RD_ATTR(ipaddress, ISCSI_HOST_IPADDRESS); | ||
2417 | SETUP_HOST_RD_ATTR(hwaddress, ISCSI_HOST_HWADDRESS); | ||
2418 | SETUP_HOST_RD_ATTR(initiatorname, ISCSI_HOST_INITIATOR_NAME); | ||
2419 | BUG_ON(count > ISCSI_HOST_ATTRS); | ||
2420 | priv->host_attrs[count] = NULL; | ||
2421 | count = 0; | ||
2422 | |||
2423 | /* connection parameters */ | 2441 | /* connection parameters */ |
2424 | priv->conn_cont.ac.class = &iscsi_connection_class.class; | 2442 | priv->conn_cont.ac.class = &iscsi_connection_class.class; |
2425 | priv->conn_cont.ac.match = iscsi_conn_match; | 2443 | priv->conn_cont.ac.match = iscsi_conn_match; |