]> git-server-git.apps.pok.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 14:15:07 +0000 (10:15 -0400)
committerSage Weil <sage@redhat.com>
Sat, 12 Sep 2015 13:20:02 +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>
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/tools/ceph_objectstore_tool.cc

index a577fd802c82a1f6749a46c02d6c5b45e165c6a1..f204135fe7f3e9d5483cc25f829d1d54f65b1ea0 100644 (file)
@@ -2858,7 +2858,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 48443ce63449037866e7a400570469a2c4a641e0..4e08927470410555179be9708a405214d404bb51 100644 (file)
@@ -2728,9 +2728,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);
   ghobject_t legacy_infos_oid(OSD::make_infos_oid());
@@ -2764,7 +2765,8 @@ epoch_t PG::peek_map_epoch(ObjectStore *store,
   bp = values[epoch_key].begin();
   ::decode(cur_epoch, bp);
 
-  return cur_epoch;
+  *pepoch = cur_epoch;
+  return 0;
 }
 
 void PG::write_if_dirty(ObjectStore::Transaction& t)
index f1dde4cb6d54cffb93fc81459ed651d9bbc27c67..7859f1a5a3c0de7343382e43eb6e25daacc18000 100644 (file)
@@ -2187,7 +2187,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 a2dbccbc5fc208df307b20d810e00a853529d87b..96dddc627df9a7a0d3d8ee8b88ce8b6ea0b2be99 100644 (file)
@@ -475,10 +475,13 @@ 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 map_epoch = 0;
+  int r = PG::peek_map_epoch(fs, pgid, &map_epoch, &bl);
+  if (r < 0)
+    cerr << __func__ << " warning: peek_map_epoch reported error" << 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;
@@ -2760,7 +2763,10 @@ int main(int argc, char **argv)
     }
 
     bufferlist bl;
-    map_epoch = PG::peek_map_epoch(fs, pgid, &bl);
+    map_epoch = 0;
+    ret = PG::peek_map_epoch(fs, pgid, &map_epoch, &bl);
+    if (ret < 0)
+      cerr << "peek_map_epoch reports error" << std::endl;
     if (debug)
       cerr << "map_epoch " << map_epoch << std::endl;