return r;
}
+ if (group_snap_id.empty() &&
+ (ictx->group_spec.pool_id != RBD_GROUP_INVALID_POOL)) {
+ r = -EINVAL;
+ lderr(cct) << "cannot enable mirroring on an image that is member of a group"
+ << cpp_strerror(r) << dendl;
+ return r;
+ }
+
cls::rbd::MirrorMode mirror_mode;
r = cls_client::mirror_mode_get(&ictx->md_ctx, &mirror_mode);
if (r < 0) {
template <typename I>
int Mirror<I>::image_disable(I *ictx, bool force) {
+ return Mirror<I>::image_disable(ictx, force, false);
+}
+
+template <typename I>
+int Mirror<I>::image_disable(I *ictx, bool force, bool allow_group_member) {
CephContext *cct = ictx->cct;
ldout(cct, 20) << "ictx=" << ictx << dendl;
return r;
}
+ if (!allow_group_member &&
+ (ictx->group_spec.pool_id != RBD_GROUP_INVALID_POOL)) {
+ r = -EINVAL;
+ lderr(cct) << "cannot disable mirroring on an image that is member of a group"
+ << cpp_strerror(r) << dendl;
+ return r;
+ }
+
cls::rbd::MirrorMode mirror_mode;
r = cls_client::mirror_mode_get(&ictx->md_ctx, &mirror_mode);
if (r < 0) {
return;
}
+ if (group_snap_id.empty() &&
+ (ictx->group_spec.pool_id != RBD_GROUP_INVALID_POOL)) {
+ lderr(ictx->cct) << "cannot promote an image that is member of a group"
+ << cpp_strerror(-EINVAL) << dendl;
+ on_promote->complete(-EINVAL);
+ return;
+ }
+
auto req = mirror::PromoteRequest<>::create(*ictx, force,
ictx->group_spec.pool_id,
ictx->group_spec.group_id,
return;
}
+ if (group_snap_id.empty() &&
+ (ictx->group_spec.pool_id != RBD_GROUP_INVALID_POOL)) {
+ lderr(ictx->cct) << "cannot demote an image that is member of a group"
+ << cpp_strerror(-EINVAL) << dendl;
+ on_cleanup->complete(-EINVAL);
+ return;
+ }
+
auto req = mirror::DemoteRequest<>::create(*ictx,
ictx->group_spec.pool_id,
ictx->group_spec.group_id,
return r;
}
+ if (ictx->group_spec.pool_id != RBD_GROUP_INVALID_POOL) {
+ r = -EINVAL;
+ lderr(cct) << "cannot resync image that is member of a group"
+ << cpp_strerror(r) << dendl;
+ return r;
+ }
+
cls::rbd::MirrorImage mirror_image;
mirror::PromotionState promotion_state;
std::string primary_mirror_uuid;
return;
}
+ if (group_snap_id.empty() &&
+ (ictx->group_spec.pool_id != RBD_GROUP_INVALID_POOL)) {
+ lderr(ictx->cct) << "cannot create mirror snapshot of an image "
+ << "that is member of a group"
+ << cpp_strerror(-EINVAL) << dendl;
+ on_finish->complete(-EINVAL);
+ return;
+ }
+
auto ctx = new C_ImageSnapshotCreate<I>(ictx, snap_create_flags,
ictx->group_spec.pool_id,
ictx->group_spec.group_id,
if (snap_ids[i] == CEPH_NOSNAP) {
continue;
}
- r = image_disable(image_ctxs[i], false);
+ r = image_disable(image_ctxs[i], false, true);
if (r < 0) {
lderr(cct) << "failed to disable mirroring on image: "
<< image_ctxs[i]->name << cpp_strerror(r) << dendl;
for (auto image_ctx : image_ctxs) {
ldout(cct, 10) << "attempting to disable image with id " << image_ctx->id
<< ": " << cpp_strerror(r) << dendl;
- r = image_disable(image_ctx, force);
+ r = image_disable(image_ctx, force, true);
if (r < 0) {
lderr(cct) << "failed to disable mirroring on image: " << image_ctx->name
<< cpp_strerror(r) << dendl;