Skip to content

Commit 0b9d3d2

Browse files
authored
Merge pull request ceph#61253 from Matan-B/wip-matanb-crimson-tri_mutex_pointer
crimson/common/tri_mutex: improve logging Reviewed-by: Yingxin Cheng <[email protected]> Reviewed-by: Aishwarya Mathuria <[email protected]>
2 parents ce91e23 + 0e027d5 commit 0b9d3d2

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

src/crimson/common/tri_mutex.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <seastar/core/future.hh>
77
#include <seastar/core/circular_buffer.hh>
88

9-
#include "common/hobject.h"
109
#include "crimson/common/log.h"
1110

1211
class read_lock {
@@ -47,9 +46,10 @@ class tri_mutex : private read_lock,
4746
public:
4847
tri_mutex() = default;
4948
#ifdef NDEBUG
50-
tri_mutex(const hobject_t &obj_name) : name() {}
49+
tri_mutex(const std::string &obj_str) : name() {}
5150
#else
52-
tri_mutex(const hobject_t &obj_name) : name(obj_name) {}
51+
tri_mutex(const std::string &obj_str) : name(obj_str) {
52+
}
5353
#endif
5454
~tri_mutex();
5555

@@ -101,8 +101,8 @@ class tri_mutex : private read_lock,
101101
}
102102
}
103103

104-
std::string get_name() const{
105-
return name.to_str();
104+
std::string_view get_name() const{
105+
return name;
106106
}
107107

108108
private:
@@ -124,7 +124,7 @@ class tri_mutex : private read_lock,
124124
type_t type;
125125
};
126126
seastar::circular_buffer<waiter_t> waiters;
127-
const hobject_t name;
127+
const std::string name;
128128
friend class read_lock;
129129
friend class write_lock;
130130
friend class excl_lock;
@@ -134,9 +134,9 @@ class tri_mutex : private read_lock,
134134
inline std::ostream& operator<<(std::ostream& os, const tri_mutex& tm)
135135
{
136136
os << fmt::format("tri_mutex {} writers {} readers {}"
137-
" exclusively_used {} waiters: {}",
137+
" exclusively_used {} waiters: {} address {}",
138138
tm.get_name(), tm.get_writers(), tm.get_readers(),
139-
tm.exclusively_used, tm.waiters.size());
139+
tm.exclusively_used, tm.waiters.size(), fmt::ptr(&tm));
140140
return os;
141141
}
142142

src/crimson/osd/object_context.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ class ObjectContext : public ceph::common::intrusive_lru_base<
7676

7777
CommonOBCPipeline obc_pipeline;
7878

79-
ObjectContext(hobject_t hoid) : lock(hoid),
79+
ObjectContext(hobject_t hoid) : lock(hoid.to_str()),
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
@@ -967,12 +967,12 @@ PG::BackgroundProcessLock::lock() noexcept
967967
}
968968

969969
// We may need to rollback the ObjectContext on failed op execution.
970-
// Copy the current obc before mutating it in order to recover on failures.
971-
ObjectContextRef duplicate_obc(const ObjectContextRef &obc) {
972-
ObjectContextRef object_context = new ObjectContext(obc->obs.oi.soid);
973-
object_context->obs = obc->obs;
974-
object_context->ssc = new SnapSetContext(*obc->ssc);
975-
return object_context;
970+
// Copy the current obc data before mutating it in order to recover on failures.
971+
std::pair<ObjectState, SnapSetContextRef>
972+
duplicate_obc_data(const ObjectContextRef &obc) {
973+
ObjectState os = obc->obs;
974+
SnapSetContextRef ssc = new SnapSetContext(*obc->ssc);
975+
return {os, ssc};
976976
}
977977

978978
PG::interruptible_future<> PG::complete_error_log(const ceph_tid_t& rep_tid,
@@ -1089,8 +1089,8 @@ PG::run_executer_fut PG::run_executer(
10891089
{
10901090
LOG_PREFIX(PG::run_executer);
10911091
auto rollbacker = ox.create_rollbacker(
1092-
[stored_obc=duplicate_obc(obc)](auto &obc) mutable {
1093-
obc->update_from(*stored_obc);
1092+
[obc_data = duplicate_obc_data(obc)](auto &obc) mutable {
1093+
obc->update_from(obc_data);
10941094
});
10951095
auto rollback_on_error = seastar::defer([&rollbacker] {
10961096
rollbacker.rollback_obc_if_modified();

0 commit comments

Comments
 (0)