Commit c17cd249 authored by Nicholas Bellinger's avatar Nicholas Bellinger

target/configfs: Kill se_device->dev_link_magic

Instead of using a hardcoded magic value in se_device when verifying
a target config_item symlink source during target_fabric_port_link(),
go ahead and use target_core_dev_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 2237498f
...@@ -2236,7 +2236,11 @@ static void target_core_dev_release(struct config_item *item) ...@@ -2236,7 +2236,11 @@ static void target_core_dev_release(struct config_item *item)
target_free_device(dev); target_free_device(dev);
} }
static struct configfs_item_operations target_core_dev_item_ops = { /*
* Used in target_core_fabric_configfs.c to verify valid se_device symlink
* within target_fabric_port_link()
*/
struct configfs_item_operations target_core_dev_item_ops = {
.release = target_core_dev_release, .release = target_core_dev_release,
}; };
......
...@@ -756,7 +756,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) ...@@ -756,7 +756,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
if (!dev) if (!dev)
return NULL; return NULL;
dev->dev_link_magic = SE_DEV_LINK_MAGIC;
dev->se_hba = hba; dev->se_hba = hba;
dev->transport = hba->backend->ops; dev->transport = hba->backend->ops;
dev->prot_length = sizeof(struct t10_pi_tuple); dev->prot_length = sizeof(struct t10_pi_tuple);
......
...@@ -620,6 +620,8 @@ static struct configfs_attribute *target_fabric_port_attrs[] = { ...@@ -620,6 +620,8 @@ static struct configfs_attribute *target_fabric_port_attrs[] = {
NULL, NULL,
}; };
extern struct configfs_item_operations target_core_dev_item_ops;
static int target_fabric_port_link( static int target_fabric_port_link(
struct config_item *lun_ci, struct config_item *lun_ci,
struct config_item *se_dev_ci) struct config_item *se_dev_ci)
...@@ -628,16 +630,16 @@ static int target_fabric_port_link( ...@@ -628,16 +630,16 @@ static int target_fabric_port_link(
struct se_lun *lun = container_of(to_config_group(lun_ci), struct se_lun *lun = container_of(to_config_group(lun_ci),
struct se_lun, lun_group); struct se_lun, lun_group);
struct se_portal_group *se_tpg; struct se_portal_group *se_tpg;
struct se_device *dev = struct se_device *dev;
container_of(to_config_group(se_dev_ci), struct se_device, dev_group);
struct target_fabric_configfs *tf; struct target_fabric_configfs *tf;
int ret; int ret;
if (dev->dev_link_magic != SE_DEV_LINK_MAGIC) { if (!se_dev_ci->ci_type ||
pr_err("Bad dev->dev_link_magic, not a valid se_dev_ci pointer:" se_dev_ci->ci_type->ct_item_ops != &target_core_dev_item_ops) {
" %p to struct se_device: %p\n", se_dev_ci, dev); pr_err("Bad se_dev_ci, not a valid se_dev_ci pointer: %p\n", se_dev_ci);
return -EFAULT; return -EFAULT;
} }
dev = container_of(to_config_group(se_dev_ci), struct se_device, dev_group);
if (!(dev->dev_flags & DF_CONFIGURED)) { if (!(dev->dev_flags & DF_CONFIGURED)) {
pr_err("se_device not configured yet, cannot port link\n"); pr_err("se_device not configured yet, cannot port link\n");
......
...@@ -746,8 +746,6 @@ struct se_dev_stat_grps { ...@@ -746,8 +746,6 @@ struct se_dev_stat_grps {
}; };
struct se_device { struct se_device {
#define SE_DEV_LINK_MAGIC 0xfeeddeef
u32 dev_link_magic;
/* RELATIVE TARGET PORT IDENTIFER Counter */ /* RELATIVE TARGET PORT IDENTIFER Counter */
u16 dev_rpti_counter; u16 dev_rpti_counter;
/* Used for SAM Task Attribute ordering */ /* Used for SAM Task Attribute ordering */
......
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