From 86588d26a9613950a51122f2071251c457bdc37a Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 14 Nov 2024 16:53:50 -0800 Subject: [PATCH] crimson/.../pg_backend: split clone into clone_for_write, set_metadata Signed-off-by: Samuel Just --- src/crimson/osd/ops_executer.cc | 7 ++++- src/crimson/osd/pg_backend.cc | 45 +++++++++++++++++++++------------ src/crimson/osd/pg_backend.h | 19 ++++++++++---- 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/src/crimson/osd/ops_executer.cc b/src/crimson/osd/ops_executer.cc index 0d6ecf5ba75..0f36cb44b84 100644 --- a/src/crimson/osd/ops_executer.cc +++ b/src/crimson/osd/ops_executer.cc @@ -904,7 +904,12 @@ void OpsExecuter::execute_clone( osd_op_params->at_version.version++; // make clone - backend.clone(clone_obc->obs.oi, initial_obs, clone_obc->obs, txn); + backend.clone_for_write(soid, coid, txn); + backend.set_metadata( + coid, + clone_obc->obs.oi, + nullptr /* snapset */, + txn); delta_stats.num_objects++; if (clone_obc->obs.oi.is_omap()) { diff --git a/src/crimson/osd/pg_backend.cc b/src/crimson/osd/pg_backend.cc index 24a381b4cf7..a40b28caa8b 100644 --- a/src/crimson/osd/pg_backend.cc +++ b/src/crimson/osd/pg_backend.cc @@ -1283,22 +1283,6 @@ PGBackend::rm_xattr( return rm_xattr_iertr::now(); } -void PGBackend::clone( - /* const */object_info_t& snap_oi, - const ObjectState& os, - const ObjectState& d_os, - ceph::os::Transaction& txn) -{ - // See OpsExecuter::execute_clone documentation - txn.clone(coll->get_cid(), ghobject_t{os.oi.soid}, ghobject_t{d_os.oi.soid}); - { - ceph::bufferlist bv; - snap_oi.encode_no_oid(bv, CEPH_FEATURES_ALL); - txn.setattr(coll->get_cid(), ghobject_t{d_os.oi.soid}, OI_ATTR, bv); - } - txn.rmattr(coll->get_cid(), ghobject_t{d_os.oi.soid}, SS_ATTR); -} - using get_omap_ertr = crimson::os::FuturizedStore::Shard::read_errorator::extend< crimson::ct_error::enodata>; @@ -1835,3 +1819,32 @@ PGBackend::read_ierrorator::future<> PGBackend::tmapget( read_errorator::pass_further{}); } +void PGBackend::set_metadata( + const hobject_t &obj, + object_info_t &oi, + const SnapSet *ss /* non-null iff head */, + ceph::os::Transaction& txn) +{ + ceph_assert((obj.is_head() && ss) || (!obj.is_head() && !ss)); + { + ceph::bufferlist bv; + oi.encode_no_oid(bv, CEPH_FEATURES_ALL); + txn.setattr(coll->get_cid(), ghobject_t{obj}, OI_ATTR, bv); + } + if (ss) { + ceph::bufferlist bss; + encode(*ss, bss); + txn.setattr(coll->get_cid(), ghobject_t{obj}, SS_ATTR, bss); + } +} + +void PGBackend::clone_for_write( + const hobject_t &from, + const hobject_t &to, + ceph::os::Transaction &txn) +{ + // See OpsExecuter::execute_clone documentation + txn.clone(coll->get_cid(), ghobject_t{from}, ghobject_t{to}); + txn.rmattr(coll->get_cid(), ghobject_t{to}, SS_ATTR); +} + diff --git a/src/crimson/osd/pg_backend.h b/src/crimson/osd/pg_backend.h index 813218983fd..c24176a10e7 100644 --- a/src/crimson/osd/pg_backend.h +++ b/src/crimson/osd/pg_backend.h @@ -308,11 +308,6 @@ public: ObjectState& os, const OSDOp& osd_op, ceph::os::Transaction& trans); - void clone( - /* const */object_info_t& snap_oi, - const ObjectState& os, - const ObjectState& d_os, - ceph::os::Transaction& trans); interruptible_future stat( CollectionRef c, const ghobject_t& oid) const; @@ -411,6 +406,20 @@ public: ceph::os::Transaction& trans, osd_op_params_t& osd_op_params, object_stat_sum_t& delta_stats); + + /// sets oi and (for head) ss attrs + void set_metadata( + const hobject_t &obj, + object_info_t &oi, + const SnapSet *ss /* non-null iff head */, + ceph::os::Transaction& trans); + + /// clone from->to and clear ss attribute on to + void clone_for_write( + const hobject_t &from, + const hobject_t &to, + ceph::os::Transaction& trans); + virtual rep_op_fut_t submit_transaction(const std::set &pg_shards, const hobject_t& hoid, -- 2.39.5