From: Matan Breizman Date: Mon, 20 Jun 2022 11:15:46 +0000 (+0000) Subject: osd: MOSDPGCreate cleanup X-Git-Tag: v18.0.0~524^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4e6ede64889a05fc95ffc2f7b70e370eafd3155a;p=ceph.git osd: MOSDPGCreate cleanup MOSDPGCreate message is not in use since Mimic. Signed-off-by: Matan Breizman --- diff --git a/src/messages/MOSDPGCreate.h b/src/messages/MOSDPGCreate.h deleted file mode 100644 index 405135ed8fe..00000000000 --- a/src/messages/MOSDPGCreate.h +++ /dev/null @@ -1,73 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2004-2006 Sage Weil - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ - - -#ifndef CEPH_MOSDPGCREATE_H -#define CEPH_MOSDPGCREATE_H - -#include "msg/Message.h" -#include "osd/osd_types.h" - -/* - * PGCreate - instruct an OSD to create a pg, if it doesn't already exist - */ - -class MOSDPGCreate final : public Message { -public: - static constexpr int HEAD_VERSION = 3; - static constexpr int COMPAT_VERSION = 3; - - version_t epoch = 0; - std::map mkpg; - std::map ctimes; - - MOSDPGCreate() - : MOSDPGCreate{0} - {} - MOSDPGCreate(epoch_t e) - : Message{MSG_OSD_PG_CREATE, HEAD_VERSION, COMPAT_VERSION}, - epoch(e) - {} -private: - ~MOSDPGCreate() final {} - -public: - std::string_view get_type_name() const override { return "pg_create"; } - - void encode_payload(uint64_t features) override { - using ceph::encode; - encode(epoch, payload); - encode(mkpg, payload); - encode(ctimes, payload); - } - void decode_payload() override { - using ceph::decode; - auto p = payload.cbegin(); - decode(epoch, p); - decode(mkpg, p); - decode(ctimes, p); - } - void print(std::ostream& out) const override { - out << "osd_pg_create(e" << epoch; - for (auto i = mkpg.begin(); i != mkpg.end(); ++i) { - out << " " << i->first << ":" << i->second.created; - } - out << ")"; - } -private: - template - friend boost::intrusive_ptr ceph::make_message(Args&&... args); -}; - -#endif diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index d9dcc872bdf..c8774fdaa19 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -47,7 +47,6 @@ #include "messages/MOSDAlive.h" #include "messages/MPoolOp.h" #include "messages/MPoolOpReply.h" -#include "messages/MOSDPGCreate.h" #include "messages/MOSDPGCreate2.h" #include "messages/MOSDPGCreated.h" #include "messages/MOSDPGTemp.h" @@ -5042,11 +5041,8 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons return next; ceph_assert(!creating_pgs_by_epoch->second.empty()); - MOSDPGCreate *oldm = nullptr; // for pre-mimic OSD compat MOSDPGCreate2 *m = nullptr; - bool old = osdmap.require_osd_release < ceph_release_t::nautilus; - epoch_t last = 0; for (auto epoch_pgs = creating_pgs_by_epoch->second.lower_bound(next); epoch_pgs != creating_pgs_by_epoch->second.end(); ++epoch_pgs) { @@ -5060,34 +5056,23 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons // last_scrub_stamp upon pg creation. auto create = creating_pgs.pgs.find(pg.pgid); ceph_assert(create != creating_pgs.pgs.end()); - if (old) { - if (!oldm) { - oldm = new MOSDPGCreate(creating_pgs_epoch); - } - oldm->mkpg.emplace(pg.pgid, - pg_create_t{create->second.create_epoch, pg.pgid, 0}); - oldm->ctimes.emplace(pg.pgid, create->second.create_stamp); - } else { - if (!m) { - m = new MOSDPGCreate2(creating_pgs_epoch); - } - m->pgs.emplace(pg, make_pair(create->second.create_epoch, - create->second.create_stamp)); - if (create->second.history.epoch_created) { - dout(20) << __func__ << " " << pg << " " << create->second.history - << " " << create->second.past_intervals << dendl; - m->pg_extra.emplace(pg, make_pair(create->second.history, - create->second.past_intervals)); - } + if (!m) { + m = new MOSDPGCreate2(creating_pgs_epoch); + } + m->pgs.emplace(pg, make_pair(create->second.create_epoch, + create->second.create_stamp)); + if (create->second.history.epoch_created) { + dout(20) << __func__ << " " << pg << " " << create->second.history + << " " << create->second.past_intervals << dendl; + m->pg_extra.emplace(pg, make_pair(create->second.history, + create->second.past_intervals)); } dout(20) << __func__ << " will create " << pg - << " at " << create->second.create_epoch << dendl; + << " at " << create->second.create_epoch << dendl; } } if (m) { con->send_message(m); - } else if (oldm) { - con->send_message(oldm); } else { dout(20) << __func__ << " osd." << osd << " from " << next << " has nothing to send" << dendl; diff --git a/src/msg/Message.cc b/src/msg/Message.cc index 266eb767678..9f57ddce391 100644 --- a/src/msg/Message.cc +++ b/src/msg/Message.cc @@ -85,7 +85,6 @@ #include "messages/MOSDPGRemove.h" #include "messages/MOSDPGInfo.h" #include "messages/MOSDPGInfo2.h" -#include "messages/MOSDPGCreate.h" #include "messages/MOSDPGCreate2.h" #include "messages/MOSDPGTrim.h" #include "messages/MOSDPGLease.h" @@ -568,9 +567,6 @@ Message *decode_message(CephContext *cct, case MSG_OSD_PG_INFO2: m = make_message(); break; - case MSG_OSD_PG_CREATE: - m = make_message(); - break; case MSG_OSD_PG_CREATE2: m = make_message(); break; diff --git a/src/msg/MessageRef.h b/src/msg/MessageRef.h index ef7a56a44d9..05c1a8e6987 100644 --- a/src/msg/MessageRef.h +++ b/src/msg/MessageRef.h @@ -143,7 +143,6 @@ class MOSDPGBackfill; class MOSDPGBackfillRemove; class MOSDPGCreate2; class MOSDPGCreated; -class MOSDPGCreate; class MOSDPGInfo; class MOSDPGLog; class MOSDPGNotify; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index dc58cb43882..2483ce38176 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -97,7 +97,6 @@ #include "messages/MOSDPGRemove.h" #include "messages/MOSDPGInfo.h" #include "messages/MOSDPGInfo2.h" -#include "messages/MOSDPGCreate.h" #include "messages/MOSDPGCreate2.h" #include "messages/MBackfillReserve.h" #include "messages/MRecoveryReserve.h" @@ -5226,81 +5225,6 @@ void OSD::resume_creating_pg() service.send_pg_temp(); } -void OSD::build_initial_pg_history( - spg_t pgid, - epoch_t created, - utime_t created_stamp, - pg_history_t *h, - PastIntervals *pi) -{ - dout(10) << __func__ << " " << pgid << " created " << created << dendl; - *h = pg_history_t(created, created_stamp); - - OSDMapRef lastmap = service.get_map(created); - int up_primary, acting_primary; - vector up, acting; - lastmap->pg_to_up_acting_osds( - pgid.pgid, &up, &up_primary, &acting, &acting_primary); - - ostringstream debug; - for (epoch_t e = created + 1; e <= get_osdmap_epoch(); ++e) { - OSDMapRef osdmap = service.get_map(e); - int new_up_primary, new_acting_primary; - vector new_up, new_acting; - osdmap->pg_to_up_acting_osds( - pgid.pgid, &new_up, &new_up_primary, &new_acting, &new_acting_primary); - - // this is a bit imprecise, but sufficient? - struct min_size_predicate_t : public IsPGRecoverablePredicate { - const pg_pool_t *pi; - bool operator()(const set &have) const { - return have.size() >= pi->min_size; - } - explicit min_size_predicate_t(const pg_pool_t *i) : pi(i) {} - } min_size_predicate(osdmap->get_pg_pool(pgid.pgid.pool())); - - bool new_interval = PastIntervals::check_new_interval( - acting_primary, - new_acting_primary, - acting, new_acting, - up_primary, - new_up_primary, - up, new_up, - h->same_interval_since, - h->last_epoch_clean, - osdmap.get(), - lastmap.get(), - pgid.pgid, - min_size_predicate, - pi, - &debug); - if (new_interval) { - h->same_interval_since = e; - if (up != new_up) { - h->same_up_since = e; - } - if (acting_primary != new_acting_primary) { - h->same_primary_since = e; - } - if (pgid.pgid.is_split(lastmap->get_pg_num(pgid.pgid.pool()), - osdmap->get_pg_num(pgid.pgid.pool()), - nullptr)) { - h->last_epoch_split = e; - } - up = new_up; - acting = new_acting; - up_primary = new_up_primary; - acting_primary = new_acting_primary; - } - lastmap = osdmap; - } - dout(20) << __func__ << " " << debug.str() << dendl; - dout(10) << __func__ << " " << *h << " " << *pi - << " [" << (pi->empty() ? pair(0,0) : - pi->get_bounds()) << ")" - << dendl; -} - void OSD::_add_heartbeat_peer(int p) { if (p == whoami) @@ -6087,8 +6011,6 @@ void OSD::tick() } } - do_waiters(); - // scrub purged_snaps every deep scrub interval { const utime_t last = superblock.last_purged_snaps_scrub; @@ -7187,7 +7109,6 @@ bool OSD::ms_dispatch(Message *m) return true; } - do_waiters(); _dispatch(m); osd_lock.unlock(); @@ -7414,29 +7335,6 @@ int OSD::ms_handle_authentication(Connection *con) return ret; } -void OSD::do_waiters() -{ - ceph_assert(ceph_mutex_is_locked(osd_lock)); - - dout(10) << "do_waiters -- start" << dendl; - while (!finished.empty()) { - OpRequestRef next = finished.front(); - finished.pop_front(); - dispatch_op(next); - } - dout(10) << "do_waiters -- finish" << dendl; -} - -void OSD::dispatch_op(OpRequestRef op) -{ - switch (op->get_req()->get_type()) { - - case MSG_OSD_PG_CREATE: - handle_pg_create(op); - break; - } -} - void OSD::_dispatch(Message *m) { ceph_assert(ceph_mutex_is_locked(osd_lock)); @@ -7461,26 +7359,6 @@ void OSD::_dispatch(Message *m) case MSG_COMMAND: handle_command(static_cast(m)); return; - - // -- need OSDMap -- - - case MSG_OSD_PG_CREATE: - { - OpRequestRef op = op_tracker.create_request(m); - if (m->trace) - op->osd_trace.init("osd op", &trace_endpoint, &m->trace); - // no map? starting up? - if (!get_osdmap()) { - dout(7) << "no OSDMap, not booted" << dendl; - logger->inc(l_osd_waiting_for_map); - waiting_for_osdmap.push_back(op); - op->mark_delayed("no osdmap"); - break; - } - - // need OSDMap - dispatch_op(op); - } } } @@ -9154,106 +9032,6 @@ void OSD::split_pgs( parent->finish_split_stats(*stat_iter, rctx.transaction); } -/* - * holding osd_lock - */ -void OSD::handle_pg_create(OpRequestRef op) -{ - // NOTE: this can be removed in P release (mimic is the last version to - // send MOSDPGCreate messages). - - auto m = op->get_req(); - ceph_assert(m->get_type() == MSG_OSD_PG_CREATE); - - dout(10) << "handle_pg_create " << *m << dendl; - - if (!require_mon_peer(op->get_req())) { - return; - } - - if (!require_same_or_newer_map(op, m->epoch, false)) - return; - - op->mark_started(); - - const auto osdmap = get_osdmap(); - map::const_iterator ci = m->ctimes.begin(); - for (map::const_iterator p = m->mkpg.begin(); - p != m->mkpg.end(); - ++p, ++ci) { - ceph_assert(ci != m->ctimes.end() && ci->first == p->first); - epoch_t created = p->second.created; - if (p->second.split_bits) // Skip split pgs - continue; - pg_t on = p->first; - - if (!osdmap->have_pg_pool(on.pool())) { - dout(20) << "ignoring pg on deleted pool " << on << dendl; - continue; - } - - dout(20) << "mkpg " << on << " e" << created << "@" << ci->second << dendl; - - spg_t pgid; - bool mapped = osdmap->get_primary_shard(on, &pgid); - ceph_assert(mapped); - - // is it still ours? - vector up, acting; - int up_primary = -1; - int acting_primary = -1; - osdmap->pg_to_up_acting_osds(on, &up, &up_primary, &acting, &acting_primary); - int role = osdmap->calc_pg_role(pg_shard_t(whoami, pgid.shard), acting); - - if (acting_primary != whoami) { - dout(10) << "mkpg " << on << " not acting_primary (" << acting_primary - << "), my role=" << role << ", skipping" << dendl; - continue; - } - - - PastIntervals pi; - pg_history_t history; - build_initial_pg_history(pgid, created, ci->second, &history, &pi); - - // The mon won't resend unless the primary changed, so we ignore - // same_interval_since. We'll pass this history with the current - // epoch as the event. - if (history.same_primary_since > m->epoch) { - dout(10) << __func__ << ": got obsolete pg create on pgid " - << pgid << " from epoch " << m->epoch - << ", primary changed in " << history.same_primary_since - << dendl; - continue; - } - enqueue_peering_evt( - pgid, - PGPeeringEventRef( - std::make_shared( - osdmap->get_epoch(), - osdmap->get_epoch(), - NullEvt(), - true, - new PGCreateInfo( - pgid, - osdmap->get_epoch(), - history, - pi, - true) - ))); - } - - { - std::lock_guard l(pending_creates_lock); - if (pending_creates_from_mon == 0) { - last_pg_create_epoch = m->epoch; - } - } - - maybe_update_heartbeat_peers(); -} - - // ---------------------------------------- // peering and recovery diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 8aa5b8cfbd7..59628ee739c 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1130,7 +1130,6 @@ protected: void tick(); void tick_without_osd_lock(); void _dispatch(Message *m); - void dispatch_op(OpRequestRef op); void check_osdmap_features(); @@ -1552,7 +1551,6 @@ private: ceph_assert(ceph_mutex_is_locked(osd_lock)); finished.splice(finished.end(), ls); } - void do_waiters(); // -- op tracking -- OpTracker op_tracker; @@ -1807,18 +1805,8 @@ protected: void load_pgs(); - /// build initial pg history and intervals on create - void build_initial_pg_history( - spg_t pgid, - epoch_t created, - utime_t created_stamp, - pg_history_t *h, - PastIntervals *pi); - epoch_t last_pg_create_epoch; - void handle_pg_create(OpRequestRef op); - void split_pgs( PG *parent, const std::set &childpgids, std::set *out_pgs, diff --git a/src/test/mon/test_mon_workloadgen.cc b/src/test/mon/test_mon_workloadgen.cc index e62c5627b40..ca2eae0d427 100644 --- a/src/test/mon/test_mon_workloadgen.cc +++ b/src/test/mon/test_mon_workloadgen.cc @@ -57,7 +57,6 @@ #include "messages/MOSDBoot.h" #include "messages/MOSDAlive.h" -#include "messages/MOSDPGCreate.h" #include "messages/MOSDPGRemove.h" #include "messages/MOSDMap.h" #include "messages/MPGStats.h" @@ -743,33 +742,6 @@ class OSDStub : public TestStub } } - void handle_pg_create(MOSDPGCreate *m) { - ceph_assert(m != NULL); - if (m->epoch < osdmap.get_epoch()) { - std::cout << __func__ << " epoch " << m->epoch << " < " - << osdmap.get_epoch() << "; dropping" << std::endl; - m->put(); - return; - } - - for (map::iterator it = m->mkpg.begin(); - it != m->mkpg.end(); ++it) { - pg_create_t &c = it->second; - std::cout << __func__ << " pg " << it->first - << " created " << c.created - << " parent " << c.parent << std::endl; - if (pgs.count(it->first)) { - std::cout << __func__ << " pg " << it->first - << " exists; skipping" << std::endl; - continue; - } - - pg_t pgid = it->first; - add_pg(pgid, c.created, c.parent); - } - send_pg_stats(); - } - void handle_osd_map(MOSDMap *m) { dout(1) << __func__ << dendl; if (m->fsid != monc.get_fsid()) { @@ -872,9 +844,6 @@ class OSDStub : public TestStub dout(1) << __func__ << " " << *m << dendl; switch (m->get_type()) { - case MSG_OSD_PG_CREATE: - handle_pg_create((MOSDPGCreate*)m); - break; case CEPH_MSG_OSD_MAP: handle_osd_map((MOSDMap*)m); break; diff --git a/src/tools/ceph-dencoder/common_types.h b/src/tools/ceph-dencoder/common_types.h index 543336a7ef7..22e3e9d35d2 100644 --- a/src/tools/ceph-dencoder/common_types.h +++ b/src/tools/ceph-dencoder/common_types.h @@ -366,9 +366,6 @@ MESSAGE(MOSDOpReply) #include "messages/MOSDPGBackfill.h" MESSAGE(MOSDPGBackfill) -#include "messages/MOSDPGCreate.h" -MESSAGE(MOSDPGCreate) - #include "messages/MOSDPGCreate2.h" MESSAGE(MOSDPGCreate2)