static constexpr tree_conf_t TREE_CONF = {
value_magic_t::ONODE,
128, // max_ns_size
- 320 // max_oid_size
+ 320, // max_oid_size
+ 1200 // max_value_payload_size
};
enum class status_t {
crimson::ct_error::value_too_large>;
insert_ertr::future<std::pair<Cursor, bool>>
insert(Transaction& t, const ghobject_t& obj, tree_value_config_t _vconf) {
+ LOG_PREFIX(OTree::insert);
+ if (_vconf.payload_size > value_builder.get_max_value_payload_size()) {
+ ERRORT("value payload size {} too large to insert {}",
+ t, _vconf.payload_size, key_hobj_t{obj});
+ return crimson::ct_error::value_too_large::make();
+ }
if (obj.hobj.nspace.size() > value_builder.get_max_ns_size()) {
ERRORT("namespace size {} too large to insert {}",
t, obj.hobj.nspace.size(), key_hobj_t{obj});
const value_header_t* Value::read_value_header() const
{
- return p_cursor->read_value_header(vb.get_header_magic());
+ auto ret = p_cursor->read_value_header(vb.get_header_magic());
+ assert(ret->payload_size <= vb.get_max_value_payload_size());
+ return ret;
}
std::pair<NodeExtentMutable&, ValueDeltaRecorder*>
value_magic_t value_magic;
string_size_t max_ns_size;
string_size_t max_oid_size;
+ value_size_t max_value_payload_size;
};
class tree_cursor_t;
virtual value_magic_t get_header_magic() const = 0;
virtual string_size_t get_max_ns_size() const = 0;
virtual string_size_t get_max_oid_size() const = 0;
+ virtual value_size_t get_max_value_payload_size() const = 0;
virtual std::unique_ptr<ValueDeltaRecorder>
build_value_recorder(ceph::bufferlist&) const = 0;
};
string_size_t get_max_oid_size() const override {
return ValueImpl::TREE_CONF.max_oid_size;
}
+ value_size_t get_max_value_payload_size() const override {
+ return ValueImpl::TREE_CONF.max_value_payload_size;
+ }
std::unique_ptr<ValueDeltaRecorder>
build_value_recorder(ceph::bufferlist& encoded) const override {
template <value_magic_t MAGIC,
string_size_t MAX_NS_SIZE,
- string_size_t MAX_OID_SIZE>
+ string_size_t MAX_OID_SIZE,
+ value_size_t MAX_VALUE_PAYLOAD_SIZE>
class TestValue final : public Value {
public:
static constexpr tree_conf_t TREE_CONF = {
MAGIC,
MAX_NS_SIZE,
- MAX_OID_SIZE
+ MAX_OID_SIZE,
+ MAX_VALUE_PAYLOAD_SIZE
};
using id_t = test_item_t::id_t;
};
using UnboundedValue = TestValue<
- value_magic_t::TEST_UNBOUND, 4096, 4096>;
+ value_magic_t::TEST_UNBOUND, 4096, 4096, 4096>;
using BoundedValue = TestValue<
- value_magic_t::TEST_BOUNDED, 320, 320>;
+ value_magic_t::TEST_BOUNDED, 320, 320, 640>;
}