mirror of
https://github.com/ceph/ceph
synced 2025-02-24 11:37:37 +00:00
Merge pull request #50343 from pkalever/fix-errormsg
librbd: report better errors when failing to enable mirroring on an image Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
commit
f443eedd5e
@ -299,6 +299,15 @@ int list_mirror_images(librados::IoCtx& io_ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename I>
|
||||
const char *pool_or_namespace(I *ictx) {
|
||||
if (!ictx->md_ctx.get_namespace().empty()) {
|
||||
return "namespace";
|
||||
} else {
|
||||
return "pool";
|
||||
}
|
||||
}
|
||||
|
||||
struct C_ImageGetInfo : public Context {
|
||||
mirror_image_info_t *mirror_image_info;
|
||||
mirror_image_mode_t *mirror_image_mode;
|
||||
@ -434,9 +443,15 @@ int Mirror<I>::image_enable(I *ictx, mirror_image_mode_t mode,
|
||||
return r;
|
||||
}
|
||||
|
||||
if (mirror_mode == cls::rbd::MIRROR_MODE_DISABLED) {
|
||||
lderr(cct) << "cannot enable mirroring: mirroring is not enabled on a "
|
||||
<< pool_or_namespace(ictx) << dendl;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (mirror_mode != cls::rbd::MIRROR_MODE_IMAGE) {
|
||||
lderr(cct) << "cannot enable mirroring in the current pool mirroring mode"
|
||||
<< dendl;
|
||||
lderr(cct) << "cannot enable mirroring: " << pool_or_namespace(ictx)
|
||||
<< " is not in image mirror mode" << dendl;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user