diff mbox series

[RFC,26/48] target: core: pr: remove se_tpg from pr_reg

Message ID 20220803162857.27770-27-d.bogdanov@yadro.com
State New
Headers show
Series Target cluster implementation over DLM | expand

Commit Message

Dmitry Bogdanov June 22, 2022, 10:25 a.m. UTC
Undepend pr_reg from se_tpg.
Use RTPI at PR creation.

Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
 drivers/target/target_core_configfs.c        |  47 ++++---
 drivers/target/target_core_fabric_configfs.c |   2 +-
 drivers/target/target_core_internal.h        |   1 +
 drivers/target/target_core_pr.c              | 126 ++++++++-----------
 drivers/target/target_core_pr.h              |   2 +-
 drivers/target/target_core_tpg.c             |  17 ++-
 include/target/target_core_base.h            |   1 -
 7 files changed, 104 insertions(+), 92 deletions(-)
diff mbox series

Patch

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index f469cfde3f1e..0978279bd5e3 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1736,6 +1736,8 @@  static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev,
 		char *page)
 {
 	struct t10_pr_registration *pr_reg;
+	struct se_portal_group *se_tpg;
+	const char *fabric_name = "Unknown";
 	char i_buf[PR_REG_ISID_ID_LEN] = { };
 
 	pr_reg = dev->dev_pr_res_holder;
@@ -1744,9 +1746,12 @@  static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev,
 
 	core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
 
+	se_tpg = core_get_tpg_by_rtpi(pr_reg->tg_pt_sep_rtpi);
+	if (se_tpg)
+		fabric_name = se_tpg->se_tpg_tfo->fabric_name;
+
 	return sprintf(page, "SPC-3 Reservation: %s Initiator: %s%s\n",
-		pr_reg->se_tpg->se_tpg_tfo->fabric_name,
-		pr_reg->pr_iport, i_buf);
+		fabric_name, pr_reg->pr_iport, i_buf);
 }
 
 static ssize_t target_core_dev_pr_show_spc2_res(struct se_device *dev,
@@ -1838,18 +1843,24 @@  static ssize_t target_pr_res_pr_holder_tg_port_show(struct config_item *item,
 		goto out_unlock;
 	}
 
-	se_tpg = pr_reg->se_tpg;
-	tfo = se_tpg->se_tpg_tfo;
-
-	len += sprintf(page+len, "SPC-3 Reservation: %s"
-		" Target Node Endpoint: %s\n", tfo->fabric_name,
-		tfo->tpg_get_wwn(se_tpg));
-	len += sprintf(page+len, "SPC-3 Reservation: Relative Port"
-		" Identifier Tag: %hu %s Portal Group Tag: %hu"
-		" %s Logical Unit: %llu\n", pr_reg->tg_pt_sep_rtpi,
-		tfo->fabric_name, tfo->tpg_get_tag(se_tpg),
-		tfo->fabric_name, pr_reg->pr_aptpl_target_lun);
+	se_tpg = core_get_tpg_by_rtpi(pr_reg->tg_pt_sep_rtpi);
+	if (se_tpg) {
+		tfo = se_tpg->se_tpg_tfo;
 
+		len += sprintf(page+len, "SPC-3 Reservation: %s Target Node Endpoint: %s\n",
+			tfo->fabric_name, tfo->tpg_get_wwn(se_tpg));
+		len += sprintf(page+len, "SPC-3 Reservation: Relative Port Identifier Tag: %hu %s Portal Group Tag: %hu %s Logical Unit: %llu\n",
+			pr_reg->tg_pt_sep_rtpi,
+			tfo->fabric_name, tfo->tpg_get_tag(se_tpg),
+			tfo->fabric_name, pr_reg->pr_aptpl_target_lun);
+	} else {
+		len += sprintf(page+len, "SPC-3 Reservation: %s Target Node Endpoint: %s\n",
+			"Unknown", "Unknown");
+		len += sprintf(page+len, "SPC-3 Reservation: Relative Port Identifier Tag: %hu %s Portal Group Tag: %hu %s Logical Unit: %llu\n",
+			pr_reg->tg_pt_sep_rtpi,
+			"Unknown", 0,
+			"Unknown", pr_reg->pr_aptpl_target_lun);
+	}
 out_unlock:
 	spin_unlock(&dev->dev_reservation_lock);
 	return len;
@@ -1860,8 +1871,9 @@  static ssize_t target_pr_res_pr_registered_i_pts_show(struct config_item *item,
 		char *page)
 {
 	struct se_device *dev = pr_to_dev(item);
-	const struct target_core_fabric_ops *tfo;
 	struct t10_pr_registration *pr_reg;
+	const char *fabric_name = "Unknown";
+	struct se_portal_group *se_tpg;
 	unsigned char buf[384];
 	char i_buf[PR_REG_ISID_ID_LEN];
 	ssize_t len = 0;
@@ -1875,11 +1887,14 @@  static ssize_t target_pr_res_pr_registered_i_pts_show(struct config_item *item,
 
 		memset(buf, 0, 384);
 		memset(i_buf, 0, PR_REG_ISID_ID_LEN);
-		tfo = pr_reg->se_tpg->se_tpg_tfo;
+		se_tpg = core_get_tpg_by_rtpi(pr_reg->tg_pt_sep_rtpi);
+		if (se_tpg)
+			fabric_name = se_tpg->se_tpg_tfo->fabric_name;
+
 		core_pr_dump_initiator_port(pr_reg, i_buf,
 					PR_REG_ISID_ID_LEN);
 		sprintf(buf, "%s Node: %s%s Key: 0x%016Lx PRgen: 0x%08x\n",
-			tfo->fabric_name,
+			fabric_name,
 			pr_reg->pr_iport, i_buf, pr_reg->pr_res_key,
 			pr_reg->pr_res_generation);
 
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index fc1b8f54fb54..fd8f3b4c4bf8 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -871,7 +871,7 @@  static ssize_t target_fabric_tpg_base_enable_store(struct config_item *item,
 	spin_lock(&g_tpg_lock);
 
 	if (op) {
-		tpg = core_get_tpg_by_rtpi(se_tpg->tpg_rtpi);
+		tpg = _core_get_tpg_by_rtpi(se_tpg->tpg_rtpi);
 		if (tpg) {
 			spin_unlock(&g_tpg_lock);
 
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 95d5add73578..51c0151c05c2 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -136,6 +136,7 @@  void core_tpg_remove_lun(struct se_portal_group *, struct se_lun *);
 struct se_node_acl *core_tpg_add_initiator_node_acl(struct se_portal_group *tpg,
 		const char *initiatorname);
 void core_tpg_del_initiator_node_acl(struct se_node_acl *acl);
+struct se_portal_group *_core_get_tpg_by_rtpi(u16 rtpi);
 struct se_portal_group *core_get_tpg_by_rtpi(u16 rtpi);
 
 /* target_core_transport.c */
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index d9e7d177b65a..c4ee6999cf96 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -612,7 +612,7 @@  struct t10_pr_registration *__core_scsi3_do_alloc_registration(
 	struct se_node_acl *nacl,
 	const char *initiatorname,
 	u64 unpacked_lun,
-	struct se_portal_group *se_tpg,
+	u16 rtpi,
 	struct se_dev_entry *dest_deve,
 	u64 mapped_lun,
 	unsigned char *isid,
@@ -661,8 +661,7 @@  struct t10_pr_registration *__core_scsi3_do_alloc_registration(
 	}
 	pr_reg->pr_res_mapped_lun = mapped_lun;
 	pr_reg->pr_aptpl_target_lun = unpacked_lun;
-	pr_reg->tg_pt_sep_rtpi = se_tpg->tpg_rtpi;
-	pr_reg->se_tpg = se_tpg;
+	pr_reg->tg_pt_sep_rtpi = rtpi;
 	pr_reg->pr_res_key = sa_res_key;
 	pr_reg->pr_reg_all_tg_pt = all_tg_pt;
 	pr_reg->pr_reg_aptpl = aptpl;
@@ -710,7 +709,7 @@  static struct t10_pr_registration *__core_scsi3_alloc_registration(
 	 */
 	pr_reg = __core_scsi3_do_alloc_registration(dev, nacl,
 						    nacl->initiatorname, lun->unpacked_lun,
-						    lun->lun_tpg,
+						    lun->lun_tpg->tpg_rtpi,
 						    deve, mapped_lun,
 						    isid, sa_res_key, all_tg_pt,
 						    aptpl);
@@ -797,7 +796,7 @@  static struct t10_pr_registration *__core_scsi3_alloc_registration(
 						nacl_tmp,
 						nacl_tmp->initiatorname,
 						dest_lun->unpacked_lun,
-						lun->lun_tpg,
+						lun->lun_tpg->tpg_rtpi,
 						deve_tmp,
 						deve_tmp->mapped_lun, NULL,
 						sa_res_key, all_tg_pt, aptpl);
@@ -1011,30 +1010,25 @@  int core_scsi3_check_aptpl_registration(
 }
 
 static void __core_scsi3_dump_registration(
-	const struct target_core_fabric_ops *tfo,
 	struct se_device *dev,
 	struct t10_pr_registration *pr_reg,
 	enum register_type register_type)
 {
-	struct se_portal_group *se_tpg = pr_reg->se_tpg;
 	char i_buf[PR_REG_ISID_ID_LEN] = { };
 
 	core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
 
-	pr_debug("SPC-3 PR [%s] Service Action: REGISTER%s Initiator"
-		" Node: %s%s\n", tfo->fabric_name, (register_type == REGISTER_AND_MOVE) ?
+	pr_debug("SPC-3 PR Service Action: REGISTER%s Initiator Node: %s%s\n",
+		(register_type == REGISTER_AND_MOVE) ?
 		"_AND_MOVE" : (register_type == REGISTER_AND_IGNORE_EXISTING_KEY) ?
 		"_AND_IGNORE_EXISTING_KEY" : "", pr_reg->pr_iport,
 		i_buf);
-	pr_debug("SPC-3 PR [%s] registration on Target Port: %s,0x%04x\n",
-		 tfo->fabric_name, tfo->tpg_get_wwn(se_tpg),
-		tfo->tpg_get_tag(se_tpg));
-	pr_debug("SPC-3 PR [%s] for %s TCM Subsystem %s Object Target"
-		" Port(s)\n",  tfo->fabric_name,
+	pr_debug("SPC-3 PR registration on Target Port: %d\n",
+		 pr_reg->tg_pt_sep_rtpi);
+	pr_debug("SPC-3 PR for %s TCM Subsystem %s Object Target Port(s)\n",
 		(pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE",
 		dev->transport->name);
-	pr_debug("SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:"
-		" 0x%08x  APTPL: %d\n", tfo->fabric_name,
+	pr_debug("SPC-3 PR SA Res Key: 0x%016llx PRgeneration: 0x%08x  APTPL: %d\n",
 		pr_reg->pr_res_key, pr_reg->pr_res_generation,
 		pr_reg->pr_reg_aptpl);
 }
@@ -1046,7 +1040,6 @@  static void __core_scsi3_add_registration(
 	enum register_type register_type,
 	int register_move)
 {
-	const struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
 	struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe;
 	struct t10_reservation *pr_tmpl = &dev->t10_pr;
 	struct se_dev_entry *deve;
@@ -1060,7 +1053,7 @@  static void __core_scsi3_add_registration(
 	spin_lock(&pr_tmpl->registration_lock);
 	list_add_tail(&pr_reg->pr_reg_list, &pr_tmpl->registration_list);
 
-	__core_scsi3_dump_registration(tfo, dev, pr_reg, register_type);
+	__core_scsi3_dump_registration(dev, pr_reg, register_type);
 	spin_unlock(&pr_tmpl->registration_lock);
 	/*
 	 * Skip extra processing for ALL_TG_PT=0 or REGISTER_AND_MOVE.
@@ -1081,8 +1074,7 @@  static void __core_scsi3_add_registration(
 		list_add_tail(&pr_reg_tmp->pr_reg_list,
 			      &pr_tmpl->registration_list);
 
-		__core_scsi3_dump_registration(tfo, dev, pr_reg_tmp,
-					       register_type);
+		__core_scsi3_dump_registration(dev, pr_reg_tmp, register_type);
 		spin_unlock(&pr_tmpl->registration_lock);
 		/*
 		 * Drop configfs group dependency reference and deve->pr_kref
@@ -1262,8 +1254,6 @@  void __core_scsi3_free_registration(
 	__releases(&pr_tmpl->registration_lock)
 	__acquires(&pr_tmpl->registration_lock)
 {
-	const struct target_core_fabric_ops *tfo =
-			pr_reg->se_tpg->se_tpg_tfo;
 	struct t10_reservation *pr_tmpl = &dev->t10_pr;
 	struct se_node_acl *nacl = pr_reg->pr_reg_nacl;
 	struct se_dev_entry *deve;
@@ -1290,8 +1280,7 @@  void __core_scsi3_free_registration(
 	 * count back to zero, and we release *pr_reg.
 	 */
 	while (atomic_read(&pr_reg->pr_res_holders) != 0) {
-		pr_debug("SPC-3 PR [%s] waiting for pr_res_holders\n",
-				tfo->fabric_name);
+		pr_debug("SPC-3 PR waiting for pr_res_holders\n");
 		cpu_relax();
 	}
 
@@ -1302,15 +1291,13 @@  void __core_scsi3_free_registration(
 	rcu_read_unlock();
 
 	spin_lock(&pr_tmpl->registration_lock);
-	pr_debug("SPC-3 PR [%s] Service Action: UNREGISTER Initiator"
-		" Node: %s%s\n", tfo->fabric_name,
-		pr_reg->pr_iport, i_buf);
-	pr_debug("SPC-3 PR [%s] for %s TCM Subsystem %s Object Target"
-		" Port(s)\n", tfo->fabric_name,
+	pr_debug("SPC-3 PR Service Action: UNREGISTER Initiator Node: %s%s\n",
+		 pr_reg->pr_iport, i_buf);
+	pr_debug("SPC-3 PR for %s TCM Subsystem %s Object Target Port(s)\n",
 		(pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE",
 		dev->transport->name);
-	pr_debug("SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:"
-		" 0x%08x\n", tfo->fabric_name, pr_reg->pr_res_key,
+	pr_debug("SPC-3 PR SA Res Key: 0x%016llx PRgeneration: 0x%08x\n",
+		pr_reg->pr_res_key,
 		pr_reg->pr_res_generation);
 
 	if (!preempt_and_abort_list) {
@@ -1830,7 +1817,9 @@  static int core_scsi3_update_aptpl_buf(
 
 		tmp[0] = '\0';
 		isid_buf[0] = '\0';
-		tpg = pr_reg->se_tpg;
+
+		tpg = core_get_tpg_by_rtpi(pr_reg->tg_pt_sep_rtpi);
+
 		/*
 		 * Write out any ISID value to APTPL metadata that was included
 		 * in the original registration.
@@ -1874,13 +1863,21 @@  static int core_scsi3_update_aptpl_buf(
 		/*
 		 * Include information about the associated SCSI target port.
 		 */
-		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,
-			reg_count);
-
+		if (tpg) {
+			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,
+				reg_count);
+		} else {
+			snprintf(tmp, 512, "target_node=%s\n"
+				"tpgt=%hu\nport_rtpi=%hu\ntarget_lun=%llu\nPR_REG_END: %d\n",
+				"",
+				0,
+				pr_reg->tg_pt_sep_rtpi, pr_reg->pr_aptpl_target_lun,
+				reg_count);
+		}
 		if ((len + strlen(tmp) >= pr_aptpl_buf_len)) {
 			pr_err("Unable to update renaming APTPL metadata,"
 			       " reallocating larger buffer\n");
@@ -2224,12 +2221,10 @@  void __core_scsi3_set_reservation(struct se_device *dev,
 	dev->dev_pr_res_holder = pr_reg;
 	core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
 
-	pr_debug("SPC-3 PR [%s] Service Action: RESERVE created new reservation holder TYPE: %s ALL_TG_PT: %d\n",
-		pr_reg->se_tpg->se_tpg_tfo->fabric_name,
+	pr_debug("SPC-3 PR Service Action: RESERVE created new reservation holder TYPE: %s ALL_TG_PT: %d\n",
 		core_scsi3_pr_dump_type(type),
 		(pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
-	pr_debug("SPC-3 PR [%s] RESERVE Node: %s%s\n",
-			pr_reg->se_tpg->se_tpg_tfo->fabric_name,
+	pr_debug("SPC-3 PR RESERVE Node: %s%s\n",
 			pr_reg->pr_iport,
 			i_buf);
 }
@@ -2308,12 +2303,10 @@  core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key)
 		 * RESERVATION CONFLICT status.
 		 */
 		if (!is_reservation_holder(pr_res_holder, pr_reg)) {
-			pr_err("SPC-3 PR: Attempted RESERVE from"
-				" [%s]: %s while reservation already held by"
-				" [%s]: %s, returning RESERVATION_CONFLICT\n",
-				cmd->se_tfo->fabric_name,
+			pr_err("SPC-3 PR: Attempted RESERVE from [%d]: %s while reservation already held by [%d]: %s, returning RESERVATION_CONFLICT\n",
+				cmd->se_lun->lun_tpg->tpg_rtpi,
 				se_sess->se_node_acl->initiatorname,
-				pr_res_holder->se_tpg->se_tpg_tfo->fabric_name,
+				pr_res_holder->tg_pt_sep_rtpi,
 				pr_res_holder->pr_iport);
 
 			spin_unlock(&dev->dev_reservation_lock);
@@ -2329,13 +2322,10 @@  core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key)
 		 */
 		if ((pr_res_holder->pr_res_type != type) ||
 		    (pr_res_holder->pr_res_scope != scope)) {
-			pr_err("SPC-3 PR: Attempted RESERVE from"
-				" [%s]: %s trying to change TYPE and/or SCOPE,"
-				" while reservation already held by [%s]: %s,"
-				" returning RESERVATION_CONFLICT\n",
-				cmd->se_tfo->fabric_name,
+			pr_err("SPC-3 PR: Attempted RESERVE from [%d]: %s trying to change TYPE and/or SCOPE, while reservation already held by [%d]: %s, returning RESERVATION_CONFLICT\n",
+				cmd->se_lun->lun_tpg->tpg_rtpi,
 				se_sess->se_node_acl->initiatorname,
-				pr_res_holder->se_tpg->se_tpg_tfo->fabric_name,
+				pr_res_holder->tg_pt_sep_rtpi,
 				pr_res_holder->pr_iport);
 
 			spin_unlock(&dev->dev_reservation_lock);
@@ -2397,7 +2387,6 @@  void __core_scsi3_complete_pro_release(
 	int explicit,
 	int unreg)
 {
-	const struct target_core_fabric_ops *tfo = pr_reg->se_tpg->se_tpg_tfo;
 	char i_buf[PR_REG_ISID_ID_LEN] = { };
 	int pr_res_type = 0, pr_res_scope = 0;
 
@@ -2442,15 +2431,14 @@  void __core_scsi3_complete_pro_release(
 	spin_unlock(&dev->t10_pr.registration_lock);
 out:
 	if (!dev->dev_pr_res_holder) {
-		pr_debug("SPC-3 PR [%s] Service Action: %s RELEASE cleared"
+		pr_debug("SPC-3 PR Service Action: %s RELEASE cleared"
 			" reservation holder TYPE: %s ALL_TG_PT: %d\n",
-			tfo->fabric_name, (explicit) ? "explicit" :
+			(explicit) ? "explicit" :
 			"implicit", core_scsi3_pr_dump_type(pr_res_type),
 			(pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
 	}
-	pr_debug("SPC-3 PR [%s] RELEASE Node: %s%s\n",
-		tfo->fabric_name, pr_reg->pr_iport,
-		i_buf);
+	pr_debug("SPC-3 PR RELEASE Node: %s%s\n",
+		 pr_reg->pr_iport, i_buf);
 	/*
 	 * Clear TYPE and SCOPE for the next PROUT Service Action: RESERVE
 	 */
@@ -2542,13 +2530,10 @@  core_scsi3_emulate_pro_release(struct se_cmd *cmd, int type, int scope,
 	 */
 	if ((pr_res_holder->pr_res_type != type) ||
 	    (pr_res_holder->pr_res_scope != scope)) {
-		pr_err("SPC-3 PR RELEASE: Attempted to release"
-			" reservation from [%s]: %s with different TYPE "
-			"and/or SCOPE  while reservation already held by"
-			" [%s]: %s, returning RESERVATION_CONFLICT\n",
-			cmd->se_tfo->fabric_name,
+		pr_err("SPC-3 PR RELEASE: Attempted to release reservation from [%d]: %s with different TYPE and/or SCOPE  while reservation already held by [%d]: %s, returning RESERVATION_CONFLICT\n",
+			cmd->se_lun->lun_tpg->tpg_rtpi,
 			se_sess->se_node_acl->initiatorname,
-			pr_res_holder->se_tpg->se_tpg_tfo->fabric_name,
+			pr_res_holder->tg_pt_sep_rtpi,
 			pr_res_holder->pr_iport);
 
 		spin_unlock(&dev->dev_reservation_lock);
@@ -2701,7 +2686,6 @@  static void __core_scsi3_complete_pro_preempt(
 	int scope,
 	enum preempt_type preempt_type)
 {
-	const struct target_core_fabric_ops *tfo = pr_reg->se_tpg->se_tpg_tfo;
 	char i_buf[PR_REG_ISID_ID_LEN] = { };
 
 	lockdep_assert_held(&dev->dev_reservation_lock);
@@ -2718,13 +2702,13 @@  static void __core_scsi3_complete_pro_preempt(
 	pr_reg->pr_res_type = type;
 	pr_reg->pr_res_scope = scope;
 
-	pr_debug("SPC-3 PR [%s] Service Action: PREEMPT%s created new"
+	pr_debug("SPC-3 PR Service Action: PREEMPT%s created new"
 		" reservation holder TYPE: %s ALL_TG_PT: %d\n",
-		tfo->fabric_name, (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
+		(preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
 		core_scsi3_pr_dump_type(type),
 		(pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
-	pr_debug("SPC-3 PR [%s] PREEMPT%s from Node: %s%s\n",
-		tfo->fabric_name, (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
+	pr_debug("SPC-3 PR PREEMPT%s from Node: %s%s\n",
+		(preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : "",
 		pr_reg->pr_iport, i_buf);
 	/*
 	 * For PREEMPT_AND_ABORT, add the preempting reservation's
diff --git a/drivers/target/target_core_pr.h b/drivers/target/target_core_pr.h
index e4bdabfc4b31..954b0dff32bf 100644
--- a/drivers/target/target_core_pr.h
+++ b/drivers/target/target_core_pr.h
@@ -86,7 +86,7 @@  struct t10_pr_registration *__core_scsi3_do_alloc_registration(
 					struct se_node_acl *nacl,
 					const char *initiatorname,
 					u64 unpacked_lun,
-					struct se_portal_group *se_tpg,
+					u16 rtpi,
 					struct se_dev_entry *dest_deve,
 					u64 mapped_lun,
 					unsigned char *isid,
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 5a81d592530f..bdcd65ce0f62 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -738,8 +738,9 @@  static ssize_t core_tpg_rtpi_show(struct config_item *item, char *page)
 	return sprintf(page, "%#x\n", se_tpg->tpg_rtpi);
 }
 
+
 struct se_portal_group *
-core_get_tpg_by_rtpi(u16 rtpi)
+_core_get_tpg_by_rtpi(u16 rtpi)
 {
 	struct se_portal_group *tpg;
 
@@ -753,6 +754,18 @@  core_get_tpg_by_rtpi(u16 rtpi)
 	return NULL;
 }
 
+struct se_portal_group *
+core_get_tpg_by_rtpi(u16 rtpi)
+{
+	struct se_portal_group *tpg;
+
+	spin_lock(&g_tpg_lock);
+	tpg = _core_get_tpg_by_rtpi(rtpi);
+	spin_unlock(&g_tpg_lock);
+
+	return tpg;
+}
+
 static ssize_t core_tpg_rtpi_store(struct config_item *item,
 				   const char *page, size_t count)
 {
@@ -773,7 +786,7 @@  static ssize_t core_tpg_rtpi_store(struct config_item *item,
 	spin_lock(&g_tpg_lock);
 
 	if (se_tpg->enabled) {
-		tpg = core_get_tpg_by_rtpi(val);
+		tpg = _core_get_tpg_by_rtpi(val);
 		if (tpg) {
 			spin_unlock(&g_tpg_lock);
 			pr_err("TARGET_CORE[%s]->TPG[%u] - RTPI %#x conflicts with TARGET_CORE[%s]->TPG[%u]\n",
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 64cb943b5d3a..5378e2d3825f 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -366,7 +366,6 @@  struct t10_pr_registration {
 	u64 pr_res_key;
 	atomic_t pr_res_holders;
 	struct se_node_acl *pr_reg_nacl;
-	struct se_portal_group *se_tpg;
 	/* Used by ALL_TG_PT=1 registration with deve->pr_ref taken */
 	struct se_dev_entry *pr_reg_deve;
 	struct list_head pr_reg_list;