]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: allow peek_map_epoch to return an error
authorSage Weil <sage@redhat.com>
Fri, 11 Sep 2015 21:41:01 +0000 (17:41 -0400)
committerSage Weil <sage@redhat.com>
Sat, 12 Sep 2015 13:20:47 +0000 (09:20 -0400)
Allow PG::peek_map_epoch to return an error indicating the PG
should be skipped.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit f15d9585edc5a12ac2d076951076247253b897c2)

[fixed *pepoch default of 0]
[fixed other return paths in peek_map_epoch]

src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/tools/ceph_objectstore_tool.cc

index 9ca9279eee2dfb866df80f39dee8a58e852546db..0c01ba6168df6e0688ba78defc91bc6082919a2e 100644 (file)
@@ -2819,7 +2819,13 @@ void OSD::load_pgs()
 
     dout(10) << "pgid " << pgid << " coll " << coll_t(pgid) << dendl;
     bufferlist bl;
-    epoch_t map_epoch = PG::peek_map_epoch(store, pgid, &bl);
+    epoch_t map_epoch = 0;
+    int r = PG::peek_map_epoch(store, pgid, &map_epoch, &bl);
+    if (r < 0) {
+      derr << __func__ << " unable to peek at " << pgid << " metadata, skipping"
+          << dendl;
+      continue;
+    }
 
     PG *pg = NULL;
     if (map_epoch > 0) {
index acafb4f3d864cb3c3e64f16a0ee49500c8fae525..3abfc5a4125984839d79a23a88b081dcd35f4759 100644 (file)
@@ -2808,9 +2808,10 @@ bool PG::_has_removal_flag(ObjectStore *store,
   return false;
 }
 
-epoch_t PG::peek_map_epoch(ObjectStore *store,
-                          spg_t pgid,
-                          bufferlist *bl)
+int PG::peek_map_epoch(ObjectStore *store,
+                      spg_t pgid,
+                      epoch_t *pepoch,
+                      bufferlist *bl)
 {
   coll_t coll(pgid);
   hobject_t legacy_infos_oid(OSD::make_infos_oid());
@@ -2855,7 +2856,8 @@ epoch_t PG::peek_map_epoch(ObjectStore *store,
       return 0;
     if (struct_v < 6) {
       ::decode(cur_epoch, bp);
-      return cur_epoch;
+      *pepoch = cur_epoch;
+      return 0;
     }
 
     // get epoch out of leveldb
@@ -2870,7 +2872,8 @@ epoch_t PG::peek_map_epoch(ObjectStore *store,
   } else {
     assert(0 == "unable to open pg metadata");
   }
-  return cur_epoch;
+  *pepoch = cur_epoch;
+  return 0;
 }
 
 #pragma GCC diagnostic pop
index ac6494ba35e9ee112eb9277172878a742bcf5326..41de9d6d14a6a021d65ca100467590136d3cea53 100644 (file)
@@ -2146,7 +2146,8 @@ public:
     __u8 &);
   void read_state(ObjectStore *store, bufferlist &bl);
   static bool _has_removal_flag(ObjectStore *store, spg_t pgid);
-  static epoch_t peek_map_epoch(ObjectStore *store, spg_t pgid, bufferlist *bl);
+  static int peek_map_epoch(ObjectStore *store, spg_t pgid,
+                           epoch_t *pepoch, bufferlist *bl);
   void update_snap_map(
     const vector<pg_log_entry_t> &log_entries,
     ObjectStore::Transaction& t);
index f9d5473d913f0ab45f0c6af9ff8a409044ab9f03..9e6894664ca8c52044b0faba7da280f40552bbd2 100644 (file)
@@ -738,10 +738,14 @@ int mark_pg_for_removal(ObjectStore *fs, spg_t pgid, ObjectStore::Transaction *t
   ghobject_t pgmeta_oid(info.pgid.make_pgmeta_oid());
 
   bufferlist bl;
-  PG::peek_map_epoch(fs, pgid, &bl);
+  epoch_t pg_epoch = 0;
+  int r = PG::peek_map_epoch(fs, pgid, &pg_epoch, &bl);
+  if (r < 0)
+    cerr << __func__ << " warning: peek_map_epoch fails" << std::endl;
+
   map<epoch_t,pg_interval_t> past_intervals;
   __u8 struct_v;
-  int r = PG::read_info(fs, pgid, coll, bl, info, past_intervals, struct_v);
+  r = PG::read_info(fs, pgid, coll, bl, info, past_intervals, struct_v);
   if (r < 0) {
     cerr << __func__ << " error on read_info " << cpp_strerror(-r) << std::endl;
     return r;
@@ -3058,7 +3062,11 @@ int main(int argc, char **argv)
     }
 
     bufferlist bl;
-    map_epoch = PG::peek_map_epoch(fs, pgid, &bl);
+    map_epoch = 0;
+    r = PG::peek_map_epoch(fs, pgid, &map_epoch, &bl);
+    if (r < 0)
+      cerr << "peek_map_epoch returns an error" << std::endl;
+
     if (debug)
       cerr << "map_epoch " << map_epoch << std::endl;