]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/OSD: introduce reset_purged_snaps_last
authorMatan Breizman <mbreizma@redhat.com>
Thu, 21 Sep 2023 12:10:07 +0000 (12:10 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Sun, 21 Jan 2024 08:29:21 +0000 (08:29 +0000)
When the OSD preboots it sends a MMonGetPurgedSnaps message to
the monitor (`_get_purged_snaps`).
The monitor will reply with all the purged snapshots that their purged_epoch_ is in the
range of superblock.purged_snaps_last + 1 up to the last superblock.current_epoch + 1.
When the OSD will handle the reply from the mon (`handle_get_purged_snaps_reply`)
it will call `record_purged_snaps` to write those purged snapshots in the
OSD store as well (PSN_ keys).

Once purged_snaps_last is reset, in the following OSD reboot, the snapshots that were marked as
purged (purged_snaps_ keys) in the mon's store will be also marked,
correspondingly, in the OSD store.
That way `scrub_purged_snaps` will be able to re-trim the snapshots that weren't
marked as purged in the OSD side (for some reason)

Fixes: https://tracker.ceph.com/issues/62981
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
(cherry picked from commit 120ed0f0e8f65c18bfcd1d649617770c2c5af663)

Manual conflict fixes: write_superblock() parameters were changed

src/osd/OSD.cc

index 1eb9951eff22ae60cdbace49543829fe8afa0ba6..75115c005e600e104e3fa7683eff195b02c6e7de 100644 (file)
@@ -3133,6 +3133,19 @@ will start to track new ops received afterwards.";
     scrub_purged_snaps();
   }
 
+  else if (prefix == "reset_purged_snaps_last") {
+    lock_guard l(osd_lock);
+    superblock.purged_snaps_last = 0;
+    ObjectStore::Transaction t;
+    dout(10) << __func__ << " updating superblock" << dendl;
+    write_superblock(cct, superblock, t);
+    ret = store->queue_transaction(service.meta_ch, std::move(t), nullptr);
+    if (ret < 0) {
+      ss << "Error writing superblock: " << cpp_strerror(ret);
+      goto out;
+    }
+  }
+
   else if (prefix == "dump_osd_network") {
     lock_guard l(osd_lock);
     int64_t value = 0;
@@ -4311,6 +4324,11 @@ void OSD::final_init()
     asok_hook,
     "Scrub purged_snaps vs snapmapper index");
   ceph_assert(r == 0);
+  r = admin_socket->register_command(
+    "reset_purged_snaps_last",
+    asok_hook,
+    "Reset the superblock's purged_snaps_last");
+  ceph_assert(r == 0);
   r = admin_socket->register_command(
     "scrubdebug "                                              \
     "name=pgid,type=CephPgid "                                 \