]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MDataPing.h
update download target update for octopus release
[ceph.git] / ceph / src / messages / MDataPing.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #ifndef CEPH_MDATAPING_H
16 #define CEPH_MDATAPING_H
17
18 #include "msg/Message.h"
19 #include "messages/MPing.h"
20 #include "include/encoding.h"
21 #if defined(HAVE_XIO)
22 extern "C" {
23 #include "libxio.h"
24 }
25 #else
26 struct xio_reg_mem {};
27 #endif /* HAVE_XIO */
28
29 typedef void (*mdata_hook_func)(struct xio_reg_mem *mp);
30
31 class MDataPing : public MessageInstance<MDataPing> {
32 public:
33 friend factory;
34
35 static constexpr int HEAD_VERSION = 1;
36 static constexpr int COMPAT_VERSION = 1;
37
38 std::string tag;
39 uint32_t counter = 0;
40 mdata_hook_func mdata_hook;
41 struct xio_reg_mem mp;
42 bool free_data;
43
44 MDataPing()
45 : MessageInstance(MSG_DATA_PING, HEAD_VERSION, COMPAT_VERSION),
46 mdata_hook(NULL),
47 free_data(false)
48 {}
49
50 struct xio_reg_mem *get_mp()
51 {
52 return &mp;
53 }
54
55 void set_rdma_hook(mdata_hook_func hook)
56 {
57 mdata_hook = hook;
58 }
59
60 private:
61 ~MDataPing() override
62 {
63 if (mdata_hook)
64 mdata_hook(&mp);
65
66 if (free_data) {
67 for (const auto& node : data.buffers()) {
68 free(const_cast<void*>(static_cast<const void*>(node.c_str())));
69 }
70 }
71 }
72
73 public:
74 void decode_payload() override {
75 auto p = payload.cbegin();
76 decode(tag, p);
77 decode(counter, p);
78 }
79 void encode_payload(uint64_t features) override {
80 using ceph::encode;
81 encode(tag, payload);
82 encode(counter, payload);
83 }
84
85 std::string_view get_type_name() const override { return "data_ping"; }
86
87 void print(ostream& out) const override {
88 out << get_type_name() << " " << tag << " " << counter;
89 }
90 };
91
92 #endif /* CEPH_MDATAPING_H */