.set_min(1)
.set_description("the number of quiesce notification attempts"),
+ Option("rbd_default_snapshot_quiesce_mode", Option::TYPE_STR, Option::LEVEL_ADVANCED)
+ .set_default("required")
+ .set_enum_allowed({"required", "ignore-error", "skip"})
+ .set_description("default snapshot quiesce mode"),
+
Option("rbd_plugins", Option::TYPE_STR, Option::LEVEL_ADVANCED)
.set_default("")
.set_description("comma-delimited list of librbd plugins to enable"),
return 0;
}
+uint32_t get_default_snap_create_flags(ImageCtx *ictx) {
+ auto mode = ictx->config.get_val<std::string>(
+ "rbd_default_snapshot_quiesce_mode");
+
+ if (mode == "required") {
+ return 0;
+ } else if (mode == "ignore-error") {
+ return RBD_SNAP_CREATE_IGNORE_QUIESCE_ERROR;
+ } else if (mode == "skip") {
+ return RBD_SNAP_CREATE_SKIP_QUIESCE;
+ } else {
+ ceph_abort_msg("invalid rbd_default_snapshot_quiesce_mode");
+ }
+}
+
} // namespace util
} // namespace librbd
#include "librbd/ImageState.h"
#include "librbd/internal.h"
#include "librbd/Operations.h"
+#include "librbd/Utils.h"
#include "librbd/api/Config.h"
#include "librbd/api/DiffIterate.h"
#include "librbd/api/Group.h"
{
ImageCtx *ictx = (ImageCtx *)ctx;
tracepoint(librbd, snap_create_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
+ auto flags = librbd::util::get_default_snap_create_flags(ictx);
librbd::NoOpProgressContext prog_ctx;
- int r = librbd::api::Snapshot<>::create(ictx, snap_name, 0, prog_ctx);
+ int r = librbd::api::Snapshot<>::create(ictx, snap_name, flags, prog_ctx);
tracepoint(librbd, snap_create_exit, r);
return r;
}
int Image::mirror_image_create_snapshot(uint64_t *snap_id)
{
ImageCtx *ictx = (ImageCtx *)ctx;
- return librbd::api::Mirror<>::image_snapshot_create(ictx, 0, snap_id);
+ auto flags = librbd::util::get_default_snap_create_flags(ictx);
+ return librbd::api::Mirror<>::image_snapshot_create(ictx, flags, snap_id);
}
int Image::mirror_image_create_snapshot2(uint32_t flags, uint64_t *snap_id)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
tracepoint(librbd, snap_create_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
+ auto flags = librbd::util::get_default_snap_create_flags(ictx);
librbd::NoOpProgressContext prog_ctx;
- int r = librbd::api::Snapshot<>::create(ictx, snap_name, 0, prog_ctx);
+ int r = librbd::api::Snapshot<>::create(ictx, snap_name, flags, prog_ctx);
tracepoint(librbd, snap_create_exit, r);
return r;
}
uint64_t *snap_id)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
- return librbd::api::Mirror<>::image_snapshot_create(ictx, 0, snap_id);
+ auto flags = librbd::util::get_default_snap_create_flags(ictx);
+ return librbd::api::Mirror<>::image_snapshot_create(ictx, flags, snap_id);
}
extern "C" int rbd_mirror_image_create_snapshot2(rbd_image_t image,
ldout(m_cct, 10) << dendl;
ceph_assert(m_image_ctx != nullptr);
+ uint64_t snap_create_flags;
+ int r = util::snap_create_flags_api_to_internal(
+ m_cct, util::get_default_snap_create_flags(m_image_ctx),
+ &snap_create_flags);
+ ceph_assert(r == 0);
auto ctx = create_context_callback<
EnableRequest<I>,
&EnableRequest<I>::handle_create_primary_snapshot>(this);
auto req = snapshot::CreatePrimaryRequest<I>::create(
m_image_ctx, m_mirror_image.global_image_id,
- (m_image_clean ? 0 : CEPH_NOSNAP),
- SNAP_CREATE_FLAG_IGNORE_NOTIFY_QUIESCE_ERROR,
+ (m_image_clean ? 0 : CEPH_NOSNAP), snap_create_flags,
snapshot::CREATE_PRIMARY_FLAG_IGNORE_EMPTY_PEERS, &m_snap_id, ctx);
req->send();
}