diff options
author | Christoph Hellwig <hch@lst.de> | 2016-01-09 08:30:45 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2016-03-11 00:44:28 -0500 |
commit | fb444abe61f5a943a41870d71eab8c4402bd46ab (patch) | |
tree | fed0a4e17519cb91a6b85b8de1857891202a1c50 /drivers/target/loopback/tcm_loop.c | |
parent | 7861728d42338e1efac9d400c39319c1b5efd05c (diff) |
target: Convert demo-mode only drivers to target_alloc_session
This patch converts existing loopback, usb-gadget, and
xen-scsiback demo-mode only fabric drivers to use the
new target_alloc_session API caller.
This includes adding a new alloc_session callback for
fabric driver internal nexus pointer assignments.
(Fixes for early for-next nexus breakage - Dan Carpenter)
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Acked-by: Juergen Gross <jgross@suse.com>
Tested-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Tested-by: Chris Boot <bootc@bootc.net>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/loopback/tcm_loop.c')
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index d41a5c300e31..0ad5ac541a7f 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -802,58 +802,48 @@ static struct configfs_attribute *tcm_loop_tpg_attrib_attrs[] = { | |||
802 | 802 | ||
803 | /* Start items for tcm_loop_nexus_cit */ | 803 | /* Start items for tcm_loop_nexus_cit */ |
804 | 804 | ||
805 | static int tcm_loop_alloc_sess_cb(struct se_portal_group *se_tpg, | ||
806 | struct se_session *se_sess, void *p) | ||
807 | { | ||
808 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, | ||
809 | struct tcm_loop_tpg, tl_se_tpg); | ||
810 | |||
811 | tl_tpg->tl_nexus = p; | ||
812 | return 0; | ||
813 | } | ||
814 | |||
805 | static int tcm_loop_make_nexus( | 815 | static int tcm_loop_make_nexus( |
806 | struct tcm_loop_tpg *tl_tpg, | 816 | struct tcm_loop_tpg *tl_tpg, |
807 | const char *name) | 817 | const char *name) |
808 | { | 818 | { |
809 | struct se_portal_group *se_tpg; | ||
810 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | 819 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
811 | struct tcm_loop_nexus *tl_nexus; | 820 | struct tcm_loop_nexus *tl_nexus; |
812 | int ret = -ENOMEM; | 821 | int ret; |
813 | 822 | ||
814 | if (tl_tpg->tl_nexus) { | 823 | if (tl_tpg->tl_nexus) { |
815 | pr_debug("tl_tpg->tl_nexus already exists\n"); | 824 | pr_debug("tl_tpg->tl_nexus already exists\n"); |
816 | return -EEXIST; | 825 | return -EEXIST; |
817 | } | 826 | } |
818 | se_tpg = &tl_tpg->tl_se_tpg; | ||
819 | 827 | ||
820 | tl_nexus = kzalloc(sizeof(struct tcm_loop_nexus), GFP_KERNEL); | 828 | tl_nexus = kzalloc(sizeof(struct tcm_loop_nexus), GFP_KERNEL); |
821 | if (!tl_nexus) { | 829 | if (!tl_nexus) { |
822 | pr_err("Unable to allocate struct tcm_loop_nexus\n"); | 830 | pr_err("Unable to allocate struct tcm_loop_nexus\n"); |
823 | return -ENOMEM; | 831 | return -ENOMEM; |
824 | } | 832 | } |
825 | /* | 833 | |
826 | * Initialize the struct se_session pointer | 834 | tl_nexus->se_sess = target_alloc_session(&tl_tpg->tl_se_tpg, 0, 0, |
827 | */ | 835 | TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS, |
828 | tl_nexus->se_sess = transport_init_session( | 836 | name, tl_nexus, tcm_loop_alloc_sess_cb); |
829 | TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS); | ||
830 | if (IS_ERR(tl_nexus->se_sess)) { | 837 | if (IS_ERR(tl_nexus->se_sess)) { |
831 | ret = PTR_ERR(tl_nexus->se_sess); | 838 | ret = PTR_ERR(tl_nexus->se_sess); |
832 | goto out; | 839 | kfree(tl_nexus); |
833 | } | 840 | return ret; |
834 | /* | ||
835 | * Since we are running in 'demo mode' this call with generate a | ||
836 | * struct se_node_acl for the tcm_loop struct se_portal_group with the SCSI | ||
837 | * Initiator port name of the passed configfs group 'name'. | ||
838 | */ | ||
839 | tl_nexus->se_sess->se_node_acl = core_tpg_check_initiator_node_acl( | ||
840 | se_tpg, (unsigned char *)name); | ||
841 | if (!tl_nexus->se_sess->se_node_acl) { | ||
842 | transport_free_session(tl_nexus->se_sess); | ||
843 | goto out; | ||
844 | } | 841 | } |
845 | /* Now, register the I_T Nexus as active. */ | 842 | |
846 | transport_register_session(se_tpg, tl_nexus->se_sess->se_node_acl, | ||
847 | tl_nexus->se_sess, tl_nexus); | ||
848 | tl_tpg->tl_nexus = tl_nexus; | ||
849 | pr_debug("TCM_Loop_ConfigFS: Established I_T Nexus to emulated" | 843 | pr_debug("TCM_Loop_ConfigFS: Established I_T Nexus to emulated" |
850 | " %s Initiator Port: %s\n", tcm_loop_dump_proto_id(tl_hba), | 844 | " %s Initiator Port: %s\n", tcm_loop_dump_proto_id(tl_hba), |
851 | name); | 845 | name); |
852 | return 0; | 846 | return 0; |
853 | |||
854 | out: | ||
855 | kfree(tl_nexus); | ||
856 | return ret; | ||
857 | } | 847 | } |
858 | 848 | ||
859 | static int tcm_loop_drop_nexus( | 849 | static int tcm_loop_drop_nexus( |