From: xinxin shu Date: Thu, 29 Jan 2015 16:58:44 +0000 (+0800) Subject: add pg_string_state function X-Git-Tag: v0.93~65^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=61378f25db334816ee1ad887aa4873e3dcd01806;p=ceph.git add pg_string_state function Signed-off-by: xinxin shu --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 324dd45b7ad2..18998bfca7e0 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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 diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 10728fa6c60c..f08ff93f31fa 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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); /*