]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/bluestore/zoned_types.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / os / bluestore / zoned_types.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #ifndef CEPH_OS_BLUESTORE_ZONED_TYPES_H
4 #define CEPH_OS_BLUESTORE_ZONED_TYPES_H
5
6 #include "include/types.h"
7 #include "kv/KeyValueDB.h"
8 #include "os/kv.h"
9
10 // Tracks two bits of information about the state of a zone: (1) number of dead
11 // bytes in a zone and (2) the write pointer. We assume that for now 32 bits is
12 // enough for the zone capacity and represent these as uint32_t, and we store
13 // them as a single 64-bit value in RocksDB so that we can use the existing
14 // Int64ArrayMergeOperator for merge and avoid the cost of point queries.
15 //
16 // We use the same struct for an on-disk and in-memory representation of the
17 // state.
18 struct zone_state_t {
19 uint32_t num_dead_bytes = 0;
20 uint32_t write_pointer = 0;
21
22 void encode(ceph::buffer::list &bl) const;
23 void decode(ceph::buffer::list::const_iterator &p);
24
25 uint64_t get_num_dead_bytes() const {
26 return num_dead_bytes;
27 }
28
29 uint64_t get_write_pointer() const {
30 return write_pointer;
31 }
32
33 void increment_num_dead_bytes(uint64_t num_bytes) {
34 num_dead_bytes += num_bytes;
35 }
36
37 void increment_write_pointer(uint64_t num_bytes) {
38 write_pointer += num_bytes;
39 }
40 };
41
42 std::ostream& operator<<(std::ostream& out, const zone_state_t& zone_state);
43
44 #endif