]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
add pg_string_state function
authorxinxin shu <xinxin.shu@intel.com>
Thu, 29 Jan 2015 16:58:44 +0000 (00:58 +0800)
committerxinxin shu <xinxin.shu@intel.com>
Thu, 29 Jan 2015 18:53:59 +0000 (02:53 +0800)
Signed-off-by: xinxin shu <xinxin.shu@intel.com>
src/osd/osd_types.cc
src/osd/osd_types.h

index 324dd45b7ad2b09a4f8f44a8acca523213958c7f..18998bfca7e09cf14d27bde216fecc0c54137c3d 100644 (file)
@@ -749,6 +749,53 @@ std::string pg_state_string(int state)
   return ret;
 }
 
+int pg_string_state(std::string state)
+{
+  int type;
+  if (state == "active")
+    type = PG_STATE_ACTIVE;
+  else if (state == "clean")
+    type = PG_STATE_CLEAN;
+  else if (state == "down")
+    type = PG_STATE_DOWN;
+  else if (state == "replay")
+    type = PG_STATE_REPLAY;
+  else if (state == "splitting")
+    type = PG_STATE_SPLITTING;
+  else if (state == "scrubbing")
+    type = PG_STATE_SCRUBBING;
+  else if (state == "scrubq")
+    type = PG_STATE_SCRUBQ;
+  else if (state == "degraded")
+    type = PG_STATE_DEGRADED;
+  else if (state == "inconsistent")
+    type = PG_STATE_INCONSISTENT;
+  else if (state == "peering")
+    type = PG_STATE_PEERING;
+  else if (state == "recoverying")
+    type = PG_STATE_RECOVERING;
+  else if (state == "backfill_wait")
+    type = PG_STATE_BACKFILL_WAIT;
+  else if (state == "incomplete")
+    type = PG_STATE_INCOMPLETE;
+  else if (state == "remapped")
+    type = PG_STATE_REMAPPED;
+  else if (state == "stale")
+    type = PG_STATE_STALE;
+  else if (state == "deep_scrub")
+    type = PG_STATE_DEEP_SCRUB;
+  else if (state == "backfill")
+    type = PG_STATE_BACKFILL;
+  else if (state == "backfill_toofull")
+    type = PG_STATE_BACKFILL_TOOFULL;
+  else if (state == "recovery_wait")
+    type = PG_STATE_RECOVERY_WAIT;
+  else if (state == "undersized")
+    type = PG_STATE_UNDERSIZED;
+  else
+    type = -1;
+  return type;
+}
 
 // -- eversion_t --
 string eversion_t::get_key_name() const
index 10728fa6c60ca3971d67b8d3233fafea32c9eeac..f08ff93f31fa132a4d57cac6823cd3765244c66d 100644 (file)
@@ -770,6 +770,7 @@ inline ostream& operator<<(ostream& out, const osd_stat_t& s) {
 #define PG_STATE_ACTIVATING   (1<<24) // pg is peered but not yet active
 
 std::string pg_state_string(int state);
+int pg_string_state(std::string state);
 
 
 /*