From 6a91d20936a2639119d7776085fbdf6c8eadb5ca Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Oct 2017 17:02:56 -0500 Subject: [PATCH] ceph-objectstore-tool: fix import of post-split pg from pre-split ancestor 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 --- src/tools/ceph_objectstore_tool.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 253882f47bb40..6f01450d02122 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -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; -- 2.39.5