Blob Blame History Raw
From 20715c075e398ebb3355b9de1b3a8a725d5262df Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Mon, 3 Jul 2023 17:04:04 +0200
Subject: [PATCH 1/3] target_core_rbd: remove snapshot existence validation
 code
References: bsc#1212857
Patch-mainline: Never, legacy SES clustered LIO/RBD

This is a port of mainline rbd 686238b7431dcca870ff0bc8ae280cdc89ee41c7
for target_core_rbd:

RBD_DEV_FLAG_EXISTS check in rbd_queue_workfn() is racy and leads to
inconsistent behaviour.  If the object (or its snapshot) isn't there,
the OSD returns ENOENT.  A read submitted before the snapshot removal
notification is processed would be zero-filled and ended with status
OK, while future reads would be failed with IOERR.  It also doesn't
handle a case when an image that is mapped read-only is removed.

On top of this, because watch is no longer established for read-only
mappings, we no longer get notifications, so rbd_exists_validate() is
effectively dead code.  While failing requests rather than returning
zeros is a good thing, RBD_DEV_FLAG_EXISTS is not it.

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 drivers/target/target_core_rbd.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/drivers/target/target_core_rbd.c b/drivers/target/target_core_rbd.c
index f28fb58c0505..e6de5fcb4f5b 100644
--- a/drivers/target/target_core_rbd.c
+++ b/drivers/target/target_core_rbd.c
@@ -312,19 +312,6 @@ tcm_rbd_execute_cmd(struct se_cmd *cmd, struct rbd_device *rbd_dev,
 		goto err;
 	}
 
-	/*
-	 * Quit early if the mapped snapshot no longer exists.  It's
-	 * still possible the snapshot will have disappeared by the
-	 * time our request arrives at the osd, but there's no sense in
-	 * sending it if we already know.
-	 */
-	if (!test_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags)) {
-		pr_warn("request for non-existent snapshot");
-		BUG_ON(rbd_dev->spec->snap_id == CEPH_NOSNAP);
-		sense = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
-		goto err;
-	}
-
 	if (offset && length > U64_MAX - offset + 1) {
 		pr_warn("bad request range (%llu~%llu)", offset, length);
 		sense = TCM_INVALID_CDB_FIELD;
@@ -589,13 +576,6 @@ tcm_rbd_execute_cmp_and_write(struct se_cmd *cmd)
 		goto err;
 	}
 
-	if (!test_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags)) {
-		pr_warn("request for non-existent snapshot");
-		BUG_ON(rbd_dev->spec->snap_id == CEPH_NOSNAP);
-		sense = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
-		goto err;
-	}
-
 	if (offset && length > U64_MAX - offset + 1) {
 		pr_warn("bad request range (%llu~%llu)", offset, length);
 		sense = TCM_INVALID_CDB_FIELD;
-- 
2.35.3