]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/.../pg_backend: split clone into clone_for_write, set_metadata
authorSamuel Just <sjust@redhat.com>
Fri, 15 Nov 2024 00:53:50 +0000 (16:53 -0800)
committerSamuel Just <sjust@redhat.com>
Fri, 13 Dec 2024 20:32:26 +0000 (12:32 -0800)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/osd/ops_executer.cc
src/crimson/osd/pg_backend.cc
src/crimson/osd/pg_backend.h

index 0d6ecf5ba7572ac3dcaf926d46117e5cc75c3068..0f36cb44b8424db5d1e08e3952bc7f8681f8c1b7 100644 (file)
@@ -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()) {
index 24a381b4cf7e24026a1f2040fc85654735e6dbd1..a40b28caa8b6258b7acad7bf520106eb6c80ff87 100644 (file)
@@ -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);
+}
+
index 813218983fdf75e1d78009962d0b9f7bf043fb97..c24176a10e73b33b014446c4eeee735f40052a21 100644 (file)
@@ -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<struct stat> 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_shard_t> &pg_shards,
                     const hobject_t& hoid,