Skip to content

Commit e56e908

Browse files
committed
crimson/osd: put snapmapper's key-value pairs into dedicated objs
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 <[email protected]>
1 parent 6f0803a commit e56e908

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

src/crimson/osd/pg.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ PG::PG(
136136
osdriver(
137137
&shard_services.get_store(),
138138
coll_ref,
139-
pgid.make_pgmeta_oid()),
139+
make_snapmapper_oid()),
140140
snap_mapper(
141141
this->shard_services.get_cct(),
142142
&osdriver,
@@ -596,7 +596,7 @@ void PG::schedule_renew_lease(epoch_t last_peering_reset, ceph::timespan delay)
596596
}
597597

598598

599-
void PG::init(
599+
seastar::future<> PG::init(
600600
int role,
601601
const vector<int>& newup, int new_up_primary,
602602
const vector<int>& newacting, int new_acting_primary,
@@ -607,6 +607,16 @@ void PG::init(
607607
peering_state.init(
608608
role, newup, new_up_primary, newacting,
609609
new_acting_primary, history, pi, t);
610+
assert(coll_ref);
611+
return shard_services.get_store().exists(
612+
get_collection_ref(), make_snapmapper_oid()
613+
).safe_then([&t, this](bool existed) {
614+
if (!existed) {
615+
t.touch(coll_ref->get_cid(), make_snapmapper_oid());
616+
}
617+
},
618+
::crimson::ct_error::assert_all{"unexpected eio"}
619+
);
610620
}
611621

612622
seastar::future<> PG::read_state(crimson::os::FuturizedStore::Shard* store)

src/crimson/osd/pg.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#include "crimson/osd/object_context_loader.h"
4242
#include "crimson/osd/scrub/pg_scrubber.h"
4343

44+
#define SNAPMAPPER_OID "snapmapper"
45+
4446
class MQuery;
4547
class OSDMap;
4648
class PGBackend;
@@ -471,7 +473,7 @@ class PG : public boost::intrusive_ref_counter<
471473
}
472474

473475
/// initialize created PG
474-
void init(
476+
seastar::future<> init(
475477
int role,
476478
const std::vector<int>& up,
477479
int up_primary,
@@ -647,12 +649,22 @@ class PG : public boost::intrusive_ref_counter<
647649
private:
648650
OSDriver osdriver;
649651
SnapMapper snap_mapper;
650-
652+
ghobject_t make_snapmapper_oid() const {
653+
return ghobject_t(hobject_t(
654+
sobject_t(
655+
object_t(SNAPMAPPER_OID),
656+
0),
657+
std::string(),
658+
pgid.ps(),
659+
pgid.pool(),
660+
std::string()));
661+
}
651662
public:
652663
// PeeringListener
653664
void publish_stats_to_osd() final;
654665
void clear_publish_stats() final;
655666
pg_stat_t get_stats() const;
667+
656668
private:
657669
std::optional<pg_stat_t> pg_stats;
658670

src/crimson/osd/shard_services.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -671,30 +671,31 @@ seastar::future<Ref<PG>> ShardServices::handle_pg_create_info(
671671
pg_shard_t(local_state.whoami, info->pgid.shard),
672672
acting);
673673

674-
PeeringCtx rctx;
674+
std::unique_ptr<PeeringCtx> rctx = std::make_unique<PeeringCtx>();
675675
create_pg_collection(
676-
rctx.transaction,
676+
rctx->transaction,
677677
info->pgid,
678678
info->pgid.get_split_bits(pp->get_pg_num()));
679679
init_pg_ondisk(
680-
rctx.transaction,
680+
rctx->transaction,
681681
info->pgid,
682682
pp);
683683

684-
pg->init(
684+
return pg->init(
685685
role,
686686
up,
687687
up_primary,
688688
acting,
689689
acting_primary,
690690
info->history,
691691
info->past_intervals,
692-
rctx.transaction);
693-
694-
return start_operation<PGAdvanceMap>(
695-
pg, *this, get_map()->get_epoch(), std::move(rctx), true
696-
).second.then([pg=pg] {
697-
return seastar::make_ready_future<Ref<PG>>(pg);
692+
rctx->transaction
693+
).then([this, pg=pg, rctx=std::move(rctx)] {
694+
return start_operation<PGAdvanceMap>(
695+
pg, *this, get_map()->get_epoch(), std::move(*rctx), true
696+
).second.then([pg=pg] {
697+
return seastar::make_ready_future<Ref<PG>>(pg);
698+
});
698699
});
699700
});
700701
});

0 commit comments

Comments
 (0)