boost::thread_unsafe_counter>
{
protected:
- virtual laddr_t get_hint() const = 0;
+ virtual laddr_hint_t init_hint(
+ extent_len_t block_size,
+ bool is_metadata) const = 0;
+ virtual laddr_hint_t generate_clone_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size,
+ bool is_metadata) const = 0;
+ laddr_hint_t get_hint(extent_len_t block_size, bool is_metadata) const {
+ assert(block_size >= laddr_t::UNIT_SIZE);
+ auto prefix = get_clone_prefix();
+ if (prefix) {
+ if (is_metadata) {
+ return laddr_hint_t::create_object_md_hint(*prefix, block_size);
+ } else {
+ return laddr_hint_t::create_object_data_hint(*prefix, block_size);
+ }
+ } else if (sibling_object_id) {
+ return generate_clone_hint(
+ *sibling_object_id, block_size, is_metadata);
+ } else {
+ return init_hint(block_size, is_metadata);
+ }
+ }
+ laddr_hint_t get_clone_hint(extent_len_t block_size, bool is_metadata) const {
+ return generate_clone_hint(
+ get_clone_prefix()->get_local_object_id(), block_size, is_metadata);
+ }
const hobject_t hobj;
+ std::optional<local_object_id_t> sibling_object_id;
+
public:
explicit Onode(const hobject_t &hobj) : hobj(hobj) {}
virtual void unset_need_cow(Transaction&) = 0;
virtual void swap_layout(Transaction&, Onode&) = 0;
- laddr_t get_metadata_hint(uint64_t block_size) const {
- return get_hint();
+ laddr_t get_metadata_hint(uint64_t block_size = laddr_t::UNIT_SIZE) const {
+ // TODO: return laddr_hint_t
+ return get_hint(block_size, /*is_metadata*/true).addr;
+ }
+ laddr_t get_data_hint(uint64_t block_size = laddr_t::UNIT_SIZE) const {
+ // TODO: return laddr_hint_t
+ return get_hint(block_size, /*is_metadata*/false).addr;
+ }
+ laddr_hint_t get_metadata_clone_hint(uint64_t block_size = laddr_t::UNIT_SIZE) const {
+ return get_clone_hint(block_size, /*is_metadata*/true);
}
- laddr_t get_data_hint() const {
- return get_hint();
+ laddr_hint_t get_data_clone_hint(uint64_t block_size = laddr_t::UNIT_SIZE) const {
+ return get_clone_hint(block_size, /*is_metadata*/false);
}
const omap_root_le_t& get_root(omap_type_t type) const {
return get_layout().get_root(type);
status = status_t::DELETED;
}
- laddr_t get_hint() const final {
- return Value::get_hint();
+ laddr_hint_t init_hint(
+ extent_len_t block_size,
+ bool is_metadata) const final {
+ return Value::init_hint(block_size, is_metadata);
+ }
+ laddr_hint_t generate_clone_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size,
+ bool is_metadata) const final {
+ return Value::generate_clone_hint(object_id, block_size, is_metadata);
}
~FLTreeOnode() final {}
};
template <KeyT type>
using full_key_t = typename _full_key_type<type>::type;
-static laddr_t get_lba_hint(shard_t shard, pool_t pool, crush_hash_t crush) {
- // FIXME: It is possible that PGs from different pools share the same prefix
- // if the mask 0xFF is not long enough, result in unexpected transaction
- // conflicts.
- return laddr_t::from_raw_uint((uint64_t)(shard & 0xFF)<<56 |
- (uint64_t)(pool & 0xFF)<<48 |
- (uint64_t)(crush )<<16);
-}
-
struct node_offset_packed_t {
node_offset_t value;
} __attribute__((packed));
// Note: this is the reversed version of the object hash
return ghobj.hobj.get_bitwise_key_u32();
}
- laddr_t get_hint() const {
- return get_lba_hint(shard(), pool(), crush());
+ laddr_hint_t create_onode_hint(
+ extent_len_t block_size = laddr_t::UNIT_SIZE) const {
+ return laddr_hint_t::create_onode_hint(
+ shard(), pool(), crush(), block_size);
+ }
+ laddr_hint_t create_fresh_object_data_hint(
+ extent_len_t block_size) const {
+ return laddr_hint_t::create_fresh_object_data_hint(
+ shard(), pool(), crush(), block_size);
+ }
+ laddr_hint_t create_fresh_object_md_hint(
+ extent_len_t block_size) const {
+ return laddr_hint_t::create_fresh_object_md_hint(
+ shard(), pool(), crush(), block_size);
+ }
+ laddr_hint_t create_clone_object_data_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size) const {
+ return laddr_hint_t::create_clone_object_data_hint(
+ shard(), pool(), crush(), object_id, block_size);
+ }
+ laddr_hint_t create_clone_object_md_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size) const {
+ return laddr_hint_t::create_clone_object_md_hint(
+ shard(), pool(), crush(), object_id, block_size);
}
std::string_view nspace() const {
// TODO(cross-node string dedup)
inline shard_t shard() const;
inline pool_t pool() const;
inline crush_hash_t crush() const;
- laddr_t get_hint() const {
- return get_lba_hint(shard(), pool(), crush());
+ laddr_hint_t create_onode_hint(
+ extent_len_t block_size = laddr_t::UNIT_SIZE) const {
+ return laddr_hint_t::create_onode_hint(
+ shard(), pool(), crush(), block_size);
+ }
+ laddr_hint_t create_fresh_object_data_hint(
+ extent_len_t block_size) const {
+ return laddr_hint_t::create_fresh_object_data_hint(
+ shard(), pool(), crush(), block_size);
+ }
+ laddr_hint_t create_fresh_object_md_hint(
+ extent_len_t block_size) const {
+ return laddr_hint_t::create_fresh_object_md_hint(
+ shard(), pool(), crush(), block_size);
+ }
+ laddr_hint_t create_clone_object_data_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size) const {
+ return laddr_hint_t::create_clone_object_data_hint(
+ shard(), pool(), crush(), object_id, block_size);
+ }
+ laddr_hint_t create_clone_object_md_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size) const {
+ return laddr_hint_t::create_clone_object_md_hint(
+ shard(), pool(), crush(), object_id, block_size);
}
std::string_view nspace() const {
// TODO(cross-node string dedup)
return p_cursor->prepare_mutate_value_payload(get_context(t));
}
-laddr_t Value::get_hint() const
+laddr_hint_t Value::init_hint(
+ extent_len_t block_size,
+ bool is_metadata) const
{
- return p_cursor->get_key_view(vb.get_header_magic()).get_hint();
+ if (is_metadata) {
+ return p_cursor->get_key_view(vb.get_header_magic())
+ .create_fresh_object_md_hint(block_size);
+ } else {
+ return p_cursor->get_key_view(vb.get_header_magic())
+ .create_fresh_object_data_hint(block_size);
+ }
+}
+
+laddr_hint_t Value::generate_clone_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size,
+ bool is_metadata) const
+{
+ if (is_metadata) {
+ return p_cursor->get_key_view(vb.get_header_magic())
+ .create_clone_object_md_hint(object_id, block_size);
+ } else {
+ return p_cursor->get_key_view(vb.get_header_magic())
+ .create_clone_object_data_hint(object_id, block_size);
+ }
}
std::unique_ptr<ValueDeltaRecorder>
return read_value_header()->payload_size;
}
- laddr_t get_hint() const;
+ laddr_hint_t init_hint(
+ extent_len_t block_size,
+ bool is_metadata) const;
+ laddr_hint_t generate_clone_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size,
+ bool is_metadata) const;
bool operator==(const Value& v) const { return p_cursor == v.p_cursor; }
bool operator!=(const Value& v) const { return !(*this == v); }
std::swap(layout.xattr_root, o_mlayout.xattr_root);
});
}
- laddr_t get_hint() const final {return L_ADDR_MIN; }
+ laddr_hint_t get_hint() const {
+ laddr_hint_t hint;
+ hint.addr = laddr_t::from_byte_offset(0);
+ hint.condition = laddr_conflict_condition_t::all_at_object_content;
+ hint.policy = laddr_conflict_policy_t::linear_search;
+ hint.block_size = laddr_t::UNIT_SIZE;
+ return hint;
+ }
+ laddr_hint_t init_hint(
+ extent_len_t block_size,
+ bool is_metadata) const final {
+ return get_hint();
+ }
+ laddr_hint_t generate_clone_hint(
+ local_object_id_t object_id,
+ extent_len_t block_size,
+ bool is_metadata) const final {
+ return get_hint();
+ }
~TestOnode() final = default;
void set_need_cow(Transaction &t) final {