Skip to content

Commit d2843c1

Browse files
Andy GroverNicholas Bellinger
authored andcommitted
target: Alter core_pr_dump_initiator_port for ease of use
We use this function exclusively in debug prints. Instead of returning 0 or 1 if isid is present, just set buf to "" if it isn't there. This saves callers from having to check the return value. Signed-off-by: Andy Grover <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 33ce6a8 commit d2843c1

File tree

3 files changed

+27
-46
lines changed

3 files changed

+27
-46
lines changed

drivers/target/target_core_configfs.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,6 @@ static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev,
983983
struct se_node_acl *se_nacl;
984984
struct t10_pr_registration *pr_reg;
985985
char i_buf[PR_REG_ISID_ID_LEN];
986-
int prf_isid;
987986

988987
memset(i_buf, 0, PR_REG_ISID_ID_LEN);
989988

@@ -992,12 +991,11 @@ static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev,
992991
return sprintf(page, "No SPC-3 Reservation holder\n");
993992

994993
se_nacl = pr_reg->pr_reg_nacl;
995-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
996-
PR_REG_ISID_ID_LEN);
994+
core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
997995

998996
return sprintf(page, "SPC-3 Reservation: %s Initiator: %s%s\n",
999997
se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
1000-
se_nacl->initiatorname, (prf_isid) ? &i_buf[0] : "");
998+
se_nacl->initiatorname, i_buf);
1001999
}
10021000

10031001
static ssize_t target_core_dev_pr_show_spc2_res(struct se_device *dev,
@@ -1116,7 +1114,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
11161114
unsigned char buf[384];
11171115
char i_buf[PR_REG_ISID_ID_LEN];
11181116
ssize_t len = 0;
1119-
int reg_count = 0, prf_isid;
1117+
int reg_count = 0;
11201118

11211119
len += sprintf(page+len, "SPC-3 PR Registrations:\n");
11221120

@@ -1127,12 +1125,11 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
11271125
memset(buf, 0, 384);
11281126
memset(i_buf, 0, PR_REG_ISID_ID_LEN);
11291127
tfo = pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo;
1130-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
1128+
core_pr_dump_initiator_port(pr_reg, i_buf,
11311129
PR_REG_ISID_ID_LEN);
11321130
sprintf(buf, "%s Node: %s%s Key: 0x%016Lx PRgen: 0x%08x\n",
11331131
tfo->get_fabric_name(),
1134-
pr_reg->pr_reg_nacl->initiatorname, (prf_isid) ?
1135-
&i_buf[0] : "", pr_reg->pr_res_key,
1132+
pr_reg->pr_reg_nacl->initiatorname, i_buf, pr_reg->pr_res_key,
11361133
pr_reg->pr_res_generation);
11371134

11381135
if (len + strlen(buf) >= PAGE_SIZE)

drivers/target/target_core_pr.c

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,15 @@ struct pr_transport_id_holder {
5353
struct list_head dest_list;
5454
};
5555

56-
int core_pr_dump_initiator_port(
56+
void core_pr_dump_initiator_port(
5757
struct t10_pr_registration *pr_reg,
5858
char *buf,
5959
u32 size)
6060
{
6161
if (!pr_reg->isid_present_at_reg)
62-
return 0;
62+
buf[0] = '\0';
6363

64-
snprintf(buf, size, ",i,0x%s", &pr_reg->pr_reg_isid[0]);
65-
return 1;
64+
snprintf(buf, size, ",i,0x%s", pr_reg->pr_reg_isid);
6665
}
6766

6867
enum register_type {
@@ -859,11 +858,9 @@ static void core_scsi3_aptpl_reserve(
859858
struct t10_pr_registration *pr_reg)
860859
{
861860
char i_buf[PR_REG_ISID_ID_LEN];
862-
int prf_isid;
863861

864862
memset(i_buf, 0, PR_REG_ISID_ID_LEN);
865-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
866-
PR_REG_ISID_ID_LEN);
863+
core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
867864

868865
spin_lock(&dev->dev_reservation_lock);
869866
dev->dev_pr_res_holder = pr_reg;
@@ -876,7 +873,7 @@ static void core_scsi3_aptpl_reserve(
876873
(pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
877874
pr_debug("SPC-3 PR [%s] RESERVE Node: %s%s\n",
878875
tpg->se_tpg_tfo->get_fabric_name(), node_acl->initiatorname,
879-
(prf_isid) ? &i_buf[0] : "");
876+
i_buf);
880877
}
881878

882879
static void __core_scsi3_add_registration(struct se_device *, struct se_node_acl *,
@@ -977,17 +974,15 @@ static void __core_scsi3_dump_registration(
977974
{
978975
struct se_portal_group *se_tpg = nacl->se_tpg;
979976
char i_buf[PR_REG_ISID_ID_LEN];
980-
int prf_isid;
981977

982978
memset(&i_buf[0], 0, PR_REG_ISID_ID_LEN);
983-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
984-
PR_REG_ISID_ID_LEN);
979+
core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
985980

986981
pr_debug("SPC-3 PR [%s] Service Action: REGISTER%s Initiator"
987982
" Node: %s%s\n", tfo->get_fabric_name(), (register_type == REGISTER_AND_MOVE) ?
988983
"_AND_MOVE" : (register_type == REGISTER_AND_IGNORE_EXISTING_KEY) ?
989984
"_AND_IGNORE_EXISTING_KEY" : "", nacl->initiatorname,
990-
(prf_isid) ? i_buf : "");
985+
i_buf);
991986
pr_debug("SPC-3 PR [%s] registration on Target Port: %s,0x%04x\n",
992987
tfo->get_fabric_name(), tfo->tpg_get_wwn(se_tpg),
993988
tfo->tpg_get_tag(se_tpg));
@@ -1236,11 +1231,9 @@ static void __core_scsi3_free_registration(
12361231
pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo;
12371232
struct t10_reservation *pr_tmpl = &dev->t10_pr;
12381233
char i_buf[PR_REG_ISID_ID_LEN];
1239-
int prf_isid;
12401234

12411235
memset(i_buf, 0, PR_REG_ISID_ID_LEN);
1242-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
1243-
PR_REG_ISID_ID_LEN);
1236+
core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
12441237

12451238
pr_reg->pr_reg_deve->def_pr_registered = 0;
12461239
pr_reg->pr_reg_deve->pr_res_key = 0;
@@ -1268,7 +1261,7 @@ static void __core_scsi3_free_registration(
12681261
pr_debug("SPC-3 PR [%s] Service Action: UNREGISTER Initiator"
12691262
" Node: %s%s\n", tfo->get_fabric_name(),
12701263
pr_reg->pr_reg_nacl->initiatorname,
1271-
(prf_isid) ? &i_buf[0] : "");
1264+
i_buf);
12721265
pr_debug("SPC-3 PR [%s] for %s TCM Subsystem %s Object Target"
12731266
" Port(s)\n", tfo->get_fabric_name(),
12741267
(pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE",
@@ -1464,7 +1457,7 @@ core_scsi3_decode_spec_i_port(
14641457
char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN];
14651458
sense_reason_t ret;
14661459
u32 tpdl, tid_len = 0;
1467-
int dest_local_nexus, prf_isid;
1460+
int dest_local_nexus;
14681461
u32 dest_rtpi = 0;
14691462

14701463
memset(dest_iport, 0, 64);
@@ -1775,17 +1768,15 @@ core_scsi3_decode_spec_i_port(
17751768
kfree(tidh);
17761769

17771770
memset(i_buf, 0, PR_REG_ISID_ID_LEN);
1778-
prf_isid = core_pr_dump_initiator_port(dest_pr_reg, &i_buf[0],
1779-
PR_REG_ISID_ID_LEN);
1771+
core_pr_dump_initiator_port(dest_pr_reg, i_buf, PR_REG_ISID_ID_LEN);
17801772

17811773
__core_scsi3_add_registration(cmd->se_dev, dest_node_acl,
17821774
dest_pr_reg, 0, 0);
17831775

17841776
pr_debug("SPC-3 PR [%s] SPEC_I_PT: Successfully"
17851777
" registered Transport ID for Node: %s%s Mapped LUN:"
17861778
" %u\n", dest_tpg->se_tpg_tfo->get_fabric_name(),
1787-
dest_node_acl->initiatorname, (prf_isid) ?
1788-
&i_buf[0] : "", dest_se_deve->mapped_lun);
1779+
dest_node_acl->initiatorname, i_buf, dest_se_deve->mapped_lun);
17891780

17901781
if (dest_local_nexus)
17911782
continue;
@@ -2351,7 +2342,6 @@ core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key)
23512342
struct t10_reservation *pr_tmpl = &dev->t10_pr;
23522343
char i_buf[PR_REG_ISID_ID_LEN];
23532344
sense_reason_t ret;
2354-
int prf_isid;
23552345

23562346
memset(i_buf, 0, PR_REG_ISID_ID_LEN);
23572347

@@ -2477,8 +2467,7 @@ core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key)
24772467
pr_reg->pr_res_type = type;
24782468
pr_reg->pr_res_holder = 1;
24792469
dev->dev_pr_res_holder = pr_reg;
2480-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
2481-
PR_REG_ISID_ID_LEN);
2470+
core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
24822471

24832472
pr_debug("SPC-3 PR [%s] Service Action: RESERVE created new"
24842473
" reservation holder TYPE: %s ALL_TG_PT: %d\n",
@@ -2487,7 +2476,7 @@ core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key)
24872476
pr_debug("SPC-3 PR [%s] RESERVE Node: %s%s\n",
24882477
cmd->se_tfo->get_fabric_name(),
24892478
se_sess->se_node_acl->initiatorname,
2490-
(prf_isid) ? &i_buf[0] : "");
2479+
i_buf);
24912480
spin_unlock(&dev->dev_reservation_lock);
24922481

24932482
if (pr_tmpl->pr_aptpl_active) {
@@ -2535,11 +2524,9 @@ static void __core_scsi3_complete_pro_release(
25352524
{
25362525
struct target_core_fabric_ops *tfo = se_nacl->se_tpg->se_tpg_tfo;
25372526
char i_buf[PR_REG_ISID_ID_LEN];
2538-
int prf_isid;
25392527

25402528
memset(i_buf, 0, PR_REG_ISID_ID_LEN);
2541-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
2542-
PR_REG_ISID_ID_LEN);
2529+
core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
25432530
/*
25442531
* Go ahead and release the current PR reservation holder.
25452532
*/
@@ -2552,7 +2539,7 @@ static void __core_scsi3_complete_pro_release(
25522539
(pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
25532540
pr_debug("SPC-3 PR [%s] RELEASE Node: %s%s\n",
25542541
tfo->get_fabric_name(), se_nacl->initiatorname,
2555-
(prf_isid) ? &i_buf[0] : "");
2542+
i_buf);
25562543
/*
25572544
* Clear TYPE and SCOPE for the next PROUT Service Action: RESERVE
25582545
*/
@@ -2826,11 +2813,9 @@ static void __core_scsi3_complete_pro_preempt(
28262813
struct se_node_acl *nacl = pr_reg->pr_reg_nacl;
28272814
struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
28282815
char i_buf[PR_REG_ISID_ID_LEN];
2829-
int prf_isid;
28302816

28312817
memset(i_buf, 0, PR_REG_ISID_ID_LEN);
2832-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
2833-
PR_REG_ISID_ID_LEN);
2818+
core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
28342819
/*
28352820
* Do an implict RELEASE of the existing reservation.
28362821
*/
@@ -2850,7 +2835,7 @@ static void __core_scsi3_complete_pro_preempt(
28502835
(pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
28512836
pr_debug("SPC-3 PR [%s] PREEMPT%s from Node: %s%s\n",
28522837
tfo->get_fabric_name(), (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
2853-
nacl->initiatorname, (prf_isid) ? &i_buf[0] : "");
2838+
nacl->initiatorname, i_buf);
28542839
/*
28552840
* For PREEMPT_AND_ABORT, add the preempting reservation's
28562841
* struct t10_pr_registration to the list that will be compared
@@ -3231,7 +3216,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
32313216
unsigned char *initiator_str;
32323217
char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN];
32333218
u32 tid_len, tmp_tid_len;
3234-
int new_reg = 0, type, scope, matching_iname, prf_isid;
3219+
int new_reg = 0, type, scope, matching_iname;
32353220
sense_reason_t ret;
32363221
unsigned short rtpi;
32373222
unsigned char proto_ident;
@@ -3575,8 +3560,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
35753560
dest_pr_reg->pr_res_holder = 1;
35763561
dest_pr_reg->pr_res_type = type;
35773562
pr_reg->pr_res_scope = scope;
3578-
prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
3579-
PR_REG_ISID_ID_LEN);
3563+
core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
35803564
/*
35813565
* Increment PRGeneration for existing registrations..
35823566
*/
@@ -3592,7 +3576,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
35923576
pr_debug("SPC-3 PR Successfully moved reservation from"
35933577
" %s Fabric Node: %s%s -> %s Fabric Node: %s %s\n",
35943578
tf_ops->get_fabric_name(), pr_reg_nacl->initiatorname,
3595-
(prf_isid) ? &i_buf[0] : "", dest_tf_ops->get_fabric_name(),
3579+
i_buf, dest_tf_ops->get_fabric_name(),
35963580
dest_node_acl->initiatorname, (iport_ptr != NULL) ?
35973581
iport_ptr : "");
35983582
/*

drivers/target/target_core_pr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
extern struct kmem_cache *t10_pr_reg_cache;
4747

48-
extern int core_pr_dump_initiator_port(struct t10_pr_registration *,
48+
extern void core_pr_dump_initiator_port(struct t10_pr_registration *,
4949
char *, u32);
5050
extern sense_reason_t target_scsi2_reservation_release(struct se_cmd *);
5151
extern sense_reason_t target_scsi2_reservation_reserve(struct se_cmd *);

0 commit comments

Comments
 (0)