target: Change core_dev_del_lun to take a se_lun instead of unpacked_lun
authorAndy Grover <agrover@redhat.com>
Mon, 30 Jun 2014 23:39:44 +0000 (16:39 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 1 Oct 2014 21:38:48 +0000 (14:38 -0700)
Remove core_tpg_pre_dellun entirely, since we don't need to get/check
a pointer we already have.

Nothing else can return an error, so core_dev_del_lun can return void.

Rename core_tpg_post_dellun to remove_lun - a clearer name, now that
pre_dellun is gone.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_device.c
drivers/target/target_core_fabric_configfs.c
drivers/target/target_core_internal.h
drivers/target/target_core_tpg.c

index 98da90167159b198dfc65a8ebdc912b350e4c6f0..e784284cbc2e79575ff04a9b069ab8b1f400b951 100644 (file)
@@ -1250,24 +1250,16 @@ struct se_lun *core_dev_add_lun(
  *
  *
  */
-int core_dev_del_lun(
+void core_dev_del_lun(
        struct se_portal_group *tpg,
-       u32 unpacked_lun)
+       struct se_lun *lun)
 {
-       struct se_lun *lun;
-
-       lun = core_tpg_pre_dellun(tpg, unpacked_lun);
-       if (IS_ERR(lun))
-               return PTR_ERR(lun);
-
-       core_tpg_post_dellun(tpg, lun);
-
-       pr_debug("%s_TPG[%u]_LUN[%u] - Deactivated %s Logical Unit from"
+       pr_debug("%s_TPG[%u]_LUN[%u] - Deactivating %s Logical Unit from"
                " device object\n", tpg->se_tpg_tfo->get_fabric_name(),
-               tpg->se_tpg_tfo->tpg_get_tag(tpg), unpacked_lun,
+               tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
                tpg->se_tpg_tfo->get_fabric_name());
 
-       return 0;
+       core_tpg_remove_lun(tpg, lun);
 }
 
 struct se_lun *core_get_lun_from_tpg(struct se_portal_group *tpg, u32 unpacked_lun)
index dc6c781732ee6e375fcacccedacf39725f268c71..0c3f90130b7d398c8670509834d3fe3a59f0de98 100644 (file)
@@ -822,7 +822,7 @@ static int target_fabric_port_unlink(
                tf->tf_ops.fabric_pre_unlink(se_tpg, lun);
        }
 
-       core_dev_del_lun(se_tpg, lun->unpacked_lun);
+       core_dev_del_lun(se_tpg, lun);
        return 0;
 }
 
index 463fddcd0ef683d0f5865f478f2e9ba17e87b5d6..42ef4ab7058569813b9fb4e2c91712014c08ba07 100644 (file)
@@ -46,7 +46,7 @@ int   se_dev_set_fabric_max_sectors(struct se_device *, u32);
 int    se_dev_set_optimal_sectors(struct se_device *, u32);
 int    se_dev_set_block_size(struct se_device *, u32);
 struct se_lun *core_dev_add_lun(struct se_portal_group *, struct se_device *, u32);
-int    core_dev_del_lun(struct se_portal_group *, u32);
+void   core_dev_del_lun(struct se_portal_group *, struct se_lun *);
 struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32);
 struct se_lun_acl *core_dev_init_initiator_node_lun_acl(struct se_portal_group *,
                struct se_node_acl *, u32, int *);
@@ -82,8 +82,7 @@ void  core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *);
 struct se_lun *core_tpg_alloc_lun(struct se_portal_group *, u32);
 int    core_tpg_add_lun(struct se_portal_group *, struct se_lun *,
                u32, struct se_device *);
-struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32 unpacked_lun);
-void core_tpg_post_dellun(struct se_portal_group *, struct se_lun *);
+void core_tpg_remove_lun(struct se_portal_group *, struct se_lun *);
 
 /* target_core_transport.c */
 extern struct kmem_cache *se_tmr_req_cache;
index b596ab509197b9cd6f3f6fd410fd9cf8647da387..259604188a9067eeb9a1f734ada8e39fd039e046 100644 (file)
@@ -335,7 +335,7 @@ void core_tpg_clear_object_luns(struct se_portal_group *tpg)
                        continue;
 
                spin_unlock(&tpg->tpg_lun_lock);
-               core_dev_del_lun(tpg, lun->unpacked_lun);
+               core_dev_del_lun(tpg, lun);
                spin_lock(&tpg->tpg_lun_lock);
        }
        spin_unlock(&tpg->tpg_lun_lock);
@@ -667,7 +667,7 @@ static void core_tpg_release_virtual_lun0(struct se_portal_group *se_tpg)
 {
        struct se_lun *lun = &se_tpg->tpg_virt_lun0;
 
-       core_tpg_post_dellun(se_tpg, lun);
+       core_tpg_remove_lun(se_tpg, lun);
 }
 
 int core_tpg_register(
@@ -837,37 +837,7 @@ int core_tpg_add_lun(
        return 0;
 }
 
-struct se_lun *core_tpg_pre_dellun(
-       struct se_portal_group *tpg,
-       u32 unpacked_lun)
-{
-       struct se_lun *lun;
-
-       if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) {
-               pr_err("%s LUN: %u exceeds TRANSPORT_MAX_LUNS_PER_TPG"
-                       "-1: %u for Target Portal Group: %u\n",
-                       tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
-                       TRANSPORT_MAX_LUNS_PER_TPG-1,
-                       tpg->se_tpg_tfo->tpg_get_tag(tpg));
-               return ERR_PTR(-EOVERFLOW);
-       }
-
-       spin_lock(&tpg->tpg_lun_lock);
-       lun = tpg->tpg_lun_list[unpacked_lun];
-       if (lun->lun_status != TRANSPORT_LUN_STATUS_ACTIVE) {
-               pr_err("%s Logical Unit Number: %u is not active on"
-                       " Target Portal Group: %u, ignoring request.\n",
-                       tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
-                       tpg->se_tpg_tfo->tpg_get_tag(tpg));
-               spin_unlock(&tpg->tpg_lun_lock);
-               return ERR_PTR(-ENODEV);
-       }
-       spin_unlock(&tpg->tpg_lun_lock);
-
-       return lun;
-}
-
-void core_tpg_post_dellun(
+void core_tpg_remove_lun(
        struct se_portal_group *tpg,
        struct se_lun *lun)
 {