Skip to content

Commit 59a206b

Browse files
ddissmartinkpetersen
authored andcommitted
scsi: target: replace fabric_ops.name with fabric_alias
iscsi_target_mod is the only LIO fabric where fabric_ops.name differs from the fabric_ops.fabric_name string. fabric_ops.name is used when matching target/$fabric ConfigFS create paths, so rename it .fabric_alias and fallback to target/$fabric vs .fabric_name comparison if .fabric_alias isn't initialised. iscsi_target_mod is the only fabric module to set .fabric_alias . All other fabric modules rely on .fabric_name matching and can drop the duplicate string. Signed-off-by: David Disseldorp <ddiss@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 30c7ca9 commit 59a206b

12 files changed

Lines changed: 28 additions & 26 deletions

File tree

‎drivers/infiniband/ulp/srpt/ib_srpt.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3673,7 +3673,6 @@ static struct configfs_attribute *srpt_wwn_attrs[] = {
36733673

36743674
static const struct target_core_fabric_ops srpt_template = {
36753675
.module = THIS_MODULE,
3676-
.name = "srpt",
36773676
.fabric_name = "srpt",
36783677
.tpg_get_wwn = srpt_get_fabric_wwn,
36793678
.tpg_get_tag = srpt_get_tag,

‎drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4039,7 +4039,6 @@ static struct configfs_attribute *ibmvscsis_tpg_attrs[] = {
40394039

40404040
static const struct target_core_fabric_ops ibmvscsis_ops = {
40414041
.module = THIS_MODULE,
4042-
.name = "ibmvscsis",
40434042
.fabric_name = "ibmvscsis",
40444043
.max_data_sg_nents = MAX_TXU / PAGE_SIZE,
40454044
.tpg_get_wwn = ibmvscsis_get_fabric_wwn,

‎drivers/scsi/qla2xxx/tcm_qla2xxx.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,6 @@ static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = {
19101910

19111911
static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
19121912
.module = THIS_MODULE,
1913-
.name = "qla2xxx",
19141913
.fabric_name = "qla2xxx",
19151914
.node_acl_size = sizeof(struct tcm_qla2xxx_nacl),
19161915
/*
@@ -1959,7 +1958,6 @@ static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
19591958

19601959
static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
19611960
.module = THIS_MODULE,
1962-
.name = "qla2xxx_npiv",
19631961
.fabric_name = "qla2xxx_npiv",
19641962
.node_acl_size = sizeof(struct tcm_qla2xxx_nacl),
19651963
.tpg_get_wwn = tcm_qla2xxx_get_fabric_wwn,

‎drivers/target/iscsi/iscsi_target_configfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ static void lio_release_cmd(struct se_cmd *se_cmd)
15441544

15451545
const struct target_core_fabric_ops iscsi_ops = {
15461546
.module = THIS_MODULE,
1547-
.name = "iscsi",
1547+
.fabric_alias = "iscsi",
15481548
.fabric_name = "iSCSI",
15491549
.node_acl_size = sizeof(struct iscsi_node_acl),
15501550
.tpg_get_wwn = lio_tpg_get_endpoint_wwn,

‎drivers/target/loopback/tcm_loop.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,6 @@ static struct configfs_attribute *tcm_loop_wwn_attrs[] = {
11441144

11451145
static const struct target_core_fabric_ops loop_ops = {
11461146
.module = THIS_MODULE,
1147-
.name = "loopback",
11481147
.fabric_name = "loopback",
11491148
.tpg_get_wwn = tcm_loop_get_endpoint_wwn,
11501149
.tpg_get_tag = tcm_loop_get_tag,

‎drivers/target/sbp/sbp_target.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,6 @@ static struct configfs_attribute *sbp_tpg_attrib_attrs[] = {
23182318

23192319
static const struct target_core_fabric_ops sbp_ops = {
23202320
.module = THIS_MODULE,
2321-
.name = "sbp",
23222321
.fabric_name = "sbp",
23232322
.tpg_get_wwn = sbp_get_fabric_wwn,
23242323
.tpg_get_tag = sbp_get_tag,

‎drivers/target/target_core_configfs.c‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ static struct target_fabric_configfs *target_core_get_fabric(
172172

173173
mutex_lock(&g_tf_lock);
174174
list_for_each_entry(tf, &g_tf_list, tf_list) {
175-
if (!strcmp(tf->tf_ops->name, name)) {
175+
const char *cmp_name = tf->tf_ops->fabric_alias;
176+
if (!cmp_name)
177+
cmp_name = tf->tf_ops->fabric_name;
178+
if (!strcmp(cmp_name, name)) {
176179
atomic_inc(&tf->tf_access_cnt);
177180
mutex_unlock(&g_tf_lock);
178181
return tf;
@@ -249,7 +252,7 @@ static struct config_group *target_core_register_fabric(
249252
return ERR_PTR(-EINVAL);
250253
}
251254
pr_debug("Target_Core_ConfigFS: REGISTER -> Located fabric:"
252-
" %s\n", tf->tf_ops->name);
255+
" %s\n", tf->tf_ops->fabric_name);
253256
/*
254257
* On a successful target_core_get_fabric() look, the returned
255258
* struct target_fabric_configfs *tf will contain a usage reference.
@@ -282,7 +285,7 @@ static void target_core_deregister_fabric(
282285
" tf list\n", config_item_name(item));
283286

284287
pr_debug("Target_Core_ConfigFS: DEREGISTER -> located fabric:"
285-
" %s\n", tf->tf_ops->name);
288+
" %s\n", tf->tf_ops->fabric_name);
286289
atomic_dec(&tf->tf_access_cnt);
287290

288291
pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing ci"
@@ -342,19 +345,22 @@ EXPORT_SYMBOL(target_undepend_item);
342345

343346
static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
344347
{
345-
if (!tfo->name) {
346-
pr_err("Missing tfo->name\n");
347-
return -EINVAL;
348-
}
349-
if (strlen(tfo->name) >= TARGET_FABRIC_NAME_SIZE) {
350-
pr_err("Passed name: %s exceeds TARGET_FABRIC"
351-
"_NAME_SIZE\n", tfo->name);
352-
return -EINVAL;
348+
if (tfo->fabric_alias) {
349+
if (strlen(tfo->fabric_alias) >= TARGET_FABRIC_NAME_SIZE) {
350+
pr_err("Passed alias: %s exceeds "
351+
"TARGET_FABRIC_NAME_SIZE\n", tfo->fabric_alias);
352+
return -EINVAL;
353+
}
353354
}
354355
if (!tfo->fabric_name) {
355356
pr_err("Missing tfo->fabric_name\n");
356357
return -EINVAL;
357358
}
359+
if (strlen(tfo->fabric_name) >= TARGET_FABRIC_NAME_SIZE) {
360+
pr_err("Passed name: %s exceeds "
361+
"TARGET_FABRIC_NAME_SIZE\n", tfo->fabric_name);
362+
return -EINVAL;
363+
}
358364
if (!tfo->tpg_get_wwn) {
359365
pr_err("Missing tfo->tpg_get_wwn()\n");
360366
return -EINVAL;
@@ -486,7 +492,7 @@ void target_unregister_template(const struct target_core_fabric_ops *fo)
486492

487493
mutex_lock(&g_tf_lock);
488494
list_for_each_entry(t, &g_tf_list, tf_list) {
489-
if (!strcmp(t->tf_ops->name, fo->name)) {
495+
if (!strcmp(t->tf_ops->fabric_name, fo->fabric_name)) {
490496
BUG_ON(atomic_read(&t->tf_access_cnt));
491497
list_del(&t->tf_list);
492498
mutex_unlock(&g_tf_lock);

‎drivers/target/tcm_fc/tfc_conf.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg)
422422

423423
static const struct target_core_fabric_ops ft_fabric_ops = {
424424
.module = THIS_MODULE,
425-
.name = "fc",
426425
.fabric_name = "fc",
427426
.node_acl_size = sizeof(struct ft_node_acl),
428427
.tpg_get_wwn = ft_get_fabric_wwn,

‎drivers/usb/gadget/function/f_tcm.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,6 @@ static int usbg_check_stop_free(struct se_cmd *se_cmd)
17131713

17141714
static const struct target_core_fabric_ops usbg_ops = {
17151715
.module = THIS_MODULE,
1716-
.name = "usb_gadget",
17171716
.fabric_name = "usb_gadget",
17181717
.tpg_get_wwn = usbg_get_fabric_wwn,
17191718
.tpg_get_tag = usbg_get_tag,

‎drivers/vhost/scsi.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2284,7 +2284,6 @@ static struct configfs_attribute *vhost_scsi_wwn_attrs[] = {
22842284

22852285
static const struct target_core_fabric_ops vhost_scsi_ops = {
22862286
.module = THIS_MODULE,
2287-
.name = "vhost",
22882287
.fabric_name = "vhost",
22892288
.tpg_get_wwn = vhost_scsi_get_fabric_wwn,
22902289
.tpg_get_tag = vhost_scsi_get_tpgt,

0 commit comments

Comments
 (0)