void PG::_finish_recovery(Context *c)
{
- lock();
+ std::scoped_lock locker{*this};
// When recovery is initiated by a repair, that flag is left on
state_clear(PG_STATE_REPAIR);
if (recovery_state.is_deleting()) {
- unlock();
return;
}
if (c == finish_sync_event) {
} else {
dout(10) << "_finish_recovery -- stale" << dendl;
}
- unlock();
}
void PG::start_recovery_op(const hobject_t& soid)
void PG::shutdown()
{
ch->flush();
- lock();
+ std::scoped_lock l{*this};
recovery_state.shutdown();
on_shutdown();
- unlock();
}
#pragma GCC diagnostic ignored "-Wpragmas"
epoch_t epoch;
FlushState(PG *pg, epoch_t epoch) : pg(pg), epoch(epoch) {}
~FlushState() {
- pg->lock();
+ std::scoped_lock l{*pg};
if (!pg->pg_has_reset_since(epoch)) {
pg->recovery_state.complete_flush();
}
- pg->unlock();
}
};
typedef std::shared_ptr<FlushState> FlushStateRef;
dout(20) << __func__ << " wake up at "
<< ceph_clock_now()
<< ", re-queuing delete" << dendl;
- lock();
+ std::scoped_lock locker{*this};
delete_needs_sleep = false;
if (!pg_has_reset_since(e)) {
osd->queue_for_pg_delete(get_pgid(), e);
}
- unlock();
});
auto delete_schedule_time = ceph::real_clock::now();
void PG::dump_pgstate_history(Formatter *f)
{
- lock();
+ std::scoped_lock l{*this};
recovery_state.dump_history(f);
- unlock();
}
void PG::dump_missing(Formatter *f)
BlessedGenContext(PrimaryLogPG *pg, GenContext<T> *c, epoch_t e)
: pg(pg), c(c), e(e) {}
void finish(T t) override {
- pg->lock();
+ std::scoped_lock locker{*pg};
if (pg->pg_has_reset_since(e))
c.reset();
else
c.release()->complete(t);
- pg->unlock();
}
bool sync_finish(T t) {
// we assume here all blessed/wrapped Contexts can complete synchronously.
BlessedContext(PrimaryLogPG *pg, Context *c, epoch_t e)
: pg(pg), c(c), e(e) {}
void finish(int r) override {
- pg->lock();
+ std::scoped_lock locker{*pg};
if (pg->pg_has_reset_since(e))
c.reset();
else
c.release()->complete(r);
- pg->unlock();
}
bool sync_finish(int r) {
// we assume here all blessed/wrapped Contexts can complete synchronously.
return true;
}
void finish(int r) override {
- pg->lock();
+ std::scoped_lock locker{*pg};
pg->_applied_recovered_object(obc);
- pg->unlock();
}
};
return true;
}
void finish(int r) override {
- pg->lock();
+ std::scoped_lock locker{*pg};
pg->_applied_recovered_object_replica();
- pg->unlock();
}
};
void finish(int r) override {
if (r == -ECANCELED)
return;
- pg->lock();
+ std::scoped_lock locker{*pg};
pg->handle_manifest_flush(oid, tid, r, offset, last_offset, lpr);
pg->osd->logger->tinc(l_osd_tier_flush_lat, ceph_clock_now() - start);
- pg->unlock();
}
};
void finish(int r) override {
if (prdop->canceled)
return;
- pg->lock();
+ std::scoped_lock locker{*pg};
if (prdop->canceled) {
- pg->unlock();
return;
}
if (last_peering_reset == pg->get_last_peering_reset()) {
pg->finish_proxy_read(oid, tid, r);
pg->osd->logger->tinc(l_osd_tier_r_lat, ceph_clock_now() - start);
}
- pg->unlock();
}
};
void finish(int r) override {
if (prdop->canceled)
return;
- pg->lock();
+ std::scoped_lock locker{*pg};
if (prdop->canceled) {
- pg->unlock();
return;
}
if (last_peering_reset == pg->get_last_peering_reset()) {
delete obj_op;
}
}
- pg->unlock();
}
};
void finish(int r) override {
if (pwop->canceled)
return;
- pg->lock();
+ std::scoped_lock locker{*pg};
if (pwop->canceled) {
- pg->unlock();
return;
}
if (last_peering_reset == pg->get_last_peering_reset()) {
pg->finish_proxy_write(oid, tid, r);
}
- pg->unlock();
}
};
: pg(pg), ctx(ctx), osd_op(osd_op), last_peering_reset(lpr)
{}
void finish(int r) override {
- pg->lock();
+ std::scoped_lock locker{*pg};
if (last_peering_reset == pg->get_last_peering_reset()) {
if (r >= 0) {
osd_op.rval = 0;
pg->close_op_ctx(ctx);
}
}
- pg->unlock();
}
};
void finish(int r) override {
if (r == -ECANCELED)
return;
- pg->lock();
+ std::scoped_lock l{*pg};
if (last_peering_reset == pg->get_last_peering_reset()) {
pg->process_copy_chunk(oid, tid, r);
cop.reset();
}
- pg->unlock();
}
};
void finish(int r) override {
if (r == -ECANCELED)
return;
- pg->lock();
+ std::scoped_lock l{*pg};
if (last_peering_reset == pg->get_last_peering_reset()) {
pg->process_copy_chunk_manifest(oid, tid, r, offset);
cop.reset();
}
- pg->unlock();
}
};
void finish(int r) override {
if (r == -ECANCELED)
return;
- pg->lock();
+ std::scoped_lock locker{*pg};
if (last_peering_reset == pg->get_last_peering_reset()) {
pg->finish_flush(oid, tid, r);
pg->osd->logger->tinc(l_osd_tier_flush_lat, ceph_clock_now() - start);
}
- pg->unlock();
}
};
epoch_t epoch)
: pg(pg), rep_tid(rep_tid), epoch(epoch) {}
void finish(int) override {
- pg->lock();
+ std::scoped_lock l{*pg};
if (!pg->pg_has_reset_since(epoch)) {
auto it = pg->log_entry_update_waiting_on.find(rep_tid);
ceph_assert(it != pg->log_entry_update_waiting_on.end());
pg->log_entry_update_waiting_on.erase(it);
}
}
- pg->unlock();
}
};
t.register_on_commit(
void PrimaryLogPG::get_watchers(list<obj_watch_item_t> *ls)
{
- lock();
+ std::scoped_lock l{*this};
pair<hobject_t, ObjectContextRef> i;
while (object_contexts.get_next(i.first, &i)) {
ObjectContextRef obc(i.second);
get_obc_watchers(obc, *ls);
}
- unlock();
}
void PrimaryLogPG::get_obc_watchers(ObjectContextRef obc, list<obj_watch_item_t> &pg_watchers)
epoch_t cur_epoch = get_osdmap_epoch();
remove_missing_object(soid, v, new FunctionContext(
[=](int) {
- lock();
+ std::scoped_lock locker{*this};
if (!pg_has_reset_since(cur_epoch)) {
bool object_missing = false;
for (const auto& shard : get_acting_recovery_backfill()) {
pgbackend->run_recovery_op(recovery_handle, priority);
}
}
- unlock();
}));
return PULL_YES;
}
epoch_t cur_epoch = get_osdmap_epoch();
t.register_on_complete(new FunctionContext(
[=](int) {
- lock();
+ std::unique_lock locker{*this};
if (!pg_has_reset_since(cur_epoch)) {
ObjectStore::Transaction t2;
on_local_recover(soid, recovery_info, ObjectContextRef(), true, &t2);
t2.register_on_complete(on_complete);
int r = osd->store->queue_transaction(ch, std::move(t2), nullptr);
ceph_assert(r == 0);
- unlock();
+ locker.unlock();
} else {
- unlock();
+ locker.unlock();
on_complete->complete(-EAGAIN);
}
}));
void PrimaryLogPG::_committed_pushed_object(
epoch_t epoch, eversion_t last_complete)
{
- lock();
+ std::scoped_lock locker{*this};
if (!pg_has_reset_since(epoch)) {
recovery_state.recovery_committed_to(last_complete);
} else {
dout(10) << __func__
<< " pg has changed, not touching last_complete_ondisk" << dendl;
}
-
- unlock();
}
void PrimaryLogPG::_applied_recovered_object(ObjectContextRef obc)
[=](int) {
const MOSDPGUpdateLogMissing *msg = static_cast<const MOSDPGUpdateLogMissing*>(
op->get_req());
- lock();
+ std::scoped_lock locker{*this};
if (!pg_has_reset_since(msg->get_epoch())) {
update_last_complete_ondisk(new_lcod);
MOSDPGUpdateLogMissingReply *reply =
reply->set_priority(CEPH_MSG_PRIO_HIGH);
msg->get_connection()->send_message(reply);
}
- unlock();
});
if (get_osdmap()->require_osd_release >= ceph_release_t::kraken) {
// Return false if no objects operated on since start of object hash space
bool PrimaryLogPG::agent_work(int start_max, int agent_flush_quota)
{
- lock();
+ std::scoped_lock locker{*this};
if (!agent_state) {
dout(10) << __func__ << " no agent state, stopping" << dendl;
- unlock();
return true;
}
if (agent_state->is_idle()) {
dout(10) << __func__ << " idle, stopping" << dendl;
- unlock();
return true;
}
if (need_delay) {
ceph_assert(agent_state->delaying == false);
agent_delay();
- unlock();
return false;
}
agent_choose_mode();
- unlock();
return true;
}
void PrimaryLogPG::agent_choose_mode_restart()
{
dout(20) << __func__ << dendl;
- lock();
+ std::scoped_lock locker{*this};
if (agent_state && agent_state->delaying) {
agent_state->delaying = false;
agent_choose_mode(true);
}
- unlock();
}
bool PrimaryLogPG::agent_choose_mode(bool restart, OpRequestRef op)