]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MDataPing.h
add subtree-ish sources for 12.0.3
[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 Message {
32
33 public:
34
35 static const int HEAD_VERSION = 1;
36 static const int COMPAT_VERSION = 1;
37
38 std::string tag;
39 uint32_t counter;
40 mdata_hook_func mdata_hook;
41 struct xio_reg_mem mp;
42 bool free_data;
43
44 MDataPing()
45 : Message(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 const std::list<buffer::ptr>& buffers = data.buffers();
68 list<bufferptr>::const_iterator pb;
69 for (pb = buffers.begin(); pb != buffers.end(); ++pb) {
70 free((void*) pb->c_str());
71 }
72 }
73 }
74
75 public:
76 void decode_payload() override {
77 bufferlist::iterator p = payload.begin();
78 ::decode(tag, p);
79 ::decode(counter, p);
80 }
81 void encode_payload(uint64_t features) override {
82 ::encode(tag, payload);
83 ::encode(counter, payload);
84 }
85
86 const char *get_type_name() const override { return "data_ping"; }
87
88 void print(ostream& out) const override {
89 out << get_type_name() << " " << tag << " " << counter;
90 }
91 };
92
93 #endif /* CEPH_MDATAPING_H */