From: Prasanna Kumar Kalever Date: Wed, 26 Mar 2025 13:40:33 +0000 (+0530) Subject: librbd/api: don't mask images in group with read-only as part of image_demote() X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=509f93e611fff22cbaba82b6b366186ade9e1606;p=ceph.git librbd/api: don't mask images in group with read-only as part of image_demote() 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 --- diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc index f33db22ddf8d0..750b6105641d4 100644 --- a/src/librbd/api/Mirror.cc +++ b/src/librbd/api/Mirror.cc @@ -989,10 +989,13 @@ void Mirror::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::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;