aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
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 /drivers/target
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>
Diffstat (limited to 'drivers/target')
-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
4 files changed, 27 insertions, 53 deletions
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)