Commit 9ae0e9ad authored by Nicholas Bellinger's avatar Nicholas Bellinger

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: default avatarChristoph Hellwig <hch@lst.de>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent c17cd249
...@@ -65,6 +65,8 @@ static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) ...@@ -65,6 +65,8 @@ static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf)
pr_debug("Setup generic %s\n", __stringify(_name)); \ pr_debug("Setup generic %s\n", __stringify(_name)); \
} }
static struct configfs_item_operations target_fabric_port_item_ops;
/* Start of tfc_tpg_mappedlun_cit */ /* Start of tfc_tpg_mappedlun_cit */
static int target_fabric_mappedlun_link( static int target_fabric_mappedlun_link(
...@@ -72,19 +74,20 @@ static int target_fabric_mappedlun_link( ...@@ -72,19 +74,20 @@ static int target_fabric_mappedlun_link(
struct config_item *lun_ci) struct config_item *lun_ci)
{ {
struct se_dev_entry *deve; struct se_dev_entry *deve;
struct se_lun *lun = container_of(to_config_group(lun_ci), struct se_lun *lun;
struct se_lun, lun_group);
struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci),
struct se_lun_acl, se_lun_group); struct se_lun_acl, se_lun_group);
struct se_portal_group *se_tpg; struct se_portal_group *se_tpg;
struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s; struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s;
bool lun_access_ro; bool lun_access_ro;
if (lun->lun_link_magic != SE_LUN_LINK_MAGIC) { if (!lun_ci->ci_type ||
pr_err("Bad lun->lun_link_magic, not a valid lun_ci pointer:" lun_ci->ci_type->ct_item_ops != &target_fabric_port_item_ops) {
" %p to struct lun: %p\n", lun_ci, lun); pr_err("Bad lun_ci, not a valid lun_ci pointer: %p\n", lun_ci);
return -EFAULT; return -EFAULT;
} }
lun = container_of(to_config_group(lun_ci), struct se_lun, lun_group);
/* /*
* Ensure that the source port exists * Ensure that the source port exists
*/ */
......
...@@ -576,7 +576,6 @@ struct se_lun *core_tpg_alloc_lun( ...@@ -576,7 +576,6 @@ struct se_lun *core_tpg_alloc_lun(
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
lun->unpacked_lun = unpacked_lun; lun->unpacked_lun = unpacked_lun;
lun->lun_link_magic = SE_LUN_LINK_MAGIC;
atomic_set(&lun->lun_acl_count, 0); atomic_set(&lun->lun_acl_count, 0);
init_completion(&lun->lun_ref_comp); init_completion(&lun->lun_ref_comp);
init_completion(&lun->lun_shutdown_comp); init_completion(&lun->lun_shutdown_comp);
......
...@@ -701,8 +701,6 @@ struct scsi_port_stats { ...@@ -701,8 +701,6 @@ struct scsi_port_stats {
struct se_lun { struct se_lun {
u64 unpacked_lun; u64 unpacked_lun;
#define SE_LUN_LINK_MAGIC 0xffff7771
u32 lun_link_magic;
bool lun_shutdown; bool lun_shutdown;
bool lun_access_ro; bool lun_access_ro;
u32 lun_index; u32 lun_index;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment