forked from ceph/ceph
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ceph#60655 from xxhdx1985126/wip-seastore-move-out…
…-root-meta crimson/os/seastore: move the root meta out of the root block Reviewed-by: Yingxin Cheng <yingxin.cheng@intel.com>
- Loading branch information
Showing
10 changed files
with
234 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=8 sw=2 smarttab | ||
|
||
#pragma once | ||
|
||
#include "crimson/os/seastore/cached_extent.h" | ||
|
||
namespace crimson::os::seastore { | ||
|
||
struct RootMetaBlock : LogicalCachedExtent { | ||
using meta_t = std::map<std::string, std::string>; | ||
using Ref = TCachedExtentRef<RootMetaBlock>; | ||
static constexpr size_t SIZE = 4096; | ||
static constexpr int MAX_META_LENGTH = 1024; | ||
|
||
explicit RootMetaBlock(ceph::bufferptr &&ptr) | ||
: LogicalCachedExtent(std::move(ptr)) {} | ||
explicit RootMetaBlock(extent_len_t length) | ||
: LogicalCachedExtent(length) {} | ||
RootMetaBlock(const RootMetaBlock &rhs) | ||
: LogicalCachedExtent(rhs) {} | ||
|
||
CachedExtentRef duplicate_for_write(Transaction&) final { | ||
return CachedExtentRef(new RootMetaBlock(*this)); | ||
} | ||
|
||
static constexpr extent_types_t TYPE = extent_types_t::ROOT_META; | ||
extent_types_t get_type() const final { | ||
return extent_types_t::ROOT_META; | ||
} | ||
|
||
/// dumps root meta as delta | ||
ceph::bufferlist get_delta() final { | ||
ceph::bufferlist bl; | ||
ceph::buffer::ptr bptr(get_bptr(), 0, MAX_META_LENGTH); | ||
bl.append(bptr); | ||
return bl; | ||
} | ||
|
||
/// overwrites root | ||
void apply_delta(const ceph::bufferlist &_bl) final | ||
{ | ||
assert(_bl.length() == MAX_META_LENGTH); | ||
ceph::bufferlist bl = _bl; | ||
bl.rebuild(); | ||
get_bptr().copy_in(0, MAX_META_LENGTH, bl.front().c_str()); | ||
} | ||
|
||
meta_t get_meta() const { | ||
bufferlist bl; | ||
bl.append(get_bptr()); | ||
meta_t ret; | ||
auto iter = bl.cbegin(); | ||
decode(ret, iter); | ||
return ret; | ||
} | ||
|
||
void set_meta(const meta_t &m) { | ||
ceph::bufferlist bl; | ||
encode(m, bl); | ||
ceph_assert(bl.length() <= MAX_META_LENGTH); | ||
bl.rebuild(); | ||
get_bptr().zero(0, MAX_META_LENGTH); | ||
get_bptr().copy_in(0, bl.length(), bl.front().c_str()); | ||
} | ||
|
||
}; | ||
using RootMetaBlockRef = RootMetaBlock::Ref; | ||
|
||
} // crimson::os::seastore | ||
|
||
|
||
#if FMT_VERSION >= 90000 | ||
template <> struct fmt::formatter<crimson::os::seastore::RootMetaBlock> | ||
: fmt::ostream_formatter {}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.