diff mbox series

[RFC,45/48] target: cluster: add reset cluster function

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

Commit Message

Dmitry Bogdanov March 11, 2022, 8:40 a.m. UTC
Introduce `reset' function pointer in target cluster ops.
For no cluster case do just clear SCSI2 reservation status.

Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
 drivers/target/target_core_device.c | 9 +++++++++
 drivers/target/target_core_tmr.c    | 9 +--------
 include/target/target_core_base.h   | 1 +
 3 files changed, 11 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 4f36d12d2213..7d0d889961c2 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -802,6 +802,14 @@  static void target_reserve2_nodlm(struct se_device *dev, struct se_session *sess
 	}
 }
 
+static void target_reset_nodlm(struct se_device *dev)
+{
+	if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) {
+		target_release_reservation(dev);
+		pr_debug("LUN_RESET: SCSI-2 Released reservation\n");
+	}
+}
+
 const struct target_cluster_ops nodlm_cluster_ops = {
 	.name = "single",
 	.owner = NULL,
@@ -813,6 +821,7 @@  const struct target_cluster_ops nodlm_cluster_ops = {
 	.pr_unlock = target_dummy_nodlm,
 	.pr_sync = target_prsync_nodlm,
 	.reserve = target_reserve2_nodlm,
+	.reset = target_reset_nodlm,
 };
 
 struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index 6984bfa976a4..878401ab8145 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -402,14 +402,7 @@  int core_tmr_lun_reset(
 {
 	core_local_lun_reset(dev, tmr, NULL, NULL);
 
-	/*
-	 * Clear any legacy SPC-2 reservation when called during
-	 * LOGICAL UNIT RESET
-	 */
-	if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) {
-		dev->cl_ops->reserve(dev, NULL);
-		pr_debug("LUN_RESET: SCSI-2 Released reservation\n");
-	}
+	dev->cl_ops->reset(dev);
 
 	target_dev_ua_allocate(dev, 0x29,
 			ASCQ_29H_BUS_DEVICE_RESET_FUNCTION_OCCURRED);
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index af3c972c3376..c8900da705b6 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -791,6 +791,7 @@  struct target_cluster_ops {
 	int (*pr_unlock)(struct se_device *dev);
 	int (*pr_sync)(struct se_device *dev, u8 pro_sa);
 	void (*reserve)(struct se_device *dev, struct se_session *sess);
+	void (*reset)(struct se_device *dev);
 };
 
 struct se_device {