diff options
Diffstat (limited to 'drivers/target/target_core_tpg.c')
| -rw-r--r-- | drivers/target/target_core_tpg.c | 43 | 
1 files changed, 23 insertions, 20 deletions
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index b9a6ec0aa5f..c036595b17c 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -116,6 +116,7 @@ struct se_node_acl *core_tpg_get_initiator_node_acl(  	return acl;  } +EXPORT_SYMBOL(core_tpg_get_initiator_node_acl);  /*	core_tpg_add_node_to_devs():   * @@ -277,7 +278,6 @@ struct se_node_acl *core_tpg_check_initiator_node_acl(  	snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname);  	acl->se_tpg = tpg;  	acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); -	spin_lock_init(&acl->stats_lock);  	acl->dynamic_node_acl = 1;  	tpg->se_tpg_tfo->set_default_node_attributes(acl); @@ -405,7 +405,6 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(  	snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname);  	acl->se_tpg = tpg;  	acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); -	spin_lock_init(&acl->stats_lock);  	tpg->se_tpg_tfo->set_default_node_attributes(acl); @@ -633,6 +632,13 @@ int core_tpg_set_initiator_node_tag(  }  EXPORT_SYMBOL(core_tpg_set_initiator_node_tag); +static void core_tpg_lun_ref_release(struct percpu_ref *ref) +{ +	struct se_lun *lun = container_of(ref, struct se_lun, lun_ref); + +	complete(&lun->lun_ref_comp); +} +  static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)  {  	/* Set in core_dev_setup_virtual_lun0() */ @@ -646,12 +652,11 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)  	atomic_set(&lun->lun_acl_count, 0);  	init_completion(&lun->lun_shutdown_comp);  	INIT_LIST_HEAD(&lun->lun_acl_list); -	INIT_LIST_HEAD(&lun->lun_cmd_list);  	spin_lock_init(&lun->lun_acl_lock); -	spin_lock_init(&lun->lun_cmd_lock);  	spin_lock_init(&lun->lun_sep_lock); +	init_completion(&lun->lun_ref_comp); -	ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); +	ret = core_tpg_add_lun(se_tpg, lun, lun_access, dev);  	if (ret < 0)  		return ret; @@ -691,10 +696,9 @@ int core_tpg_register(  		atomic_set(&lun->lun_acl_count, 0);  		init_completion(&lun->lun_shutdown_comp);  		INIT_LIST_HEAD(&lun->lun_acl_list); -		INIT_LIST_HEAD(&lun->lun_cmd_list);  		spin_lock_init(&lun->lun_acl_lock); -		spin_lock_init(&lun->lun_cmd_lock);  		spin_lock_init(&lun->lun_sep_lock); +		init_completion(&lun->lun_ref_comp);  	}  	se_tpg->se_tpg_type = se_tpg_type; @@ -777,7 +781,7 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)  }  EXPORT_SYMBOL(core_tpg_deregister); -struct se_lun *core_tpg_pre_addlun( +struct se_lun *core_tpg_alloc_lun(  	struct se_portal_group *tpg,  	u32 unpacked_lun)  { @@ -807,18 +811,24 @@ struct se_lun *core_tpg_pre_addlun(  	return lun;  } -int core_tpg_post_addlun( +int core_tpg_add_lun(  	struct se_portal_group *tpg,  	struct se_lun *lun,  	u32 lun_access, -	void *lun_ptr) +	struct se_device *dev)  {  	int ret; -	ret = core_dev_export(lun_ptr, tpg, lun); +	ret = percpu_ref_init(&lun->lun_ref, core_tpg_lun_ref_release);  	if (ret < 0)  		return ret; +	ret = core_dev_export(dev, tpg, lun); +	if (ret < 0) { +		percpu_ref_cancel_init(&lun->lun_ref); +		return ret; +	} +  	spin_lock(&tpg->tpg_lun_lock);  	lun->lun_access = lun_access;  	lun->lun_status = TRANSPORT_LUN_STATUS_ACTIVE; @@ -827,14 +837,6 @@ int core_tpg_post_addlun(  	return 0;  } -static void core_tpg_shutdown_lun( -	struct se_portal_group *tpg, -	struct se_lun *lun) -{ -	core_clear_lun_from_tpg(lun, tpg); -	transport_clear_lun_from_sessions(lun); -} -  struct se_lun *core_tpg_pre_dellun(  	struct se_portal_group *tpg,  	u32 unpacked_lun) @@ -869,7 +871,8 @@ int core_tpg_post_dellun(  	struct se_portal_group *tpg,  	struct se_lun *lun)  { -	core_tpg_shutdown_lun(tpg, lun); +	core_clear_lun_from_tpg(lun, tpg); +	transport_clear_lun_ref(lun);  	core_dev_unexport(lun->lun_se_dev, tpg, lun);  | 
