From 36817117d6c718d26dd684e238b89d29a58dc059 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 6 Oct 2017 13:43:57 -0500 Subject: [PATCH] ceph-objectstore-tool: refuse to import PG older that OSD's oldest_epoch We don't have a way to construct a valid PastIntervals history. Signed-off-by: Sage Weil --- src/tools/ceph_objectstore_tool.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index b6d23c5e06a79..3e6a90068dd4b 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -295,6 +295,7 @@ ghobject_t biginfo_oid; int file_fd = fd_none; bool debug; +bool force = false; super_header sh; uint64_t testalign; @@ -468,7 +469,7 @@ int write_pg(ObjectStore::Transaction &t, epoch_t epoch, pg_info_t &info, divergent_priors_t &divergent, pg_missing_t &missing) { - cout << __func__ << " info " << info << std::endl; + cout << __func__ << " epoch " << epoch << " info " << info << std::endl; int ret = write_info(t, epoch, info, past_intervals); if (ret) return ret; @@ -1073,6 +1074,15 @@ int get_pg_metadata(ObjectStore *store, bufferlist &bl, metadata_section &ms, " some objects may be ignored due to a split" << std::endl; } } + if (ms.osdmap.get_epoch() < sb.oldest_map) { + cerr << "PG export's map " << ms.osdmap.get_epoch() + << " is older than OSD's oldest_map " << sb.oldest_map << std::endl; + if (!force) { + cerr << " pass --force to proceed anyway (with incomplete PastIntervals)" + << std::endl; + return -EINVAL; + } + } // Make sure old_pg_num is 0 in the unusual case that OSDMap not in export // nor can we find a local copy. @@ -2486,7 +2496,6 @@ int main(int argc, char **argv) unsigned epoch = 0; ghobject_t ghobj; bool human_readable; - bool force; Formatter *formatter; bool head; -- 2.39.5