Skip to content

Commit 32c9183

Browse files
committed
crimson/osd/pg: add PG::remove_object_maybe_snapmapped()
(recover/backfill)_delete should remove oids in the snap mapper together with the objects Signed-off-by: Xuehan Xu <[email protected]>
1 parent f2fdffa commit 32c9183

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

src/crimson/osd/pg.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,4 +1771,20 @@ PG::already_complete(const osd_reqid_t& reqid)
17711771
}
17721772
}
17731773

1774+
void PG::remove_maybe_snapmapped_object(
1775+
ceph::os::Transaction &t,
1776+
const hobject_t &soid)
1777+
{
1778+
t.remove(
1779+
coll_ref->get_cid(),
1780+
ghobject_t{soid, ghobject_t::NO_GEN, pg_whoami.shard});
1781+
if (soid.snap < CEPH_MAXSNAP) {
1782+
OSDriver::OSTransaction _t(osdriver.get_transaction(&t));
1783+
int r = snap_mapper.remove_oid(soid, &_t);
1784+
if (!(r == 0 || r == -ENOENT)) {
1785+
logger().debug("{}: remove_oid returned {}", __func__, cpp_strerror(r));
1786+
ceph_abort();
1787+
}
1788+
}
1789+
}
17741790
}

src/crimson/osd/pg.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,17 @@ class PG : public boost::intrusive_ref_counter<
432432
}
433433
void unreserve_recovery_space() final {}
434434

435+
void remove_maybe_snapmapped_object(
436+
ceph::os::Transaction &t,
437+
const hobject_t &soid);
438+
435439
struct PGLogEntryHandler : public PGLog::LogEntryHandler {
436440
PG *pg;
437441
ceph::os::Transaction *t;
438442
PGLogEntryHandler(PG *pg, ceph::os::Transaction *t) : pg(pg), t(t) {}
439443

440444
// LogEntryHandler
441-
void remove(const hobject_t &hoid) override {
442-
// TODO
443-
}
445+
void remove(const hobject_t &soid) override {}
444446
void try_stash(const hobject_t &hoid, version_t v) override {
445447
// TODO
446448
}

src/crimson/osd/recovery_backend.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <fmt/format.h>
55

6+
#include "crimson/common/coroutine.h"
67
#include "crimson/common/exception.h"
78
#include "crimson/osd/recovery_backend.h"
89
#include "crimson/osd/pg.h"
@@ -206,12 +207,14 @@ RecoveryBackend::handle_backfill_remove(
206207
ObjectStore::Transaction t;
207208
for ([[maybe_unused]] const auto& [soid, ver] : m.ls) {
208209
// TODO: the reserved space management. PG::try_reserve_recovery_space().
209-
t.remove(pg.get_collection_ref()->get_cid(),
210-
ghobject_t(soid, ghobject_t::NO_GEN, pg.get_pg_whoami().shard));
210+
co_await interruptor::async([this, soid=soid, &t] {
211+
pg.remove_maybe_snapmapped_object(t, soid);
212+
});
211213
}
212214
logger().debug("RecoveryBackend::handle_backfill_remove: do_transaction...");
213-
return shard_services.get_store().do_transaction(
214-
pg.get_collection_ref(), std::move(t)).or_terminate();
215+
co_await interruptor::make_interruptible(
216+
shard_services.get_store().do_transaction(
217+
pg.get_collection_ref(), std::move(t)).or_terminate());
215218
}
216219

217220
RecoveryBackend::interruptible_future<BackfillInterval>

src/crimson/osd/replicated_recovery_backend.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ ReplicatedRecoveryBackend::local_recover_delete(
232232
(auto lomt) -> interruptible_future<> {
233233
if (lomt->os.exists) {
234234
return seastar::do_with(ceph::os::Transaction(),
235-
[this, lomt = std::move(lomt)](auto& txn) {
236-
return backend->remove(lomt->os, txn).then_interruptible(
235+
[this, lomt = std::move(lomt)](auto& txn) mutable {
236+
return interruptor::async([this, lomt=std::move(lomt), &txn] {
237+
pg.remove_maybe_snapmapped_object(txn, lomt->os.oi.soid);
238+
}).then_interruptible(
237239
[this, &txn]() mutable {
238240
logger().debug("ReplicatedRecoveryBackend::local_recover_delete: do_transaction...");
239241
return shard_services.get_store().do_transaction(coll,

0 commit comments

Comments
 (0)