]>
git.proxmox.com Git - ceph.git/blob - ceph/src/cls/fifo/cls_fifo_ops.h
91a012c0847ec4c842d3cc6b7e1b1aaa4cd2213d
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2019 Red Hat, Inc.
8 * Copyright (C) 2019 SUSE LLC
10 * This is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License version 2.1, as published by the Free Software
13 * Foundation. See file COPYING.
24 #include "include/buffer.h"
25 #include "include/encoding.h"
26 #include "include/types.h"
28 #include "cls/fifo/cls_fifo_types.h"
30 namespace rados::cls::fifo::op
{
34 std::optional
<objv
> version
;
39 std::optional
<std::string
> oid_prefix
;
41 std::uint64_t max_part_size
{0};
42 std::uint64_t max_entry_size
{0};
44 bool exclusive
{false};
46 void encode(ceph::buffer::list
& bl
) const {
47 ENCODE_START(1, 1, bl
);
50 encode(pool
.name
, bl
);
52 encode(oid_prefix
, bl
);
53 encode(max_part_size
, bl
);
54 encode(max_entry_size
, bl
);
55 encode(exclusive
, bl
);
58 void decode(ceph::buffer::list::const_iterator
& bl
) {
62 decode(pool
.name
, bl
);
64 decode(oid_prefix
, bl
);
65 decode(max_part_size
, bl
);
66 decode(max_entry_size
, bl
);
67 decode(exclusive
, bl
);
71 WRITE_CLASS_ENCODER(create_meta
)
75 std::optional
<objv
> version
;
77 void encode(ceph::buffer::list
& bl
) const {
78 ENCODE_START(1, 1, bl
);
82 void decode(ceph::buffer::list::const_iterator
& bl
) {
88 WRITE_CLASS_ENCODER(get_meta
)
93 std::uint32_t part_header_size
{0};
94 /* per entry extra data that is stored */
95 std::uint32_t part_entry_overhead
{0};
97 void encode(ceph::buffer::list
& bl
) const {
98 ENCODE_START(1, 1, bl
);
100 encode(part_header_size
, bl
);
101 encode(part_entry_overhead
, bl
);
104 void decode(ceph::buffer::list::const_iterator
& bl
) {
107 decode(part_header_size
, bl
);
108 decode(part_entry_overhead
, bl
);
112 WRITE_CLASS_ENCODER(get_meta_reply
)
118 std::optional
<std::uint64_t> tail_part_num
;
119 std::optional
<std::uint64_t> head_part_num
;
120 std::optional
<std::uint64_t> min_push_part_num
;
121 std::optional
<std::uint64_t> max_push_part_num
;
122 std::vector
<journal_entry
> journal_entries_add
;
123 std::vector
<journal_entry
> journal_entries_rm
;
125 void encode(ceph::buffer::list
& bl
) const {
126 ENCODE_START(1, 1, bl
);
128 encode(tail_part_num
, bl
);
129 encode(head_part_num
, bl
);
130 encode(min_push_part_num
, bl
);
131 encode(max_push_part_num
, bl
);
132 encode(journal_entries_add
, bl
);
133 encode(journal_entries_rm
, bl
);
136 void decode(ceph::buffer::list::const_iterator
& bl
) {
139 decode(tail_part_num
, bl
);
140 decode(head_part_num
, bl
);
141 decode(min_push_part_num
, bl
);
142 decode(max_push_part_num
, bl
);
143 decode(journal_entries_add
, bl
);
144 decode(journal_entries_rm
, bl
);
148 WRITE_CLASS_ENCODER(update_meta
)
155 void encode(ceph::buffer::list
& bl
) const {
156 ENCODE_START(1, 1, bl
);
161 void decode(ceph::buffer::list::const_iterator
& bl
) {
168 WRITE_CLASS_ENCODER(init_part
)
173 std::deque
<ceph::buffer::list
> data_bufs
;
174 std::uint64_t total_len
{0};
176 void encode(ceph::buffer::list
& bl
) const {
177 ENCODE_START(1, 1, bl
);
179 encode(data_bufs
, bl
);
180 encode(total_len
, bl
);
183 void decode(ceph::buffer::list::const_iterator
& bl
) {
186 decode(data_bufs
, bl
);
187 decode(total_len
, bl
);
191 WRITE_CLASS_ENCODER(push_part
)
195 std::optional
<std::string
> tag
;
196 std::uint64_t ofs
{0};
197 bool exclusive
= false;
199 void encode(ceph::buffer::list
& bl
) const {
200 ENCODE_START(1, 1, bl
);
203 encode(exclusive
, bl
);
206 void decode(ceph::buffer::list::const_iterator
& bl
) {
210 decode(exclusive
, bl
);
214 WRITE_CLASS_ENCODER(trim_part
)
218 std::optional
<std::string
> tag
;
219 std::uint64_t ofs
{0};
220 int max_entries
{100};
222 void encode(ceph::buffer::list
& bl
) const {
223 ENCODE_START(1, 1, bl
);
226 encode(max_entries
, bl
);
229 void decode(ceph::buffer::list::const_iterator
& bl
) {
233 decode(max_entries
, bl
);
237 WRITE_CLASS_ENCODER(list_part
)
238 inline constexpr int MAX_LIST_ENTRIES
= 512;
240 struct list_part_reply
243 std::vector
<part_list_entry
> entries
;
245 bool full_part
{false}; /* whether part is full or still can be written to.
246 A non full part is by definition head part */
248 void encode(ceph::buffer::list
& bl
) const {
249 ENCODE_START(1, 1, bl
);
253 encode(full_part
, bl
);
256 void decode(ceph::buffer::list::const_iterator
& bl
) {
261 decode(full_part
, bl
);
265 WRITE_CLASS_ENCODER(list_part_reply
)
269 void encode(ceph::buffer::list
&bl
) const {
270 ENCODE_START(1, 1, bl
);
273 void decode(ceph::buffer::list::const_iterator
&bl
) {
278 WRITE_CLASS_ENCODER(get_part_info
)
280 struct get_part_info_reply
284 void encode(ceph::buffer::list
&bl
) const {
285 ENCODE_START(1, 1, bl
);
289 void decode(ceph::buffer::list::const_iterator
&bl
) {
295 WRITE_CLASS_ENCODER(get_part_info_reply
)
297 inline constexpr auto CLASS
= "fifo";
298 inline constexpr auto CREATE_META
= "create_meta";
299 inline constexpr auto GET_META
= "get_meta";
300 inline constexpr auto UPDATE_META
= "update_meta";
301 inline constexpr auto INIT_PART
= "init_part";
302 inline constexpr auto PUSH_PART
= "push_part";
303 inline constexpr auto TRIM_PART
= "trim_part";
304 inline constexpr auto LIST_PART
= "part_list";
305 inline constexpr auto GET_PART_INFO
= "get_part_info";
306 } // namespace rados::cls::fifo::op