namespace crimson::os::seastore {
struct onode_layout_t {
+ // around 350 bytes for fixed fields in object_info_t,
+ // the left are for the variable-sized fields like oid
+ // FIXME: object_info_t may need to shrinked, at least
+ // oid doesn't need to be held in it.
+ static constexpr int MAX_OI_LENGTH = 1024;
+ // We might want to move the ss field out of onode_layout_t.
+ // The reason is that ss_attr may grow to relative large, as
+ // its clone_overlap may grow to a large size, if applications
+ // set objects to a relative large size(for the purpose of reducing
+ // the number of objects per OSD, so that all objects' metadata
+ // can be cached in memory) and do many modifications between
+ // snapshots.
+ static constexpr int MAX_SS_LENGTH = 128;
+
ceph_le32 size{0};
+ ceph_le32 oi_size{0};
+ ceph_le32 ss_size{0};
omap_root_le_t omap_root;
object_data_le_t object_data;
+
+ char oi[MAX_OI_LENGTH];
+ char ss[MAX_SS_LENGTH];
} __attribute__((packed));
class Transaction;
auto c = static_cast<SeastoreCollection*>(ch.get());
logger().debug("{} {} {}",
__func__, c->get_cid(), oid);
- return crimson::ct_error::enoent::make();
+ return repeat_with_onode<attrs_t>(
+ c, oid, [=](auto &t, auto& onode) {
+ auto& layout = onode.get_layout();
+ SeaStore::attrs_t attrs;
+ attrs[OI_ATTR] = ceph::bufferptr(&layout.oi[0], layout.oi_size);
+ attrs[SS_ATTR] = ceph::bufferptr(&layout.ss[0], layout.ss_size);
+ return attrs;
+ }).handle_error(crimson::ct_error::input_output_error::handle([this] {
+ logger().error("EIO when getting attrs");
+ abort();
+ }), crimson::ct_error::pass_further_all{});
}
seastar::future<struct stat> SeaStore::stat(
{
logger().debug("{} onode={}",
__func__, *onode);
+ auto& layout = onode->get_mutable_layout(*ctx.transaction);
+ for (auto& [key, val] : aset) {
+ if (key == OI_ATTR) {
+ if (__builtin_expect(
+ val.length() > onode_layout_t::MAX_OI_LENGTH,
+ false)) {
+ logger().error("{} onode={} oi attr too long!");
+ return crimson::ct_error::input_output_error::make();
+ }
+ layout.oi_size = val.length();
+ val.copy_out(0, val.length(), &layout.oi[0]);
+ } else if (key == SS_ATTR) {
+ if (__builtin_expect(
+ val.length() > onode_layout_t::MAX_SS_LENGTH,
+ false)) {
+ logger().error("{} onode={} oi attr too long!");
+ return crimson::ct_error::input_output_error::make();
+ }
+ layout.ss_size = val.length();
+ val.copy_out(0, val.length(), &layout.ss[0]);
+ } else {
+ //FIXME: right now, only OI_ATTR and SS_ATTR are supported
+ assert(0 == "only OI_ATTR and SS_ATTR are supported for now");
+ }
+ }
return tm_ertr::now();
}