All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Bogdanov <d.bogdanov@yadro.com>
To: Martin Petersen <martin.petersen@oracle.com>,
	<target-devel@vger.kernel.org>
Cc: <linux-scsi@vger.kernel.org>, <linux@yadro.com>,
	Dmitry Bogdanov <d.bogdanov@yadro.com>
Subject: [RFC PATCH 26/48] target: core: pr: remove se_tpg from pr_reg
Date: Wed, 22 Jun 2022 13:25:24 +0300	[thread overview]
Message-ID: <20220803162857.27770-27-d.bogdanov@yadro.com> (raw)
In-Reply-To: <20220803162857.27770-1-d.bogdanov@yadro.com>

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 --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;
-- 
2.25.1


  parent reply	other threads:[~2022-08-03 16:29 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 16:04 [RFC PATCH 00/48] Target cluster implementation over DLM Dmitry Bogdanov
2019-12-21  0:53 ` [RFC PATCH 07/48] scsi: target/core: Add common port attributes Dmitry Bogdanov
2019-12-21 23:45 ` [RFC PATCH 05/48] scsi: target/core: Use RTPI from target port Dmitry Bogdanov
2019-12-21 23:49 ` [RFC PATCH 06/48] scsi: target/core: Drop device-based RTPI Dmitry Bogdanov
2020-04-04 10:48 ` [RFC PATCH 01/48] scsi: target/core: Add a way to hide a port group Dmitry Bogdanov
2020-04-20  0:18 ` [RFC PATCH 02/48] scsi: target/core: Set MULTIP bit for se_device with multiple ports Dmitry Bogdanov
2020-04-20 17:20 ` [RFC PATCH 03/48] scsi: target/core: Add cleanup sequence in core_tpg_register() Dmitry Bogdanov
2020-04-20 17:57 ` [RFC PATCH 04/48] scsi: target/core: Add RTPI field to target port Dmitry Bogdanov
2020-04-21 14:00 ` [RFC PATCH 08/48] scsi: target/core: Add RTPI attribute for " Dmitry Bogdanov
2020-04-30 14:16 ` [RFC PATCH 10/48] scsi: target/core: Unlock PR generation bump Dmitry Bogdanov
2021-02-25 12:18 ` [RFC PATCH 09/48] target: core: check RTPI uniquity for enabled TPG Dmitry Bogdanov
2021-11-17 11:12 ` [RFC PATCH 36/48] target: cluster: introduce cluster ops Dmitry Bogdanov
2021-11-18  7:52 ` [RFC PATCH 31/48] dlm_ckv: introduce DLM cluster key-value storage Dmitry Bogdanov
2021-11-22 17:07 ` [RFC PATCH 32/48] dlm_ckv: add notification service Dmitry Bogdanov
2021-11-22 17:12 ` [RFC PATCH 33/48] dlm_ckv: add key-value storage service Dmitry Bogdanov
2021-11-29  9:00 ` [RFC PATCH 38/48] target: cluster: store PR data in DLM cluster Dmitry Bogdanov
2021-12-01 15:42 ` [RFC PATCH 15/48] target: core: remove unused variable in se_dev_entry Dmitry Bogdanov
2021-12-06 10:56 ` [RFC PATCH 14/48] target: core: new key must be used for moved PR Dmitry Bogdanov
2021-12-06 13:39 ` [RFC PATCH 39/48] target: cluster: read PR data from cluster Dmitry Bogdanov
2021-12-07  9:47 ` [RFC PATCH 35/48] target: add virtual remote target Dmitry Bogdanov
2021-12-10 12:43 ` [RFC PATCH 17/48] target: core: make some functions public Dmitry Bogdanov
2021-12-13 18:58 ` [RFC PATCH 18/48] target: core: proper clear reservation on LUN RESET Dmitry Bogdanov
2021-12-13 19:15 ` [RFC PATCH 19/48] target: core: remove superfluous checks Dmitry Bogdanov
2021-12-13 19:20 ` [RFC PATCH 20/48] target: core: proper check of SCSI-2 reservation Dmitry Bogdanov
2021-12-13 19:28 ` [RFC PATCH 21/48] target: core: checks against peer node SCSI2 reservation Dmitry Bogdanov
2021-12-16 10:20 ` [RFC PATCH 42/48] target: cluster: sync SPC-2 reservations Dmitry Bogdanov
2021-12-17  9:27 ` [RFC PATCH 41/48] target: cluster: sync-up PR data on cluster join Dmitry Bogdanov
2021-12-22 12:38 ` [RFC PATCH 34/48] dlm_ckv: add KV get/set async API Dmitry Bogdanov
2021-12-24  9:45 ` [RFC PATCH 16/48] target: core: undepend PR registrant of nacl Dmitry Bogdanov
2021-12-24  9:52 ` [RFC PATCH 40/48] target: cluster: sync PR for dynamic acls Dmitry Bogdanov
2022-02-28 10:37 ` [RFC PATCH 43/48] target: cluster: allocate UAs on PR sync Dmitry Bogdanov
2022-03-02  7:13 ` [RFC PATCH 12/48] target: core: fix memory leak in preempt_and_abort Dmitry Bogdanov
2022-03-04 10:38 ` [RFC PATCH 11/48] target: core: fix preempt and abort for allreg res Dmitry Bogdanov
2022-03-04 10:44 ` [RFC PATCH 13/48] target: core: abort all preempted regs if requested Dmitry Bogdanov
2022-03-04 12:35 ` [RFC PATCH 44/48] target: cluster: support PR OUT preempt and abort Dmitry Bogdanov
2022-03-11  8:11 ` [RFC PATCH 22/48] target: core: UA on all luns after reset Dmitry Bogdanov
2022-03-11  8:33 ` [RFC PATCH 23/48] target: core: refactor LUN_RESET code Dmitry Bogdanov
2022-03-11  8:40 ` [RFC PATCH 45/48] target: cluster: add reset cluster function Dmitry Bogdanov
2022-03-11  9:30 ` [RFC PATCH 46/48] target: cluster: implement LUN reset in DLM cluster Dmitry Bogdanov
2022-03-25  6:35 ` [RFC PATCH 47/48] target: cluster: split cluster sync function Dmitry Bogdanov
2022-03-25  7:58 ` [RFC PATCH 48/48] target: cluster: request data on initial sync Dmitry Bogdanov
2022-06-21 13:05 ` [RFC PATCH 24/48] target: core: pr: use RTPI in APTPL Dmitry Bogdanov
2022-06-22 10:25 ` Dmitry Bogdanov [this message]
2022-06-29  7:50 ` [RFC PATCH 27/48] target: core: fix parsing PR OUT TID Dmitry Bogdanov
2022-06-29 10:06 ` [RFC PATCH 28/48] target: core: add function to compare TransportID Dmitry Bogdanov
2022-06-30 11:11 ` [RFC PATCH 29/48] target: core: store proto_id in APTPL Dmitry Bogdanov
2022-07-01  7:26 ` [RFC PATCH 30/48] target: core: rethink APTPL registrations Dmitry Bogdanov
2022-07-22 14:59 ` [RFC PATCH 37/48] target: cluster: introduce dlm cluster Dmitry Bogdanov
2022-07-27 16:21 ` [RFC PATCH 25/48] target: core: pr: have Transport ID stored Dmitry Bogdanov
2022-08-03 17:36 ` [RFC PATCH 00/48] Target cluster implementation over DLM Mike Christie
2022-08-04 11:01   ` Dmitry Bogdanov
2022-08-05 20:01 [RFC PATCH 27/48] target: core: fix parsing PR OUT TID kernel test robot
2022-08-08 10:31 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220803162857.27770-27-d.bogdanov@yadro.com \
    --to=d.bogdanov@yadro.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@yadro.com \
    --cc=martin.petersen@oracle.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.