Skip to content

Commit 71ba426

Browse files
committed
crimson/osd/recovery_backend: fix RecoveryBackend::temp_contents usage
All temp objects are added *only* to PGBackend::temp_content. cleaning RecoveryBackend::temp_contents (which is always empty) instead of PGBackend::temp_contents is wrong. Signed-off-by: Xuehan Xu <[email protected]>
1 parent e33c5a3 commit 71ba426

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/crimson/osd/pg_backend.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,6 @@ class PGBackend
486486
friend class ::crimson::osd::PG;
487487

488488
protected:
489-
boost::container::flat_set<hobject_t> temp_contents;
490-
491489
template <class... Args>
492490
void add_temp_obj(Args&&... args) {
493491
temp_contents.insert(std::forward<Args>(args)...);
@@ -501,5 +499,15 @@ class PGBackend
501499
clear_temp_obj(oid);
502500
}
503501
}
502+
template <typename Func>
503+
void for_each_temp_obj(Func &&f) {
504+
std::for_each(temp_contents.begin(), temp_contents.end(), f);
505+
}
506+
void clear_temp_objs() {
507+
temp_contents.clear();
508+
}
509+
private:
510+
boost::container::flat_set<hobject_t> temp_contents;
511+
504512
friend class RecoveryBackend;
505513
};

src/crimson/osd/recovery_backend.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ void RecoveryBackend::clear_temp_obj(const hobject_t &oid)
4545
void RecoveryBackend::clean_up(ceph::os::Transaction& t,
4646
std::string_view why)
4747
{
48-
for (auto& soid : temp_contents) {
48+
for_each_temp_obj([&](auto &soid) {
4949
t.remove(pg.get_collection_ref()->get_cid(),
5050
ghobject_t(soid, ghobject_t::NO_GEN, pg.get_pg_whoami().shard));
51-
}
52-
temp_contents.clear();
51+
});
52+
clear_temp_objs();
5353

5454
for (auto& [soid, recovery_waiter] : recovering) {
5555
if ((recovery_waiter->pull_info

src/crimson/osd/recovery_backend.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "crimson/os/futurized_collection.h"
1111
#include "crimson/osd/pg_interval_interrupt_condition.h"
1212
#include "crimson/osd/object_context.h"
13+
#include "crimson/osd/pg_backend.h"
1314
#include "crimson/osd/shard_services.h"
1415

1516
#include "messages/MOSDPGBackfill.h"
@@ -22,8 +23,6 @@ namespace crimson::osd{
2223
class PG;
2324
}
2425

25-
class PGBackend;
26-
2726
class RecoveryBackend {
2827
public:
2928
class WaitForObjectRecovery;
@@ -240,10 +239,15 @@ class RecoveryBackend {
240239
const hobject_t& target,
241240
eversion_t version) const;
242241

243-
boost::container::flat_set<hobject_t> temp_contents;
244-
245242
void add_temp_obj(const hobject_t &oid);
246243
void clear_temp_obj(const hobject_t &oid);
244+
template <typename Func>
245+
void for_each_temp_obj(Func &&f) {
246+
backend->for_each_temp_obj(std::forward<Func>(f));
247+
}
248+
void clear_temp_objs() {
249+
backend->clear_temp_objs();
250+
}
247251

248252
void clean_up(ceph::os::Transaction& t, std::string_view why);
249253
virtual seastar::future<> on_stop() = 0;

0 commit comments

Comments
 (0)