From 2c8241b7db40c1485910be5be5a5686a13875d8c Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 20 Feb 2023 23:01:20 +0300 Subject: [PATCH] Remove PG "peered" state --- mon/mon.js | 2 +- src/osd_cluster.cpp | 9 +-------- src/osd_peering.cpp | 10 +--------- src/osd_peering_pg.cpp | 11 +++-------- src/pg_states.cpp | 8 +++----- src/pg_states.h | 28 +++++++++++++--------------- 6 files changed, 22 insertions(+), 46 deletions(-) diff --git a/mon/mon.js b/mon/mon.js index e190fc9c..d0cf1be0 100644 --- a/mon/mon.js +++ b/mon/mon.js @@ -261,7 +261,7 @@ const etcd_tree = { /* : { : { primary: osd_num_t, - state: ("starting"|"peering"|"peered"|"incomplete"|"active"|"repeering"|"stopping"|"offline"| + state: ("starting"|"peering"|"incomplete"|"active"|"repeering"|"stopping"|"offline"| "degraded"|"has_incomplete"|"has_degraded"|"has_misplaced"|"has_unclean"| "has_invalid"|"left_on_dead")[], } diff --git a/src/osd_cluster.cpp b/src/osd_cluster.cpp index 005dca69..fcb12324 100644 --- a/src/osd_cluster.cpp +++ b/src/osd_cluster.cpp @@ -683,7 +683,7 @@ void osd_t::apply_pg_config() auto vec_all_peers = std::vector(all_peers.begin(), all_peers.end()); if (currently_taken) { - if (pg_it->second.state & (PG_ACTIVE | PG_INCOMPLETE | PG_PEERING | PG_REPEERING | PG_PEERED)) + if (pg_it->second.state & (PG_ACTIVE | PG_INCOMPLETE | PG_PEERING | PG_REPEERING)) { if (pg_it->second.target_set == pg_cfg.target_set && pg_it->second.target_history == pg_cfg.target_history && @@ -963,13 +963,6 @@ void osd_t::report_pg_states() } this->pgs.erase(pg_it); } - else if (pg_it->second.state & PG_PEERED) - { - // Activate PG after PG PEERED state is reported along with history - // (if the state wasn't changed again) - pg_it->second.state = pg_it->second.state & ~PG_PEERED | PG_ACTIVE; - report_pg_state(pg_it->second); - } } } // Push other PG state updates, if any diff --git a/src/osd_peering.cpp b/src/osd_peering.cpp index 2167baa3..5cbb1057 100644 --- a/src/osd_peering.cpp +++ b/src/osd_peering.cpp @@ -50,10 +50,6 @@ void osd_t::handle_peers() still = true; } } - else if (p.second.state & PG_PEERED) - { - still = true; - } } if (!still) { @@ -74,10 +70,6 @@ void osd_t::handle_peers() } still = true; } - else if (p.second.state & PG_PEERED) - { - still = true; - } } if (!still) { @@ -100,7 +92,7 @@ void osd_t::repeer_pgs(osd_num_t peer_osd) { auto & pg = p.second; bool repeer = false; - if (pg.state & (PG_PEERING | PG_PEERED | PG_ACTIVE | PG_INCOMPLETE)) + if (pg.state & (PG_PEERING | PG_ACTIVE | PG_INCOMPLETE)) { for (osd_num_t pg_osd: pg.all_peers) { diff --git a/src/osd_peering_pg.cpp b/src/osd_peering_pg.cpp index bf79fe50..ee5d8a18 100644 --- a/src/osd_peering_pg.cpp +++ b/src/osd_peering_pg.cpp @@ -88,13 +88,9 @@ void pg_obj_state_check_t::walk() { // Activate as degraded // Current OSD set will be added into target_history on first write - pg->state |= PG_DEGRADED | PG_PEERED; - } - else - { - // Just activate - pg->state |= PG_ACTIVE; + pg->state |= PG_DEGRADED; } + pg->state |= PG_ACTIVE; if (pg->state == PG_ACTIVE && pg->cur_peers.size() < pg->all_peers.size()) { pg->state |= PG_LEFT_ON_DEAD; @@ -460,11 +456,10 @@ void pg_t::calc_object_states(int log_level) void pg_t::print_state() { printf( - "[PG %u/%u] is %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s (%lu objects)\n", pool_id, pg_num, + "[PG %u/%u] is %s%s%s%s%s%s%s%s%s%s%s%s%s%s (%lu objects)\n", pool_id, pg_num, (state & PG_STARTING) ? "starting" : "", (state & PG_OFFLINE) ? "offline" : "", (state & PG_PEERING) ? "peering" : "", - (state & PG_PEERED) ? "peered" : "", (state & PG_INCOMPLETE) ? "incomplete" : "", (state & PG_ACTIVE) ? "active" : "", (state & PG_REPEERING) ? "repeering" : "", diff --git a/src/pg_states.cpp b/src/pg_states.cpp index 86f255cd..f480dbbf 100644 --- a/src/pg_states.cpp +++ b/src/pg_states.cpp @@ -3,12 +3,11 @@ #include "pg_states.h" -const int pg_state_bit_count = 16; +const int pg_state_bit_count = 14; -const int pg_state_bits[16] = { +const int pg_state_bits[14] = { PG_STARTING, PG_PEERING, - PG_PEERED, PG_INCOMPLETE, PG_ACTIVE, PG_REPEERING, @@ -23,10 +22,9 @@ const int pg_state_bits[16] = { PG_LEFT_ON_DEAD, }; -const char *pg_state_names[16] = { +const char *pg_state_names[14] = { "starting", "peering", - "peered", "incomplete", "active", "repeering", diff --git a/src/pg_states.h b/src/pg_states.h index eec667c4..605c817a 100644 --- a/src/pg_states.h +++ b/src/pg_states.h @@ -4,27 +4,25 @@ #pragma once // Placement group states -// STARTING -> [acquire lock] -> PEERING -> PEERED -// PEERED -> [report history if required!] -> INCOMPLETE|ACTIVE +// STARTING -> [acquire lock] -> PEERING -> INCOMPLETE|ACTIVE // ACTIVE -> REPEERING -> PEERING // ACTIVE -> STOPPING -> OFFLINE -> [release lock] // Exactly one of these: #define PG_STARTING (1<<0) #define PG_PEERING (1<<1) -#define PG_PEERED (1<<2) -#define PG_INCOMPLETE (1<<3) -#define PG_ACTIVE (1<<4) -#define PG_REPEERING (1<<5) -#define PG_STOPPING (1<<6) -#define PG_OFFLINE (1<<7) +#define PG_INCOMPLETE (1<<2) +#define PG_ACTIVE (1<<3) +#define PG_REPEERING (1<<4) +#define PG_STOPPING (1<<5) +#define PG_OFFLINE (1<<6) // Plus any of these: -#define PG_DEGRADED (1<<8) -#define PG_HAS_INCOMPLETE (1<<9) -#define PG_HAS_DEGRADED (1<<10) -#define PG_HAS_MISPLACED (1<<11) -#define PG_HAS_UNCLEAN (1<<12) -#define PG_HAS_INVALID (1<<13) -#define PG_LEFT_ON_DEAD (1<<14) +#define PG_DEGRADED (1<<7) +#define PG_HAS_INCOMPLETE (1<<8) +#define PG_HAS_DEGRADED (1<<9) +#define PG_HAS_MISPLACED (1<<10) +#define PG_HAS_UNCLEAN (1<<11) +#define PG_HAS_INVALID (1<<12) +#define PG_LEFT_ON_DEAD (1<<13) // Lower bits that represent object role (EC 0/1/2... or always 0 with replication) // 12 bits is a safe default that doesn't depend on pg_stripe_size or pg_block_size