lun->lun_tpg should always be set.

Signed-off-by: Andy Grover <agro...@redhat.com>
---
 drivers/target/target_core_device.c   |   17 +++++++----------
 drivers/target/target_core_internal.h |    6 ++----
 drivers/target/target_core_tpg.c      |    4 ++--
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 753e7ca..a432d7b 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -583,7 +583,6 @@ static void core_release_port(struct se_device *dev, struct 
se_port *port)
 
 int core_dev_export(
        struct se_device *dev,
-       struct se_portal_group *tpg,
        struct se_lun *lun)
 {
        struct se_hba *hba = dev->se_hba;
@@ -599,17 +598,13 @@ int core_dev_export(
        dev->export_count++;
        spin_unlock(&hba->device_lock);
 
-       core_export_port(dev, tpg, port, lun);
+       core_export_port(dev, lun->lun_tpg, port, lun);
        return 0;
 }
 
-void core_dev_unexport(
-       struct se_device *dev,
-       struct se_portal_group *tpg,
-       struct se_lun *lun)
+void core_dev_unexport(struct se_lun *lun)
 {
-       struct se_hba *hba = dev->se_hba;
-       struct se_port *port = lun->lun_sep;
+       struct se_hba *hba;
 
        spin_lock(&lun->lun_sep_lock);
        if (lun->lun_se_dev == NULL) {
@@ -618,10 +613,12 @@ void core_dev_unexport(
        }
        spin_unlock(&lun->lun_sep_lock);
 
-       core_release_port(dev, port);
+       core_release_port(lun->lun_se_dev, lun->lun_sep);
+
+       hba = lun->lun_se_dev->se_hba;
 
        spin_lock(&hba->device_lock);
-       dev->export_count--;
+       lun->lun_se_dev->export_count--;
        spin_unlock(&hba->device_lock);
 
        lun->lun_se_dev = NULL;
diff --git a/drivers/target/target_core_internal.h 
b/drivers/target/target_core_internal.h
index 4d3b559..5b232a7 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -16,10 +16,8 @@ int  core_enable_device_list_for_node(struct se_lun *, 
struct se_lun_acl *,
 void   core_disable_device_list_for_node(struct se_lun *, struct se_dev_entry 
*,
                u32, struct se_node_acl *, struct se_portal_group *);
 void   core_clear_lun_from_tpg(struct se_lun *, struct se_portal_group *);
-int    core_dev_export(struct se_device *, struct se_portal_group *,
-               struct se_lun *);
-void   core_dev_unexport(struct se_device *, struct se_portal_group *,
-               struct se_lun *);
+int    core_dev_export(struct se_device *, struct se_lun *);
+void   core_dev_unexport(struct se_lun *);
 int    se_dev_set_task_timeout(struct se_device *, u32);
 int    se_dev_set_max_unmap_lba_count(struct se_device *, u32);
 int    se_dev_set_max_unmap_block_desc_count(struct se_device *, u32);
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index c63f6cd..d9fbdd0 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -765,7 +765,7 @@ int core_tpg_add_lun(
 {
        int ret;
 
-       ret = core_dev_export(dev, tpg, lun);
+       ret = core_dev_export(dev, lun);
        if (ret < 0)
                return ret;
 
@@ -803,6 +803,6 @@ void core_tpg_remove_lun(
        struct se_lun *lun)
 {
        core_clear_lun_from_tpg(lun, tpg);
-       core_dev_unexport(lun->lun_se_dev, tpg, lun);
+       core_dev_unexport(lun);
        put_lun(lun);
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to