From: Matan Breizman Date: Mon, 6 Jan 2025 18:21:20 +0000 (+0000) Subject: crimson/osd/pg: duplicate_obc to not create ObjectContext X-Git-Tag: v20.0.0~337^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dfc909d071ea40538d50668652c882d65f86b139;p=ceph.git crimson/osd/pg: duplicate_obc to not create ObjectContext 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 --- diff --git a/src/crimson/osd/object_context.h b/src/crimson/osd/object_context.h index 4195e5dc5975..83037889bedb 100644 --- a/src/crimson/osd/object_context.h +++ b/src/crimson/osd/object_context.h @@ -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 obc_data) { + obs = obc_data.first; + ssc = obc_data.second; } const hobject_t &get_oid() const { diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index bf521498abf4..985926734b43 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -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 +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();