blob: 55162a4e4b58df9e8b3682c04c5bc058ea7a23e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "tools/rbd_mirror/image_replayer/Utils.h"
#include "include/rados/librados.hpp"
#include "common/debug.h"
#include "common/errno.h"
#include "cls/journal/cls_journal_types.h"
#include "librbd/journal/Types.h"
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rbd_mirror
#undef dout_prefix
#define dout_prefix *_dout << "rbd::mirror::image_replayer::util::" \
<< __func__ << ": "
namespace rbd {
namespace mirror {
namespace image_replayer {
namespace util {
std::string compute_image_spec(librados::IoCtx& io_ctx,
const std::string& image_name) {
std::string name = io_ctx.get_namespace();
if (!name.empty()) {
name += "/";
}
return io_ctx.get_pool_name() + "/" + name + image_name;
}
bool decode_client_meta(const cls::journal::Client& client,
librbd::journal::MirrorPeerClientMeta* client_meta) {
dout(15) << dendl;
librbd::journal::ClientData client_data;
auto it = client.data.cbegin();
try {
decode(client_data, it);
} catch (const buffer::error &err) {
derr << "failed to decode client meta data: " << err.what() << dendl;
return false;
}
auto local_client_meta = boost::get<librbd::journal::MirrorPeerClientMeta>(
&client_data.client_meta);
if (local_client_meta == nullptr) {
derr << "unknown peer registration" << dendl;
return false;
}
*client_meta = *local_client_meta;
dout(15) << "client found: client_meta=" << *client_meta << dendl;
return true;
}
} // namespace util
} // namespace image_replayer
} // namespace mirror
} // namespace rbd
|