]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-objectstore-tool: fix import of post-split pg from pre-split ancestor 18229/head
authorSage Weil <sage@redhat.com>
Tue, 10 Oct 2017 22:02:56 +0000 (17:02 -0500)
committerSage Weil <sage@redhat.com>
Tue, 10 Oct 2017 22:02:56 +0000 (17:02 -0500)
If we export a PG, it later splits, and then we try to import a
post-split portion of it, we need to generate the PastIntervals
properly (instead of crashing).

Fixes: http://tracker.ceph.com/issues/21753
Signed-off-by: Sage Weil <sage@redhat.com>
src/tools/ceph_objectstore_tool.cc

index 253882f47bb400215faf1f9d3303f95580155fe3..6f01450d021227b346374fc25327f796a19835f9 100644 (file)
@@ -1181,7 +1181,8 @@ int get_pg_metadata(ObjectStore *store, bufferlist &bl, metadata_section &ms,
        ms.info.history.last_epoch_clean,
        nextmap,
        lastmap,
-       ms.info.pgid.pgid,
+       ms.info.pgid.pgid.get_ancestor(
+         lastmap->get_pg_num(ms.info.pgid.pgid.pool())),
        &min_size_predicate,
        &ms.past_intervals,
        &cerr);
@@ -1193,10 +1194,19 @@ int get_pg_metadata(ObjectStore *store, bufferlist &bl, metadata_section &ms,
        if (acting_primary != new_acting_primary) {
          ms.info.history.same_primary_since = nextmap->get_epoch();
        }
-       if (pgid.pgid.is_split(lastmap->get_pg_num(ms.info.pgid.pgid.pool()),
-                              nextmap->get_pg_num(ms.info.pgid.pgid.pool()),
-                              nullptr)) {
-         ms.info.history.last_epoch_split = nextmap->get_epoch();
+       unsigned old_pg_num = lastmap->get_pg_num(ms.info.pgid.pgid.pool());
+       unsigned new_pg_num = nextmap->get_pg_num(ms.info.pgid.pgid.pool());
+       if (pgid.pgid.m_seed >= old_pg_num) {
+         if (pgid.pgid.m_seed < new_pg_num) {
+           ms.info.history.epoch_created = nextmap->get_epoch();
+           ms.info.history.last_epoch_split = nextmap->get_epoch();
+         }
+         // we don't actually care about the ancestor splits because only
+         // the latest split is recorded.
+       } else {
+         if (pgid.pgid.is_split(old_pg_num, new_pg_num, nullptr)) {
+           ms.info.history.last_epoch_split = nextmap->get_epoch();
+         }
        }
        up = new_up;
        acting = new_acting;