diff options
Diffstat (limited to 'drivers/target/iscsi/iscsi_target_configfs.c')
-rw-r--r-- | drivers/target/iscsi/iscsi_target_configfs.c | 208 |
1 files changed, 89 insertions, 119 deletions
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 48384b675e62..469fce44ebad 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -37,9 +37,6 @@ | |||
37 | #include "iscsi_target_util.h" | 37 | #include "iscsi_target_util.h" |
38 | #include "iscsi_target.h" | 38 | #include "iscsi_target.h" |
39 | #include <target/iscsi/iscsi_target_stat.h> | 39 | #include <target/iscsi/iscsi_target_stat.h> |
40 | #include "iscsi_target_configfs.h" | ||
41 | |||
42 | struct target_fabric_configfs *lio_target_fabric_configfs; | ||
43 | 40 | ||
44 | struct lio_target_configfs_attribute { | 41 | struct lio_target_configfs_attribute { |
45 | struct configfs_attribute attr; | 42 | struct configfs_attribute attr; |
@@ -1052,6 +1049,11 @@ TPG_ATTR(default_erl, S_IRUGO | S_IWUSR); | |||
1052 | */ | 1049 | */ |
1053 | DEF_TPG_ATTRIB(t10_pi); | 1050 | DEF_TPG_ATTRIB(t10_pi); |
1054 | TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR); | 1051 | TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR); |
1052 | /* | ||
1053 | * Define iscsi_tpg_attrib_s_fabric_prot_type | ||
1054 | */ | ||
1055 | DEF_TPG_ATTRIB(fabric_prot_type); | ||
1056 | TPG_ATTR(fabric_prot_type, S_IRUGO | S_IWUSR); | ||
1055 | 1057 | ||
1056 | static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { | 1058 | static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { |
1057 | &iscsi_tpg_attrib_authentication.attr, | 1059 | &iscsi_tpg_attrib_authentication.attr, |
@@ -1065,6 +1067,7 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { | |||
1065 | &iscsi_tpg_attrib_demo_mode_discovery.attr, | 1067 | &iscsi_tpg_attrib_demo_mode_discovery.attr, |
1066 | &iscsi_tpg_attrib_default_erl.attr, | 1068 | &iscsi_tpg_attrib_default_erl.attr, |
1067 | &iscsi_tpg_attrib_t10_pi.attr, | 1069 | &iscsi_tpg_attrib_t10_pi.attr, |
1070 | &iscsi_tpg_attrib_fabric_prot_type.attr, | ||
1068 | NULL, | 1071 | NULL, |
1069 | }; | 1072 | }; |
1070 | 1073 | ||
@@ -1410,8 +1413,18 @@ out: | |||
1410 | 1413 | ||
1411 | TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR); | 1414 | TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR); |
1412 | 1415 | ||
1416 | static ssize_t lio_target_tpg_show_dynamic_sessions( | ||
1417 | struct se_portal_group *se_tpg, | ||
1418 | char *page) | ||
1419 | { | ||
1420 | return target_show_dynamic_sessions(se_tpg, page); | ||
1421 | } | ||
1422 | |||
1423 | TF_TPG_BASE_ATTR_RO(lio_target, dynamic_sessions); | ||
1424 | |||
1413 | static struct configfs_attribute *lio_target_tpg_attrs[] = { | 1425 | static struct configfs_attribute *lio_target_tpg_attrs[] = { |
1414 | &lio_target_tpg_enable.attr, | 1426 | &lio_target_tpg_enable.attr, |
1427 | &lio_target_tpg_dynamic_sessions.attr, | ||
1415 | NULL, | 1428 | NULL, |
1416 | }; | 1429 | }; |
1417 | 1430 | ||
@@ -1450,10 +1463,8 @@ static struct se_portal_group *lio_target_tiqn_addtpg( | |||
1450 | if (!tpg) | 1463 | if (!tpg) |
1451 | return NULL; | 1464 | return NULL; |
1452 | 1465 | ||
1453 | ret = core_tpg_register( | 1466 | ret = core_tpg_register(&iscsi_ops, wwn, &tpg->tpg_se_tpg, |
1454 | &lio_target_fabric_configfs->tf_ops, | 1467 | tpg, TRANSPORT_TPG_TYPE_NORMAL); |
1455 | wwn, &tpg->tpg_se_tpg, tpg, | ||
1456 | TRANSPORT_TPG_TYPE_NORMAL); | ||
1457 | if (ret < 0) | 1468 | if (ret < 0) |
1458 | return NULL; | 1469 | return NULL; |
1459 | 1470 | ||
@@ -1872,6 +1883,20 @@ static int lio_tpg_check_prod_mode_write_protect( | |||
1872 | return tpg->tpg_attrib.prod_mode_write_protect; | 1883 | return tpg->tpg_attrib.prod_mode_write_protect; |
1873 | } | 1884 | } |
1874 | 1885 | ||
1886 | static int lio_tpg_check_prot_fabric_only( | ||
1887 | struct se_portal_group *se_tpg) | ||
1888 | { | ||
1889 | struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; | ||
1890 | /* | ||
1891 | * Only report fabric_prot_type if t10_pi has also been enabled | ||
1892 | * for incoming ib_isert sessions. | ||
1893 | */ | ||
1894 | if (!tpg->tpg_attrib.t10_pi) | ||
1895 | return 0; | ||
1896 | |||
1897 | return tpg->tpg_attrib.fabric_prot_type; | ||
1898 | } | ||
1899 | |||
1875 | static void lio_tpg_release_fabric_acl( | 1900 | static void lio_tpg_release_fabric_acl( |
1876 | struct se_portal_group *se_tpg, | 1901 | struct se_portal_group *se_tpg, |
1877 | struct se_node_acl *se_acl) | 1902 | struct se_node_acl *se_acl) |
@@ -1953,115 +1978,60 @@ static void lio_release_cmd(struct se_cmd *se_cmd) | |||
1953 | iscsit_release_cmd(cmd); | 1978 | iscsit_release_cmd(cmd); |
1954 | } | 1979 | } |
1955 | 1980 | ||
1956 | /* End functions for target_core_fabric_ops */ | 1981 | const struct target_core_fabric_ops iscsi_ops = { |
1957 | 1982 | .module = THIS_MODULE, | |
1958 | int iscsi_target_register_configfs(void) | 1983 | .name = "iscsi", |
1959 | { | 1984 | .get_fabric_name = iscsi_get_fabric_name, |
1960 | struct target_fabric_configfs *fabric; | 1985 | .get_fabric_proto_ident = iscsi_get_fabric_proto_ident, |
1961 | int ret; | 1986 | .tpg_get_wwn = lio_tpg_get_endpoint_wwn, |
1962 | 1987 | .tpg_get_tag = lio_tpg_get_tag, | |
1963 | lio_target_fabric_configfs = NULL; | 1988 | .tpg_get_default_depth = lio_tpg_get_default_depth, |
1964 | fabric = target_fabric_configfs_init(THIS_MODULE, "iscsi"); | 1989 | .tpg_get_pr_transport_id = iscsi_get_pr_transport_id, |
1965 | if (IS_ERR(fabric)) { | 1990 | .tpg_get_pr_transport_id_len = iscsi_get_pr_transport_id_len, |
1966 | pr_err("target_fabric_configfs_init() for" | 1991 | .tpg_parse_pr_out_transport_id = iscsi_parse_pr_out_transport_id, |
1967 | " LIO-Target failed!\n"); | 1992 | .tpg_check_demo_mode = lio_tpg_check_demo_mode, |
1968 | return PTR_ERR(fabric); | 1993 | .tpg_check_demo_mode_cache = lio_tpg_check_demo_mode_cache, |
1969 | } | 1994 | .tpg_check_demo_mode_write_protect = |
1970 | /* | 1995 | lio_tpg_check_demo_mode_write_protect, |
1971 | * Setup the fabric API of function pointers used by target_core_mod.. | 1996 | .tpg_check_prod_mode_write_protect = |
1972 | */ | 1997 | lio_tpg_check_prod_mode_write_protect, |
1973 | fabric->tf_ops.get_fabric_name = &iscsi_get_fabric_name; | 1998 | .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only, |
1974 | fabric->tf_ops.get_fabric_proto_ident = &iscsi_get_fabric_proto_ident; | 1999 | .tpg_alloc_fabric_acl = lio_tpg_alloc_fabric_acl, |
1975 | fabric->tf_ops.tpg_get_wwn = &lio_tpg_get_endpoint_wwn; | 2000 | .tpg_release_fabric_acl = lio_tpg_release_fabric_acl, |
1976 | fabric->tf_ops.tpg_get_tag = &lio_tpg_get_tag; | 2001 | .tpg_get_inst_index = lio_tpg_get_inst_index, |
1977 | fabric->tf_ops.tpg_get_default_depth = &lio_tpg_get_default_depth; | 2002 | .check_stop_free = lio_check_stop_free, |
1978 | fabric->tf_ops.tpg_get_pr_transport_id = &iscsi_get_pr_transport_id; | 2003 | .release_cmd = lio_release_cmd, |
1979 | fabric->tf_ops.tpg_get_pr_transport_id_len = | 2004 | .shutdown_session = lio_tpg_shutdown_session, |
1980 | &iscsi_get_pr_transport_id_len; | 2005 | .close_session = lio_tpg_close_session, |
1981 | fabric->tf_ops.tpg_parse_pr_out_transport_id = | 2006 | .sess_get_index = lio_sess_get_index, |
1982 | &iscsi_parse_pr_out_transport_id; | 2007 | .sess_get_initiator_sid = lio_sess_get_initiator_sid, |
1983 | fabric->tf_ops.tpg_check_demo_mode = &lio_tpg_check_demo_mode; | 2008 | .write_pending = lio_write_pending, |
1984 | fabric->tf_ops.tpg_check_demo_mode_cache = | 2009 | .write_pending_status = lio_write_pending_status, |
1985 | &lio_tpg_check_demo_mode_cache; | 2010 | .set_default_node_attributes = lio_set_default_node_attributes, |
1986 | fabric->tf_ops.tpg_check_demo_mode_write_protect = | 2011 | .get_task_tag = iscsi_get_task_tag, |
1987 | &lio_tpg_check_demo_mode_write_protect; | 2012 | .get_cmd_state = iscsi_get_cmd_state, |
1988 | fabric->tf_ops.tpg_check_prod_mode_write_protect = | 2013 | .queue_data_in = lio_queue_data_in, |
1989 | &lio_tpg_check_prod_mode_write_protect; | 2014 | .queue_status = lio_queue_status, |
1990 | fabric->tf_ops.tpg_alloc_fabric_acl = &lio_tpg_alloc_fabric_acl; | 2015 | .queue_tm_rsp = lio_queue_tm_rsp, |
1991 | fabric->tf_ops.tpg_release_fabric_acl = &lio_tpg_release_fabric_acl; | 2016 | .aborted_task = lio_aborted_task, |
1992 | fabric->tf_ops.tpg_get_inst_index = &lio_tpg_get_inst_index; | 2017 | .fabric_make_wwn = lio_target_call_coreaddtiqn, |
1993 | fabric->tf_ops.check_stop_free = &lio_check_stop_free, | 2018 | .fabric_drop_wwn = lio_target_call_coredeltiqn, |
1994 | fabric->tf_ops.release_cmd = &lio_release_cmd; | 2019 | .fabric_make_tpg = lio_target_tiqn_addtpg, |
1995 | fabric->tf_ops.shutdown_session = &lio_tpg_shutdown_session; | 2020 | .fabric_drop_tpg = lio_target_tiqn_deltpg, |
1996 | fabric->tf_ops.close_session = &lio_tpg_close_session; | 2021 | .fabric_make_np = lio_target_call_addnptotpg, |
1997 | fabric->tf_ops.sess_get_index = &lio_sess_get_index; | 2022 | .fabric_drop_np = lio_target_call_delnpfromtpg, |
1998 | fabric->tf_ops.sess_get_initiator_sid = &lio_sess_get_initiator_sid; | 2023 | .fabric_make_nodeacl = lio_target_make_nodeacl, |
1999 | fabric->tf_ops.write_pending = &lio_write_pending; | 2024 | .fabric_drop_nodeacl = lio_target_drop_nodeacl, |
2000 | fabric->tf_ops.write_pending_status = &lio_write_pending_status; | 2025 | |
2001 | fabric->tf_ops.set_default_node_attributes = | 2026 | .tfc_discovery_attrs = lio_target_discovery_auth_attrs, |
2002 | &lio_set_default_node_attributes; | 2027 | .tfc_wwn_attrs = lio_target_wwn_attrs, |
2003 | fabric->tf_ops.get_task_tag = &iscsi_get_task_tag; | 2028 | .tfc_tpg_base_attrs = lio_target_tpg_attrs, |
2004 | fabric->tf_ops.get_cmd_state = &iscsi_get_cmd_state; | 2029 | .tfc_tpg_attrib_attrs = lio_target_tpg_attrib_attrs, |
2005 | fabric->tf_ops.queue_data_in = &lio_queue_data_in; | 2030 | .tfc_tpg_auth_attrs = lio_target_tpg_auth_attrs, |
2006 | fabric->tf_ops.queue_status = &lio_queue_status; | 2031 | .tfc_tpg_param_attrs = lio_target_tpg_param_attrs, |
2007 | fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp; | 2032 | .tfc_tpg_np_base_attrs = lio_target_portal_attrs, |
2008 | fabric->tf_ops.aborted_task = &lio_aborted_task; | 2033 | .tfc_tpg_nacl_base_attrs = lio_target_initiator_attrs, |
2009 | /* | 2034 | .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs, |
2010 | * Setup function pointers for generic logic in target_core_fabric_configfs.c | 2035 | .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs, |
2011 | */ | 2036 | .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs, |
2012 | fabric->tf_ops.fabric_make_wwn = &lio_target_call_coreaddtiqn; | 2037 | }; |
2013 | fabric->tf_ops.fabric_drop_wwn = &lio_target_call_coredeltiqn; | ||
2014 | fabric->tf_ops.fabric_make_tpg = &lio_target_tiqn_addtpg; | ||
2015 | fabric->tf_ops.fabric_drop_tpg = &lio_target_tiqn_deltpg; | ||
2016 | fabric->tf_ops.fabric_post_link = NULL; | ||
2017 | fabric->tf_ops.fabric_pre_unlink = NULL; | ||
2018 | fabric->tf_ops.fabric_make_np = &lio_target_call_addnptotpg; | ||
2019 | fabric->tf_ops.fabric_drop_np = &lio_target_call_delnpfromtpg; | ||
2020 | fabric->tf_ops.fabric_make_nodeacl = &lio_target_make_nodeacl; | ||
2021 | fabric->tf_ops.fabric_drop_nodeacl = &lio_target_drop_nodeacl; | ||
2022 | /* | ||
2023 | * Setup default attribute lists for various fabric->tf_cit_tmpl | ||
2024 | * sturct config_item_type's | ||
2025 | */ | ||
2026 | fabric->tf_cit_tmpl.tfc_discovery_cit.ct_attrs = lio_target_discovery_auth_attrs; | ||
2027 | fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = lio_target_wwn_attrs; | ||
2028 | fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = lio_target_tpg_attrs; | ||
2029 | fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = lio_target_tpg_attrib_attrs; | ||
2030 | fabric->tf_cit_tmpl.tfc_tpg_auth_cit.ct_attrs = lio_target_tpg_auth_attrs; | ||
2031 | fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = lio_target_tpg_param_attrs; | ||
2032 | fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = lio_target_portal_attrs; | ||
2033 | fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = lio_target_initiator_attrs; | ||
2034 | fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = lio_target_nacl_attrib_attrs; | ||
2035 | fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = lio_target_nacl_auth_attrs; | ||
2036 | fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = lio_target_nacl_param_attrs; | ||
2037 | |||
2038 | ret = target_fabric_configfs_register(fabric); | ||
2039 | if (ret < 0) { | ||
2040 | pr_err("target_fabric_configfs_register() for" | ||
2041 | " LIO-Target failed!\n"); | ||
2042 | target_fabric_configfs_free(fabric); | ||
2043 | return ret; | ||
2044 | } | ||
2045 | |||
2046 | lio_target_fabric_configfs = fabric; | ||
2047 | pr_debug("LIO_TARGET[0] - Set fabric ->" | ||
2048 | " lio_target_fabric_configfs\n"); | ||
2049 | return 0; | ||
2050 | } | ||
2051 | |||
2052 | |||
2053 | void iscsi_target_deregister_configfs(void) | ||
2054 | { | ||
2055 | if (!lio_target_fabric_configfs) | ||
2056 | return; | ||
2057 | /* | ||
2058 | * Shutdown discovery sessions and disable discovery TPG | ||
2059 | */ | ||
2060 | if (iscsit_global->discovery_tpg) | ||
2061 | iscsit_tpg_disable_portal_group(iscsit_global->discovery_tpg, 1); | ||
2062 | |||
2063 | target_fabric_configfs_deregister(lio_target_fabric_configfs); | ||
2064 | lio_target_fabric_configfs = NULL; | ||
2065 | pr_debug("LIO_TARGET[0] - Cleared" | ||
2066 | " lio_target_fabric_configfs\n"); | ||
2067 | } | ||