diff mbox series

[RFC,13/48] target: core: abort all preempted regs if requested

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

Commit Message

Dmitry Bogdanov March 4, 2022, 10:44 a.m. UTC
According to SPC the aborting shall always happened.

SPC-4: 5.12.11.2.6 Preempting and aborting
 If the SERVICE ACTION RESERVATION KEY field is set to zero and an all
 registrants persistent reservation is present, the device server shall
 abort all commands for all registered I_T nexuses.

Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
 drivers/target/target_core_pr.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 0b3a22f51c5e..b943f8f379cf 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -2956,9 +2956,23 @@  core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
 				type, scope, preempt_type);
 		}
 
-		if (preempt_type == PREEMPT_AND_ABORT)
+		/*
+		 * SPC-4 5.12.11.2.6 Preempting and aborting
+		 * The actions described in this subclause shall be performed
+		 * for all I_T nexuses that are registered with the non-zero
+		 * SERVICE ACTION RESERVATION KEY value, without regard for
+		 * whether the preempted I_T nexuses hold the persistent
+		 * reservation. If the SERVICE ACTION RESERVATION KEY field is
+		 * set to zero and an all registrants persistent reservation is
+		 * present, the device server shall abort all commands for all
+		 * registered I_T nexuses.
+		 */
+		if (preempt_type == PREEMPT_AND_ABORT) {
+			core_tmr_lun_reset(dev, NULL, &preempt_and_abort_list,
+					   cmd);
 			core_scsi3_release_preempt_and_abort(
 				&preempt_and_abort_list, pr_reg_n);
+		}
 
 		spin_unlock(&dev->dev_reservation_lock);