]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/rbd_mirror/image_replayer/snapshot/PrepareReplayRequest.cc
import ceph 15.2.14
[ceph.git] / ceph / src / tools / rbd_mirror / image_replayer / snapshot / PrepareReplayRequest.cc
CommitLineData
9f95a23c
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#include "PrepareReplayRequest.h"
5#include "common/debug.h"
6#include "common/dout.h"
7#include "common/errno.h"
8#include "librbd/ImageCtx.h"
9#include "librbd/Utils.h"
10#include "librbd/mirror/snapshot/ImageMeta.h"
11#include "tools/rbd_mirror/ProgressContext.h"
12#include "tools/rbd_mirror/image_replayer/snapshot/StateBuilder.h"
13
14#define dout_context g_ceph_context
15#define dout_subsys ceph_subsys_rbd_mirror
16#undef dout_prefix
17#define dout_prefix *_dout << "rbd::mirror::image_replayer::snapshot::" \
18 << "PrepareReplayRequest: " << this << " " \
19 << __func__ << ": "
20
21namespace rbd {
22namespace mirror {
23namespace image_replayer {
24namespace snapshot {
25
26using librbd::util::create_context_callback;
27
28template <typename I>
29void PrepareReplayRequest<I>::send() {
30 *m_resync_requested = false;
31 *m_syncing = false;
32
33 load_local_image_meta();
34}
35
36template <typename I>
37void PrepareReplayRequest<I>::load_local_image_meta() {
38 dout(15) << dendl;
39
40 ceph_assert(m_state_builder->local_image_meta == nullptr);
41 m_state_builder->local_image_meta =
42 librbd::mirror::snapshot::ImageMeta<I>::create(
43 m_state_builder->local_image_ctx, m_local_mirror_uuid);
44
45 auto ctx = create_context_callback<
46 PrepareReplayRequest<I>,
47 &PrepareReplayRequest<I>::handle_load_local_image_meta>(this);
48 m_state_builder->local_image_meta->load(ctx);
49}
50
51template <typename I>
52void PrepareReplayRequest<I>::handle_load_local_image_meta(int r) {
53 dout(15) << "r=" << r << dendl;
54
55 if (r < 0 && r != -ENOENT) {
56 derr << "failed to load local image-meta: " << cpp_strerror(r) << dendl;
57 finish(r);
58 return;
59 }
60
61 *m_resync_requested = m_state_builder->local_image_meta->resync_requested;
62 finish(0);
63}
64
65} // namespace snapshot
66} // namespace image_replayer
67} // namespace mirror
68} // namespace rbd
69
70template class rbd::mirror::image_replayer::snapshot::PrepareReplayRequest<librbd::ImageCtx>;