From 0fec7a9fea055f3da00b3fe534692e8617fc3ea0 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 19 Jun 2024 00:26:43 +0300 Subject: [PATCH] Drop dirty peer connections also when stopping PG to guarantee that clients do not miss fsync --- src/osd/osd.h | 1 + src/osd/osd_peering.cpp | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/osd/osd.h b/src/osd/osd.h index c1833c25..66015e2d 100644 --- a/src/osd/osd.h +++ b/src/osd/osd.h @@ -254,6 +254,7 @@ class osd_t bool check_peer_config(osd_client_t *cl, json11::Json conf); void repeer_pgs(osd_num_t osd_num); void start_pg_peering(pg_t & pg); + void drop_dirty_pg_connections(pool_pg_num_t pg); void submit_list_subop(osd_num_t role_osd, pg_peering_state_t *ps); void discard_list_subop(osd_op_t *list_op); bool stop_pg(pg_t & pg); diff --git a/src/osd/osd_peering.cpp b/src/osd/osd_peering.cpp index f440d595..4f722d81 100644 --- a/src/osd/osd_peering.cpp +++ b/src/osd/osd_peering.cpp @@ -168,20 +168,15 @@ void osd_t::reset_pg(pg_t & pg) dirty_pgs.erase({ .pool_id = pg.pool_id, .pg_num = pg.pg_num }); } -// Repeer on each connect/disconnect peer event -void osd_t::start_pg_peering(pg_t & pg) +// Drop connections of clients who have this PG in dirty_pgs +void osd_t::drop_dirty_pg_connections(pool_pg_num_t pg) { - pg.state = PG_PEERING; - this->peering_state |= OSD_PEERING_PGS; - reset_pg(pg); - report_pg_state(pg); - // Drop connections of clients who have this PG in dirty_pgs if (immediate_commit != IMMEDIATE_ALL) { std::vector to_stop; for (auto & cp: msgr.clients) { - if (cp.second->dirty_pgs.find({ .pool_id = pg.pool_id, .pg_num = pg.pg_num }) != cp.second->dirty_pgs.end()) + if (cp.second->dirty_pgs.find(pg) != cp.second->dirty_pgs.end()) { to_stop.push_back(cp.first); } @@ -191,6 +186,16 @@ void osd_t::start_pg_peering(pg_t & pg) msgr.stop_client(peer_fd); } } +} + +// Repeer on each connect/disconnect peer event +void osd_t::start_pg_peering(pg_t & pg) +{ + pg.state = PG_PEERING; + this->peering_state |= OSD_PEERING_PGS; + reset_pg(pg); + report_pg_state(pg); + drop_dirty_pg_connections({ .pool_id = pg.pool_id, .pg_num = pg.pg_num }); // Try to connect with current peers if they're up, but we don't have connections to them // Otherwise we may erroneously decide that the pg is incomplete :-) for (auto pg_osd: pg.all_peers) @@ -460,6 +465,7 @@ bool osd_t::stop_pg(pg_t & pg) { return false; } + drop_dirty_pg_connections({ .pool_id = pg.pool_id, .pg_num = pg.pg_num }); if (!(pg.state & (PG_ACTIVE | PG_REPEERING))) { finish_stop_pg(pg);