]>
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) 2013 Inktank Storage, Inc. | |
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 MOSDECSUBOPWRITE_H | |
16 | #define MOSDECSUBOPWRITE_H | |
17 | ||
18 | #include "MOSDFastDispatchOp.h" | |
19 | #include "osd/ECMsgTypes.h" | |
20 | ||
9f95a23c | 21 | class MOSDECSubOpWrite : public MOSDFastDispatchOp { |
11fdf7f2 TL |
22 | private: |
23 | static constexpr int HEAD_VERSION = 2; | |
24 | static constexpr int COMPAT_VERSION = 1; | |
7c673cae FG |
25 | |
26 | public: | |
27 | spg_t pgid; | |
11fdf7f2 | 28 | epoch_t map_epoch = 0, min_epoch = 0; |
7c673cae FG |
29 | ECSubWrite op; |
30 | ||
31 | int get_cost() const override { | |
32 | return 0; | |
33 | } | |
34 | epoch_t get_map_epoch() const override { | |
35 | return map_epoch; | |
36 | } | |
37 | epoch_t get_min_epoch() const override { | |
38 | return min_epoch; | |
39 | } | |
40 | spg_t get_spg() const override { | |
41 | return pgid; | |
42 | } | |
43 | ||
44 | MOSDECSubOpWrite() | |
9f95a23c | 45 | : MOSDFastDispatchOp{MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION} |
7c673cae FG |
46 | {} |
47 | MOSDECSubOpWrite(ECSubWrite &in_op) | |
9f95a23c | 48 | : MOSDFastDispatchOp{MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION} { |
7c673cae FG |
49 | op.claim(in_op); |
50 | } | |
51 | ||
52 | void decode_payload() override { | |
f67539c2 | 53 | using ceph::decode; |
11fdf7f2 TL |
54 | auto p = payload.cbegin(); |
55 | decode(pgid, p); | |
56 | decode(map_epoch, p); | |
57 | decode(op, p); | |
7c673cae | 58 | if (header.version >= 2) { |
11fdf7f2 | 59 | decode(min_epoch, p); |
7c673cae FG |
60 | decode_trace(p); |
61 | } else { | |
62 | min_epoch = map_epoch; | |
63 | } | |
64 | } | |
65 | ||
66 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
67 | using ceph::encode; |
68 | encode(pgid, payload); | |
69 | encode(map_epoch, payload); | |
70 | encode(op, payload); | |
71 | encode(min_epoch, payload); | |
7c673cae FG |
72 | encode_trace(payload, features); |
73 | } | |
74 | ||
11fdf7f2 | 75 | std::string_view get_type_name() const override { return "MOSDECSubOpWrite"; } |
7c673cae | 76 | |
f67539c2 | 77 | void print(std::ostream& out) const override { |
7c673cae FG |
78 | out << "MOSDECSubOpWrite(" << pgid |
79 | << " " << map_epoch << "/" << min_epoch | |
80 | << " " << op; | |
81 | out << ")"; | |
82 | } | |
83 | ||
84 | void clear_buffers() override { | |
85 | op.t = ObjectStore::Transaction(); | |
86 | op.log_entries.clear(); | |
87 | } | |
9f95a23c TL |
88 | private: |
89 | template<class T, typename... Args> | |
90 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
91 | }; |
92 | ||
93 | #endif |