char oi[MAX_OI_LENGTH] = {0};
char ss[MAX_SS_LENGTH] = {0};
+ /**
+ * needs_cow
+ *
+ * If true, all lba mappings for onode must be cloned
+ * to a new range prior to mutation. See ObjectDataHandler::copy_on_write,
+ * do_clone, do_clonerange
+ */
+ bool need_cow = false;
onode_layout_t() : omap_root(omap_type_t::OMAP), log_root(omap_type_t::LOG),
xattr_root(omap_type_t::XATTR) {}
virtual void update_snapset(Transaction&, ceph::bufferlist&) = 0;
virtual void clear_object_info(Transaction&) = 0;
virtual void clear_snapset(Transaction&) = 0;
+ virtual void set_need_cow(Transaction&) = 0;
+ virtual void unset_need_cow(Transaction&) = 0;
laddr_t get_metadata_hint(uint64_t block_size) const {
assert(default_metadata_offset);
ceph::decode(op, bliter);
auto &mlayout = *reinterpret_cast<onode_layout_t*>(value.get_write());
switch (op) {
+ case delta_op_t::UNSET_NEED_COW:
+ DEBUG("setting need_cow");
+ bliter.copy(
+ sizeof(mlayout.need_cow),
+ (char *)&mlayout.need_cow);
+ break;
+ case delta_op_t::SET_NEED_COW:
+ DEBUG("setting need_cow");
+ bliter.copy(
+ sizeof(mlayout.need_cow),
+ (char *)&mlayout.need_cow);
+ break;
case delta_op_t::UPDATE_ONODE_SIZE:
DEBUG("update onode size");
bliter.copy(sizeof(mlayout.size), (char *)&mlayout.size);
auto &encoded = get_encoded(payload_mut);
ceph::encode(op, encoded);
switch(op) {
+ case delta_op_t::UNSET_NEED_COW:
+ DEBUG("setting need_cow");
+ encoded.append(
+ (const char *)&layout.need_cow,
+ sizeof(layout.need_cow));
+ break;
+ case delta_op_t::SET_NEED_COW:
+ DEBUG("setting need_cow");
+ encoded.append(
+ (const char *)&layout.need_cow,
+ sizeof(layout.need_cow));
+ break;
case delta_op_t::UPDATE_ONODE_SIZE:
DEBUG("update onode size");
encoded.append(
UPDATE_SNAPSET,
CLEAR_OBJECT_INFO,
CLEAR_SNAPSET,
- CREATE_DEFAULT
+ CREATE_DEFAULT,
+ SET_NEED_COW,
+ UNSET_NEED_COW
};
Recorder(bufferlist &bl) : ValueDeltaRecorder(bl) {}
});
}
+ void set_need_cow(Transaction &t) final {
+ with_mutable_layout(
+ t,
+ [](NodeExtentMutable &payload_mut, Recorder *recorder) {
+ auto &mlayout = *reinterpret_cast<onode_layout_t*>(
+ payload_mut.get_write());
+ mlayout.need_cow = true;
+ if (recorder) {
+ recorder->encode_update(
+ payload_mut, Recorder::delta_op_t::SET_NEED_COW);
+ }
+ });
+ }
+
+ void unset_need_cow(Transaction &t) final {
+ with_mutable_layout(
+ t,
+ [](NodeExtentMutable &payload_mut, Recorder *recorder) {
+ auto &mlayout = *reinterpret_cast<onode_layout_t*>(
+ payload_mut.get_write());
+ mlayout.need_cow = false;
+ if (recorder) {
+ recorder->encode_update(
+ payload_mut, Recorder::delta_op_t::UNSET_NEED_COW);
+ }
+ });
+ }
+
void update_onode_size(Transaction &t, uint32_t size) final {
with_mutable_layout(
t,
laddr_t get_hint() const final {return L_ADDR_MIN; }
~TestOnode() final = default;
+ void set_need_cow(Transaction &t) final {
+ with_mutable_layout(t, [](onode_layout_t &mlayout) {
+ mlayout.need_cow = true;
+ });
+ }
+
+ void unset_need_cow(Transaction &t) final {
+ with_mutable_layout(t, [](onode_layout_t &mlayout) {
+ mlayout.need_cow = false;
+ });
+ }
+
void update_onode_size(Transaction &t, uint32_t size) final {
with_mutable_layout(t, [size](onode_layout_t &mlayout) {
mlayout.size = size;