Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

authored by

Andy Grover and committed by
Nicholas Bellinger
d2843c17 33ce6a87

+27 -46
+5 -8
drivers/target/target_core_configfs.c
··· 983 983 struct se_node_acl *se_nacl; 984 984 struct t10_pr_registration *pr_reg; 985 985 char i_buf[PR_REG_ISID_ID_LEN]; 986 - int prf_isid; 987 986 988 987 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 989 988 ··· 991 992 return sprintf(page, "No SPC-3 Reservation holder\n"); 992 993 993 994 se_nacl = pr_reg->pr_reg_nacl; 994 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 995 - PR_REG_ISID_ID_LEN); 995 + core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 996 996 997 997 return sprintf(page, "SPC-3 Reservation: %s Initiator: %s%s\n", 998 998 se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(), 999 - se_nacl->initiatorname, (prf_isid) ? &i_buf[0] : ""); 999 + se_nacl->initiatorname, i_buf); 1000 1000 } 1001 1001 1002 1002 static ssize_t target_core_dev_pr_show_spc2_res(struct se_device *dev, ··· 1114 1116 unsigned char buf[384]; 1115 1117 char i_buf[PR_REG_ISID_ID_LEN]; 1116 1118 ssize_t len = 0; 1117 - int reg_count = 0, prf_isid; 1119 + int reg_count = 0; 1118 1120 1119 1121 len += sprintf(page+len, "SPC-3 PR Registrations:\n"); 1120 1122 ··· 1125 1127 memset(buf, 0, 384); 1126 1128 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 1127 1129 tfo = pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; 1128 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 1130 + core_pr_dump_initiator_port(pr_reg, i_buf, 1129 1131 PR_REG_ISID_ID_LEN); 1130 1132 sprintf(buf, "%s Node: %s%s Key: 0x%016Lx PRgen: 0x%08x\n", 1131 1133 tfo->get_fabric_name(), 1132 - pr_reg->pr_reg_nacl->initiatorname, (prf_isid) ? 1133 - &i_buf[0] : "", pr_reg->pr_res_key, 1134 + pr_reg->pr_reg_nacl->initiatorname, i_buf, pr_reg->pr_res_key, 1134 1135 pr_reg->pr_res_generation); 1135 1136 1136 1137 if (len + strlen(buf) >= PAGE_SIZE)
+21 -37
drivers/target/target_core_pr.c
··· 53 53 struct list_head dest_list; 54 54 }; 55 55 56 - int core_pr_dump_initiator_port( 56 + void core_pr_dump_initiator_port( 57 57 struct t10_pr_registration *pr_reg, 58 58 char *buf, 59 59 u32 size) 60 60 { 61 61 if (!pr_reg->isid_present_at_reg) 62 - return 0; 62 + buf[0] = '\0'; 63 63 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); 66 65 } 67 66 68 67 enum register_type { ··· 858 859 struct t10_pr_registration *pr_reg) 859 860 { 860 861 char i_buf[PR_REG_ISID_ID_LEN]; 861 - int prf_isid; 862 862 863 863 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 864 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 865 - PR_REG_ISID_ID_LEN); 864 + core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 866 865 867 866 spin_lock(&dev->dev_reservation_lock); 868 867 dev->dev_pr_res_holder = pr_reg; ··· 873 876 (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); 874 877 pr_debug("SPC-3 PR [%s] RESERVE Node: %s%s\n", 875 878 tpg->se_tpg_tfo->get_fabric_name(), node_acl->initiatorname, 876 - (prf_isid) ? &i_buf[0] : ""); 879 + i_buf); 877 880 } 878 881 879 882 static void __core_scsi3_add_registration(struct se_device *, struct se_node_acl *, ··· 974 977 { 975 978 struct se_portal_group *se_tpg = nacl->se_tpg; 976 979 char i_buf[PR_REG_ISID_ID_LEN]; 977 - int prf_isid; 978 980 979 981 memset(&i_buf[0], 0, PR_REG_ISID_ID_LEN); 980 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 981 - PR_REG_ISID_ID_LEN); 982 + core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 982 983 983 984 pr_debug("SPC-3 PR [%s] Service Action: REGISTER%s Initiator" 984 985 " Node: %s%s\n", tfo->get_fabric_name(), (register_type == REGISTER_AND_MOVE) ? 985 986 "_AND_MOVE" : (register_type == REGISTER_AND_IGNORE_EXISTING_KEY) ? 986 987 "_AND_IGNORE_EXISTING_KEY" : "", nacl->initiatorname, 987 - (prf_isid) ? i_buf : ""); 988 + i_buf); 988 989 pr_debug("SPC-3 PR [%s] registration on Target Port: %s,0x%04x\n", 989 990 tfo->get_fabric_name(), tfo->tpg_get_wwn(se_tpg), 990 991 tfo->tpg_get_tag(se_tpg)); ··· 1231 1236 pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; 1232 1237 struct t10_reservation *pr_tmpl = &dev->t10_pr; 1233 1238 char i_buf[PR_REG_ISID_ID_LEN]; 1234 - int prf_isid; 1235 1239 1236 1240 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 1237 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 1238 - PR_REG_ISID_ID_LEN); 1241 + core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 1239 1242 1240 1243 pr_reg->pr_reg_deve->def_pr_registered = 0; 1241 1244 pr_reg->pr_reg_deve->pr_res_key = 0; ··· 1261 1268 pr_debug("SPC-3 PR [%s] Service Action: UNREGISTER Initiator" 1262 1269 " Node: %s%s\n", tfo->get_fabric_name(), 1263 1270 pr_reg->pr_reg_nacl->initiatorname, 1264 - (prf_isid) ? &i_buf[0] : ""); 1271 + i_buf); 1265 1272 pr_debug("SPC-3 PR [%s] for %s TCM Subsystem %s Object Target" 1266 1273 " Port(s)\n", tfo->get_fabric_name(), 1267 1274 (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", ··· 1457 1464 char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; 1458 1465 sense_reason_t ret; 1459 1466 u32 tpdl, tid_len = 0; 1460 - int dest_local_nexus, prf_isid; 1467 + int dest_local_nexus; 1461 1468 u32 dest_rtpi = 0; 1462 1469 1463 1470 memset(dest_iport, 0, 64); ··· 1768 1775 kfree(tidh); 1769 1776 1770 1777 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 1771 - prf_isid = core_pr_dump_initiator_port(dest_pr_reg, &i_buf[0], 1772 - PR_REG_ISID_ID_LEN); 1778 + core_pr_dump_initiator_port(dest_pr_reg, i_buf, PR_REG_ISID_ID_LEN); 1773 1779 1774 1780 __core_scsi3_add_registration(cmd->se_dev, dest_node_acl, 1775 1781 dest_pr_reg, 0, 0); ··· 1776 1784 pr_debug("SPC-3 PR [%s] SPEC_I_PT: Successfully" 1777 1785 " registered Transport ID for Node: %s%s Mapped LUN:" 1778 1786 " %u\n", dest_tpg->se_tpg_tfo->get_fabric_name(), 1779 - dest_node_acl->initiatorname, (prf_isid) ? 1780 - &i_buf[0] : "", dest_se_deve->mapped_lun); 1787 + dest_node_acl->initiatorname, i_buf, dest_se_deve->mapped_lun); 1781 1788 1782 1789 if (dest_local_nexus) 1783 1790 continue; ··· 2342 2351 struct t10_reservation *pr_tmpl = &dev->t10_pr; 2343 2352 char i_buf[PR_REG_ISID_ID_LEN]; 2344 2353 sense_reason_t ret; 2345 - int prf_isid; 2346 2354 2347 2355 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 2348 2356 ··· 2467 2477 pr_reg->pr_res_type = type; 2468 2478 pr_reg->pr_res_holder = 1; 2469 2479 dev->dev_pr_res_holder = pr_reg; 2470 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 2471 - PR_REG_ISID_ID_LEN); 2480 + core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 2472 2481 2473 2482 pr_debug("SPC-3 PR [%s] Service Action: RESERVE created new" 2474 2483 " reservation holder TYPE: %s ALL_TG_PT: %d\n", ··· 2476 2487 pr_debug("SPC-3 PR [%s] RESERVE Node: %s%s\n", 2477 2488 cmd->se_tfo->get_fabric_name(), 2478 2489 se_sess->se_node_acl->initiatorname, 2479 - (prf_isid) ? &i_buf[0] : ""); 2490 + i_buf); 2480 2491 spin_unlock(&dev->dev_reservation_lock); 2481 2492 2482 2493 if (pr_tmpl->pr_aptpl_active) { ··· 2524 2535 { 2525 2536 struct target_core_fabric_ops *tfo = se_nacl->se_tpg->se_tpg_tfo; 2526 2537 char i_buf[PR_REG_ISID_ID_LEN]; 2527 - int prf_isid; 2528 2538 2529 2539 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 2530 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 2531 - PR_REG_ISID_ID_LEN); 2540 + core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 2532 2541 /* 2533 2542 * Go ahead and release the current PR reservation holder. 2534 2543 */ ··· 2539 2552 (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); 2540 2553 pr_debug("SPC-3 PR [%s] RELEASE Node: %s%s\n", 2541 2554 tfo->get_fabric_name(), se_nacl->initiatorname, 2542 - (prf_isid) ? &i_buf[0] : ""); 2555 + i_buf); 2543 2556 /* 2544 2557 * Clear TYPE and SCOPE for the next PROUT Service Action: RESERVE 2545 2558 */ ··· 2813 2826 struct se_node_acl *nacl = pr_reg->pr_reg_nacl; 2814 2827 struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo; 2815 2828 char i_buf[PR_REG_ISID_ID_LEN]; 2816 - int prf_isid; 2817 2829 2818 2830 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 2819 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 2820 - PR_REG_ISID_ID_LEN); 2831 + core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 2821 2832 /* 2822 2833 * Do an implict RELEASE of the existing reservation. 2823 2834 */ ··· 2835 2850 (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); 2836 2851 pr_debug("SPC-3 PR [%s] PREEMPT%s from Node: %s%s\n", 2837 2852 tfo->get_fabric_name(), (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "", 2838 - nacl->initiatorname, (prf_isid) ? &i_buf[0] : ""); 2853 + nacl->initiatorname, i_buf); 2839 2854 /* 2840 2855 * For PREEMPT_AND_ABORT, add the preempting reservation's 2841 2856 * struct t10_pr_registration to the list that will be compared ··· 3216 3231 unsigned char *initiator_str; 3217 3232 char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; 3218 3233 u32 tid_len, tmp_tid_len; 3219 - int new_reg = 0, type, scope, matching_iname, prf_isid; 3234 + int new_reg = 0, type, scope, matching_iname; 3220 3235 sense_reason_t ret; 3221 3236 unsigned short rtpi; 3222 3237 unsigned char proto_ident; ··· 3560 3575 dest_pr_reg->pr_res_holder = 1; 3561 3576 dest_pr_reg->pr_res_type = type; 3562 3577 pr_reg->pr_res_scope = scope; 3563 - prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0], 3564 - PR_REG_ISID_ID_LEN); 3578 + core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 3565 3579 /* 3566 3580 * Increment PRGeneration for existing registrations.. 3567 3581 */ ··· 3576 3592 pr_debug("SPC-3 PR Successfully moved reservation from" 3577 3593 " %s Fabric Node: %s%s -> %s Fabric Node: %s %s\n", 3578 3594 tf_ops->get_fabric_name(), pr_reg_nacl->initiatorname, 3579 - (prf_isid) ? &i_buf[0] : "", dest_tf_ops->get_fabric_name(), 3595 + i_buf, dest_tf_ops->get_fabric_name(), 3580 3596 dest_node_acl->initiatorname, (iport_ptr != NULL) ? 3581 3597 iport_ptr : ""); 3582 3598 /*
+1 -1
drivers/target/target_core_pr.h
··· 45 45 46 46 extern struct kmem_cache *t10_pr_reg_cache; 47 47 48 - extern int core_pr_dump_initiator_port(struct t10_pr_registration *, 48 + extern void core_pr_dump_initiator_port(struct t10_pr_registration *, 49 49 char *, u32); 50 50 extern sense_reason_t target_scsi2_reservation_release(struct se_cmd *); 51 51 extern sense_reason_t target_scsi2_reservation_reserve(struct se_cmd *);