aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-05-03 02:50:52 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2015-05-30 21:04:20 -0400
commitd588cf8f618d7b316743a0bc99fede20f7a01bb7 (patch)
treeee81f6056ec9868f83338b67256a9e21044f6f84
parentee7619f2eb21304dcc846b8dc8f8c3d6cbe11792 (diff)
target: Fix se_tpg_tfo->tf_subsys regression + remove tf_subsystem
There is just one configfs subsystem in the target code, so we might as well add two helpers to reference / unreference it from the core code instead of passing pointers to it around. This fixes a regression introduced for v4.1-rc1 with commit 9ac8928e6, where configfs_depend_item() callers using se_tpg_tfo->tf_subsys would fail, because the assignment from the original target_core_subsystem[] is no longer happening at target_register_template() time. (Fix target_core_exit_configfs pointer dereference - Sagi) Signed-off-by: Christoph Hellwig <hch@lst.de> Reported-by: Himanshu Madhani <himanshu.madhani@qlogic.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c6
-rw-r--r--drivers/target/target_core_configfs.c30
-rw-r--r--drivers/target/target_core_internal.h3
-rw-r--r--drivers/target/target_core_pr.c32
-rw-r--r--drivers/target/target_core_xcopy.c15
-rw-r--r--drivers/vhost/scsi.c6
-rw-r--r--include/target/target_core_configfs.h2
-rw-r--r--include/target/target_core_fabric.h4
8 files changed, 34 insertions, 64 deletions
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 68c2002e78bf..5c9e680aa375 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1020,8 +1020,7 @@ static void tcm_qla2xxx_depend_tpg(struct work_struct *work)
1020 struct se_portal_group *se_tpg = &base_tpg->se_tpg; 1020 struct se_portal_group *se_tpg = &base_tpg->se_tpg;
1021 struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha; 1021 struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;
1022 1022
1023 if (!configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys, 1023 if (!target_depend_item(&se_tpg->tpg_group.cg_item)) {
1024 &se_tpg->tpg_group.cg_item)) {
1025 atomic_set(&base_tpg->lport_tpg_enabled, 1); 1024 atomic_set(&base_tpg->lport_tpg_enabled, 1);
1026 qlt_enable_vha(base_vha); 1025 qlt_enable_vha(base_vha);
1027 } 1026 }
@@ -1037,8 +1036,7 @@ static void tcm_qla2xxx_undepend_tpg(struct work_struct *work)
1037 1036
1038 if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) { 1037 if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) {
1039 atomic_set(&base_tpg->lport_tpg_enabled, 0); 1038 atomic_set(&base_tpg->lport_tpg_enabled, 0);
1040 configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys, 1039 target_undepend_item(&se_tpg->tpg_group.cg_item);
1041 &se_tpg->tpg_group.cg_item);
1042 } 1040 }
1043 complete(&base_tpg->tpg_base_comp); 1041 complete(&base_tpg->tpg_base_comp);
1044} 1042}
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index ddaf76a4ac2a..1580077971f8 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -212,10 +212,6 @@ static struct config_group *target_core_register_fabric(
212 212
213 pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:" 213 pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:"
214 " %s\n", tf->tf_group.cg_item.ci_name); 214 " %s\n", tf->tf_group.cg_item.ci_name);
215 /*
216 * Setup tf_ops.tf_subsys pointer for usage with configfs_depend_item()
217 */
218 tf->tf_ops.tf_subsys = tf->tf_subsys;
219 tf->tf_fabric = &tf->tf_group.cg_item; 215 tf->tf_fabric = &tf->tf_group.cg_item;
220 pr_debug("Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric" 216 pr_debug("Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric"
221 " for %s\n", name); 217 " for %s\n", name);
@@ -291,10 +287,17 @@ static struct configfs_subsystem target_core_fabrics = {
291 }, 287 },
292}; 288};
293 289
294struct configfs_subsystem *target_core_subsystem[] = { 290int target_depend_item(struct config_item *item)
295 &target_core_fabrics, 291{
296 NULL, 292 return configfs_depend_item(&target_core_fabrics, item);
297}; 293}
294EXPORT_SYMBOL(target_depend_item);
295
296void target_undepend_item(struct config_item *item)
297{
298 return configfs_undepend_item(&target_core_fabrics, item);
299}
300EXPORT_SYMBOL(target_undepend_item);
298 301
299/*############################################################################## 302/*##############################################################################
300// Start functions called by external Target Fabrics Modules 303// Start functions called by external Target Fabrics Modules
@@ -467,7 +470,6 @@ int target_register_template(const struct target_core_fabric_ops *fo)
467 * struct target_fabric_configfs->tf_cit_tmpl 470 * struct target_fabric_configfs->tf_cit_tmpl
468 */ 471 */
469 tf->tf_module = fo->module; 472 tf->tf_module = fo->module;
470 tf->tf_subsys = target_core_subsystem[0];
471 snprintf(tf->tf_name, TARGET_FABRIC_NAME_SIZE, "%s", fo->name); 473 snprintf(tf->tf_name, TARGET_FABRIC_NAME_SIZE, "%s", fo->name);
472 474
473 tf->tf_ops = *fo; 475 tf->tf_ops = *fo;
@@ -2870,7 +2872,7 @@ static int __init target_core_init_configfs(void)
2870{ 2872{
2871 struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL; 2873 struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL;
2872 struct config_group *lu_gp_cg = NULL; 2874 struct config_group *lu_gp_cg = NULL;
2873 struct configfs_subsystem *subsys; 2875 struct configfs_subsystem *subsys = &target_core_fabrics;
2874 struct t10_alua_lu_gp *lu_gp; 2876 struct t10_alua_lu_gp *lu_gp;
2875 int ret; 2877 int ret;
2876 2878
@@ -2878,7 +2880,6 @@ static int __init target_core_init_configfs(void)
2878 " Engine: %s on %s/%s on "UTS_RELEASE"\n", 2880 " Engine: %s on %s/%s on "UTS_RELEASE"\n",
2879 TARGET_CORE_VERSION, utsname()->sysname, utsname()->machine); 2881 TARGET_CORE_VERSION, utsname()->sysname, utsname()->machine);
2880 2882
2881 subsys = target_core_subsystem[0];
2882 config_group_init(&subsys->su_group); 2883 config_group_init(&subsys->su_group);
2883 mutex_init(&subsys->su_mutex); 2884 mutex_init(&subsys->su_mutex);
2884 2885
@@ -3008,13 +3009,10 @@ out_global:
3008 3009
3009static void __exit target_core_exit_configfs(void) 3010static void __exit target_core_exit_configfs(void)
3010{ 3011{
3011 struct configfs_subsystem *subsys;
3012 struct config_group *hba_cg, *alua_cg, *lu_gp_cg; 3012 struct config_group *hba_cg, *alua_cg, *lu_gp_cg;
3013 struct config_item *item; 3013 struct config_item *item;
3014 int i; 3014 int i;
3015 3015
3016 subsys = target_core_subsystem[0];
3017
3018 lu_gp_cg = &alua_lu_gps_group; 3016 lu_gp_cg = &alua_lu_gps_group;
3019 for (i = 0; lu_gp_cg->default_groups[i]; i++) { 3017 for (i = 0; lu_gp_cg->default_groups[i]; i++) {
3020 item = &lu_gp_cg->default_groups[i]->cg_item; 3018 item = &lu_gp_cg->default_groups[i]->cg_item;
@@ -3045,8 +3043,8 @@ static void __exit target_core_exit_configfs(void)
3045 * We expect subsys->su_group.default_groups to be released 3043 * We expect subsys->su_group.default_groups to be released
3046 * by configfs subsystem provider logic.. 3044 * by configfs subsystem provider logic..
3047 */ 3045 */
3048 configfs_unregister_subsystem(subsys); 3046 configfs_unregister_subsystem(&target_core_fabrics);
3049 kfree(subsys->su_group.default_groups); 3047 kfree(target_core_fabrics.su_group.default_groups);
3050 3048
3051 core_alua_free_lu_gp(default_lu_gp); 3049 core_alua_free_lu_gp(default_lu_gp);
3052 default_lu_gp = NULL; 3050 default_lu_gp = NULL;
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 874a9bc988d8..68bd7f5d9f73 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -4,9 +4,6 @@
4/* target_core_alua.c */ 4/* target_core_alua.c */
5extern struct t10_alua_lu_gp *default_lu_gp; 5extern struct t10_alua_lu_gp *default_lu_gp;
6 6
7/* target_core_configfs.c */
8extern struct configfs_subsystem *target_core_subsystem[];
9
10/* target_core_device.c */ 7/* target_core_device.c */
11extern struct mutex g_device_mutex; 8extern struct mutex g_device_mutex;
12extern struct list_head g_device_list; 9extern struct list_head g_device_list;
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index c1aa9655e96e..b7c81acf08d0 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1367,41 +1367,26 @@ void core_scsi3_free_all_registrations(
1367 1367
1368static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg) 1368static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg)
1369{ 1369{
1370 return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, 1370 return target_depend_item(&tpg->tpg_group.cg_item);
1371 &tpg->tpg_group.cg_item);
1372} 1371}
1373 1372
1374static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg) 1373static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg)
1375{ 1374{
1376 configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, 1375 target_undepend_item(&tpg->tpg_group.cg_item);
1377 &tpg->tpg_group.cg_item);
1378
1379 atomic_dec_mb(&tpg->tpg_pr_ref_count); 1376 atomic_dec_mb(&tpg->tpg_pr_ref_count);
1380} 1377}
1381 1378
1382static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl) 1379static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl)
1383{ 1380{
1384 struct se_portal_group *tpg = nacl->se_tpg;
1385
1386 if (nacl->dynamic_node_acl) 1381 if (nacl->dynamic_node_acl)
1387 return 0; 1382 return 0;
1388 1383 return target_depend_item(&nacl->acl_group.cg_item);
1389 return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys,
1390 &nacl->acl_group.cg_item);
1391} 1384}
1392 1385
1393static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl) 1386static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl)
1394{ 1387{
1395 struct se_portal_group *tpg = nacl->se_tpg; 1388 if (!nacl->dynamic_node_acl)
1396 1389 target_undepend_item(&nacl->acl_group.cg_item);
1397 if (nacl->dynamic_node_acl) {
1398 atomic_dec_mb(&nacl->acl_pr_ref_count);
1399 return;
1400 }
1401
1402 configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys,
1403 &nacl->acl_group.cg_item);
1404
1405 atomic_dec_mb(&nacl->acl_pr_ref_count); 1390 atomic_dec_mb(&nacl->acl_pr_ref_count);
1406} 1391}
1407 1392
@@ -1419,8 +1404,7 @@ static int core_scsi3_lunacl_depend_item(struct se_dev_entry *se_deve)
1419 nacl = lun_acl->se_lun_nacl; 1404 nacl = lun_acl->se_lun_nacl;
1420 tpg = nacl->se_tpg; 1405 tpg = nacl->se_tpg;
1421 1406
1422 return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, 1407 return target_depend_item(&lun_acl->se_lun_group.cg_item);
1423 &lun_acl->se_lun_group.cg_item);
1424} 1408}
1425 1409
1426static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve) 1410static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve)
@@ -1438,9 +1422,7 @@ static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve)
1438 nacl = lun_acl->se_lun_nacl; 1422 nacl = lun_acl->se_lun_nacl;
1439 tpg = nacl->se_tpg; 1423 tpg = nacl->se_tpg;
1440 1424
1441 configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, 1425 target_undepend_item(&lun_acl->se_lun_group.cg_item);
1442 &lun_acl->se_lun_group.cg_item);
1443
1444 atomic_dec_mb(&se_deve->pr_ref_count); 1426 atomic_dec_mb(&se_deve->pr_ref_count);
1445} 1427}
1446 1428
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index a600ff15dcfd..8fd680ac941b 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -58,7 +58,6 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
58 bool src) 58 bool src)
59{ 59{
60 struct se_device *se_dev; 60 struct se_device *se_dev;
61 struct configfs_subsystem *subsys = target_core_subsystem[0];
62 unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN], *dev_wwn; 61 unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN], *dev_wwn;
63 int rc; 62 int rc;
64 63
@@ -90,8 +89,7 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
90 " se_dev\n", xop->src_dev); 89 " se_dev\n", xop->src_dev);
91 } 90 }
92 91
93 rc = configfs_depend_item(subsys, 92 rc = target_depend_item(&se_dev->dev_group.cg_item);
94 &se_dev->dev_group.cg_item);
95 if (rc != 0) { 93 if (rc != 0) {
96 pr_err("configfs_depend_item attempt failed:" 94 pr_err("configfs_depend_item attempt failed:"
97 " %d for se_dev: %p\n", rc, se_dev); 95 " %d for se_dev: %p\n", rc, se_dev);
@@ -99,8 +97,8 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
99 return rc; 97 return rc;
100 } 98 }
101 99
102 pr_debug("Called configfs_depend_item for subsys: %p se_dev: %p" 100 pr_debug("Called configfs_depend_item for se_dev: %p"
103 " se_dev->se_dev_group: %p\n", subsys, se_dev, 101 " se_dev->se_dev_group: %p\n", se_dev,
104 &se_dev->dev_group); 102 &se_dev->dev_group);
105 103
106 mutex_unlock(&g_device_mutex); 104 mutex_unlock(&g_device_mutex);
@@ -373,7 +371,6 @@ static int xcopy_pt_get_cmd_state(struct se_cmd *se_cmd)
373 371
374static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop) 372static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop)
375{ 373{
376 struct configfs_subsystem *subsys = target_core_subsystem[0];
377 struct se_device *remote_dev; 374 struct se_device *remote_dev;
378 375
379 if (xop->op_origin == XCOL_SOURCE_RECV_OP) 376 if (xop->op_origin == XCOL_SOURCE_RECV_OP)
@@ -381,11 +378,11 @@ static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop)
381 else 378 else
382 remote_dev = xop->src_dev; 379 remote_dev = xop->src_dev;
383 380
384 pr_debug("Calling configfs_undepend_item for subsys: %p" 381 pr_debug("Calling configfs_undepend_item for"
385 " remote_dev: %p remote_dev->dev_group: %p\n", 382 " remote_dev: %p remote_dev->dev_group: %p\n",
386 subsys, remote_dev, &remote_dev->dev_group.cg_item); 383 remote_dev, &remote_dev->dev_group.cg_item);
387 384
388 configfs_undepend_item(subsys, &remote_dev->dev_group.cg_item); 385 target_undepend_item(&remote_dev->dev_group.cg_item);
389} 386}
390 387
391static void xcopy_pt_release_cmd(struct se_cmd *se_cmd) 388static void xcopy_pt_release_cmd(struct se_cmd *se_cmd)
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 5e19bb53b3a9..ea32b386797f 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -1409,8 +1409,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
1409 * dependency now. 1409 * dependency now.
1410 */ 1410 */
1411 se_tpg = &tpg->se_tpg; 1411 se_tpg = &tpg->se_tpg;
1412 ret = configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys, 1412 ret = target_depend_item(&se_tpg->tpg_group.cg_item);
1413 &se_tpg->tpg_group.cg_item);
1414 if (ret) { 1413 if (ret) {
1415 pr_warn("configfs_depend_item() failed: %d\n", ret); 1414 pr_warn("configfs_depend_item() failed: %d\n", ret);
1416 kfree(vs_tpg); 1415 kfree(vs_tpg);
@@ -1513,8 +1512,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
1513 * to allow vhost-scsi WWPN se_tpg->tpg_group shutdown to occur. 1512 * to allow vhost-scsi WWPN se_tpg->tpg_group shutdown to occur.
1514 */ 1513 */
1515 se_tpg = &tpg->se_tpg; 1514 se_tpg = &tpg->se_tpg;
1516 configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys, 1515 target_undepend_item(&se_tpg->tpg_group.cg_item);
1517 &se_tpg->tpg_group.cg_item);
1518 } 1516 }
1519 if (match) { 1517 if (match) {
1520 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) { 1518 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
diff --git a/include/target/target_core_configfs.h b/include/target/target_core_configfs.h
index 25bb04c4209e..b99c01170392 100644
--- a/include/target/target_core_configfs.h
+++ b/include/target/target_core_configfs.h
@@ -40,8 +40,6 @@ struct target_fabric_configfs {
40 struct config_item *tf_fabric; 40 struct config_item *tf_fabric;
41 /* Passed from fabric modules */ 41 /* Passed from fabric modules */
42 struct config_item_type *tf_fabric_cit; 42 struct config_item_type *tf_fabric_cit;
43 /* Pointer to target core subsystem */
44 struct configfs_subsystem *tf_subsys;
45 /* Pointer to fabric's struct module */ 43 /* Pointer to fabric's struct module */
46 struct module *tf_module; 44 struct module *tf_module;
47 struct target_core_fabric_ops tf_ops; 45 struct target_core_fabric_ops tf_ops;
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index 17c7f5ac7ea0..0f4dc3768587 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -4,7 +4,6 @@
4struct target_core_fabric_ops { 4struct target_core_fabric_ops {
5 struct module *module; 5 struct module *module;
6 const char *name; 6 const char *name;
7 struct configfs_subsystem *tf_subsys;
8 char *(*get_fabric_name)(void); 7 char *(*get_fabric_name)(void);
9 u8 (*get_fabric_proto_ident)(struct se_portal_group *); 8 u8 (*get_fabric_proto_ident)(struct se_portal_group *);
10 char *(*tpg_get_wwn)(struct se_portal_group *); 9 char *(*tpg_get_wwn)(struct se_portal_group *);
@@ -109,6 +108,9 @@ struct target_core_fabric_ops {
109int target_register_template(const struct target_core_fabric_ops *fo); 108int target_register_template(const struct target_core_fabric_ops *fo);
110void target_unregister_template(const struct target_core_fabric_ops *fo); 109void target_unregister_template(const struct target_core_fabric_ops *fo);
111 110
111int target_depend_item(struct config_item *item);
112void target_undepend_item(struct config_item *item);
113
112struct se_session *transport_init_session(enum target_prot_op); 114struct se_session *transport_init_session(enum target_prot_op);
113int transport_alloc_session_tags(struct se_session *, unsigned int, 115int transport_alloc_session_tags(struct se_session *, unsigned int,
114 unsigned int); 116 unsigned int);