]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: move OSDService::max_oldest_map into OSDSuperblock
authorMatan Breizman <mbreizma@redhat.com>
Thu, 3 Nov 2022 07:51:35 +0000 (07:51 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Tue, 16 May 2023 10:36:50 +0000 (10:36 +0000)
Persist max_oldest_map to the superblock.

Note: cherry-pick was manually edited (change in existing OSD members from original commit)

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
(cherry picked from commit 5c65627edc7daaf71c034c21579dfcd0b9982f10)

src/osd/OSD.cc
src/osd/OSD.h
src/osd/osd_types.cc
src/osd/osd_types.h

index 7d8cf923c1f3f89178add28a79eb5ff0aafd30f2..ceca805bfc08861f6eeed28fc16e3c4fd04b5c25 100644 (file)
@@ -261,7 +261,6 @@ OSDService::OSDService(OSD *osd, ceph::async::io_context_pool& poolctx) :
   osd_skip_data_digest(cct->_conf, "osd_skip_data_digest"),
   publish_lock{ceph::make_mutex("OSDService::publish_lock")},
   pre_publish_lock{ceph::make_mutex("OSDService::pre_publish_lock")},
-  max_oldest_map(0),
   m_scrub_queue{cct, *this},
   agent_valid_iterator(false),
   agent_ops(0),
@@ -1337,7 +1336,7 @@ MOSDMap *OSDService::build_incremental_map_msg(epoch_t since, epoch_t to,
 {
   MOSDMap *m = new MOSDMap(monc->get_fsid(),
                           osdmap->get_encoding_features());
-  m->oldest_map = max_oldest_map;
+  m->oldest_map = sblock.max_oldest_map;
   m->newest_map = sblock.newest_map;
 
   int max = cct->_conf->osd_map_message_max;
@@ -1347,8 +1346,9 @@ MOSDMap *OSDService::build_incremental_map_msg(epoch_t since, epoch_t to,
     // we don't have the next map the target wants, so start with a
     // full map.
     bufferlist bl;
-    dout(10) << __func__ << " oldest map " << max_oldest_map << " > since "
-            << since << ", starting with full map" << dendl;
+    dout(10) << __func__ << " oldest map " << sblock.max_oldest_map
+             << " > since " << since << ", starting with full map"
+             << dendl;
     since = m->oldest_map;
     if (!get_map_bl(since, bl)) {
       derr << __func__ << " missing full map " << since << dendl;
@@ -1419,7 +1419,7 @@ void OSDService::send_incremental_map(epoch_t since, Connection *con,
       // just send latest full map
       MOSDMap *m = new MOSDMap(monc->get_fsid(),
                               osdmap->get_encoding_features());
-      m->oldest_map = max_oldest_map;
+      m->oldest_map = sblock.max_oldest_map;
       m->newest_map = sblock.newest_map;
       get_map_bl(to, m->maps[to]);
       send_map(m, con);
@@ -3684,6 +3684,11 @@ int OSD::init()
     // We need to persist the new compat_set before we
     // do anything else
     dout(5) << "Upgrading superblock adding: " << diff << dendl;
+
+    if (!superblock.max_oldest_map) {
+      superblock.max_oldest_map = superblock.oldest_map;
+    }
+
     ObjectStore::Transaction t;
     write_superblock(t);
     r = store->queue_transaction(service.meta_ch, std::move(t));
@@ -3801,7 +3806,6 @@ int OSD::init()
   service.init();
   service.publish_map(osdmap);
   service.publish_superblock(superblock);
-  service.max_oldest_map = superblock.oldest_map;
 
   for (auto& shard : shards) {
     // put PGs in a temporary set because we may modify pg_slots
@@ -8071,9 +8075,12 @@ void OSD::handle_osd_map(MOSDMap *m)
   logger->inc(l_osd_mape, last - first + 1);
   if (first <= superblock.newest_map)
     logger->inc(l_osd_mape_dup, superblock.newest_map - first + 1);
-  if (service.max_oldest_map < m->oldest_map) {
-    service.max_oldest_map = m->oldest_map;
-    ceph_assert(service.max_oldest_map >= superblock.oldest_map);
+
+  if (superblock.max_oldest_map < m->oldest_map) {
+    superblock.max_oldest_map = m->oldest_map;
+    dout(10) << " superblock max_oldest_map new epoch is: "
+             << superblock.max_oldest_map << dendl;
+    ceph_assert(superblock.max_oldest_map >= superblock.oldest_map);
   }
 
   // make sure there is something new, here, before we bother flushing
index 4326c4b5b018ed8654d5effab078ac04a89077af..c7b55613c400ac5c8faecae72069567bcf05d9a6 100644 (file)
@@ -149,7 +149,6 @@ public:
 
   int get_nodeid() const { return whoami; }
 
-  std::atomic<epoch_t> max_oldest_map;
 private:
   OSDMapRef osdmap;
 
index 829646809c5c00219d5d285fbcfedfbd9eafc47d..8bdcf39be69636e303f630f61fdb63fc0a508628 100644 (file)
@@ -5662,7 +5662,7 @@ void pg_hit_set_history_t::generate_test_instances(list<pg_hit_set_history_t*>&
 
 void OSDSuperblock::encode(ceph::buffer::list &bl) const
 {
-  ENCODE_START(9, 5, bl);
+  ENCODE_START(10, 5, bl);
   encode(cluster_fsid, bl);
   encode(whoami, bl);
   encode(current_epoch, bl);
@@ -5677,12 +5677,13 @@ void OSDSuperblock::encode(ceph::buffer::list &bl) const
   encode((uint32_t)0, bl);  // map<int64_t,epoch_t> pool_last_epoch_marked_full
   encode(purged_snaps_last, bl);
   encode(last_purged_snaps_scrub, bl);
+  encode(max_oldest_map, bl);
   ENCODE_FINISH(bl);
 }
 
 void OSDSuperblock::decode(ceph::buffer::list::const_iterator &bl)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(9, 5, 5, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(10, 5, 5, bl);
   if (struct_v < 3) {
     string magic;
     decode(magic, bl);
@@ -5716,6 +5717,11 @@ void OSDSuperblock::decode(ceph::buffer::list::const_iterator &bl)
   } else {
     purged_snaps_last = 0;
   }
+  if (struct_v >= 10) {
+    decode(max_oldest_map, bl);
+  } else {
+    max_oldest_map = 0;
+  }
   DECODE_FINISH(bl);
 }
 
@@ -5735,6 +5741,7 @@ void OSDSuperblock::dump(Formatter *f) const
   f->dump_int("last_epoch_mounted", mounted);
   f->dump_unsigned("purged_snaps_last", purged_snaps_last);
   f->dump_stream("last_purged_snaps_scrub") << last_purged_snaps_scrub;
+  f->dump_int("max_oldest_map", max_oldest_map);
 }
 
 void OSDSuperblock::generate_test_instances(list<OSDSuperblock*>& o)
index e36fb17056f3d77f795f6d7a27b3d8e91d17f58a..f91189e77b3f99362bb3b04024f425c49f68e01e 100644 (file)
@@ -5480,6 +5480,8 @@ public:
   epoch_t purged_snaps_last = 0;
   utime_t last_purged_snaps_scrub;
 
+  epoch_t max_oldest_map = 0;  // maximum oldest map we have.
+
   void encode(ceph::buffer::list &bl) const;
   void decode(ceph::buffer::list::const_iterator &bl);
   void dump(ceph::Formatter *f) const;
@@ -5495,7 +5497,7 @@ inline std::ostream& operator<<(std::ostream& out, const OSDSuperblock& sb)
              << " e" << sb.current_epoch
              << " [" << sb.oldest_map << "," << sb.newest_map << "]"
             << " lci=[" << sb.mounted << "," << sb.clean_thru << "]"
-             << ")";
+             << " max oldest=" << sb.max_oldest_map << ")";
 }