]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/pg: duplicate_obc to not create ObjectContext
authorMatan Breizman <mbreizma@redhat.com>
Mon, 6 Jan 2025 18:21:20 +0000 (18:21 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 8 Jan 2025 10:28:06 +0000 (10:28 +0000)
Creating an ObjectContext instance will also result
in creating unnecessary members such as ObjectContext::tri_mutex.

While it should not cause any issues, it makes debugging tri_mutex
much harder as each object will result in an extra (unused) lock which
is destructed in the end of every run_executer execution (due to
the required `rollback_on_error.cancel()` call).

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/osd/object_context.h
src/crimson/osd/pg.cc

index 4195e5dc59754cebac1fcc73bfe0766feeaf4edf..83037889bedbf887ca624ef0394996d3e5554522 100644 (file)
@@ -79,9 +79,10 @@ public:
   ObjectContext(hobject_t hoid) : lock(hoid),
                                   obs(std::move(hoid)) {}
 
-  void update_from(const ObjectContext &obc) {
-    obs = obc.obs;
-    ssc = obc.ssc;
+  void update_from(
+    std::pair<ObjectState, SnapSetContextRef> obc_data) {
+    obs = obc_data.first;
+    ssc = obc_data.second;
   }
 
   const hobject_t &get_oid() const {
index bf521498abf4987964632e862f73cff8dc91d209..985926734b43a27b8d0c5cf2001d2ee50a1938f2 100644 (file)
@@ -956,12 +956,12 @@ PG::BackgroundProcessLock::lock() noexcept
 }
 
 // We may need to rollback the ObjectContext on failed op execution.
-// Copy the current obc before mutating it in order to recover on failures.
-ObjectContextRef duplicate_obc(const ObjectContextRef &obc) {
-  ObjectContextRef object_context = new ObjectContext(obc->obs.oi.soid);
-  object_context->obs = obc->obs;
-  object_context->ssc = new SnapSetContext(*obc->ssc);
-  return object_context;
+// Copy the current obc data before mutating it in order to recover on failures.
+std::pair<ObjectState, SnapSetContextRef>
+duplicate_obc_data(const ObjectContextRef &obc) {
+  ObjectState os = obc->obs;
+  SnapSetContextRef ssc = new SnapSetContext(*obc->ssc);
+  return {os, ssc};
 }
 
 PG::interruptible_future<> PG::complete_error_log(const ceph_tid_t& rep_tid,
@@ -1078,8 +1078,8 @@ PG::run_executer_fut PG::run_executer(
 {
   LOG_PREFIX(PG::run_executer);
   auto rollbacker = ox.create_rollbacker(
-    [stored_obc=duplicate_obc(obc)](auto &obc) mutable {
-      obc->update_from(*stored_obc);
+    [obc_data = duplicate_obc_data(obc)](auto &obc) mutable {
+      obc->update_from(obc_data);
     });
   auto rollback_on_error = seastar::defer([&rollbacker] {
     rollbacker.rollback_obc_if_modified();