diff mbox series

[RFC,20/48] target: core: proper check of SCSI-2 reservation

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

Commit Message

Dmitry Bogdanov Dec. 13, 2021, 7:20 p.m. UTC
Use a check of the flag instead of session pointer like in other places.

Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
 drivers/target/target_core_configfs.c | 17 +++++++++++------
 drivers/target/target_core_pr.c       |  6 +++---
 2 files changed, 14 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 6e654edc4399..34901f0b2350 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1756,12 +1756,17 @@  static ssize_t target_core_dev_pr_show_spc2_res(struct se_device *dev,
 	struct se_node_acl *se_nacl;
 	ssize_t len;
 
-	if (sess) {
-		se_nacl = sess->se_node_acl;
-		len = sprintf(page,
-			      "SPC-2 Reservation: %s Initiator: %s\n",
-			      se_nacl->se_tpg->se_tpg_tfo->fabric_name,
-			      se_nacl->initiatorname);
+	if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) {
+		if (sess) {
+			se_nacl = sess->se_node_acl;
+			len = sprintf(page,
+				"SPC-2 Reservation: %s Initiator: %s\n",
+				se_nacl->se_tpg->se_tpg_tfo->fabric_name,
+				se_nacl->initiatorname);
+		} else {
+			len = sprintf(page,
+				"SPC-2 Reservation: peer node\n");
+		}
 	} else {
 		len = sprintf(page, "No SPC-2 Reservation holder\n");
 	}
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 4bb16de29a1e..2f4c65d5d766 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -208,7 +208,7 @@  target_scsi2_reservation_release(struct se_cmd *cmd)
 		return TCM_RESERVATION_CONFLICT;
 
 	spin_lock(&dev->dev_reservation_lock);
-	if (!dev->reservation_holder)
+	if (!(dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS))
 		goto out_unlock;
 
 	if (dev->reservation_holder->se_node_acl != sess->se_node_acl)
@@ -261,8 +261,8 @@  target_scsi2_reservation_reserve(struct se_cmd *cmd)
 
 	tpg = sess->se_tpg;
 	spin_lock(&dev->dev_reservation_lock);
-	if (dev->reservation_holder &&
-	    dev->reservation_holder->se_node_acl != sess->se_node_acl) {
+	if ((dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) &&
+	     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",