[RFC PATCH 24/48] target: core: pr: use RTPI in APTPL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since RTPI is an unique identifier of target port there is no need to
check fabric name and port tag.
RTPI is already saved in APTPL data, so it is backward compatible
change.

Signed-off-by: Dmitry Bogdanov <d.bogdanov@xxxxxxxxx>
---
 drivers/target/target_core_configfs.c |  4 ++-
 drivers/target/target_core_pr.c       | 41 +++++++--------------------
 drivers/target/target_core_pr.h       |  2 +-
 include/target/target_core_base.h     |  5 ----
 4 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 34901f0b2350..f469cfde3f1e 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1993,6 +1993,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item,
 	u64 mapped_lun = 0, target_lun = 0;
 	int ret = -1, res_holder = 0, all_tg_pt = 0, arg, token;
 	u16 tpgt = 0;
+	u16 rtpi = 0;
 	u8 type = 0;
 
 	if (!dev->dev_attrib.emulate_pr ||
@@ -2127,6 +2128,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item,
 			ret = match_int(args, &arg);
 			if (ret)
 				goto out;
+			rtpi = (u16)arg;
 			break;
 		case Opt_target_lun:
 			ret = match_u64(args, &tmp_ll);
@@ -2153,7 +2155,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item,
 	}
 
 	ret = core_scsi3_alloc_aptpl_registration(&dev->t10_pr, sa_res_key,
-			i_port, isid, mapped_lun, t_port, tpgt, target_lun,
+			i_port, isid, mapped_lun, rtpi, target_lun,
 			res_holder, all_tg_pt, type);
 out:
 	kfree(i_fabric);
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index dfecb155bf88..1f19bfd0fa00 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -832,8 +832,7 @@ int core_scsi3_alloc_aptpl_registration(
 	unsigned char *i_port,
 	unsigned char *isid,
 	u64 mapped_lun,
-	unsigned char *t_port,
-	u16 tpgt,
+	u16 rtpi,
 	u64 target_lun,
 	int res_holder,
 	int all_tg_pt,
@@ -841,7 +840,7 @@ int core_scsi3_alloc_aptpl_registration(
 {
 	struct t10_pr_registration *pr_reg;
 
-	if (!i_port || !t_port || !sa_res_key) {
+	if (!i_port || !sa_res_key) {
 		pr_err("Illegal parameters for APTPL registration\n");
 		return -EINVAL;
 	}
@@ -867,6 +866,7 @@ int core_scsi3_alloc_aptpl_registration(
 	pr_reg->pr_reg_aptpl = 1;
 	pr_reg->pr_res_scope = 0; /* Always LUN_SCOPE */
 	pr_reg->pr_res_type = type;
+	pr_reg->tg_pt_sep_rtpi = rtpi;
 	/*
 	 * If an ISID value had been saved in APTPL metadata for this
 	 * SCSI Initiator Port, restore it now.
@@ -877,11 +877,9 @@ int core_scsi3_alloc_aptpl_registration(
 		pr_reg->isid_present_at_reg = 1;
 	}
 	/*
-	 * Copy the i_port and t_port information from caller.
+	 * Copy the i_port information from caller.
 	 */
 	snprintf(pr_reg->pr_iport, PR_APTPL_MAX_IPORT_LEN, "%s", i_port);
-	snprintf(pr_reg->pr_tport, PR_APTPL_MAX_TPORT_LEN, "%s", t_port);
-	pr_reg->pr_reg_tpgt = tpgt;
 	/*
 	 * Set pr_res_holder from caller, the pr_reg who is the reservation
 	 * holder will get it's pointer set in core_scsi3_aptpl_reserve() once
@@ -933,17 +931,7 @@ static int __core_scsi3_check_aptpl_registration(
 {
 	struct t10_pr_registration *pr_reg, *pr_reg_tmp;
 	struct t10_reservation *pr_tmpl = &dev->t10_pr;
-	unsigned char i_port[PR_APTPL_MAX_IPORT_LEN] = { };
-	unsigned char t_port[PR_APTPL_MAX_TPORT_LEN] = { };
-	u16 tpgt;
 
-	/*
-	 * Copy Initiator Port information from struct se_node_acl
-	 */
-	snprintf(i_port, PR_APTPL_MAX_IPORT_LEN, "%s", nacl->initiatorname);
-	snprintf(t_port, PR_APTPL_MAX_TPORT_LEN, "%s",
-			tpg->se_tpg_tfo->tpg_get_wwn(tpg));
-	tpgt = tpg->se_tpg_tfo->tpg_get_tag(tpg);
 	/*
 	 * Look for the matching registrations+reservation from those
 	 * created from APTPL metadata.  Note that multiple registrations
@@ -954,11 +942,8 @@ static int __core_scsi3_check_aptpl_registration(
 	list_for_each_entry_safe(pr_reg, pr_reg_tmp, &pr_tmpl->aptpl_reg_list,
 				pr_reg_aptpl_list) {
 
-		if (!strcmp(pr_reg->pr_iport, i_port) &&
-		     (pr_reg->pr_res_mapped_lun == mapped_lun) &&
-		    !(strcmp(pr_reg->pr_tport, t_port)) &&
-		     (pr_reg->pr_reg_tpgt == tpgt) &&
-		     (pr_reg->pr_aptpl_target_lun == target_lun)) {
+		if (!strcmp(pr_reg->pr_iport, nacl->initiatorname) &&
+		     (pr_reg->tg_pt_sep_rtpi == tpg->tpg_rtpi)) {
 			/*
 			 * Obtain the ->pr_reg_deve pointer + reference, that
 			 * is released by __core_scsi3_add_registration() below.
@@ -1851,25 +1836,22 @@ static int core_scsi3_update_aptpl_buf(
 		 * reservation holder.
 		 */
 		if (dev->dev_pr_res_holder == pr_reg) {
-			snprintf(tmp, 512, "PR_REG_START: %d"
-				"\ninitiator_fabric=%s\n"
+			snprintf(tmp, 512, "PR_REG_START: %d\n"
 				"initiator_node=%s\n%s"
 				"sa_res_key=%llu\n"
 				"res_holder=1\nres_type=%02x\n"
 				"res_scope=%02x\nres_all_tg_pt=%d\n"
 				"mapped_lun=%llu\n", reg_count,
-				tpg->se_tpg_tfo->fabric_name,
 				pr_reg->pr_iport, isid_buf,
 				pr_reg->pr_res_key, pr_reg->pr_res_type,
 				pr_reg->pr_res_scope, pr_reg->pr_reg_all_tg_pt,
 				pr_reg->pr_res_mapped_lun);
 		} else {
 			snprintf(tmp, 512, "PR_REG_START: %d\n"
-				"initiator_fabric=%s\ninitiator_node=%s\n%s"
+				"initiator_node=%s\n%s"
 				"sa_res_key=%llu\nres_holder=0\n"
 				"res_all_tg_pt=%d\nmapped_lun=%llu\n",
-				reg_count, tpg->se_tpg_tfo->fabric_name,
-				pr_reg->pr_iport, isid_buf,
+				reg_count, pr_reg->pr_iport, isid_buf,
 				pr_reg->pr_res_key, pr_reg->pr_reg_all_tg_pt,
 				pr_reg->pr_res_mapped_lun);
 		}
@@ -1885,9 +1867,8 @@ static int core_scsi3_update_aptpl_buf(
 		/*
 		 * Include information about the associated SCSI target port.
 		 */
-		snprintf(tmp, 512, "target_fabric=%s\ntarget_node=%s\n"
-			"tpgt=%hu\nport_rtpi=%hu\ntarget_lun=%llu\nPR_REG_END:"
-			" %d\n", tpg->se_tpg_tfo->fabric_name,
+		snprintf(tmp, 512, "target_node=%s\n"
+			"tpgt=%hu\nport_rtpi=%hu\ntarget_lun=%llu\nPR_REG_END: %d\n",
 			tpg->se_tpg_tfo->tpg_get_wwn(tpg),
 			tpg->se_tpg_tfo->tpg_get_tag(tpg),
 			pr_reg->tg_pt_sep_rtpi, pr_reg->pr_aptpl_target_lun,
diff --git a/drivers/target/target_core_pr.h b/drivers/target/target_core_pr.h
index 9c4710f34d94..e4bdabfc4b31 100644
--- a/drivers/target/target_core_pr.h
+++ b/drivers/target/target_core_pr.h
@@ -64,7 +64,7 @@ extern sense_reason_t target_scsi2_reservation_reserve(struct se_cmd *);
 extern int core_scsi3_alloc_aptpl_registration(
 			struct t10_reservation *, u64,
 			unsigned char *, unsigned char *, u64,
-			unsigned char *, u16, u64, int, int, u8);
+			u16, u64, int, int, u8);
 extern int core_scsi3_check_aptpl_registration(struct se_device *,
 			struct se_portal_group *, struct se_lun *,
 			struct se_node_acl *, u64);
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 1b673b25c6cd..095b96cb3557 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -347,11 +347,6 @@ struct t10_pr_registration {
 	/* Used during APTPL metadata reading */
 #define PR_APTPL_MAX_IPORT_LEN			256
 	unsigned char pr_iport[PR_APTPL_MAX_IPORT_LEN];
-	/* Used during APTPL metadata reading */
-#define PR_APTPL_MAX_TPORT_LEN			256
-	unsigned char pr_tport[PR_APTPL_MAX_TPORT_LEN];
-	u16 pr_aptpl_rpti;
-	u16 pr_reg_tpgt;
 	/* Reservation effects all target ports */
 	int pr_reg_all_tg_pt;
 	/* Activate Persistence across Target Power Loss */
-- 
2.25.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux