Skip to content

Commit cd9d7cb

Browse files
Andy GroverNicholas Bellinger
authored andcommitted
target: Change core_dev_del_lun to take a se_lun instead of unpacked_lun
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>
1 parent cc83881 commit cd9d7cb

4 files changed

Lines changed: 11 additions & 50 deletions

File tree

‎drivers/target/target_core_device.c‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,24 +1250,16 @@ struct se_lun *core_dev_add_lun(
12501250
*
12511251
*
12521252
*/
1253-
int core_dev_del_lun(
1253+
void core_dev_del_lun(
12541254
struct se_portal_group *tpg,
1255-
u32 unpacked_lun)
1255+
struct se_lun *lun)
12561256
{
1257-
struct se_lun *lun;
1258-
1259-
lun = core_tpg_pre_dellun(tpg, unpacked_lun);
1260-
if (IS_ERR(lun))
1261-
return PTR_ERR(lun);
1262-
1263-
core_tpg_post_dellun(tpg, lun);
1264-
1265-
pr_debug("%s_TPG[%u]_LUN[%u] - Deactivated %s Logical Unit from"
1257+
pr_debug("%s_TPG[%u]_LUN[%u] - Deactivating %s Logical Unit from"
12661258
" device object\n", tpg->se_tpg_tfo->get_fabric_name(),
1267-
tpg->se_tpg_tfo->tpg_get_tag(tpg), unpacked_lun,
1259+
tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
12681260
tpg->se_tpg_tfo->get_fabric_name());
12691261

1270-
return 0;
1262+
core_tpg_remove_lun(tpg, lun);
12711263
}
12721264

12731265
struct se_lun *core_get_lun_from_tpg(struct se_portal_group *tpg, u32 unpacked_lun)

‎drivers/target/target_core_fabric_configfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ static int target_fabric_port_unlink(
822822
tf->tf_ops.fabric_pre_unlink(se_tpg, lun);
823823
}
824824

825-
core_dev_del_lun(se_tpg, lun->unpacked_lun);
825+
core_dev_del_lun(se_tpg, lun);
826826
return 0;
827827
}
828828

‎drivers/target/target_core_internal.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int se_dev_set_fabric_max_sectors(struct se_device *, u32);
4646
int se_dev_set_optimal_sectors(struct se_device *, u32);
4747
int se_dev_set_block_size(struct se_device *, u32);
4848
struct se_lun *core_dev_add_lun(struct se_portal_group *, struct se_device *, u32);
49-
int core_dev_del_lun(struct se_portal_group *, u32);
49+
void core_dev_del_lun(struct se_portal_group *, struct se_lun *);
5050
struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32);
5151
struct se_lun_acl *core_dev_init_initiator_node_lun_acl(struct se_portal_group *,
5252
struct se_node_acl *, u32, int *);
@@ -82,8 +82,7 @@ void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *);
8282
struct se_lun *core_tpg_alloc_lun(struct se_portal_group *, u32);
8383
int core_tpg_add_lun(struct se_portal_group *, struct se_lun *,
8484
u32, struct se_device *);
85-
struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32 unpacked_lun);
86-
void core_tpg_post_dellun(struct se_portal_group *, struct se_lun *);
85+
void core_tpg_remove_lun(struct se_portal_group *, struct se_lun *);
8786

8887
/* target_core_transport.c */
8988
extern struct kmem_cache *se_tmr_req_cache;

‎drivers/target/target_core_tpg.c‎

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void core_tpg_clear_object_luns(struct se_portal_group *tpg)
335335
continue;
336336

337337
spin_unlock(&tpg->tpg_lun_lock);
338-
core_dev_del_lun(tpg, lun->unpacked_lun);
338+
core_dev_del_lun(tpg, lun);
339339
spin_lock(&tpg->tpg_lun_lock);
340340
}
341341
spin_unlock(&tpg->tpg_lun_lock);
@@ -667,7 +667,7 @@ static void core_tpg_release_virtual_lun0(struct se_portal_group *se_tpg)
667667
{
668668
struct se_lun *lun = &se_tpg->tpg_virt_lun0;
669669

670-
core_tpg_post_dellun(se_tpg, lun);
670+
core_tpg_remove_lun(se_tpg, lun);
671671
}
672672

673673
int core_tpg_register(
@@ -837,37 +837,7 @@ int core_tpg_add_lun(
837837
return 0;
838838
}
839839

840-
struct se_lun *core_tpg_pre_dellun(
841-
struct se_portal_group *tpg,
842-
u32 unpacked_lun)
843-
{
844-
struct se_lun *lun;
845-
846-
if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) {
847-
pr_err("%s LUN: %u exceeds TRANSPORT_MAX_LUNS_PER_TPG"
848-
"-1: %u for Target Portal Group: %u\n",
849-
tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
850-
TRANSPORT_MAX_LUNS_PER_TPG-1,
851-
tpg->se_tpg_tfo->tpg_get_tag(tpg));
852-
return ERR_PTR(-EOVERFLOW);
853-
}
854-
855-
spin_lock(&tpg->tpg_lun_lock);
856-
lun = tpg->tpg_lun_list[unpacked_lun];
857-
if (lun->lun_status != TRANSPORT_LUN_STATUS_ACTIVE) {
858-
pr_err("%s Logical Unit Number: %u is not active on"
859-
" Target Portal Group: %u, ignoring request.\n",
860-
tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
861-
tpg->se_tpg_tfo->tpg_get_tag(tpg));
862-
spin_unlock(&tpg->tpg_lun_lock);
863-
return ERR_PTR(-ENODEV);
864-
}
865-
spin_unlock(&tpg->tpg_lun_lock);
866-
867-
return lun;
868-
}
869-
870-
void core_tpg_post_dellun(
840+
void core_tpg_remove_lun(
871841
struct se_portal_group *tpg,
872842
struct se_lun *lun)
873843
{

0 commit comments

Comments
 (0)