Skip to content

Commit 45e4495

Browse files
authored
Merge pull request ceph#55407 from xxhdx1985126/wip-64282
crimson/osd/shard_services: make sure that only up/acting members can create pgs Reviewed-by: Chunmei Liu <[email protected]> Reviewed-by: Matan Breizman <[email protected]> Reviewed-by: Samuel Just <[email protected]>
2 parents 365171e + ddac5d1 commit 45e4495

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/crimson/osd/shard_services.cc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,23 @@ seastar::future<Ref<PG>> ShardServices::make_pg(
610610

611611
seastar::future<Ref<PG>> ShardServices::handle_pg_create_info(
612612
std::unique_ptr<PGCreateInfo> info) {
613-
LOG_PREFIX(OSDSingletonState::trim_maps);
614613
return seastar::do_with(
615614
std::move(info),
616-
[FNAME, this](auto &info)
615+
[this](auto &info)
617616
-> seastar::future<Ref<PG>> {
618617
return get_map(info->epoch).then(
619-
[&info, FNAME, this](cached_map_t startmap)
618+
[&info, this](cached_map_t startmap)
620619
-> seastar::future<std::tuple<Ref<PG>, cached_map_t>> {
620+
LOG_PREFIX(ShardServices::handle_pg_create_info);
621621
const spg_t &pgid = info->pgid;
622+
if (!get_map()->is_up_acting_osd_shard(pgid, local_state.whoami)
623+
|| !startmap->is_up_acting_osd_shard(pgid, local_state.whoami)) {
624+
DEBUG("ignore pgid {}, doesn't exist anymore, discarding");
625+
local_state.pg_map.pg_creation_canceled(pgid);
626+
return seastar::make_ready_future<
627+
std::tuple<Ref<PG>, OSDMapService::cached_map_t>
628+
>(std::make_tuple(Ref<PG>(), startmap));
629+
}
622630
if (info->by_mon) {
623631
int64_t pool_id = pgid.pgid.pool();
624632
const pg_pool_t *pool = get_map()->get_pg_pool(pool_id);
@@ -708,9 +716,9 @@ ShardServices::get_or_create_pg(
708716
std::unique_ptr<PGCreateInfo> info)
709717
{
710718
if (info) {
711-
auto [fut, creating] = local_state.pg_map.wait_for_pg(
719+
auto [fut, existed] = local_state.pg_map.wait_for_pg(
712720
std::move(trigger), pgid);
713-
if (!creating) {
721+
if (!existed) {
714722
local_state.pg_map.set_creating(pgid);
715723
(void)handle_pg_create_info(
716724
std::move(info));

0 commit comments

Comments
 (0)