void PGMapDigest::encode(bufferlist& bl, uint64_t features) const
{
// NOTE: see PGMap::encode_digest
- ENCODE_START(1, 1, bl);
+ uint8_t v = 2;
+ if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
+ v = 1;
+ }
+ ENCODE_START(v, 1, bl);
::encode(num_pg, bl);
::encode(num_pg_active, bl);
::encode(num_pg_unknown, bl);
::encode(pg_pool_sum, bl, features);
::encode(pg_sum, bl, features);
::encode(osd_sum, bl);
- ::encode(num_pg_by_state, bl);
+ if (v >= 2) {
+ ::encode(num_pg_by_state, bl);
+ } else {
+ uint32_t n = num_pg_by_state.size();
+ ::encode(n, bl);
+ for (auto p : num_pg_by_state) {
+ ::encode((uint32_t)p.first, bl);
+ ::encode(p.second, bl);
+ }
+ }
::encode(num_pg_by_osd, bl);
::encode(num_pg_by_pool, bl);
::encode(osd_last_seq, bl);
void PGMapDigest::decode(bufferlist::iterator& p)
{
- DECODE_START(1, p);
+ DECODE_START(2, p);
::decode(num_pg, p);
::decode(num_pg_active, p);
::decode(num_pg_unknown, p);
::decode(pg_pool_sum, p);
::decode(pg_sum, p);
::decode(osd_sum, p);
- ::decode(num_pg_by_state, p);
+ if (struct_v >= 2) {
+ ::decode(num_pg_by_state, p);
+ } else {
+ map<int32_t, int32_t> nps;
+ ::decode(nps, p);
+ for (auto i : nps) {
+ num_pg_by_state[i.first] = i.second;
+ }
+ }
::decode(num_pg_by_osd, p);
::decode(num_pg_by_pool, p);
::decode(osd_last_seq, p);
state = -1;
break;
} else {
- int filter = pg_string_state(state_str);
+ int64_t filter = pg_string_state(state_str);
if (filter < 0) {
*ss << "'" << state_str << "' is not a valid pg state,"
<< " available choices: " << pg_state_string(0xFFFFFFFF);
mempool::pgmap::map<int64_t,int64_t> num_pg_by_pool;
pool_stat_t pg_sum;
osd_stat_t osd_sum;
- mempool::pgmap::unordered_map<int32_t,int32_t> num_pg_by_state;
+ mempool::pgmap::unordered_map<uint64_t,int32_t> num_pg_by_state;
struct pg_count {
int32_t acting = 0;
int32_t up = 0;
protected:
int role; // 0 = primary, 1 = replica, -1=none.
- unsigned state; // PG_STATE_*
+ uint64_t state; // PG_STATE_*
bool send_notify; ///< true if we are non-primary and should notify the primary
role = r;
}
- bool state_test(int m) const { return (state & m) != 0; }
- void state_set(int m) { state |= m; }
- void state_clear(int m) { state &= ~m; }
+ bool state_test(uint64_t m) const { return (state & m) != 0; }
+ void state_set(uint64_t m) { state |= m; }
+ void state_clear(uint64_t m) { state &= ~m; }
bool is_complete() const { return info.last_complete == info.last_update; }
bool should_send_notify() const { return send_notify; }
return oss.str();
}
-std::string pg_state_string(int state)
+std::string pg_state_string(uint64_t state)
{
ostringstream oss;
if (state & PG_STATE_STALE)
return ret;
}
-int pg_string_state(const std::string& state)
+int64_t pg_string_state(const std::string& state)
{
- int type;
+ int64_t type;
if (state == "active")
type = PG_STATE_ACTIVE;
else if (state == "clean")
void pg_stat_t::encode(bufferlist &bl) const
{
- ENCODE_START(22, 22, bl);
+ ENCODE_START(23, 22, bl);
::encode(version, bl);
::encode(reported_seq, bl);
::encode(reported_epoch, bl);
- ::encode(state, bl);
+ ::encode((__u32)state, bl); // for older peers
::encode(log_start, bl);
::encode(ondisk_log_start, bl);
::encode(created, bl);
::encode(last_peered, bl);
::encode(last_became_peered, bl);
::encode(pin_stats_invalid, bl);
+ ::encode(state, bl);
ENCODE_FINISH(bl);
}
void pg_stat_t::decode(bufferlist::iterator &bl)
{
bool tmp;
- DECODE_START(22, bl);
+ uint32_t old_state;
+ DECODE_START(23, bl);
::decode(version, bl);
::decode(reported_seq, bl);
::decode(reported_epoch, bl);
- ::decode(state, bl);
+ ::decode(old_state, bl);
::decode(log_start, bl);
::decode(ondisk_log_start, bl);
::decode(created, bl);
::decode(last_became_peered, bl);
::decode(tmp, bl);
pin_stats_invalid = tmp;
+ if (struct_v >= 23) {
+ ::decode(state, bl);
+ } else {
+ state = old_state;
+ }
DECODE_FINISH(bl);
}
/*
* pg states
*/
-#define PG_STATE_CREATING (1<<0) // creating
-#define PG_STATE_ACTIVE (1<<1) // i am active. (primary: replicas too)
-#define PG_STATE_CLEAN (1<<2) // peers are complete, clean of stray replicas.
-#define PG_STATE_DOWN (1<<4) // a needed replica is down, PG offline
-//#define PG_STATE_REPLAY (1<<5) // crashed, waiting for replay
-//#define PG_STATE_STRAY (1<<6) // i must notify the primary i exist.
-//#define PG_STATE_SPLITTING (1<<7) // i am splitting
-#define PG_STATE_SCRUBBING (1<<8) // scrubbing
-//#define PG_STATE_SCRUBQ (1<<9) // queued for scrub
-#define PG_STATE_DEGRADED (1<<10) // pg contains objects with reduced redundancy
-#define PG_STATE_INCONSISTENT (1<<11) // pg replicas are inconsistent (but shouldn't be)
-#define PG_STATE_PEERING (1<<12) // pg is (re)peering
-#define PG_STATE_REPAIR (1<<13) // pg should repair on next scrub
-#define PG_STATE_RECOVERING (1<<14) // pg is recovering/migrating objects
-#define PG_STATE_BACKFILL_WAIT (1<<15) // [active] reserving backfill
-#define PG_STATE_INCOMPLETE (1<<16) // incomplete content, peering failed.
-#define PG_STATE_STALE (1<<17) // our state for this pg is stale, unknown.
-#define PG_STATE_REMAPPED (1<<18) // pg is explicitly remapped to different OSDs than CRUSH
-#define PG_STATE_DEEP_SCRUB (1<<19) // deep scrub: check CRC32 on files
-#define PG_STATE_BACKFILLING (1<<20) // [active] backfilling pg content
-#define PG_STATE_BACKFILL_TOOFULL (1<<21) // backfill can't proceed: too full
-#define PG_STATE_RECOVERY_WAIT (1<<22) // waiting for recovery reservations
-#define PG_STATE_UNDERSIZED (1<<23) // pg acting < pool size
-#define PG_STATE_ACTIVATING (1<<24) // pg is peered but not yet active
-#define PG_STATE_PEERED (1<<25) // peered, cannot go active, can recover
-#define PG_STATE_SNAPTRIM (1<<26) // trimming snaps
-#define PG_STATE_SNAPTRIM_WAIT (1<<27) // queued to trim snaps
-#define PG_STATE_RECOVERY_TOOFULL (1<<28) // recovery can't proceed: too full
-#define PG_STATE_SNAPTRIM_ERROR (1<<29) // error stopped trimming snaps
-#define PG_STATE_FORCED_RECOVERY (1<<30) // force recovery of this pg before any other
-#define PG_STATE_FORCED_BACKFILL (1<<31) // force backfill of this pg before any other
-
-std::string pg_state_string(int state);
+#define PG_STATE_CREATING (1ULL << 0) // creating
+#define PG_STATE_ACTIVE (1ULL << 1) // i am active. (primary: replicas too)
+#define PG_STATE_CLEAN (1ULL << 2) // peers are complete, clean of stray replicas.
+#define PG_STATE_DOWN (1ULL << 4) // a needed replica is down, PG offline
+//#define PG_STATE_REPLAY (1ULL << 5) // crashed, waiting for replay
+//#define PG_STATE_STRAY (1ULL << 6) // i must notify the primary i exist.
+//#define PG_STATE_SPLITTING (1ULL << 7) // i am splitting
+#define PG_STATE_SCRUBBING (1ULL << 8) // scrubbing
+//#define PG_STATE_SCRUBQ (1ULL << 9) // queued for scrub
+#define PG_STATE_DEGRADED (1ULL << 10) // pg contains objects with reduced redundancy
+#define PG_STATE_INCONSISTENT (1ULL << 11) // pg replicas are inconsistent (but shouldn't be)
+#define PG_STATE_PEERING (1ULL << 12) // pg is (re)peering
+#define PG_STATE_REPAIR (1ULL << 13) // pg should repair on next scrub
+#define PG_STATE_RECOVERING (1ULL << 14) // pg is recovering/migrating objects
+#define PG_STATE_BACKFILL_WAIT (1ULL << 15) // [active] reserving backfill
+#define PG_STATE_INCOMPLETE (1ULL << 16) // incomplete content, peering failed.
+#define PG_STATE_STALE (1ULL << 17) // our state for this pg is stale, unknown.
+#define PG_STATE_REMAPPED (1ULL << 18) // pg is explicitly remapped to different OSDs than CRUSH
+#define PG_STATE_DEEP_SCRUB (1ULL << 19) // deep scrub: check CRC32 on files
+#define PG_STATE_BACKFILLING (1ULL << 20) // [active] backfilling pg content
+#define PG_STATE_BACKFILL_TOOFULL (1ULL << 21) // backfill can't proceed: too full
+#define PG_STATE_RECOVERY_WAIT (1ULL << 22) // waiting for recovery reservations
+#define PG_STATE_UNDERSIZED (1ULL << 23) // pg acting < pool size
+#define PG_STATE_ACTIVATING (1ULL << 24) // pg is peered but not yet active
+#define PG_STATE_PEERED (1ULL << 25) // peered, cannot go active, can recover
+#define PG_STATE_SNAPTRIM (1ULL << 26) // trimming snaps
+#define PG_STATE_SNAPTRIM_WAIT (1ULL << 27) // queued to trim snaps
+#define PG_STATE_RECOVERY_TOOFULL (1ULL << 28) // recovery can't proceed: too full
+#define PG_STATE_SNAPTRIM_ERROR (1ULL << 29) // error stopped trimming snaps
+#define PG_STATE_FORCED_RECOVERY (1ULL << 30) // force recovery of this pg before any other
+#define PG_STATE_FORCED_BACKFILL (1ULL << 31) // force backfill of this pg before any other
+
+std::string pg_state_string(uint64_t state);
std::string pg_vector_string(const vector<int32_t> &a);
-int pg_string_state(const std::string& state);
+int64_t pg_string_state(const std::string& state);
/*
eversion_t version;
version_t reported_seq; // sequence number
epoch_t reported_epoch; // epoch of this report
- __u32 state;
+ uint64_t state;
utime_t last_fresh; // last reported
utime_t last_change; // new state != previous state
utime_t last_active; // state & PG_STATE_ACTIVE