Skip to content

Commit dfc909d

Browse files
committed
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 <[email protected]>
1 parent 87648ed commit dfc909d

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/crimson/osd/object_context.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ class ObjectContext : public ceph::common::intrusive_lru_base<
7979
ObjectContext(hobject_t hoid) : lock(hoid),
8080
obs(std::move(hoid)) {}
8181

82-
void update_from(const ObjectContext &obc) {
83-
obs = obc.obs;
84-
ssc = obc.ssc;
82+
void update_from(
83+
std::pair<ObjectState, SnapSetContextRef> obc_data) {
84+
obs = obc_data.first;
85+
ssc = obc_data.second;
8586
}
8687

8788
const hobject_t &get_oid() const {

src/crimson/osd/pg.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -956,12 +956,12 @@ PG::BackgroundProcessLock::lock() noexcept
956956
}
957957

958958
// We may need to rollback the ObjectContext on failed op execution.
959-
// Copy the current obc before mutating it in order to recover on failures.
960-
ObjectContextRef duplicate_obc(const ObjectContextRef &obc) {
961-
ObjectContextRef object_context = new ObjectContext(obc->obs.oi.soid);
962-
object_context->obs = obc->obs;
963-
object_context->ssc = new SnapSetContext(*obc->ssc);
964-
return object_context;
959+
// Copy the current obc data before mutating it in order to recover on failures.
960+
std::pair<ObjectState, SnapSetContextRef>
961+
duplicate_obc_data(const ObjectContextRef &obc) {
962+
ObjectState os = obc->obs;
963+
SnapSetContextRef ssc = new SnapSetContext(*obc->ssc);
964+
return {os, ssc};
965965
}
966966

967967
PG::interruptible_future<> PG::complete_error_log(const ceph_tid_t& rep_tid,
@@ -1078,8 +1078,8 @@ PG::run_executer_fut PG::run_executer(
10781078
{
10791079
LOG_PREFIX(PG::run_executer);
10801080
auto rollbacker = ox.create_rollbacker(
1081-
[stored_obc=duplicate_obc(obc)](auto &obc) mutable {
1082-
obc->update_from(*stored_obc);
1081+
[obc_data = duplicate_obc_data(obc)](auto &obc) mutable {
1082+
obc->update_from(obc_data);
10831083
});
10841084
auto rollback_on_error = seastar::defer([&rollbacker] {
10851085
rollbacker.rollback_obc_if_modified();

0 commit comments

Comments
 (0)