]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-objectstore-tool: refuse to import PG older that OSD's oldest_epoch
authorSage Weil <sage@redhat.com>
Fri, 6 Oct 2017 18:43:57 +0000 (13:43 -0500)
committerSage Weil <sage@redhat.com>
Fri, 6 Oct 2017 19:26:56 +0000 (14:26 -0500)
We don't have a way to construct a valid PastIntervals history.

Signed-off-by: Sage Weil <sage@redhat.com>
src/tools/ceph_objectstore_tool.cc

index b6d23c5e06a796ea2b53c62338ba8a60ef6d5344..3e6a90068dd4be3ed209c9ac1bf32a8207874e79 100644 (file)
@@ -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;