diff mbox series

[RFC,21/48] target: core: checks against peer node SCSI2 reservation

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

Commit Message

Dmitry Bogdanov Dec. 13, 2021, 7:28 p.m. UTC
For the case of SCSI-2 reservation by peer node dev->reservation_holder
session is NULL. So use this information as reservation existence.

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

Patch

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 2f4c65d5d766..c4329f639323 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -95,7 +95,8 @@  target_scsi2_reservation_check(struct se_cmd *cmd)
 		break;
 	}
 
-	if (dev->reservation_holder->se_node_acl != sess->se_node_acl)
+	if (!dev->reservation_holder ||
+	    dev->reservation_holder->se_node_acl != sess->se_node_acl)
 		return TCM_RESERVATION_CONFLICT;
 
 	if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS_WITH_ISID) {
@@ -211,6 +212,9 @@  target_scsi2_reservation_release(struct se_cmd *cmd)
 	if (!(dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS))
 		goto out_unlock;
 
+	if (!dev->reservation_holder)
+		goto out_unlock;
+
 	if (dev->reservation_holder->se_node_acl != sess->se_node_acl)
 		goto out_unlock;
 
@@ -262,12 +266,15 @@  target_scsi2_reservation_reserve(struct se_cmd *cmd)
 	tpg = sess->se_tpg;
 	spin_lock(&dev->dev_reservation_lock);
 	if ((dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) &&
-	     dev->reservation_holder->se_node_acl != sess->se_node_acl) {
+	    (!dev->reservation_holder ||
+	     dev->reservation_holder->se_node_acl != sess->se_node_acl)) {
 		pr_err("SCSI-2 RESERVATION CONFLICT for %s fabric\n",
 			tpg->se_tpg_tfo->fabric_name);
 		pr_err("Original reserver LUN: %llu %s\n",
 			cmd->se_lun->unpacked_lun,
-			dev->reservation_holder->se_node_acl->initiatorname);
+			(dev->reservation_holder) ?
+			 dev->reservation_holder->se_node_acl->initiatorname :
+			 "peer");
 		pr_err("Current attempt - LUN: %llu -> MAPPED LUN: %llu"
 			" from %s \n", cmd->se_lun->unpacked_lun,
 			cmd->orig_fe_lun,