Skip to content

Commit 9ae0e9a

Browse files
author
Nicholas Bellinger
committed
target/configfs: Kill se_lun->lun_link_magic
Instead of using a hardcoded magic value in se_lun when verifying a target config_item symlink source during target_fabric_mappedlun_link(), go ahead and use target_fabric_port_item_ops directly instead. Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Mike Christie <mchristi@redhat.com> Cc: Hannes Reinecke <hare@suse.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent c17cd24 commit 9ae0e9a

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎drivers/target/target_core_fabric_configfs.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,29 @@ static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf)
6565
pr_debug("Setup generic %s\n", __stringify(_name)); \
6666
}
6767

68+
static struct configfs_item_operations target_fabric_port_item_ops;
69+
6870
/* Start of tfc_tpg_mappedlun_cit */
6971

7072
static int target_fabric_mappedlun_link(
7173
struct config_item *lun_acl_ci,
7274
struct config_item *lun_ci)
7375
{
7476
struct se_dev_entry *deve;
75-
struct se_lun *lun = container_of(to_config_group(lun_ci),
76-
struct se_lun, lun_group);
77+
struct se_lun *lun;
7778
struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci),
7879
struct se_lun_acl, se_lun_group);
7980
struct se_portal_group *se_tpg;
8081
struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s;
8182
bool lun_access_ro;
8283

83-
if (lun->lun_link_magic != SE_LUN_LINK_MAGIC) {
84-
pr_err("Bad lun->lun_link_magic, not a valid lun_ci pointer:"
85-
" %p to struct lun: %p\n", lun_ci, lun);
84+
if (!lun_ci->ci_type ||
85+
lun_ci->ci_type->ct_item_ops != &target_fabric_port_item_ops) {
86+
pr_err("Bad lun_ci, not a valid lun_ci pointer: %p\n", lun_ci);
8687
return -EFAULT;
8788
}
89+
lun = container_of(to_config_group(lun_ci), struct se_lun, lun_group);
90+
8891
/*
8992
* Ensure that the source port exists
9093
*/

‎drivers/target/target_core_tpg.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ struct se_lun *core_tpg_alloc_lun(
576576
return ERR_PTR(-ENOMEM);
577577
}
578578
lun->unpacked_lun = unpacked_lun;
579-
lun->lun_link_magic = SE_LUN_LINK_MAGIC;
580579
atomic_set(&lun->lun_acl_count, 0);
581580
init_completion(&lun->lun_ref_comp);
582581
init_completion(&lun->lun_shutdown_comp);

‎include/target/target_core_base.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,6 @@ struct scsi_port_stats {
701701

702702
struct se_lun {
703703
u64 unpacked_lun;
704-
#define SE_LUN_LINK_MAGIC 0xffff7771
705-
u32 lun_link_magic;
706704
bool lun_shutdown;
707705
bool lun_access_ro;
708706
u32 lun_index;

0 commit comments

Comments
 (0)