]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_MMDSFRAGMENTNOTIFY_H | |
16 | #define CEPH_MMDSFRAGMENTNOTIFY_H | |
17 | ||
18 | #include "msg/Message.h" | |
19 | ||
9f95a23c | 20 | class MMDSFragmentNotify : public SafeMessage { |
11fdf7f2 | 21 | private: |
a8e16298 TL |
22 | static constexpr int HEAD_VERSION = 2; |
23 | static constexpr int COMPAT_VERSION = 1; | |
24 | ||
25 | dirfrag_t base_dirfrag; | |
26 | int8_t bits = 0; | |
27 | bool ack_wanted = false; | |
7c673cae FG |
28 | |
29 | public: | |
11fdf7f2 TL |
30 | inodeno_t get_ino() const { return base_dirfrag.ino; } |
31 | frag_t get_basefrag() const { return base_dirfrag.frag; } | |
a8e16298 | 32 | dirfrag_t get_base_dirfrag() const { return base_dirfrag; } |
11fdf7f2 | 33 | int get_bits() const { return bits; } |
a8e16298 TL |
34 | bool is_ack_wanted() const { return ack_wanted; } |
35 | void mark_ack_wanted() { ack_wanted = true; } | |
7c673cae FG |
36 | |
37 | bufferlist basebl; | |
38 | ||
11fdf7f2 | 39 | protected: |
a8e16298 | 40 | MMDSFragmentNotify() : |
9f95a23c | 41 | SafeMessage{MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION} {} |
a8e16298 | 42 | MMDSFragmentNotify(dirfrag_t df, int b, uint64_t tid) : |
9f95a23c | 43 | SafeMessage{MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION}, |
a8e16298 TL |
44 | base_dirfrag(df), bits(b) { |
45 | set_tid(tid); | |
46 | } | |
7c673cae FG |
47 | ~MMDSFragmentNotify() override {} |
48 | ||
49 | public: | |
11fdf7f2 | 50 | std::string_view get_type_name() const override { return "fragment_notify"; } |
7c673cae | 51 | void print(ostream& o) const override { |
a8e16298 | 52 | o << "fragment_notify(" << base_dirfrag << " " << (int)bits << ")"; |
7c673cae FG |
53 | } |
54 | ||
55 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
56 | using ceph::encode; |
57 | encode(base_dirfrag, payload); | |
58 | encode(bits, payload); | |
59 | encode(basebl, payload); | |
60 | encode(ack_wanted, payload); | |
7c673cae FG |
61 | } |
62 | void decode_payload() override { | |
11fdf7f2 TL |
63 | auto p = payload.cbegin(); |
64 | decode(base_dirfrag, p); | |
65 | decode(bits, p); | |
66 | decode(basebl, p); | |
a8e16298 | 67 | if (header.version >= 2) |
11fdf7f2 | 68 | decode(ack_wanted, p); |
7c673cae | 69 | } |
9f95a23c TL |
70 | private: |
71 | template<class T, typename... Args> | |
72 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
73 | }; |
74 | ||
75 | #endif |