#include "crimson/os/seastore/btree/btree_range_pin.h"
#include "crimson/os/seastore/root_block.h"
-#define RESERVATION_PTR reinterpret_cast<ChildableCachedExtent*>(0x1)
-
namespace crimson::os::seastore::lba_manager::btree {
struct lba_map_val_t;
}
bool is_valid_child_ptr(ChildableCachedExtent* child);
+bool is_reserved_ptr(ChildableCachedExtent* child);
+
+inline ChildableCachedExtent* get_reserved_ptr() {
+ return (ChildableCachedExtent*)0x1;
+}
+
template <typename T>
phy_tree_root_t& get_phy_tree_root(root_t& r);
namespace crimson::os::seastore {
bool is_valid_child_ptr(ChildableCachedExtent* child) {
- return child != nullptr && child != RESERVATION_PTR;
+ return child != nullptr && child != get_reserved_ptr();
+}
+
+bool is_reserved_ptr(ChildableCachedExtent* child) {
+ return child == get_reserved_ptr();
}
} // namespace crimson::os::seastore
// copy sources when committing this lba node, because
// we rely on pointers' "nullness" to avoid copying
// pointers for updated values
- children[offset] = RESERVATION_PTR;
+ children[offset] = get_reserved_ptr();
}
}
if (!child) {
child = source.children[foreign_it.get_offset()];
// child can be either valid if present, nullptr if absent,
- // or RESERVATION_PTR.
+ // or reserved ptr.
}
foreign_it++;
local_it++;
get_child_ret_t<LogicalCachedExtent>
get_logical_child(op_context_t<NODE_KEY> c, uint16_t pos) final {
auto child = this->children[pos];
+ ceph_assert(!is_reserved_ptr(child));
if (is_valid_child_ptr(child)) {
ceph_assert(child->is_logical());
return c.cache.template get_extent_viewable_by_trans<
// children are considered stable if any of the following case is true:
// 1. The child extent is absent in cache
// 2. The child extent is stable
+ //
+ // For reserved mappings, the return values are undefined.
bool is_child_stable(uint16_t pos) const final {
auto child = this->children[pos];
- if (is_valid_child_ptr(child)) {
+ if (is_reserved_ptr(child)) {
+ return true;
+ } else if (is_valid_child_ptr(child)) {
ceph_assert(child->is_logical());
return child->is_stable();
} else if (this->is_pending()) {
child_pos->link_child(c);
}
+ // For reserved mappings, the return values are
+ // undefined although it won't crash
virtual bool is_stable() const = 0;
virtual bool is_clone() const = 0;
bool is_zero_reserved() const {