Commit d588cf8f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger

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 9ac8928e,
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: default avatarChristoph Hellwig <hch@lst.de>
Reported-by: default avatarHimanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent ee7619f2
...@@ -1020,8 +1020,7 @@ static void tcm_qla2xxx_depend_tpg(struct work_struct *work) ...@@ -1020,8 +1020,7 @@ static void tcm_qla2xxx_depend_tpg(struct work_struct *work)
struct se_portal_group *se_tpg = &base_tpg->se_tpg; struct se_portal_group *se_tpg = &base_tpg->se_tpg;
struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha; struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;
if (!configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys, if (!target_depend_item(&se_tpg->tpg_group.cg_item)) {
&se_tpg->tpg_group.cg_item)) {
atomic_set(&base_tpg->lport_tpg_enabled, 1); atomic_set(&base_tpg->lport_tpg_enabled, 1);
qlt_enable_vha(base_vha); qlt_enable_vha(base_vha);
} }
...@@ -1037,8 +1036,7 @@ static void tcm_qla2xxx_undepend_tpg(struct work_struct *work) ...@@ -1037,8 +1036,7 @@ static void tcm_qla2xxx_undepend_tpg(struct work_struct *work)
if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) { if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) {
atomic_set(&base_tpg->lport_tpg_enabled, 0); atomic_set(&base_tpg->lport_tpg_enabled, 0);
configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys, target_undepend_item(&se_tpg->tpg_group.cg_item);
&se_tpg->tpg_group.cg_item);
} }
complete(&base_tpg->tpg_base_comp); complete(&base_tpg->tpg_base_comp);
} }
......
...@@ -212,10 +212,6 @@ static struct config_group *target_core_register_fabric( ...@@ -212,10 +212,6 @@ static struct config_group *target_core_register_fabric(
pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:" pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:"
" %s\n", tf->tf_group.cg_item.ci_name); " %s\n", tf->tf_group.cg_item.ci_name);
/*
* Setup tf_ops.tf_subsys pointer for usage with configfs_depend_item()
*/
tf->tf_ops.tf_subsys = tf->tf_subsys;
tf->tf_fabric = &tf->tf_group.cg_item; tf->tf_fabric = &tf->tf_group.cg_item;
pr_debug("Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric" pr_debug("Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric"
" for %s\n", name); " for %s\n", name);
...@@ -291,10 +287,17 @@ static struct configfs_subsystem target_core_fabrics = { ...@@ -291,10 +287,17 @@ static struct configfs_subsystem target_core_fabrics = {
}, },
}; };
struct configfs_subsystem *target_core_subsystem[] = { int target_depend_item(struct config_item *item)
&target_core_fabrics, {
NULL, return configfs_depend_item(&target_core_fabrics, item);
}; }
EXPORT_SYMBOL(target_depend_item);
void target_undepend_item(struct config_item *item)
{
return configfs_undepend_item(&target_core_fabrics, item);
}
EXPORT_SYMBOL(target_undepend_item);
/*############################################################################## /*##############################################################################
// Start functions called by external Target Fabrics Modules // Start functions called by external Target Fabrics Modules
...@@ -467,7 +470,6 @@ int target_register_template(const struct target_core_fabric_ops *fo) ...@@ -467,7 +470,6 @@ int target_register_template(const struct target_core_fabric_ops *fo)
* struct target_fabric_configfs->tf_cit_tmpl * struct target_fabric_configfs->tf_cit_tmpl
*/ */
tf->tf_module = fo->module; tf->tf_module = fo->module;
tf->tf_subsys = target_core_subsystem[0];
snprintf(tf->tf_name, TARGET_FABRIC_NAME_SIZE, "%s", fo->name); snprintf(tf->tf_name, TARGET_FABRIC_NAME_SIZE, "%s", fo->name);
tf->tf_ops = *fo; tf->tf_ops = *fo;
...@@ -2870,7 +2872,7 @@ static int __init target_core_init_configfs(void) ...@@ -2870,7 +2872,7 @@ static int __init target_core_init_configfs(void)
{ {
struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL; struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL;
struct config_group *lu_gp_cg = NULL; struct config_group *lu_gp_cg = NULL;
struct configfs_subsystem *subsys; struct configfs_subsystem *subsys = &target_core_fabrics;
struct t10_alua_lu_gp *lu_gp; struct t10_alua_lu_gp *lu_gp;
int ret; int ret;
...@@ -2878,7 +2880,6 @@ static int __init target_core_init_configfs(void) ...@@ -2878,7 +2880,6 @@ static int __init target_core_init_configfs(void)
" Engine: %s on %s/%s on "UTS_RELEASE"\n", " Engine: %s on %s/%s on "UTS_RELEASE"\n",
TARGET_CORE_VERSION, utsname()->sysname, utsname()->machine); TARGET_CORE_VERSION, utsname()->sysname, utsname()->machine);
subsys = target_core_subsystem[0];
config_group_init(&subsys->su_group); config_group_init(&subsys->su_group);
mutex_init(&subsys->su_mutex); mutex_init(&subsys->su_mutex);
...@@ -3008,13 +3009,10 @@ static int __init target_core_init_configfs(void) ...@@ -3008,13 +3009,10 @@ static int __init target_core_init_configfs(void)
static void __exit target_core_exit_configfs(void) static void __exit target_core_exit_configfs(void)
{ {
struct configfs_subsystem *subsys;
struct config_group *hba_cg, *alua_cg, *lu_gp_cg; struct config_group *hba_cg, *alua_cg, *lu_gp_cg;
struct config_item *item; struct config_item *item;
int i; int i;
subsys = target_core_subsystem[0];
lu_gp_cg = &alua_lu_gps_group; lu_gp_cg = &alua_lu_gps_group;
for (i = 0; lu_gp_cg->default_groups[i]; i++) { for (i = 0; lu_gp_cg->default_groups[i]; i++) {
item = &lu_gp_cg->default_groups[i]->cg_item; item = &lu_gp_cg->default_groups[i]->cg_item;
...@@ -3045,8 +3043,8 @@ static void __exit target_core_exit_configfs(void) ...@@ -3045,8 +3043,8 @@ static void __exit target_core_exit_configfs(void)
* We expect subsys->su_group.default_groups to be released * We expect subsys->su_group.default_groups to be released
* by configfs subsystem provider logic.. * by configfs subsystem provider logic..
*/ */
configfs_unregister_subsystem(subsys); configfs_unregister_subsystem(&target_core_fabrics);
kfree(subsys->su_group.default_groups); kfree(target_core_fabrics.su_group.default_groups);
core_alua_free_lu_gp(default_lu_gp); core_alua_free_lu_gp(default_lu_gp);
default_lu_gp = NULL; default_lu_gp = NULL;
......
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
/* target_core_alua.c */ /* target_core_alua.c */
extern struct t10_alua_lu_gp *default_lu_gp; extern struct t10_alua_lu_gp *default_lu_gp;
/* target_core_configfs.c */
extern struct configfs_subsystem *target_core_subsystem[];
/* target_core_device.c */ /* target_core_device.c */
extern struct mutex g_device_mutex; extern struct mutex g_device_mutex;
extern struct list_head g_device_list; extern struct list_head g_device_list;
......
...@@ -1367,41 +1367,26 @@ void core_scsi3_free_all_registrations( ...@@ -1367,41 +1367,26 @@ void core_scsi3_free_all_registrations(
static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg) static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg)
{ {
return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, return target_depend_item(&tpg->tpg_group.cg_item);
&tpg->tpg_group.cg_item);
} }
static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg) static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg)
{ {
configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, target_undepend_item(&tpg->tpg_group.cg_item);
&tpg->tpg_group.cg_item);
atomic_dec_mb(&tpg->tpg_pr_ref_count); atomic_dec_mb(&tpg->tpg_pr_ref_count);
} }
static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl) static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl)
{ {
struct se_portal_group *tpg = nacl->se_tpg;
if (nacl->dynamic_node_acl) if (nacl->dynamic_node_acl)
return 0; return 0;
return target_depend_item(&nacl->acl_group.cg_item);
return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys,
&nacl->acl_group.cg_item);
} }
static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl) static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl)
{ {
struct se_portal_group *tpg = nacl->se_tpg; if (!nacl->dynamic_node_acl)
target_undepend_item(&nacl->acl_group.cg_item);
if (nacl->dynamic_node_acl) {
atomic_dec_mb(&nacl->acl_pr_ref_count);
return;
}
configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys,
&nacl->acl_group.cg_item);
atomic_dec_mb(&nacl->acl_pr_ref_count); atomic_dec_mb(&nacl->acl_pr_ref_count);
} }
...@@ -1419,8 +1404,7 @@ static int core_scsi3_lunacl_depend_item(struct se_dev_entry *se_deve) ...@@ -1419,8 +1404,7 @@ static int core_scsi3_lunacl_depend_item(struct se_dev_entry *se_deve)
nacl = lun_acl->se_lun_nacl; nacl = lun_acl->se_lun_nacl;
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, return target_depend_item(&lun_acl->se_lun_group.cg_item);
&lun_acl->se_lun_group.cg_item);
} }
static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve) static 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,9 +1422,7 @@ static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve)
nacl = lun_acl->se_lun_nacl; nacl = lun_acl->se_lun_nacl;
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, target_undepend_item(&lun_acl->se_lun_group.cg_item);
&lun_acl->se_lun_group.cg_item);
atomic_dec_mb(&se_deve->pr_ref_count); atomic_dec_mb(&se_deve->pr_ref_count);
} }
......
...@@ -58,7 +58,6 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op ...@@ -58,7 +58,6 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
bool src) bool src)
{ {
struct se_device *se_dev; struct se_device *se_dev;
struct configfs_subsystem *subsys = target_core_subsystem[0];
unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN], *dev_wwn; unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN], *dev_wwn;
int rc; int rc;
...@@ -90,8 +89,7 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op ...@@ -90,8 +89,7 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
" se_dev\n", xop->src_dev); " se_dev\n", xop->src_dev);
} }
rc = configfs_depend_item(subsys, rc = target_depend_item(&se_dev->dev_group.cg_item);
&se_dev->dev_group.cg_item);
if (rc != 0) { if (rc != 0) {
pr_err("configfs_depend_item attempt failed:" pr_err("configfs_depend_item attempt failed:"
" %d for se_dev: %p\n", rc, se_dev); " %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,8 +97,8 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
return rc; return rc;
} }
pr_debug("Called configfs_depend_item for subsys: %p se_dev: %p" pr_debug("Called configfs_depend_item for se_dev: %p"
" se_dev->se_dev_group: %p\n", subsys, se_dev, " se_dev->se_dev_group: %p\n", se_dev,
&se_dev->dev_group); &se_dev->dev_group);
mutex_unlock(&g_device_mutex); mutex_unlock(&g_device_mutex);
...@@ -373,7 +371,6 @@ static int xcopy_pt_get_cmd_state(struct se_cmd *se_cmd) ...@@ -373,7 +371,6 @@ static int xcopy_pt_get_cmd_state(struct se_cmd *se_cmd)
static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop) static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop)
{ {
struct configfs_subsystem *subsys = target_core_subsystem[0];
struct se_device *remote_dev; struct se_device *remote_dev;
if (xop->op_origin == XCOL_SOURCE_RECV_OP) if (xop->op_origin == XCOL_SOURCE_RECV_OP)
...@@ -381,11 +378,11 @@ static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop) ...@@ -381,11 +378,11 @@ static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop)
else else
remote_dev = xop->src_dev; remote_dev = xop->src_dev;
pr_debug("Calling configfs_undepend_item for subsys: %p" pr_debug("Calling configfs_undepend_item for"
" remote_dev: %p remote_dev->dev_group: %p\n", " remote_dev: %p remote_dev->dev_group: %p\n",
subsys, remote_dev, &remote_dev->dev_group.cg_item); remote_dev, &remote_dev->dev_group.cg_item);
configfs_undepend_item(subsys, &remote_dev->dev_group.cg_item); target_undepend_item(&remote_dev->dev_group.cg_item);
} }
static void xcopy_pt_release_cmd(struct se_cmd *se_cmd) static void xcopy_pt_release_cmd(struct se_cmd *se_cmd)
......
...@@ -1409,8 +1409,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, ...@@ -1409,8 +1409,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
* dependency now. * dependency now.
*/ */
se_tpg = &tpg->se_tpg; se_tpg = &tpg->se_tpg;
ret = configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys, ret = target_depend_item(&se_tpg->tpg_group.cg_item);
&se_tpg->tpg_group.cg_item);
if (ret) { if (ret) {
pr_warn("configfs_depend_item() failed: %d\n", ret); pr_warn("configfs_depend_item() failed: %d\n", ret);
kfree(vs_tpg); kfree(vs_tpg);
...@@ -1513,8 +1512,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs, ...@@ -1513,8 +1512,7 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
* to allow vhost-scsi WWPN se_tpg->tpg_group shutdown to occur. * to allow vhost-scsi WWPN se_tpg->tpg_group shutdown to occur.
*/ */
se_tpg = &tpg->se_tpg; se_tpg = &tpg->se_tpg;
configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys, target_undepend_item(&se_tpg->tpg_group.cg_item);
&se_tpg->tpg_group.cg_item);
} }
if (match) { if (match) {
for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) { for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
......
...@@ -40,8 +40,6 @@ struct target_fabric_configfs { ...@@ -40,8 +40,6 @@ struct target_fabric_configfs {
struct config_item *tf_fabric; struct config_item *tf_fabric;
/* Passed from fabric modules */ /* Passed from fabric modules */
struct config_item_type *tf_fabric_cit; struct config_item_type *tf_fabric_cit;
/* Pointer to target core subsystem */
struct configfs_subsystem *tf_subsys;
/* Pointer to fabric's struct module */ /* Pointer to fabric's struct module */
struct module *tf_module; struct module *tf_module;
struct target_core_fabric_ops tf_ops; struct target_core_fabric_ops tf_ops;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
struct target_core_fabric_ops { struct target_core_fabric_ops {
struct module *module; struct module *module;
const char *name; const char *name;
struct configfs_subsystem *tf_subsys;
char *(*get_fabric_name)(void); char *(*get_fabric_name)(void);
u8 (*get_fabric_proto_ident)(struct se_portal_group *); u8 (*get_fabric_proto_ident)(struct se_portal_group *);
char *(*tpg_get_wwn)(struct se_portal_group *); char *(*tpg_get_wwn)(struct se_portal_group *);
...@@ -109,6 +108,9 @@ struct target_core_fabric_ops { ...@@ -109,6 +108,9 @@ struct target_core_fabric_ops {
int target_register_template(const struct target_core_fabric_ops *fo); int target_register_template(const struct target_core_fabric_ops *fo);
void target_unregister_template(const struct target_core_fabric_ops *fo); void target_unregister_template(const struct target_core_fabric_ops *fo);
int target_depend_item(struct config_item *item);
void target_undepend_item(struct config_item *item);
struct se_session *transport_init_session(enum target_prot_op); struct se_session *transport_init_session(enum target_prot_op);
int transport_alloc_session_tags(struct se_session *, unsigned int, int transport_alloc_session_tags(struct se_session *, unsigned int,
unsigned int); unsigned int);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment