#include "common/errno.h"
#include "include/assert.h"
#include "librbd/ImageState.h"
-#include "librbd/Journal.h"
#include "librbd/image/CloneRequest.h"
#include "librbd/image/CreateRequest.h"
#include "librbd/image/RemoveRequest.h"
return complete(-EINVAL);
}
- if ((m_p_features & RBD_FEATURE_JOURNALING) != 0) {
- m_force_non_primary = !m_non_primary_global_image_id.empty();
- using klass = CloneRequest<I>;
- Context *ctx = create_context_callback<
- klass, &klass::handle_validate_parent>(this);
-
- Journal<I>::is_tag_owner(m_p_imctx, &m_is_primary, ctx);
- return;
- }
-
- send_validate_child();
-}
-
-template <typename I>
-void CloneRequest<I>::handle_validate_parent(int r) {
- ldout(m_cct, 20) << this << " " << __func__ << " r=" << r << dendl;
-
- if (r < 0) {
- lderr(m_cct) << "failed to determine tag ownership: " << cpp_strerror(r)
- << dendl;
- return complete(r);
- }
-
- if ((m_p_features & RBD_FEATURE_JOURNALING) != 0) {
- if (!m_is_primary && !m_force_non_primary) {
- lderr(m_cct) << "parent is non-primary mirrored image" << dendl;
- return complete(-EINVAL);
- }
- }
-
send_validate_child();
}
ldout(m_cct, 20) << this << " " << __func__ << dendl;
using klass = CloneRequest<I>;
- Context *ctx = create_context_callback<klass, &klass::handle_enable_mirror>(this);
+ Context *ctx = create_context_callback<
+ klass, &klass::handle_enable_mirror>(this);
mirror::EnableRequest<I> *req = mirror::EnableRequest<I>::create(
m_imctx->md_ctx, m_id, m_non_primary_global_image_id,
template <typename ImageCtxT = ImageCtx>
class CloneRequest {
public:
- static CloneRequest *create(ImageCtxT *p_imctx, IoCtx &c_ioctx, const std::string &c_name,
- const std::string &c_id, ImageOptions c_options,
+ static CloneRequest *create(ImageCtxT *p_imctx, IoCtx &c_ioctx,
+ const std::string &c_name,
+ const std::string &c_id, ImageOptions c_options,
const std::string &non_primary_global_image_id,
const std::string &primary_mirror_uuid,
ContextWQ *op_work_queue, Context *on_finish) {
return new CloneRequest(p_imctx, c_ioctx, c_name, c_id, c_options,
- non_primary_global_image_id, primary_mirror_uuid,
- op_work_queue, on_finish);
+ non_primary_global_image_id, primary_mirror_uuid,
+ op_work_queue, on_finish);
}
+ CloneRequest(ImageCtxT *p_imctx, IoCtx &c_ioctx, const std::string &c_name,
+ const std::string &c_id, ImageOptions c_options,
+ const std::string &non_primary_global_image_id,
+ const std::string &primary_mirror_uuid,
+ ContextWQ *op_work_queue, Context *on_finish);
+
void send();
private:
/**
* @endverbatim
*/
- CloneRequest(ImageCtxT *p_imctx, IoCtx &c_ioctx, const std::string &c_name,
- const std::string &c_id,
- ImageOptions c_options,
- const std::string &non_primary_global_image_id,
- const std::string &primary_mirror_uuid,
- ContextWQ *op_work_queue, Context *on_finish);
-
ImageCtxT *m_p_imctx;
IoCtx &m_ioctx;
std::string m_name;
bufferlist m_out_bl;
uint64_t m_size;
int m_r_saved = 0;
- bool m_is_primary;
- bool m_force_non_primary;
void validate_options();
void send_validate_parent();
- void handle_validate_parent(int r);
void send_validate_child();
void handle_validate_child(int r);