diff mbox series

[RFC,17/48] target: core: make some functions public

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

Commit Message

Dmitry Bogdanov Dec. 10, 2021, 12:43 p.m. UTC
Make functions of alloc/free and reserve/release reservation be public
to use them from cluster code.

Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
 drivers/target/target_core_pr.c | 51 +++++++++++++++++++--------------
 drivers/target/target_core_pr.h | 24 ++++++++++++++++
 2 files changed, 54 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index aa967ea74e5b..aaa383e1ee58 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -64,9 +64,6 @@  enum preempt_type {
 	PREEMPT_AND_ABORT,
 };
 
-static void __core_scsi3_complete_pro_release(struct se_device *,
-					      struct t10_pr_registration *, int, int);
-
 static int is_reservation_holder(
 	struct t10_pr_registration *pr_res_holder,
 	struct t10_pr_registration *pr_reg)
@@ -606,7 +603,7 @@  static u32 core_scsi3_pr_generation(struct se_device *dev)
 	return atomic_inc_return(&dev->t10_pr.pr_generation);
 }
 
-static struct t10_pr_registration *__core_scsi3_do_alloc_registration(
+struct t10_pr_registration *__core_scsi3_do_alloc_registration(
 	struct se_device *dev,
 	struct se_node_acl *nacl,
 	const char *initiatorname,
@@ -1261,7 +1258,7 @@  static int core_scsi3_check_implicit_release(
 	return ret;
 }
 
-static void __core_scsi3_free_registration(
+void __core_scsi3_free_registration(
 	struct se_device *dev,
 	struct t10_pr_registration *pr_reg,
 	struct list_head *preempt_and_abort_list,
@@ -2219,6 +2216,32 @@  unsigned char *core_scsi3_pr_dump_type(int type)
 	return "Unknown SPC-3 PR Type";
 }
 
+void __core_scsi3_set_reservation(struct se_device *dev,
+				  struct t10_pr_registration *pr_reg,
+				  int scope, int type)
+{
+	char i_buf[PR_REG_ISID_ID_LEN];
+
+	memset(i_buf, 0, PR_REG_ISID_ID_LEN);
+
+	lockdep_assert_held(&dev->dev_reservation_lock);
+
+	pr_reg->pr_res_scope = scope;
+	pr_reg->pr_res_type = type;
+	pr_reg->pr_res_holder = 1;
+	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,
+		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_reg->pr_iport,
+			i_buf);
+}
+
 static sense_reason_t
 core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key)
 {
@@ -2227,7 +2250,6 @@  core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key)
 	struct se_lun *se_lun = cmd->se_lun;
 	struct t10_pr_registration *pr_reg, *pr_res_holder;
 	struct t10_reservation *pr_tmpl = &dev->t10_pr;
-	char i_buf[PR_REG_ISID_ID_LEN] = { };
 	sense_reason_t ret;
 
 	if (!se_sess || !se_lun) {
@@ -2346,20 +2368,7 @@  core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key)
 	 * Otherwise, our *pr_reg becomes the PR reservation holder for said
 	 * TYPE/SCOPE.  Also set the received scope and type in *pr_reg.
 	 */
-	pr_reg->pr_res_scope = scope;
-	pr_reg->pr_res_type = type;
-	pr_reg->pr_res_holder = 1;
-	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",
-		cmd->se_tfo->fabric_name, 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",
-			cmd->se_tfo->fabric_name,
-			se_sess->se_node_acl->initiatorname,
-			i_buf);
+	__core_scsi3_set_reservation(dev, pr_reg, scope, type);
 	spin_unlock(&dev->dev_reservation_lock);
 
 	if (pr_tmpl->pr_aptpl_active)
@@ -2390,7 +2399,7 @@  core_scsi3_emulate_pro_reserve(struct se_cmd *cmd, int type, int scope,
 	}
 }
 
-static void __core_scsi3_complete_pro_release(
+void __core_scsi3_complete_pro_release(
 	struct se_device *dev,
 	struct t10_pr_registration *pr_reg,
 	int explicit,
diff --git a/drivers/target/target_core_pr.h b/drivers/target/target_core_pr.h
index 202f9aec963a..9c4710f34d94 100644
--- a/drivers/target/target_core_pr.h
+++ b/drivers/target/target_core_pr.h
@@ -75,4 +75,28 @@  extern sense_reason_t target_scsi3_emulate_pr_in(struct se_cmd *);
 extern sense_reason_t target_scsi3_emulate_pr_out(struct se_cmd *);
 extern sense_reason_t target_check_reservation(struct se_cmd *);
 
+void __core_scsi3_set_reservation(struct se_device *dev,
+				  struct t10_pr_registration *pr_reg,
+				  int scope, int type);
+void __core_scsi3_complete_pro_release(struct se_device *dev,
+				       struct t10_pr_registration *pr_reg,
+				       int explicit, int unreg);
+struct t10_pr_registration *__core_scsi3_do_alloc_registration(
+					struct se_device *dev,
+					struct se_node_acl *nacl,
+					const char *initiatorname,
+					u64 unpacked_lun,
+					struct se_portal_group *se_tpg,
+					struct se_dev_entry *dest_deve,
+					u64 mapped_lun,
+					unsigned char *isid,
+					u64 sa_res_key,
+					int all_tg_pt,
+					int aptpl);
+void __core_scsi3_free_registration(struct se_device *dev,
+				    struct t10_pr_registration *pr_reg,
+				    struct list_head *preempt_and_abort_list,
+				    int dec_holders);
+
+
 #endif /* TARGET_CORE_PR_H */