]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/api: don't mask images in group with read-only as part of image_demote()
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Wed, 26 Mar 2025 13:40:33 +0000 (19:10 +0530)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 24 Apr 2025 15:56:37 +0000 (21:26 +0530)
if the images are part of a group wait until group_demote() is finally done
with GroupUnlinkPeerRequest() and then mask the images part of the group with
IMAGE_READ_ONLY_FLAG_NON_PRIMARY.

Thanks to Nithya for working along for a better fix here.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/librbd/api/Mirror.cc

index f33db22ddf8d035cc0ff2f3cc745883934f8c8d2..750b6105641d47ff06a0042cf6b30a341347a557 100644 (file)
@@ -989,10 +989,13 @@ void Mirror<I>::image_demote(I *ictx,
   CephContext *cct = ictx->cct;
   ldout(cct, 20) << "ictx=" << ictx << dendl;
 
-  auto on_cleanup = new LambdaContext([ictx, on_finish](int r) {
-      ictx->image_lock.lock();
-      ictx->read_only_mask |= IMAGE_READ_ONLY_FLAG_NON_PRIMARY;
-      ictx->image_lock.unlock();
+  auto on_cleanup = new LambdaContext([ictx, group_snap_id, on_finish](int r) {
+      // for images part of the group do it as part of the group demote.
+      if (group_snap_id.empty()) {
+        ictx->image_lock.lock();
+        ictx->read_only_mask |= IMAGE_READ_ONLY_FLAG_NON_PRIMARY;
+        ictx->image_lock.unlock();
+      }
 
       ictx->state->handle_update_notification();
 
@@ -3501,6 +3504,12 @@ int Mirror<I>::group_demote(IoCtx& group_ioctx,
     req->send();
     cond.wait();
   }
+  for (size_t i = 0; i < image_ctxs.size(); ++i) {
+    ImageCtx *ictx = image_ctxs[i];
+    ictx->image_lock.lock();
+    ictx->read_only_mask |= IMAGE_READ_ONLY_FLAG_NON_PRIMARY;
+    ictx->image_lock.unlock();
+  }
   close_images(&image_ctxs);
 
   return ret_code;