diff options
Diffstat (limited to 'drivers/target/target_core_tpg.c')
| -rw-r--r-- | drivers/target/target_core_tpg.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index b9a6ec0aa5fe..f697f8baec54 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( | |||
| 116 | 116 | ||
| 117 | return acl; | 117 | return acl; |
| 118 | } | 118 | } |
| 119 | EXPORT_SYMBOL(core_tpg_get_initiator_node_acl); | ||
| 119 | 120 | ||
| 120 | /* core_tpg_add_node_to_devs(): | 121 | /* core_tpg_add_node_to_devs(): |
| 121 | * | 122 | * |
| @@ -633,6 +634,13 @@ int core_tpg_set_initiator_node_tag( | |||
| 633 | } | 634 | } |
| 634 | EXPORT_SYMBOL(core_tpg_set_initiator_node_tag); | 635 | EXPORT_SYMBOL(core_tpg_set_initiator_node_tag); |
| 635 | 636 | ||
| 637 | static void core_tpg_lun_ref_release(struct percpu_ref *ref) | ||
| 638 | { | ||
| 639 | struct se_lun *lun = container_of(ref, struct se_lun, lun_ref); | ||
| 640 | |||
| 641 | complete(&lun->lun_ref_comp); | ||
| 642 | } | ||
| 643 | |||
| 636 | static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) | 644 | static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) |
| 637 | { | 645 | { |
| 638 | /* Set in core_dev_setup_virtual_lun0() */ | 646 | /* Set in core_dev_setup_virtual_lun0() */ |
| @@ -646,15 +654,20 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) | |||
| 646 | atomic_set(&lun->lun_acl_count, 0); | 654 | atomic_set(&lun->lun_acl_count, 0); |
| 647 | init_completion(&lun->lun_shutdown_comp); | 655 | init_completion(&lun->lun_shutdown_comp); |
| 648 | INIT_LIST_HEAD(&lun->lun_acl_list); | 656 | INIT_LIST_HEAD(&lun->lun_acl_list); |
| 649 | INIT_LIST_HEAD(&lun->lun_cmd_list); | ||
| 650 | spin_lock_init(&lun->lun_acl_lock); | 657 | spin_lock_init(&lun->lun_acl_lock); |
| 651 | spin_lock_init(&lun->lun_cmd_lock); | ||
| 652 | spin_lock_init(&lun->lun_sep_lock); | 658 | spin_lock_init(&lun->lun_sep_lock); |
| 659 | init_completion(&lun->lun_ref_comp); | ||
| 653 | 660 | ||
| 654 | ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); | 661 | ret = percpu_ref_init(&lun->lun_ref, core_tpg_lun_ref_release); |
| 655 | if (ret < 0) | 662 | if (ret < 0) |
| 656 | return ret; | 663 | return ret; |
| 657 | 664 | ||
| 665 | ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); | ||
| 666 | if (ret < 0) { | ||
| 667 | percpu_ref_cancel_init(&lun->lun_ref); | ||
| 668 | return ret; | ||
| 669 | } | ||
| 670 | |||
| 658 | return 0; | 671 | return 0; |
| 659 | } | 672 | } |
| 660 | 673 | ||
| @@ -691,10 +704,9 @@ int core_tpg_register( | |||
| 691 | atomic_set(&lun->lun_acl_count, 0); | 704 | atomic_set(&lun->lun_acl_count, 0); |
| 692 | init_completion(&lun->lun_shutdown_comp); | 705 | init_completion(&lun->lun_shutdown_comp); |
| 693 | INIT_LIST_HEAD(&lun->lun_acl_list); | 706 | INIT_LIST_HEAD(&lun->lun_acl_list); |
| 694 | INIT_LIST_HEAD(&lun->lun_cmd_list); | ||
| 695 | spin_lock_init(&lun->lun_acl_lock); | 707 | spin_lock_init(&lun->lun_acl_lock); |
| 696 | spin_lock_init(&lun->lun_cmd_lock); | ||
| 697 | spin_lock_init(&lun->lun_sep_lock); | 708 | spin_lock_init(&lun->lun_sep_lock); |
| 709 | init_completion(&lun->lun_ref_comp); | ||
| 698 | } | 710 | } |
| 699 | 711 | ||
| 700 | se_tpg->se_tpg_type = se_tpg_type; | 712 | se_tpg->se_tpg_type = se_tpg_type; |
| @@ -815,10 +827,16 @@ int core_tpg_post_addlun( | |||
| 815 | { | 827 | { |
| 816 | int ret; | 828 | int ret; |
| 817 | 829 | ||
| 818 | ret = core_dev_export(lun_ptr, tpg, lun); | 830 | ret = percpu_ref_init(&lun->lun_ref, core_tpg_lun_ref_release); |
| 819 | if (ret < 0) | 831 | if (ret < 0) |
| 820 | return ret; | 832 | return ret; |
| 821 | 833 | ||
| 834 | ret = core_dev_export(lun_ptr, tpg, lun); | ||
| 835 | if (ret < 0) { | ||
| 836 | percpu_ref_cancel_init(&lun->lun_ref); | ||
| 837 | return ret; | ||
| 838 | } | ||
| 839 | |||
| 822 | spin_lock(&tpg->tpg_lun_lock); | 840 | spin_lock(&tpg->tpg_lun_lock); |
| 823 | lun->lun_access = lun_access; | 841 | lun->lun_access = lun_access; |
| 824 | lun->lun_status = TRANSPORT_LUN_STATUS_ACTIVE; | 842 | lun->lun_status = TRANSPORT_LUN_STATUS_ACTIVE; |
| @@ -827,14 +845,6 @@ int core_tpg_post_addlun( | |||
| 827 | return 0; | 845 | return 0; |
| 828 | } | 846 | } |
| 829 | 847 | ||
| 830 | static void core_tpg_shutdown_lun( | ||
| 831 | struct se_portal_group *tpg, | ||
| 832 | struct se_lun *lun) | ||
| 833 | { | ||
| 834 | core_clear_lun_from_tpg(lun, tpg); | ||
| 835 | transport_clear_lun_from_sessions(lun); | ||
| 836 | } | ||
| 837 | |||
| 838 | struct se_lun *core_tpg_pre_dellun( | 848 | struct se_lun *core_tpg_pre_dellun( |
| 839 | struct se_portal_group *tpg, | 849 | struct se_portal_group *tpg, |
| 840 | u32 unpacked_lun) | 850 | u32 unpacked_lun) |
| @@ -869,7 +879,8 @@ int core_tpg_post_dellun( | |||
| 869 | struct se_portal_group *tpg, | 879 | struct se_portal_group *tpg, |
| 870 | struct se_lun *lun) | 880 | struct se_lun *lun) |
| 871 | { | 881 | { |
| 872 | core_tpg_shutdown_lun(tpg, lun); | 882 | core_clear_lun_from_tpg(lun, tpg); |
| 883 | transport_clear_lun_ref(lun); | ||
| 873 | 884 | ||
| 874 | core_dev_unexport(lun->lun_se_dev, tpg, lun); | 885 | core_dev_unexport(lun->lun_se_dev, tpg, lun); |
| 875 | 886 | ||
