Skip to content

Commit db3addf

Browse files
committed
crimson/osd/shard_services: retain map references in OSDSingletonState::store_maps
Introduced: 3f11cd9 Fixes: https://tracker.ceph.com/issues/63996 Signed-off-by: Samuel Just <[email protected]>
1 parent cb02911 commit db3addf

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

src/crimson/osd/osd_meta.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,31 @@ OSDMeta::load_final_pool_info(int64_t pool) {
105105

106106
void OSDMeta::store_final_pool_info(
107107
ceph::os::Transaction &t,
108-
OSDMap* lastmap,
109-
std::map<epoch_t, OSDMap*> &added_map)
108+
LocalOSDMapRef previous,
109+
std::map<epoch_t, LocalOSDMapRef> &added_map)
110110
{
111111
for (auto [e, map] : added_map) {
112-
if (!lastmap) {
113-
lastmap = map;
112+
if (!previous) {
113+
previous = map;
114114
continue;
115115
}
116-
for (auto &[pool_id, pool] : lastmap->get_pools()) {
116+
for (auto &[pool_id, pool] : previous->get_pools()) {
117117
if (!map->have_pg_pool(pool_id)) {
118118
ghobject_t obj = final_pool_info_oid(pool_id);
119119
bufferlist bl;
120120
encode(pool, bl, CEPH_FEATURES_ALL);
121-
string name = lastmap->get_pool_name(pool_id);
121+
string name = previous->get_pool_name(pool_id);
122122
encode(name, bl);
123123
std::map<string, string> profile;
124124
if (pool.is_erasure()) {
125-
profile = lastmap->get_erasure_code_profile(
125+
profile = previous->get_erasure_code_profile(
126126
pool.erasure_code_profile);
127127
}
128128
encode(profile, bl);
129129
t.write(coll->get_cid(), obj, 0, bl.length(), bl);
130130
}
131131
}
132-
lastmap = map;
132+
previous = map;
133133
}
134134
}
135135

src/crimson/osd/osd_meta.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <map>
77
#include <string>
88
#include <seastar/core/future.hh>
9+
#include "osd/OSDMap.h"
910
#include "osd/osd_types.h"
1011
#include "crimson/os/futurized_collection.h"
1112
#include "crimson/os/futurized_store.h"
@@ -63,8 +64,8 @@ class OSDMeta {
6364
ec_profile_t>> load_final_pool_info(int64_t pool);
6465
void store_final_pool_info(
6566
ceph::os::Transaction&,
66-
OSDMap* lastmap,
67-
std::map<epoch_t, OSDMap*>&);
67+
LocalOSDMapRef lastmap,
68+
std::map<epoch_t, LocalOSDMapRef>&);
6869
private:
6970
static ghobject_t osdmap_oid(epoch_t epoch);
7071
static ghobject_t inc_osdmap_oid(epoch_t epoch);

src/crimson/osd/shard_services.cc

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,13 @@ seastar::future<std::unique_ptr<OSDMap>> OSDSingletonState::load_map(epoch_t e)
466466
});
467467
}
468468

469-
seastar::future<> OSDSingletonState::store_maps(ceph::os::Transaction& t,
470-
epoch_t start, Ref<MOSDMap> m)
469+
seastar::future<> OSDSingletonState::store_maps(
470+
ceph::os::Transaction& t,
471+
epoch_t start, Ref<MOSDMap> m)
471472
{
472473
LOG_PREFIX(OSDSingletonState::store_maps);
473474
return seastar::do_with(
474-
std::map<epoch_t, OSDMap*>(),
475+
std::map<epoch_t, local_cached_map_t>(),
475476
[&t, FNAME, m, start, this](auto &added_maps) {
476477
return seastar::do_for_each(
477478
boost::make_counting_iterator(start),
@@ -482,8 +483,7 @@ seastar::future<> OSDSingletonState::store_maps(ceph::os::Transaction& t,
482483
o->decode(p->second);
483484
INFO("storing osdmap.{}", e);
484485
store_map_bl(t, e, std::move(std::move(p->second)));
485-
added_maps.emplace(e, o.get());
486-
osdmaps.insert(e, std::move(o));
486+
added_maps.emplace(e, osdmaps.insert(e, std::move(o)));
487487
return seastar::now();
488488
} else if (auto p = m->incremental_maps.find(e);
489489
p != m->incremental_maps.end()) {
@@ -500,19 +500,27 @@ seastar::future<> OSDSingletonState::store_maps(ceph::os::Transaction& t,
500500
o->encode(fbl, inc.encode_features | CEPH_FEATURE_RESERVED);
501501
INFO("storing osdmap.{}", o->get_epoch());
502502
store_map_bl(t, e, std::move(fbl));
503-
added_maps.emplace(e, o.get());
504-
osdmaps.insert(e, std::move(o));
503+
added_maps.emplace(e, osdmaps.insert(e, std::move(o)));
505504
return seastar::now();
506505
});
507506
} else {
508507
ERROR("MOSDMap lied about what maps it had?");
509508
return seastar::now();
510509
}
511510
}).then([&t, FNAME, this, &added_maps] {
512-
auto [e, map] = *added_maps.begin();
513-
auto lastmap = osdmaps.find(e - 1).get();
514-
meta_coll->store_final_pool_info(t, lastmap, added_maps);
515-
return seastar::now();
511+
epoch_t last_map_epoch = superblock.get_newest_map();
512+
auto last_map_fut = last_map_epoch > 0
513+
? get_local_map(last_map_epoch)
514+
: seastar::make_ready_future<local_cached_map_t>();
515+
return last_map_fut.then(
516+
[&t, FNAME, last_map_epoch, this, &added_maps](auto lastmap) {
517+
INFO("storing final pool info lastmap epoch {}, added maps {}->{}",
518+
last_map_epoch,
519+
added_maps.begin()->first,
520+
added_maps.rbegin()->first);
521+
meta_coll->store_final_pool_info(t, lastmap, added_maps);
522+
return seastar::now();
523+
});
516524
});
517525
});
518526
}

0 commit comments

Comments
 (0)