diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/crimson/os/seastore/onode.cc | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/crimson/os/seastore/onode.cc')
-rw-r--r-- | src/crimson/os/seastore/onode.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/crimson/os/seastore/onode.cc b/src/crimson/os/seastore/onode.cc new file mode 100644 index 000000000..a8b925b70 --- /dev/null +++ b/src/crimson/os/seastore/onode.cc @@ -0,0 +1,44 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "onode.h" +#include "include/encoding.h" + +namespace crimson::os::seastore { + +size_t Onode::size() const +{ + return ceph::encoded_sizeof(*this); +} + +void Onode::encode(void* buffer, size_t len) +{ + struct [[gnu::packed]] encoded_t { + uint8_t struct_v; + uint8_t struct_compat; + uint32_t struct_len; + uint32_t len; + char data[]; + }; + auto p = reinterpret_cast<encoded_t*>(buffer); + assert(std::numeric_limits<uint16_t>::max() >= size()); + assert(len >= size()); + p->struct_v = 1; + p->struct_compat = 1; + p->struct_len = sizeof(encoded_t) + payload.size(); + p->len = payload.size(); + std::memcpy(p->data, payload.data(), payload.size()); +} + +bool operator==(const Onode& lhs, const Onode& rhs) +{ + return lhs.get() == rhs.get(); +} + +std::ostream& operator<<(std::ostream &out, const Onode &rhs) +{ + return out << rhs.get(); +} + +} + |