Skip to content

Commit

Permalink
crimson/osd: put snapmapper's key-value pairs into dedicated objs
Browse files Browse the repository at this point in the history
Otherwise, PG::read_log_and_missing() will meet those key-values and
won't know what to do with them. This is modeling what the classic
osd is doing

Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
  • Loading branch information
xxhdx1985126 committed Jan 19, 2024
1 parent a29eed9 commit a91c509
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
14 changes: 12 additions & 2 deletions src/crimson/osd/pg.cc
Expand Up @@ -135,7 +135,7 @@ PG::PG(
osdriver(
&shard_services.get_store(),
coll_ref,
pgid.make_pgmeta_oid()),
make_snapmapper_oid()),
snap_mapper(
this->shard_services.get_cct(),
&osdriver,
Expand Down Expand Up @@ -596,7 +596,7 @@ void PG::schedule_renew_lease(epoch_t last_peering_reset, ceph::timespan delay)
}


void PG::init(
seastar::future<> PG::init(
int role,
const vector<int>& newup, int new_up_primary,
const vector<int>& newacting, int new_acting_primary,
Expand All @@ -607,6 +607,16 @@ void PG::init(
peering_state.init(
role, newup, new_up_primary, newacting,
new_acting_primary, history, pi, t);
assert(coll_ref);
return shard_services.get_store().exists(
get_collection_ref(), make_snapmapper_oid()
).safe_then([&t, this](bool existed) {
if (!existed) {
t.touch(coll_ref->get_cid(), make_snapmapper_oid());
}
},
::crimson::ct_error::assert_all{"unexpected eio"}
);
}

seastar::future<> PG::read_state(crimson::os::FuturizedStore::Shard* store)
Expand Down
12 changes: 11 additions & 1 deletion src/crimson/osd/pg.h
Expand Up @@ -471,7 +471,7 @@ class PG : public boost::intrusive_ref_counter<
}

/// initialize created PG
void init(
seastar::future<> init(
int role,
const std::vector<int>& up,
int up_primary,
Expand Down Expand Up @@ -646,6 +646,16 @@ class PG : public boost::intrusive_ref_counter<
OSDriver osdriver;
SnapMapper snap_mapper;

ghobject_t make_snapmapper_oid() {
return ghobject_t(hobject_t(
sobject_t(
object_t("snapmapper"),
0),
std::string(),
pgid.ps(),
pgid.pool(),
std::string()));
}
public:
// PeeringListener
void publish_stats_to_osd() final;
Expand Down
21 changes: 11 additions & 10 deletions src/crimson/osd/shard_services.cc
Expand Up @@ -669,30 +669,31 @@ seastar::future<Ref<PG>> ShardServices::handle_pg_create_info(
pg_shard_t(local_state.whoami, info->pgid.shard),
acting);

PeeringCtx rctx;
std::unique_ptr<PeeringCtx> rctx = std::make_unique<PeeringCtx>();
create_pg_collection(
rctx.transaction,
rctx->transaction,
info->pgid,
info->pgid.get_split_bits(pp->get_pg_num()));
init_pg_ondisk(
rctx.transaction,
rctx->transaction,
info->pgid,
pp);

pg->init(
return pg->init(
role,
up,
up_primary,
acting,
acting_primary,
info->history,
info->past_intervals,
rctx.transaction);

return start_operation<PGAdvanceMap>(
pg, *this, get_map()->get_epoch(), std::move(rctx), true
).second.then([pg=pg] {
return seastar::make_ready_future<Ref<PG>>(pg);
rctx->transaction
).then([this, pg=pg, rctx=std::move(rctx)] {
return start_operation<PGAdvanceMap>(
pg, *this, get_map()->get_epoch(), std::move(*rctx), true
).second.then([pg=pg] {
return seastar::make_ready_future<Ref<PG>>(pg);
});
});
});
});
Expand Down

0 comments on commit a91c509

Please sign in to comment.