From: Kefu Chai Date: Sun, 14 Apr 2019 07:01:57 +0000 (+0800) Subject: src/: use make_message instead of Foo::create() X-Git-Tag: v15.1.0~2896^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=868b47e65a051daa942622b106f08fca2afa9918;p=ceph-ci.git src/: use make_message instead of Foo::create() Signed-off-by: Kefu Chai --- diff --git a/src/client/Client.cc b/src/client/Client.cc index fad1a9a11e0..082ea717327 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2055,7 +2055,7 @@ MetaSession *Client::_open_mds_session(mds_rank_t mds) } } - auto m = MClientSession::create(CEPH_SESSION_REQUEST_OPEN); + auto m = make_message(CEPH_SESSION_REQUEST_OPEN); m->metadata = metadata; m->supported_features = feature_bitset_t(CEPHFS_FEATURES_CLIENT_SUPPORTED); session->con->send_message2(std::move(m)); @@ -2066,7 +2066,7 @@ void Client::_close_mds_session(MetaSession *s) { ldout(cct, 2) << __func__ << " mds." << s->mds_num << " seq " << s->seq << dendl; s->state = MetaSession::STATE_CLOSING; - s->con->send_message2(MClientSession::create(CEPH_SESSION_REQUEST_CLOSE, s->seq)); + s->con->send_message2(make_message(CEPH_SESSION_REQUEST_CLOSE, s->seq)); } void Client::_closed_mds_session(MetaSession *s) @@ -2148,7 +2148,7 @@ void Client::handle_client_session(const MConstRef& m) if (auto& m = session->release; m) { session->con->send_message2(std::move(m)); } - session->con->send_message2(MClientSession::create(CEPH_SESSION_FLUSHMSG_ACK, m->get_seq())); + session->con->send_message2(make_message(CEPH_SESSION_FLUSHMSG_ACK, m->get_seq())); break; case CEPH_SESSION_FORCE_RO: @@ -2251,7 +2251,7 @@ void Client::send_request(MetaRequest *request, MetaSession *session, ref_t Client::build_client_request(MetaRequest *request) { - auto req = MClientRequest::create(request->get_op()); + auto req = make_message(request->get_op()); req->set_tid(request->tid); req->set_stamp(request->op_stamp); memcpy(&req->head, &request->head, sizeof(ceph_mds_request_head)); @@ -2783,7 +2783,7 @@ void Client::send_reconnect(MetaSession *session) early_kick_flushing_caps(session); - auto m = MClientReconnect::create(); + auto m = make_message(); bool allow_multi = session->mds_features.test(CEPHFS_FEATURE_MULTI_RECONNECT); // i have an open session. @@ -2799,7 +2799,7 @@ void Client::send_reconnect(MetaSession *session) m->mark_more(); session->con->send_message2(std::move(m)); - m = MClientReconnect::create(); + m = make_message(); } Cap &cap = it->second; @@ -2965,7 +2965,7 @@ void Client::got_mds_push(MetaSession *s) s->seq++; ldout(cct, 10) << " mds." << s->mds_num << " seq now " << s->seq << dendl; if (s->state == MetaSession::STATE_CLOSING) { - s->con->send_message2(MClientSession::create(CEPH_SESSION_REQUEST_CLOSE, s->seq)); + s->con->send_message2(make_message(CEPH_SESSION_REQUEST_CLOSE, s->seq)); } } @@ -3005,7 +3005,9 @@ void Client::handle_lease(const MConstRef& m) revoke: { - auto reply = MClientLease::create(CEPH_MDS_LEASE_RELEASE, seq, m->get_mask(), m->get_ino(), m->get_first(), m->get_last(), m->dname); + auto reply = make_message(CEPH_MDS_LEASE_RELEASE, seq, + m->get_mask(), m->get_ino(), + m->get_first(), m->get_last(), m->dname); m->get_connection()->send_message2(std::move(reply)); } } @@ -3359,7 +3361,7 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, if (flush) follows = in->snaprealm->get_snap_context().seq; - auto m = MClientCaps::create(op, + auto m = make_message(op, in->ino, 0, cap->cap_id, cap->seq, @@ -3728,7 +3730,7 @@ void Client::flush_snaps(Inode *in, bool all_again) session->flushing_caps_tids.insert(capsnap.flush_tid); } - auto m = MClientCaps::create(CEPH_CAP_OP_FLUSHSNAP, in->ino, in->snaprealm->ino, 0, mseq, + auto m = make_message(CEPH_CAP_OP_FLUSHSNAP, in->ino, in->snaprealm->ino, 0, mseq, cap_epoch_barrier); m->caller_uid = capsnap.cap_dirtier_uid; m->caller_gid = capsnap.cap_dirtier_gid; @@ -5951,7 +5953,7 @@ void Client::flush_mdlog(MetaSession *session) // will crash if they see an unknown CEPH_SESSION_* value in this msg. const uint64_t features = session->con->get_features(); if (HAVE_FEATURE(features, SERVER_LUMINOUS)) { - auto m = MClientSession::create(CEPH_SESSION_REQUEST_FLUSH_MDLOG); + auto m = make_message(CEPH_SESSION_REQUEST_FLUSH_MDLOG); session->con->send_message2(std::move(m)); } } @@ -6219,7 +6221,7 @@ void Client::renew_caps(MetaSession *session) ldout(cct, 10) << "renew_caps mds." << session->mds_num << dendl; session->last_cap_renew_request = ceph_clock_now(); uint64_t seq = ++session->cap_renew_seq; - session->con->send_message2(MClientSession::create(CEPH_SESSION_REQUEST_RENEWCAPS, seq)); + session->con->send_message2(make_message(CEPH_SESSION_REQUEST_RENEWCAPS, seq)); } @@ -14369,7 +14371,7 @@ int Client::start_reclaim(const std::string& uuid, unsigned flags, if (session->reclaim_state == MetaSession::RECLAIM_NULL || session->reclaim_state == MetaSession::RECLAIMING) { session->reclaim_state = MetaSession::RECLAIMING; - auto m = MClientReclaim::create(uuid, flags); + auto m = make_message(uuid, flags); session->con->send_message2(std::move(m)); wait_on_list(waiting_for_reclaim); } else if (session->reclaim_state == MetaSession::RECLAIM_FAIL) { @@ -14421,7 +14423,7 @@ void Client::finish_reclaim() for (auto &p : mds_sessions) { p.second.reclaim_state = MetaSession::RECLAIM_NULL; - auto m = MClientReclaim::create("", MClientReclaim::FLAG_FINISH); + auto m = make_message("", MClientReclaim::FLAG_FINISH); p.second.con->send_message2(std::move(m)); } diff --git a/src/common/CommandTable.h b/src/common/CommandTable.h index c269773efa8..3c16d8d4054 100644 --- a/src/common/CommandTable.h +++ b/src/common/CommandTable.h @@ -31,7 +31,7 @@ class CommandOp MCommand::ref get_message(const uuid_d &fsid) const { - auto m = MCommand::create(fsid); + auto m = make_message(fsid); m->cmd = cmd; m->set_data(inbl); m->set_tid(tid); diff --git a/src/crimson/osd/heartbeat.cc b/src/crimson/osd/heartbeat.cc index a44fd7e79a8..f2c203a23a0 100644 --- a/src/crimson/osd/heartbeat.cc +++ b/src/crimson/osd/heartbeat.cc @@ -20,12 +20,6 @@ namespace { seastar::logger& logger() { return ceph::get_logger(ceph_subsys_osd); } - - template - Ref make_message(Args&&... args) - { - return {new Message{std::forward(args)...}, false}; - } } Heartbeat::Heartbeat(const OSDMapService& service, diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index cae846471b6..124fed81d1e 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -37,12 +37,6 @@ namespace { seastar::logger& logger() { return ceph::get_logger(ceph_subsys_osd); } - - template - Ref make_message(Args&&... args) - { - return {new Message{std::forward(args)...}, false}; - } static constexpr int TICK_INTERVAL = 1; } diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index cb87cc03ca5..dffb98d1fc7 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -36,11 +36,6 @@ namespace { seastar::logger& logger() { return ceph::get_logger(ceph_subsys_osd); } - template - Ref make_message(Args&&... args) - { - return {new Message{std::forward(args)...}, false}; - } } using recovery::AdvMap; diff --git a/src/mds/Beacon.cc b/src/mds/Beacon.cc index de1284ba5dc..b1aac5855c3 100644 --- a/src/mds/Beacon.cc +++ b/src/mds/Beacon.cc @@ -197,7 +197,7 @@ bool Beacon::_send() ceph_assert(want_state != MDSMap::STATE_NULL); - auto beacon = MMDSBeacon::create( + auto beacon = make_message( monc->get_fsid(), mds_gid_t(monc->get_global_id()), name, epoch, diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index d16d29f3344..95356aec54d 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -2057,7 +2057,7 @@ void CInode::finish_scatter_update(ScatterLock *lock, CDir *dir, mempool_inode *pi = get_projected_inode(); fnode_t *pf = dir->project_fnode(); - std::string_view ename = 0; + std::string_view ename; switch (lock->get_type()) { case CEPH_LOCK_IFILE: pf->fragstat.version = pi->dirstat.version; diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 014d8d7f4ae..a4776c00fa3 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -136,7 +136,7 @@ void Locker::send_lock_message(SimpleLock *lock, int msg) if (mds->is_cluster_degraded() && mds->mdsmap->get_state(it.first) < MDSMap::STATE_REJOIN) continue; - auto m = MLock::create(lock, msg, mds->get_nodeid()); + auto m = make_message(lock, msg, mds->get_nodeid()); mds->send_message_mds(m, it.first); } } @@ -147,7 +147,7 @@ void Locker::send_lock_message(SimpleLock *lock, int msg, const bufferlist &data if (mds->is_cluster_degraded() && mds->mdsmap->get_state(it.first) < MDSMap::STATE_REJOIN) continue; - auto m = MLock::create(lock, msg, mds->get_nodeid()); + auto m = make_message(lock, msg, mds->get_nodeid()); m->set_data(data); mds->send_message_mds(m, it.first); } @@ -431,7 +431,8 @@ bool Locker::acquire_locks(MDRequestRef& mdr, return false; } - auto req = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_AUTHPIN); + auto req = make_message(mdr->reqid, mdr->attempt, + MMDSSlaveRequest::OP_AUTHPIN); for (set::iterator q = p->second.begin(); q != p->second.end(); ++q) { @@ -707,7 +708,8 @@ void Locker::_drop_locks(MutationImpl *mut, set *pneed_issue, if (!mds->is_cluster_degraded() || mds->mdsmap->get_state(*p) >= MDSMap::STATE_REJOIN) { dout(10) << "_drop_non_rdlocks dropping remote locks on mds." << *p << dendl; - auto slavereq = MMDSSlaveRequest::create(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_DROPLOCKS); + auto slavereq = make_message(mut->reqid, mut->attempt, + MMDSSlaveRequest::OP_DROPLOCKS); mds->send_message_mds(slavereq, *p); } } @@ -885,12 +887,12 @@ void Locker::eval_gather(SimpleLock *lock, bool first, bool *pneed_issue, MDSCon mds->mdsmap->get_state(auth) >= MDSMap::STATE_REJOIN) { switch (lock->get_state()) { case LOCK_SYNC_LOCK: - mds->send_message_mds(MLock::create(lock, LOCK_AC_LOCKACK, mds->get_nodeid()), auth); + mds->send_message_mds(make_message(lock, LOCK_AC_LOCKACK, mds->get_nodeid()), auth); break; case LOCK_MIX_SYNC: { - auto reply = MLock::create(lock, LOCK_AC_SYNCACK, mds->get_nodeid()); + auto reply = make_message(lock, LOCK_AC_SYNCACK, mds->get_nodeid()); lock->encode_locked_state(reply->get_data()); mds->send_message_mds(reply, auth); next = LOCK_MIX_SYNC2; @@ -908,7 +910,7 @@ void Locker::eval_gather(SimpleLock *lock, bool first, bool *pneed_issue, MDSCon case LOCK_SYNC_MIX: { - auto reply = MLock::create(lock, LOCK_AC_MIXACK, mds->get_nodeid()); + auto reply = make_message(lock, LOCK_AC_MIXACK, mds->get_nodeid()); mds->send_message_mds(reply, auth); next = LOCK_SYNC_MIX2; } @@ -918,7 +920,7 @@ void Locker::eval_gather(SimpleLock *lock, bool first, bool *pneed_issue, MDSCon { bufferlist data; lock->encode_locked_state(data); - mds->send_message_mds(MLock::create(lock, LOCK_AC_LOCKACK, mds->get_nodeid(), data), auth); + mds->send_message_mds(make_message(lock, LOCK_AC_LOCKACK, mds->get_nodeid(), data), auth); (static_cast(lock))->start_flush(); // we'll get an AC_LOCKFLUSHED to complete } @@ -1281,7 +1283,7 @@ bool Locker::_rdlock_kick(SimpleLock *lock, bool as_anon) mds->mdsmap->is_clientreplay_or_active_or_stopping(auth)) { dout(10) << "requesting rdlock from auth on " << *lock << " on " << *lock->get_parent() << dendl; - mds->send_message_mds(MLock::create(lock, LOCK_AC_REQRDLOCK, mds->get_nodeid()), auth); + mds->send_message_mds(make_message(lock, LOCK_AC_REQRDLOCK, mds->get_nodeid()), auth); } return false; } @@ -1504,7 +1506,7 @@ bool Locker::wrlock_start(const MutationImpl::LockOp &op, MDRequestRef& mut, boo mds->mdsmap->is_clientreplay_or_active_or_stopping(auth)) { dout(10) << "requesting scatter from auth on " << *lock << " on " << *lock->get_parent() << dendl; - mds->send_message_mds(MLock::create(lock, LOCK_AC_REQSCATTER, mds->get_nodeid()), auth); + mds->send_message_mds(make_message(lock, LOCK_AC_REQSCATTER, mds->get_nodeid()), auth); } break; } @@ -1563,7 +1565,7 @@ void Locker::remote_wrlock_start(SimpleLock *lock, mds_rank_t target, MDRequestR // send lock request mut->start_locking(lock, target); mut->more()->slaves.insert(target); - auto r = MMDSSlaveRequest::create(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_WRLOCK); + auto r = make_message(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_WRLOCK); r->set_lock_type(lock->get_type()); lock->get_parent()->set_object_info(r->get_object_info()); mds->send_message_mds(r, target); @@ -1587,7 +1589,7 @@ void Locker::remote_wrlock_finish(const MutationImpl::lock_iterator& it, Mutatio << " " << *lock->get_parent() << dendl; if (!mds->is_cluster_degraded() || mds->mdsmap->get_state(target) >= MDSMap::STATE_REJOIN) { - auto slavereq = MMDSSlaveRequest::create(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_UNWRLOCK); + auto slavereq = make_message(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_UNWRLOCK); slavereq->set_lock_type(lock->get_type()); lock->get_parent()->set_object_info(slavereq->get_object_info()); mds->send_message_mds(slavereq, target); @@ -1671,7 +1673,7 @@ bool Locker::xlock_start(SimpleLock *lock, MDRequestRef& mut) // send lock request mut->more()->slaves.insert(auth); mut->start_locking(lock, auth); - auto r = MMDSSlaveRequest::create(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_XLOCK); + auto r = make_message(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_XLOCK); r->set_lock_type(lock->get_type()); lock->get_parent()->set_object_info(r->get_object_info()); mds->send_message_mds(r, auth); @@ -1739,7 +1741,7 @@ void Locker::xlock_finish(const MutationImpl::lock_iterator& it, MutationImpl *m mds_rank_t auth = lock->get_parent()->authority().first; if (!mds->is_cluster_degraded() || mds->mdsmap->get_state(auth) >= MDSMap::STATE_REJOIN) { - auto slavereq = MMDSSlaveRequest::create(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_UNXLOCK); + auto slavereq = make_message(mut->reqid, mut->attempt, MMDSSlaveRequest::OP_UNXLOCK); slavereq->set_lock_type(lock->get_type()); lock->get_parent()->set_object_info(slavereq->get_object_info()); mds->send_message_mds(slavereq, auth); @@ -2072,7 +2074,7 @@ bool Locker::issue_caps(CInode *in, Capability *only_cap) cap->reset_num_revoke_warnings(); } - auto m = MClientCaps::create(op, in->ino(), + auto m = make_message(op, in->ino(), in->find_snaprealm()->inode->ino(), cap->get_cap_id(), cap->get_last_seq(), @@ -2098,7 +2100,7 @@ void Locker::issue_truncate(CInode *in) for (auto &p : in->client_caps) { Capability *cap = &p.second; - auto m = MClientCaps::create(CEPH_CAP_OP_TRUNC, + auto m = make_message(CEPH_CAP_OP_TRUNC, in->ino(), in->find_snaprealm()->inode->ino(), cap->get_cap_id(), cap->get_last_seq(), @@ -2252,7 +2254,7 @@ void Locker::request_inode_file_caps(CInode *in) if (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(auth)) - mds->send_message_mds(MInodeFileCaps::create(in->ino(), in->replica_caps_wanted), auth); + mds->send_message_mds(make_message(in->ino(), in->replica_caps_wanted), auth); } } @@ -2499,7 +2501,7 @@ void Locker::share_inode_max_size(CInode *in, Capability *only_cap) if (cap->pending() & (CEPH_CAP_FILE_WR|CEPH_CAP_FILE_BUFFER)) { dout(10) << "share_inode_max_size with client." << client << dendl; cap->inc_last_seq(); - auto m = MClientCaps::create(CEPH_CAP_OP_GRANT, + auto m = make_message(CEPH_CAP_OP_GRANT, in->ino(), in->find_snaprealm()->inode->ino(), cap->get_cap_id(), @@ -2699,9 +2701,9 @@ void Locker::handle_client_caps(const cref_t &m) << " for client." << client << dendl; ref_t ack; if (op == CEPH_CAP_OP_FLUSHSNAP) { - ack = MClientCaps::create(CEPH_CAP_OP_FLUSHSNAP_ACK, m->get_ino(), 0, 0, 0, 0, 0, dirty, 0, mds->get_osd_epoch_barrier()); + ack = make_message(CEPH_CAP_OP_FLUSHSNAP_ACK, m->get_ino(), 0, 0, 0, 0, 0, dirty, 0, mds->get_osd_epoch_barrier()); } else { - ack = MClientCaps::create(CEPH_CAP_OP_FLUSH_ACK, m->get_ino(), 0, m->get_cap_id(), m->get_seq(), m->get_caps(), 0, dirty, 0, mds->get_osd_epoch_barrier()); + ack = make_message(CEPH_CAP_OP_FLUSH_ACK, m->get_ino(), 0, m->get_cap_id(), m->get_seq(), m->get_caps(), 0, dirty, 0, mds->get_osd_epoch_barrier()); } ack->set_snap_follows(follows); ack->set_client_tid(m->get_client_tid()); @@ -2823,7 +2825,7 @@ void Locker::handle_client_caps(const cref_t &m) // case we get a dup response, so whatever.) ref_t ack; if (dirty) { - ack = MClientCaps::create(CEPH_CAP_OP_FLUSHSNAP_ACK, in->ino(), 0, 0, 0, 0, 0, dirty, 0, mds->get_osd_epoch_barrier()); + ack = make_message(CEPH_CAP_OP_FLUSHSNAP_ACK, in->ino(), 0, 0, 0, 0, 0, dirty, 0, mds->get_osd_epoch_barrier()); ack->set_snap_follows(follows); ack->set_client_tid(m->get_client_tid()); ack->set_oldest_flush_tid(m->get_oldest_flush_tid()); @@ -2906,7 +2908,7 @@ void Locker::handle_client_caps(const cref_t &m) if (dirty && in->is_auth()) { dout(7) << " flush client." << client << " dirty " << ccap_string(dirty) << " seq " << m->get_seq() << " on " << *in << dendl; - ack = MClientCaps::create(CEPH_CAP_OP_FLUSH_ACK, in->ino(), 0, cap->get_cap_id(), m->get_seq(), + ack = make_message(CEPH_CAP_OP_FLUSH_ACK, in->ino(), 0, cap->get_cap_id(), m->get_seq(), m->get_caps(), 0, dirty, 0, mds->get_osd_epoch_barrier()); ack->set_client_tid(m->get_client_tid()); ack->set_oldest_flush_tid(m->get_oldest_flush_tid()); @@ -3741,7 +3743,7 @@ void Locker::handle_client_lease(const cref_t &m) dout(7) << "handle_client_lease client." << client << " renew on " << *dn << (!dn->lock.can_lease(client)?", revoking lease":"") << dendl; if (dn->lock.can_lease(client)) { - auto reply = MClientLease::create(*m); + auto reply = make_message(*m); int pool = 1; // fixme.. do something smart! reply->h.duration_ms = (int)(1000 * mdcache->client_lease_durations[pool]); reply->h.seq = ++l->seq; @@ -3812,7 +3814,7 @@ void Locker::revoke_client_leases(SimpleLock *lock) // i should also revoke the dir ICONTENT lease, if they have it! CInode *diri = dn->get_dir()->get_inode(); - auto lease = MClientLease::create(CEPH_MDS_LEASE_REVOKE, l->seq, mask, diri->ino(), diri->first, CEPH_NOSNAP, dn->get_name()); + auto lease = make_message(CEPH_MDS_LEASE_REVOKE, l->seq, mask, diri->ino(), diri->first, CEPH_NOSNAP, dn->get_name()); mds->send_message_client_counted(lease, l->client); } } @@ -4682,7 +4684,7 @@ void Locker::scatter_nudge(ScatterLock *lock, MDSContext *c, bool forcelockchang // request unscatter? mds_rank_t auth = lock->get_parent()->authority().first; if (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(auth)) { - mds->send_message_mds(MLock::create(lock, LOCK_AC_NUDGE, mds->get_nodeid()), auth); + mds->send_message_mds(make_message(lock, LOCK_AC_NUDGE, mds->get_nodeid()), auth); } // wait... diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index ee809fbcbf8..2cb109a4e11 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -400,7 +400,7 @@ void MDBalancer::send_heartbeat() for (const auto& r : up) { if (r == mds->get_nodeid()) continue; - auto hb = MHeartbeat::create(load, beat_epoch); + auto hb = make_message(load, beat_epoch); hb->get_import_map() = import_map; mds->send_message_mds(hb, r); } diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 4d5398ac7fc..15913a35d13 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -1979,14 +1979,14 @@ update: cap->last_rsize = i->rstat.rsize(); cap->last_rbytes = i->rstat.rbytes; - auto msg = MClientQuota::create(); + auto msg = make_message(); msg->ino = in->ino(); msg->rstat = i->rstat; msg->quota = i->quota; mds->send_message_client_counted(msg, cap->get_session()); } for (const auto &it : in->get_replicas()) { - auto msg = MGatherCaps::create(); + auto msg = make_message(); msg->ino = in->ino(); mds->send_message_mds(msg, it.first); } @@ -2412,7 +2412,7 @@ void MDCache::_logged_slave_commit(mds_rank_t from, metareqid_t reqid) dout(10) << "_logged_slave_commit from mds." << from << " " << reqid << dendl; // send a message - auto req = MMDSSlaveRequest::create(reqid, 0, MMDSSlaveRequest::OP_COMMITTED); + auto req = make_message(reqid, 0, MMDSSlaveRequest::OP_COMMITTED); mds->send_message_mds(req, from); } @@ -2666,7 +2666,7 @@ void MDCache::send_slave_resolves() for (map >::iterator p = uncommitted_slave_updates.begin(); p != uncommitted_slave_updates.end(); ++p) { - resolves[p->first] = MMDSResolve::create(); + resolves[p->first] = make_message(); for (map::iterator q = p->second.begin(); q != p->second.end(); ++q) { @@ -2690,7 +2690,7 @@ void MDCache::send_slave_resolves() if (resolve_set.count(master) || is_ambiguous_slave_update(p->first, master)) { dout(10) << " including uncommitted " << *mdr << dendl; if (!resolves.count(master)) - resolves[master] = MMDSResolve::create(); + resolves[master] = make_message(); if (!mdr->committing && mdr->has_more() && mdr->more()->is_inode_exporter) { // re-send cap exports @@ -2734,7 +2734,7 @@ void MDCache::send_subtree_resolves() if (*p == mds->get_nodeid()) continue; if (mds->is_resolve() || mds->mdsmap->is_resolve(*p)) - resolves[*p] = MMDSResolve::create(); + resolves[*p] = make_message(); } map > my_subtrees; @@ -3118,7 +3118,7 @@ void MDCache::handle_resolve(const cref_t &m) } } - auto ack = MMDSResolveAck::create(); + auto ack = make_message(); for (const auto &p : m->slave_requests) { if (uncommitted_masters.count(p.first)) { //mds->sessionmap.have_completed_request(p.first)) { // COMMIT @@ -3922,9 +3922,9 @@ void MDCache::rejoin_send_rejoins() if (*p == mds->get_nodeid()) continue; // nothing to myself! if (rejoin_sent.count(*p)) continue; // already sent a rejoin to this node! if (mds->is_rejoin()) - rejoins[*p] = MMDSCacheRejoin::create(MMDSCacheRejoin::OP_WEAK); + rejoins[*p] = make_message(MMDSCacheRejoin::OP_WEAK); else if (mds->mdsmap->is_rejoin(*p)) - rejoins[*p] = MMDSCacheRejoin::create(MMDSCacheRejoin::OP_STRONG); + rejoins[*p] = make_message(MMDSCacheRejoin::OP_STRONG); } if (mds->is_rejoin()) { @@ -4291,7 +4291,7 @@ void MDCache::handle_cache_rejoin_weak(const cref_t &weak) if (mds->is_clientreplay() || mds->is_active() || mds->is_stopping()) { survivor = true; dout(10) << "i am a surivivor, and will ack immediately" << dendl; - ack = MMDSCacheRejoin::create(MMDSCacheRejoin::OP_ACK); + ack = make_message(MMDSCacheRejoin::OP_ACK); map > imported_caps; @@ -5068,7 +5068,7 @@ void MDCache::handle_cache_rejoin_ack(const cref_t &ack) } // mark client caps stale. - auto m = MClientCaps::create(CEPH_CAP_OP_EXPORT, p->first, 0, + auto m = make_message(CEPH_CAP_OP_EXPORT, p->first, 0, r->second.capinfo.cap_id, 0, mds->get_osd_epoch_barrier()); m->set_cap_peer(q->second.cap_id, q->second.issue_seq, q->second.mseq, @@ -5502,7 +5502,7 @@ void MDCache::prepare_realm_split(SnapRealm *realm, client_t client, inodeno_t i snap = it->second; snap->head.op = CEPH_SNAP_OP_SPLIT; } else { - snap = MClientSnap::create(CEPH_SNAP_OP_SPLIT); + snap = make_message(CEPH_SNAP_OP_SPLIT); splits.emplace(std::piecewise_construct, std::forward_as_tuple(client), std::forward_as_tuple(snap)); snap->head.split = realm->inode->ino(); snap->bl = realm->get_snap_trace(); @@ -5534,7 +5534,7 @@ void MDCache::prepare_realm_merge(SnapRealm *realm, SnapRealm *parent_realm, ceph_assert(!p.second->empty()); auto em = splits.emplace(std::piecewise_construct, std::forward_as_tuple(p.first), std::forward_as_tuple()); if (em.second) { - auto update = MClientSnap::create(CEPH_SNAP_OP_SPLIT); + auto update = make_message(CEPH_SNAP_OP_SPLIT); update->head.split = parent_realm->inode->ino(); update->split_inos = split_inos; update->split_realms = split_realms; @@ -5650,7 +5650,9 @@ void MDCache::export_remaining_imported_caps() Session *session = mds->sessionmap.get_session(entity_name_t::CLIENT(q->first.v)); if (session) { // mark client caps stale. - auto stale = MClientCaps::create(CEPH_CAP_OP_EXPORT, p->first, 0, 0, 0, mds->get_osd_epoch_barrier()); + auto stale = make_message(CEPH_CAP_OP_EXPORT, p->first, + 0, 0, 0, + mds->get_osd_epoch_barrier()); stale->set_cap_peer(0, 0, 0, -1, 0); mds->send_message_client_counted(stale, q->first); } @@ -5727,7 +5729,10 @@ void MDCache::do_cap_import(Session *session, CInode *in, Capability *cap, cap->set_last_issue(); cap->set_last_issue_stamp(ceph_clock_now()); cap->clear_new(); - auto reap = MClientCaps::create(CEPH_CAP_OP_IMPORT, in->ino(), realm->inode->ino(), cap->get_cap_id(), cap->get_last_seq(), cap->pending(), cap->wanted(), 0, cap->get_mseq(), mds->get_osd_epoch_barrier()); + auto reap = make_message( + CEPH_CAP_OP_IMPORT, in->ino(), realm->inode->ino(), cap->get_cap_id(), + cap->get_last_seq(), cap->pending(), cap->wanted(), 0, cap->get_mseq(), + mds->get_osd_epoch_barrier()); in->encode_cap_message(reap, cap); reap->snapbl = realm->get_snap_trace(); reap->set_cap_peer(p_cap_id, p_seq, p_mseq, peer, p_flags); @@ -5924,7 +5929,7 @@ void MDCache::finish_snaprealm_reconnect(client_t client, SnapRealm *realm, snap if (seq < realm->get_newest_seq()) { dout(10) << "finish_snaprealm_reconnect client." << client << " has old seq " << seq << " < " << realm->get_newest_seq() << " on " << *realm << dendl; - auto snap = MClientSnap::create(CEPH_SNAP_OP_UPDATE); + auto snap = make_message(CEPH_SNAP_OP_UPDATE); snap->bl = realm->get_snap_trace(); for (const auto& child : realm->open_children) snap->split_realms.push_back(child->inode->ino()); @@ -5980,7 +5985,7 @@ void MDCache::rejoin_send_acks() ++p) { if (rejoin_ack_sent.count(*p)) continue; - acks[*p] = MMDSCacheRejoin::create(MMDSCacheRejoin::OP_ACK); + acks[*p] = make_message(MMDSCacheRejoin::OP_ACK); } rejoin_ack_sent = recovery_set; @@ -6623,7 +6628,7 @@ std::pair MDCache::trim(uint64_t count) auto em = expiremap.emplace(std::piecewise_construct, std::forward_as_tuple(rank), std::forward_as_tuple()); if (em.second) { - em.first->second = MCacheExpire::create(mds->get_nodeid()); + em.first->second = make_message(mds->get_nodeid()); } dout(20) << __func__ << ": try expiring " << *mdsdir_in << " for stopping mds." << mds << dendl; @@ -6752,7 +6757,7 @@ bool MDCache::trim_dentry(CDentry *dn, expiremap& expiremap) ceph_assert(a != mds->get_nodeid()); auto em = expiremap.emplace(std::piecewise_construct, std::forward_as_tuple(a), std::forward_as_tuple()); if (em.second) - em.first->second = MCacheExpire::create(mds->get_nodeid()); + em.first->second = make_message(mds->get_nodeid()); em.first->second->add_dentry(con->dirfrag(), dir->dirfrag(), dn->get_name(), dn->last, dn->get_replica_nonce()); } } @@ -6808,7 +6813,7 @@ void MDCache::trim_dirfrag(CDir *dir, CDir *con, expiremap& expiremap) ceph_assert(a != mds->get_nodeid()); auto em = expiremap.emplace(std::piecewise_construct, std::forward_as_tuple(a), std::forward_as_tuple()); if (em.second) - em.first->second = MCacheExpire::create(mds->get_nodeid()); /* new */ + em.first->second = make_message(mds->get_nodeid()); /* new */ em.first->second->add_dir(condf, dir->dirfrag(), dir->replica_nonce); } } @@ -6875,7 +6880,7 @@ bool MDCache::trim_inode(CDentry *dn, CInode *in, CDir *con, expiremap& expirema ceph_assert(a != mds->get_nodeid()); auto em = expiremap.emplace(std::piecewise_construct, std::forward_as_tuple(a), std::forward_as_tuple()); if (em.second) - em.first->second = MCacheExpire::create(mds->get_nodeid()); /* new */ + em.first->second = make_message(mds->get_nodeid()); /* new */ em.first->second->add_inode(df, in->vino(), in->get_replica_nonce()); } } @@ -7236,7 +7241,7 @@ void MDCache::handle_cache_expire(const cref_t &m) auto em = delayed_expire[parent_dir].emplace(std::piecewise_construct, std::forward_as_tuple(from), std::forward_as_tuple()); if (em.second) - em.first->second = MCacheExpire::create(from); /* new */ + em.first->second = make_message(from); /* new */ // merge these expires into it em.first->second->add_realm(p.first, p.second); @@ -8801,7 +8806,7 @@ void MDCache::do_open_ino_peer(inodeno_t ino, open_ino_info_t& info) // got backtrace from peer or backtrace just fetched if (info.discover || !info.fetch_backtrace) pa = &info.ancestors; - mds->send_message_mds(MMDSOpenIno::create(info.tid, ino, pa), peer); + mds->send_message_mds(make_message(info.tid, ino, pa), peer); if (mds->logger) mds->logger->inc(l_mds_openino_peer_discover); } @@ -8822,7 +8827,7 @@ void MDCache::handle_open_ino(const cref_t &m, int err) CInode *in = get_inode(ino); if (in) { dout(10) << " have " << *in << dendl; - reply = MMDSOpenInoReply::create(m->get_tid(), ino, mds_rank_t(0)); + reply = make_message(m->get_tid(), ino, mds_rank_t(0)); if (in->is_auth()) { touch_inode(in); while (1) { @@ -8838,13 +8843,13 @@ void MDCache::handle_open_ino(const cref_t &m, int err) reply->hint = in->authority().first; } } else if (err < 0) { - reply = MMDSOpenInoReply::create(m->get_tid(), ino, MDS_RANK_NONE, err); + reply = make_message(m->get_tid(), ino, MDS_RANK_NONE, err); } else { mds_rank_t hint = MDS_RANK_NONE; int ret = open_ino_traverse_dir(ino, m, m->ancestors, false, false, &hint); if (ret > 0) return; - reply = MMDSOpenInoReply::create(m->get_tid(), ino, hint, ret); + reply = make_message(m->get_tid(), ino, hint, ret); } mds->send_message_mds(reply, from); } @@ -9018,7 +9023,7 @@ void MDCache::_do_find_ino_peer(find_ino_peer_info_t& fip) } } else { fip.checking = m; - mds->send_message_mds(MMDSFindIno::create(fip.tid, fip.ino), m); + mds->send_message_mds(make_message(fip.tid, fip.ino), m); } } @@ -9029,7 +9034,7 @@ void MDCache::handle_find_ino(const cref_t &m) } dout(10) << "handle_find_ino " << *m << dendl; - auto r = MMDSFindInoReply::create(m->tid); + auto r = make_message(m->tid); CInode *in = get_inode(m->ino); if (in) { in->make_path(r->path); @@ -9306,8 +9311,8 @@ void MDCache::request_drop_foreign_locks(MDRequestRef& mdr) for (set::iterator p = mdr->more()->slaves.begin(); p != mdr->more()->slaves.end(); ++p) { - auto r = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, - MMDSSlaveRequest::OP_FINISH); + auto r = make_message(mdr->reqid, mdr->attempt, + MMDSSlaveRequest::OP_FINISH); if (mdr->killed && !mdr->committing) { r->mark_abort(); @@ -9483,7 +9488,7 @@ void MDCache::do_realm_invalidate_and_update_notify(CInode *in, int snapop, bool auto em = updates.emplace(std::piecewise_construct, std::forward_as_tuple(client), std::forward_as_tuple()); if (em.second) { - auto update = MClientSnap::create(CEPH_SNAP_OP_SPLIT); + auto update = make_message(CEPH_SNAP_OP_SPLIT); update->head.split = in->ino(); update->split_inos = split_inos; update->split_realms = split_realms; @@ -9567,7 +9572,7 @@ void MDCache::send_snap_update(CInode *in, version_t stid, int snap_op) in->encode_snap(snap_blob); for (auto p : mds_set) { - auto m = MMDSSnapUpdate::create(in->ino(), stid, snap_op); + auto m = make_message(in->ino(), stid, snap_op); m->snap_blob = snap_blob; mds->send_message_mds(m, p); } @@ -9625,7 +9630,7 @@ void MDCache::notify_global_snaprealm_update(int snap_op) for (auto &session : sessions) { if (!session->is_open() && !session->is_stale()) continue; - auto update = MClientSnap::create(snap_op); + auto update = make_message(snap_op); update->head.split = global_snaprealm->inode->ino(); update->bl = global_snaprealm->get_snap_trace(); mds->send_message_client_counted(update, session); @@ -9700,7 +9705,8 @@ void MDCache::fetch_backtrace(inodeno_t ino, int64_t pool, bufferlist& bl, Conte void MDCache::_send_discover(discover_info_t& d) { - auto dis = MDiscover::create(d.ino, d.frag, d.snap, d.want_path, d.want_base_dir, d.want_xlocked); + auto dis = make_message(d.ino, d.frag, d.snap, d.want_path, + d.want_base_dir, d.want_xlocked); dis->set_tid(d.tid); mds->send_message_mds(dis, d.mds); } @@ -9892,7 +9898,7 @@ void MDCache::handle_discover(const cref_t &dis) CInode *cur = 0; - auto reply = MDiscoverReply::create(*dis); + auto reply = make_message(*dis); snapid_t snapid = dis->get_snapid(); @@ -10501,7 +10507,7 @@ int MDCache::send_dir_updates(CDir *dir, bool bcast) for (const auto &r : dir->dir_rep_by) { s.insert(r); } - mds->send_message_mds(MDirUpdate::create(mds->get_nodeid(), dir->dirfrag(), dir->dir_rep, s, path, bcast), *it); + mds->send_message_mds(make_message(mds->get_nodeid(), dir->dirfrag(), dir->dir_rep, s, path, bcast), *it); } return 0; @@ -10570,7 +10576,7 @@ void MDCache::send_dentry_link(CDentry *dn, MDRequestRef& mdr) rejoin_gather.count(p.first))) continue; CDentry::linkage_t *dnl = dn->get_linkage(); - auto m = MDentryLink::create(subtree->dirfrag(), dn->get_dir()->dirfrag(), dn->get_name(), dnl->is_primary()); + auto m = make_message(subtree->dirfrag(), dn->get_dir()->dirfrag(), dn->get_name(), dnl->is_primary()); if (dnl->is_primary()) { dout(10) << " primary " << *dnl->get_inode() << dendl; replicate_inode(dnl->get_inode(), p.first, m->bl, @@ -10657,7 +10663,7 @@ void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn, MDRequestRef& md rejoin_gather.count(*it))) continue; - auto unlink = MDentryUnlink::create(dn->get_dir()->dirfrag(), dn->get_name()); + auto unlink = make_message(dn->get_dir()->dirfrag(), dn->get_name()); if (straydn) { replicate_stray(straydn, *it, unlink->straybl); unlink->snapbl = snapbl; @@ -11511,7 +11517,7 @@ void MDCache::_fragment_stored(MDRequestRef& mdr) rejoin_gather.count(p.first))) continue; - auto notify = MMDSFragmentNotify::create(basedirfrag, info.bits, mdr->reqid.tid); + auto notify = make_message(basedirfrag, info.bits, mdr->reqid.tid); if (diri_auth != CDIR_AUTH_UNKNOWN && // subtree root diri_auth != p.first) { // not auth mds of diri /* @@ -11734,7 +11740,7 @@ void MDCache::handle_fragment_notify(const cref_t ¬ify) } if (notify->is_ack_wanted()) { - auto ack = MMDSFragmentNotifyAck::create(notify->get_base_dirfrag(), + auto ack = make_message(notify->get_base_dirfrag(), notify->get_bits(), notify->get_tid()); mds->send_message_mds(ack, from); } diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index db0b7f543ae..9d91043541a 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -601,7 +601,7 @@ void MDSDaemon::send_command_reply(const cref_t &m, MDSRank *mds_rank, } priv.reset(); - auto reply = MCommandReply::create(r, outs); + auto reply = make_message(r, outs); reply->set_tid(m->get_tid()); reply->set_data(outbl); m->get_connection()->send_message2(reply); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 1791048e8a0..a17bbe7008f 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -648,7 +648,7 @@ void MDSRank::update_targets() if (send) { dout(15) << "updating export_targets, now " << new_map_targets.size() << " ranks are targets" << dendl; - auto m = MMDSLoadTargets::create(mds_gid_t(monc->get_global_id()), new_map_targets); + auto m = make_message(mds_gid_t(monc->get_global_id()), new_map_targets); monc->send_mon_message(m.detach()); } } @@ -1380,7 +1380,7 @@ void MDSRank::send_message_mds(const ref_t& m, mds_rank_t mds) // send mdsmap first? if (mds != whoami && peer_mdsmap_epoch[mds] < mdsmap->get_epoch()) { - auto _m = MMDSMap::create(monc->get_fsid(), *mdsmap); + auto _m = make_message(monc->get_fsid(), *mdsmap); messenger->send_to_mds(_m.detach(), mdsmap->get_addrs(mds)); peer_mdsmap_epoch[mds] = mdsmap->get_epoch(); } @@ -1404,7 +1404,7 @@ void MDSRank::forward_message_mds(const cref_t& m, mds_rank_t md // tell the client where it should go auto session = get_session(m); - auto f = MClientRequestForward::create(m->get_tid(), mds, m->get_num_fwd()+1, client_must_resend); + auto f = make_message(m->get_tid(), mds, m->get_num_fwd()+1, client_must_resend); send_message_client(f, session); } @@ -3445,7 +3445,7 @@ void MDSRank::bcast_mds_map() set clients; sessionmap.get_client_session_set(clients); for (const auto &session : clients) { - auto m = MMDSMap::create(monc->get_fsid(), *mdsmap); + auto m = make_message(monc->get_fsid(), *mdsmap); session->get_connection()->send_message2(std::move(m)); } last_client_mdsmap_bcast = mdsmap->get_epoch(); diff --git a/src/mds/MDSTableClient.cc b/src/mds/MDSTableClient.cc index 7e53db476d3..9794ab53248 100644 --- a/src/mds/MDSTableClient.cc +++ b/src/mds/MDSTableClient.cc @@ -102,7 +102,7 @@ void MDSTableClient::handle_request(const cref_t &m) dout(10) << "stray agree on " << reqid << " tid " << tid << ", sending ROLLBACK" << dendl; ceph_assert(!server_ready); - auto req = MMDSTableRequest::create(table, TABLESERVER_OP_ROLLBACK, 0, tid); + auto req = make_message(table, TABLESERVER_OP_ROLLBACK, 0, tid); mds->send_message_mds(req, mds->get_mds_map()->get_tableserver()); } break; @@ -174,7 +174,7 @@ void MDSTableClient::_prepare(bufferlist& mutation, version_t *ptid, bufferlist if (server_ready) { // send message - auto req = MMDSTableRequest::create(table, TABLESERVER_OP_PREPARE, reqid); + auto req = make_message(table, TABLESERVER_OP_PREPARE, reqid); req->bl = mutation; mds->send_message_mds(req, mds->get_mds_map()->get_tableserver()); } else @@ -198,7 +198,7 @@ void MDSTableClient::commit(version_t tid, LogSegment *ls) if (server_ready) { // send message - auto req = MMDSTableRequest::create(table, TABLESERVER_OP_COMMIT, 0, tid); + auto req = make_message(table, TABLESERVER_OP_COMMIT, 0, tid); mds->send_message_mds(req, mds->get_mds_map()->get_tableserver()); } else dout(10) << "tableserver is not ready yet, deferring request" << dendl; @@ -232,7 +232,7 @@ void MDSTableClient::resend_commits() p != pending_commit.end(); ++p) { dout(10) << "resending commit on " << p->first << dendl; - auto req = MMDSTableRequest::create(table, TABLESERVER_OP_COMMIT, 0, p->first); + auto req = make_message(table, TABLESERVER_OP_COMMIT, 0, p->first); mds->send_message_mds(req, mds->get_mds_map()->get_tableserver()); } } @@ -248,7 +248,7 @@ void MDSTableClient::resend_prepares() p != pending_prepare.end(); ++p) { dout(10) << "resending prepare on " << p->first << dendl; - auto req = MMDSTableRequest::create(table, TABLESERVER_OP_PREPARE, p->first); + auto req = make_message(table, TABLESERVER_OP_PREPARE, p->first); req->bl = p->second.mutation; mds->send_message_mds(req, mds->get_mds_map()->get_tableserver()); } diff --git a/src/mds/MDSTableServer.cc b/src/mds/MDSTableServer.cc index 04677c9b957..3666e0db9e4 100644 --- a/src/mds/MDSTableServer.cc +++ b/src/mds/MDSTableServer.cc @@ -80,7 +80,7 @@ void MDSTableServer::_prepare_logged(const cref_t &req, versio _prepare(req->bl, req->reqid, from, out); ceph_assert(version == tid); - auto reply = MMDSTableRequest::create(table, TABLESERVER_OP_AGREE, req->reqid, tid); + auto reply = make_message(table, TABLESERVER_OP_AGREE, req->reqid, tid); reply->bl = std::move(out); if (_notify_prep(tid)) { @@ -153,7 +153,7 @@ void MDSTableServer::handle_commit(const cref_t &req) else if (tid <= version) { dout(0) << "got commit for tid " << tid << " <= " << version << ", already committed, sending ack." << dendl; - auto reply = MMDSTableRequest::create(table, TABLESERVER_OP_ACK, req->reqid, tid); + auto reply = make_message(table, TABLESERVER_OP_ACK, req->reqid, tid); mds->send_message(reply, req->get_connection()); } else { @@ -176,7 +176,7 @@ void MDSTableServer::_commit_logged(const cref_t &req) _commit(tid, req); _note_commit(tid); - auto reply = MMDSTableRequest::create(table, TABLESERVER_OP_ACK, req->reqid, req->get_tid()); + auto reply = make_message(table, TABLESERVER_OP_ACK, req->reqid, req->get_tid()); mds->send_message_mds(reply, mds_rank_t(req->get_source().num())); } @@ -281,13 +281,13 @@ void MDSTableServer::_do_server_recovery() next_reqids[who] = p.second.reqid + 1; version_t tid = p.second.tid; - auto reply = MMDSTableRequest::create(table, TABLESERVER_OP_AGREE, p.second.reqid, tid); + auto reply = make_message(table, TABLESERVER_OP_AGREE, p.second.reqid, tid); _get_reply_buffer(tid, &reply->bl); mds->send_message_mds(reply, who); } for (auto p : active_clients) { - auto reply = MMDSTableRequest::create(table, TABLESERVER_OP_SERVER_READY, next_reqids[p]); + auto reply = make_message(table, TABLESERVER_OP_SERVER_READY, next_reqids[p]); mds->send_message_mds(reply, p); } recovered = true; @@ -331,12 +331,12 @@ void MDSTableServer::handle_mds_recovery(mds_rank_t who) if (p->second.reqid >= next_reqid) next_reqid = p->second.reqid + 1; - auto reply = MMDSTableRequest::create(table, TABLESERVER_OP_AGREE, p->second.reqid, p->second.tid); + auto reply = make_message(table, TABLESERVER_OP_AGREE, p->second.reqid, p->second.tid); _get_reply_buffer(p->second.tid, &reply->bl); mds->send_message_mds(reply, who); } - auto reply = MMDSTableRequest::create(table, TABLESERVER_OP_SERVER_READY, next_reqid); + auto reply = make_message(table, TABLESERVER_OP_SERVER_READY, next_reqid); mds->send_message_mds(reply, who); } diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index b1868b53f15..b5579dcb15d 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -275,7 +275,9 @@ void Migrator::export_try_cancel(CDir *dir, bool notify_peer) if (notify_peer && (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(it->second.peer))) // tell them. - mds->send_message_mds(MExportDirCancel::create(dir->dirfrag(), it->second.tid), it->second.peer); + mds->send_message_mds(make_message(dir->dirfrag(), + it->second.tid), + it->second.peer); break; case EXPORT_FREEZING: @@ -287,7 +289,9 @@ void Migrator::export_try_cancel(CDir *dir, bool notify_peer) if (notify_peer && (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(it->second.peer))) // tell them. - mds->send_message_mds(MExportDirCancel::create(dir->dirfrag(), it->second.tid), it->second.peer); + mds->send_message_mds(make_message(dir->dirfrag(), + it->second.tid), + it->second.peer); break; // NOTE: state order reversal, warning comes after prepping @@ -325,7 +329,9 @@ void Migrator::export_try_cancel(CDir *dir, bool notify_peer) if (notify_peer && (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(it->second.peer))) // tell them. - mds->send_message_mds(MExportDirCancel::create(dir->dirfrag(), it->second.tid), it->second.peer); + mds->send_message_mds(make_message(dir->dirfrag(), + it->second.tid), + it->second.peer); break; case EXPORT_EXPORTING: @@ -1097,8 +1103,9 @@ void Migrator::dispatch_export_dir(MDRequestRef& mdr, int count) // send ExportDirDiscover (ask target) filepath path; dir->inode->make_path(path); - auto discover = MExportDirDiscover::create(dir->dirfrag(), path, - mds->get_nodeid(), it->second.tid); + auto discover = make_message(dir->dirfrag(), path, + mds->get_nodeid(), + it->second.tid); mds->send_message_mds(discover, dest); ceph_assert(g_conf()->mds_kill_export_at != 2); @@ -1289,7 +1296,7 @@ void Migrator::export_frozen(CDir *dir, uint64_t tid) cache->get_subtree_bounds(dir, bounds); // generate prep message, log entry. - auto prep = MExportDirPrep::create(dir->dirfrag(), it->second.tid); + auto prep = make_message(dir->dirfrag(), it->second.tid); // include list of bystanders for (const auto &p : dir->get_replicas()) { @@ -1476,7 +1483,7 @@ void Migrator::handle_export_prep_ack(const cref_t &m) it->second.warning_ack_waiting.insert(p.first); it->second.notify_ack_waiting.insert(p.first); // we'll eventually get a notifyack, too! - auto notify = MExportDirNotify::create(dir->dirfrag(), it->second.tid, true, + auto notify = make_message(dir->dirfrag(), it->second.tid, true, mds_authority_t(mds->get_nodeid(),CDIR_AUTH_UNKNOWN), mds_authority_t(mds->get_nodeid(),it->second.peer)); for (auto &cdir : bounds) { @@ -1548,7 +1555,7 @@ void Migrator::export_go_synced(CDir *dir, uint64_t tid) mds->balancer->subtract_export(dir); // fill export message with cache data - auto req = MExportDir::create(dir->dirfrag(), it->second.tid); + auto req = make_message(dir->dirfrag(), it->second.tid); map exported_client_map; map exported_client_metadata_map; uint64_t num_exported_inodes = encode_export_dir(req->export_data, @@ -1643,9 +1650,9 @@ void Migrator::finish_export_inode_caps(CInode *in, mds_rank_t peer, const Capability *cap = &p.second; dout(7) << "finish_export_inode_caps telling client." << p.first << " exported caps on " << *in << dendl; - auto m = MClientCaps::create(CEPH_CAP_OP_EXPORT, in->ino(), 0, - cap->get_cap_id(), cap->get_mseq(), mds->get_osd_epoch_barrier()); - + auto m = make_message(CEPH_CAP_OP_EXPORT, in->ino(), 0, + cap->get_cap_id(), cap->get_mseq(), + mds->get_osd_epoch_barrier()); map::iterator q = peer_imported.find(p.first); ceph_assert(q != peer_imported.end()); m->set_cap_peer(q->second.cap_id, q->second.issue_seq, q->second.mseq, @@ -1920,7 +1927,7 @@ void Migrator::export_notify_abort(CDir *dir, export_state_t& stat, set& for (set::iterator p = stat.notify_ack_waiting.begin(); p != stat.notify_ack_waiting.end(); ++p) { - auto notify = MExportDirNotify::create(dir->dirfrag(), stat.tid, true, + auto notify = make_message(dir->dirfrag(), stat.tid, true, pair(mds->get_nodeid(), stat.peer), pair(mds->get_nodeid(), CDIR_AUTH_UNKNOWN)); for (set::iterator i = bounds.begin(); i != bounds.end(); ++i) @@ -2025,7 +2032,7 @@ void Migrator::export_logged_finish(CDir *dir) for (set::iterator p = stat.notify_ack_waiting.begin(); p != stat.notify_ack_waiting.end(); ++p) { - auto notify = MExportDirNotify::create(dir->dirfrag(), stat.tid, true, + auto notify = make_message(dir->dirfrag(), stat.tid, true, pair(mds->get_nodeid(), stat.peer), pair(stat.peer, CDIR_AUTH_UNKNOWN)); @@ -2046,7 +2053,7 @@ void Migrator::export_logged_finish(CDir *dir) // notify peer to send cap import messages to clients if (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(stat.peer)) { - mds->send_message_mds(MExportDirFinish::create(dir->dirfrag(), false, stat.tid), stat.peer); + mds->send_message_mds(make_message(dir->dirfrag(), false, stat.tid), stat.peer); } else { dout(7) << "not sending MExportDirFinish, dest has failed" << dendl; } @@ -2128,7 +2135,7 @@ void Migrator::export_finish(CDir *dir) // send finish/commit to new auth if (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(it->second.peer)) { - mds->send_message_mds(MExportDirFinish::create(dir->dirfrag(), true, it->second.tid), it->second.peer); + mds->send_message_mds(make_message(dir->dirfrag(), true, it->second.tid), it->second.peer); } else { dout(7) << "not sending MExportDirFinish last, dest has failed" << dendl; } @@ -2245,7 +2252,7 @@ void Migrator::handle_export_discover(const cref_t &m, bool if (!mds->is_active()) { dout(7) << " not active, send NACK " << dendl; - mds->send_message_mds(MExportDirDiscoverAck::create(df, m->get_tid(), false), from); + mds->send_message_mds(make_message(df, m->get_tid(), false), from); return; } @@ -2307,7 +2314,7 @@ void Migrator::handle_export_discover(const cref_t &m, bool // reply dout(7) << " sending export_discover_ack on " << *in << dendl; - mds->send_message_mds(MExportDirDiscoverAck::create(df, m->get_tid()), p_state->peer); + mds->send_message_mds(make_message(df, m->get_tid()), p_state->peer); assert (g_conf()->mds_kill_import_at != 2); } @@ -2582,7 +2589,7 @@ void Migrator::handle_export_prep(const cref_t &m, bool did_assi // ok! dout(7) << " sending export_prep_ack on " << *dir << dendl; - mds->send_message(MExportDirPrepAck::create(dir->dirfrag(), success, m->get_tid()), m->get_connection()); + mds->send_message(make_message(dir->dirfrag(), success, m->get_tid()), m->get_connection()); ceph_assert(g_conf()->mds_kill_import_at != 4); } @@ -2883,7 +2890,7 @@ void Migrator::import_notify_finish(CDir *dir, set& bounds) for (set::iterator p = stat.bystanders.begin(); p != stat.bystanders.end(); ++p) { - auto notify = MExportDirNotify::create(dir->dirfrag(), stat.tid, false, + auto notify = make_message(dir->dirfrag(), stat.tid, false, pair(stat.peer, mds->get_nodeid()), pair(mds->get_nodeid(), CDIR_AUTH_UNKNOWN)); for (set::iterator i = bounds.begin(); i != bounds.end(); ++i) @@ -2905,7 +2912,7 @@ void Migrator::import_notify_abort(CDir *dir, set& bounds) stat.bystanders.erase(p++); continue; } - auto notify = MExportDirNotify::create(dir->dirfrag(), stat.tid, true, + auto notify = make_message(dir->dirfrag(), stat.tid, true, mds_authority_t(stat.peer, mds->get_nodeid()), mds_authority_t(stat.peer, CDIR_AUTH_UNKNOWN)); for (set::iterator i = bounds.begin(); i != bounds.end(); ++i) @@ -2996,7 +3003,7 @@ void Migrator::import_logged_start(dirfrag_t df, CDir *dir, mds_rank_t from, // test surviving observer of a failed migration that did not complete //assert(dir->replica_map.size() < 2 || mds->get_nodeid() != 0); - auto ack = MExportDirAck::create(dir->dirfrag(), it->second.tid); + auto ack = make_message(dir->dirfrag(), it->second.tid); encode(imported_caps, ack->imported_caps); mds->send_message_mds(ack, from); @@ -3426,7 +3433,7 @@ void Migrator::handle_export_notify(const cref_t &m) // send ack if (m->wants_ack()) { - mds->send_message_mds(MExportDirNotifyAck::create(m->get_dirfrag(), m->get_tid(), m->get_new_auth()), from); + mds->send_message_mds(make_message(m->get_dirfrag(), m->get_tid(), m->get_new_auth()), from); } else { // aborted. no ack. dout(7) << "handle_export_notify no ack requested" << dendl; @@ -3444,7 +3451,7 @@ void Migrator::export_caps(CInode *in) ceph_assert(!in->is_ambiguous_auth()); ceph_assert(!in->state_test(CInode::STATE_EXPORTINGCAPS)); - auto ex = MExportCaps::create(); + auto ex = make_message(); ex->ino = in->ino(); encode_export_inode_caps(in, false, ex->cap_bl, ex->client_map, ex->client_metadata_map); @@ -3475,7 +3482,7 @@ void Migrator::handle_export_caps_ack(const cref_t &ack) dout(7) << __func__ << " telling client." << it.first << " exported caps on " << *in << dendl; - auto m = MClientCaps::create(CEPH_CAP_OP_EXPORT, in->ino(), 0, + auto m = make_message(CEPH_CAP_OP_EXPORT, in->ino(), 0, cap->get_cap_id(), cap->get_mseq(), mds->get_osd_epoch_barrier()); m->set_cap_peer(it.second.cap_id, it.second.issue_seq, it.second.mseq, from, 0); @@ -3575,7 +3582,7 @@ void Migrator::logged_import_caps(CInode *in, mds->locker->eval(in, CEPH_CAP_LOCKS, true); if (!imported_caps.empty()) { - auto ack = MExportCapsAck::create(in->ino()); + auto ack = make_message(in->ino()); map peer_caps_ids; for (auto &p : imported_caps ) peer_caps_ids[p.first] = it->second.at(p.first).cap_id; diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 112a48bf898..15f62cadde3 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -332,7 +332,7 @@ void Server::reclaim_session(Session *session, const cref_t &m) return; } - auto reply = MClientReclaimReply::create(0); + auto reply = make_message(0); if (m->get_uuid().empty()) { dout(10) << __func__ << " invalid message (no uuid)" << dendl; reply->set_result(-EINVAL); @@ -507,7 +507,7 @@ void Server::handle_client_session(const cref_t &m) }; auto send_reject_message = [this, &session, &log_session_status](std::string_view err_str) { - auto m = MClientSession::create(CEPH_SESSION_REJECT); + auto m = make_message(CEPH_SESSION_REJECT); if (session->info.has_feature(CEPHFS_FEATURE_MIMIC)) m->metadata["error_string"] = err_str; mds->send_message_client(m, session); @@ -607,7 +607,7 @@ void Server::handle_client_session(const cref_t &m) mds->locker->resume_stale_caps(session); mds->sessionmap.touch_session(session); } - auto reply = MClientSession::create(CEPH_SESSION_RENEWCAPS, m->get_seq()); + auto reply = make_message(CEPH_SESSION_RENEWCAPS, m->get_seq()); mds->send_message_client(reply, session); } else { dout(10) << "ignoring renewcaps on non open|stale session (" << session->get_state_name() << ")" << dendl; @@ -672,7 +672,7 @@ void Server::flush_session(Session *session, MDSGatherBuilder *gather) { version_t seq = session->wait_for_flush(gather->new_sub()); mds->send_message_client( - MClientSession::create(CEPH_SESSION_FLUSHMSG, seq), session); + make_message(CEPH_SESSION_FLUSHMSG, seq), session); } void Server::flush_client_sessions(set& client_set, MDSGatherBuilder& gather) @@ -717,12 +717,12 @@ void Server::_session_logged(Session *session, uint64_t state_seq, bool open, ve mds->sessionmap.set_state(session, Session::STATE_OPEN); mds->sessionmap.touch_session(session); ceph_assert(session->get_connection()); - auto reply = MClientSession::create(CEPH_SESSION_OPEN); + auto reply = make_message(CEPH_SESSION_OPEN); if (session->info.has_feature(CEPHFS_FEATURE_MIMIC)) reply->supported_features = supported_features; mds->send_message_client(reply, session); if (mdcache->is_readonly()) { - auto m = MClientSession::create(CEPH_SESSION_FORCE_RO); + auto m = make_message(CEPH_SESSION_FORCE_RO); mds->send_message_client(m, session); } } else if (session->is_closing() || @@ -769,7 +769,7 @@ void Server::_session_logged(Session *session, uint64_t state_seq, bool open, ve } // reset session - mds->send_message_client(MClientSession::create(CEPH_SESSION_CLOSE), session); + mds->send_message_client(make_message(CEPH_SESSION_CLOSE), session); mds->sessionmap.set_state(session, Session::STATE_CLOSED); session->clear(); mds->sessionmap.remove_session(session); @@ -866,13 +866,13 @@ void Server::finish_force_open_sessions(const mapsessionmap.set_state(session, Session::STATE_OPEN); mds->sessionmap.touch_session(session); - auto reply = MClientSession::create(CEPH_SESSION_OPEN); + auto reply = make_message(CEPH_SESSION_OPEN); if (session->info.has_feature(CEPHFS_FEATURE_MIMIC)) reply->supported_features = supported_features; mds->send_message_client(reply, session); if (mdcache->is_readonly()) - mds->send_message_client(MClientSession::create(CEPH_SESSION_FORCE_RO), session); + mds->send_message_client(make_message(CEPH_SESSION_FORCE_RO), session); } } else { dout(10) << "force_open_sessions skipping already-open " << session->info.inst << dendl; @@ -985,7 +985,7 @@ void Server::find_idle_sessions() mds->sessionmap.set_state(session, Session::STATE_STALE); mds->locker->revoke_stale_caps(session); mds->locker->remove_stale_leases(session); - mds->send_message_client(MClientSession::create(CEPH_SESSION_STALE, session->get_push_seq()), session); + mds->send_message_client(make_message(CEPH_SESSION_STALE, session->get_push_seq()), session); finish_flush_session(session, session->get_push_seq()); } } @@ -1248,7 +1248,7 @@ void Server::handle_client_reconnect(const cref_t &m) } if (deny) { - auto r = MClientSession::create(CEPH_SESSION_CLOSE); + auto r = make_message(CEPH_SESSION_CLOSE); mds->send_message_client(r, session); if (session->is_open()) kill_session(session, nullptr); @@ -1257,7 +1257,7 @@ void Server::handle_client_reconnect(const cref_t &m) if (!m->has_more()) { // notify client of success with an OPEN - auto reply = MClientSession::create(CEPH_SESSION_OPEN); + auto reply = make_message(CEPH_SESSION_OPEN); if (session->info.has_feature(CEPHFS_FEATURE_MIMIC)) reply->supported_features = supported_features; mds->send_message_client(reply, session); @@ -1636,7 +1636,7 @@ std::pair Server::recall_client_state(MDSGatherBuilder* gather, dout(7) << " recalling " << recall << " caps; session_recall_throttle = " << session_recall_throttle << "; global_recall_throttle = " << global_recall_throttle << dendl; - auto m = MClientSession::create(CEPH_SESSION_RECALL_STATE); + auto m = make_message(CEPH_SESSION_RECALL_STATE); m->head.max_caps = newlim; mds->send_message_client(m, session); if (gather) { @@ -1664,7 +1664,7 @@ void Server::force_clients_readonly() if (!session->info.inst.name.is_client() || !(session->is_open() || session->is_stale())) continue; - mds->send_message_client(MClientSession::create(CEPH_SESSION_FORCE_RO), session); + mds->send_message_client(make_message(CEPH_SESSION_FORCE_RO), session); } } @@ -1719,7 +1719,7 @@ void Server::submit_mdlog_entry(LogEvent *le, MDSLogContextBase *fin, MDRequestR void Server::respond_to_request(MDRequestRef& mdr, int r) { if (mdr->client_request) { - reply_client_request(mdr, MClientReply::create(*mdr->client_request, r)); + reply_client_request(mdr, make_message(*mdr->client_request, r)); } else if (mdr->internal_op > -1) { dout(10) << "respond_to_request on internal request " << mdr << dendl; if (!mdr->internal_op_finish) @@ -1854,7 +1854,7 @@ void Server::early_reply(MDRequestRef& mdr, CInode *tracei, CDentry *tracedn) } - auto reply = MClientReply::create(*req, 0); + auto reply = make_message(*req, 0); reply->set_unsafe(); // mark xlocks "done", indicating that we are exposing uncommitted changes. @@ -2146,7 +2146,7 @@ void Server::handle_client_request(const cref_t &req) req->get_op() != CEPH_MDS_OP_OPEN && req->get_op() != CEPH_MDS_OP_CREATE)) { dout(5) << "already completed " << req->get_reqid() << dendl; - auto reply = MClientReply::create(*req, 0); + auto reply = make_message(*req, 0); if (created != inodeno_t()) { bufferlist extra; encode(created, extra); @@ -2415,7 +2415,7 @@ void Server::handle_slave_request(const cref_t &m) // the purpose of rename notify is enforcing causal message ordering. making sure // bystanders have received all messages from rename srcdn's auth MDS. if (m->get_op() == MMDSSlaveRequest::OP_RENAMENOTIFY) { - auto reply = MMDSSlaveRequest::create(m->get_reqid(), m->get_attempt(), MMDSSlaveRequest::OP_RENAMENOTIFYACK); + auto reply = make_message(m->get_reqid(), m->get_attempt(), MMDSSlaveRequest::OP_RENAMENOTIFYACK); mds->send_message(reply, m->get_connection()); return; } @@ -2645,7 +2645,7 @@ void Server::dispatch_slave_request(MDRequestRef& mdr) return; // ack - auto r = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, replycode); + auto r = make_message(mdr->reqid, mdr->attempt, replycode); r->set_lock_type(lock->get_type()); lock->get_parent()->set_object_info(r->get_object_info()); if (replycode == MMDSSlaveRequest::OP_XLOCKACK) @@ -2808,7 +2808,7 @@ void Server::handle_slave_auth_pin(MDRequestRef& mdr) } // ack! - auto reply = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_AUTHPINACK); + auto reply = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_AUTHPINACK); // return list of my auth_pins (if any) for (const auto &p : mdr->auth_pins) { @@ -5126,7 +5126,7 @@ void Server::create_quota_realm(CInode *in) { dout(10) << __func__ << " " << *in << dendl; - auto req = MClientRequest::create(CEPH_MDS_OP_SETXATTR); + auto req = make_message(CEPH_MDS_OP_SETXATTR); req->set_filepath(filepath(in->ino())); req->set_string2("ceph.quota"); // empty vxattr value @@ -6091,7 +6091,7 @@ void Server::_link_remote(MDRequestRef& mdr, bool inc, CDentry *dn, CInode *targ op = MMDSSlaveRequest::OP_LINKPREP; else op = MMDSSlaveRequest::OP_UNLINKPREP; - auto req = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, op); + auto req = make_message(mdr->reqid, mdr->attempt, op); targeti->set_object_info(req->get_object_info()); req->op_stamp = mdr->get_op_stamp(); if (auto& desti_srnode = mdr->more()->desti_srnode) @@ -6338,7 +6338,7 @@ void Server::_logged_slave_link(MDRequestRef& mdr, CInode *targeti, bool adjust_ // ack if (!mdr->aborted) { - auto reply = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_LINKPREPACK); + auto reply = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_LINKPREPACK); mds->send_message_mds(reply, mdr->slave_to_mds); } else { dout(10) << " abort flag set, finishing" << dendl; @@ -6383,7 +6383,7 @@ void Server::_committed_slave(MDRequestRef& mdr) ceph_assert(g_conf()->mds_kill_link_at != 8); - auto req = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_COMMITTED); + auto req = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_COMMITTED); mds->send_message_mds(req, mdr->slave_to_mds); mdcache->request_finish(mdr); } @@ -6899,7 +6899,7 @@ bool Server::_rmdir_prepare_witness(MDRequestRef& mdr, mds_rank_t who, vectorreqid, mdr->attempt, MMDSSlaveRequest::OP_RMDIRPREP); + auto req = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RMDIRPREP); req->srcdnpath = filepath(trace.front()->get_dir()->ino()); for (auto dn : trace) req->srcdnpath.push_dentry(dn->get_name()); @@ -7048,7 +7048,7 @@ void Server::_logged_slave_rmdir(MDRequestRef& mdr, CDentry *dn, CDentry *strayd mdr->straydn = 0; if (!mdr->aborted) { - auto reply = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RMDIRPREPACK); + auto reply = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RMDIRPREPACK); if (!mdr->more()->slave_update_journaled) reply->mark_not_journaled(); mds->send_message_mds(reply, mdr->slave_to_mds); @@ -7818,7 +7818,7 @@ bool Server::_rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, setreqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREP); + auto req = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREP); req->srcdnpath = filepath(srctrace.front()->get_dir()->ino()); for (auto dn : srctrace) @@ -8488,7 +8488,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr) if (mdr->slave_request->is_interrupted()) { dout(10) << " slave request interrupted, sending noop reply" << dendl; - auto reply = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREPACK); + auto reply = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREPACK); reply->mark_interrupted(); mds->send_message_mds(reply, mdr->slave_to_mds); mdr->reset_slave_request(); @@ -8592,7 +8592,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr) (mds->is_cluster_degraded() && !mds->mdsmap->is_clientreplay_or_active_or_stopping(*p))) continue; - auto notify = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMENOTIFY); + auto notify = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMENOTIFY); mds->send_message_mds(notify, *p); mdr->more()->waiting_on_slave.insert(*p); } @@ -8621,7 +8621,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr) if (reply_witness) { ceph_assert(!srcdnrep.empty()); - auto reply = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREPACK); + auto reply = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREPACK); reply->witnesses.swap(srcdnrep); mds->send_message_mds(reply, mdr->slave_to_mds); mdr->reset_slave_request(); @@ -8724,7 +8724,7 @@ void Server::_logged_slave_rename(MDRequestRef& mdr, // prepare ack ref_t reply; if (!mdr->aborted) { - reply = MMDSSlaveRequest::create(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREPACK); + reply = make_message(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREPACK); if (!mdr->more()->slave_update_journaled) reply->mark_not_journaled(); } diff --git a/src/mds/SnapClient.cc b/src/mds/SnapClient.cc index 99784d5f111..7ddf1e7c8af 100644 --- a/src/mds/SnapClient.cc +++ b/src/mds/SnapClient.cc @@ -115,7 +115,7 @@ void SnapClient::handle_notify_prep(const cref_t &m) { dout(10) << __func__ << " " << *m << dendl; handle_query_result(m); - auto ack = MMDSTableRequest::create(table, TABLESERVER_OP_NOTIFY_ACK, 0, m->get_tid()); + auto ack = make_message(table, TABLESERVER_OP_NOTIFY_ACK, 0, m->get_tid()); mds->send_message(ack, m->get_connection()); } @@ -153,7 +153,7 @@ void SnapClient::refresh(version_t want, MDSContext *onfinish) return; mds_rank_t ts = mds->mdsmap->get_tableserver(); - auto req = MMDSTableRequest::create(table, TABLESERVER_OP_QUERY, ++last_reqid, 0); + auto req = make_message(table, TABLESERVER_OP_QUERY, ++last_reqid, 0); using ceph::encode; char op = 'F'; encode(op, req->bl); diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc index 51e0cbaf2f4..8b0f2b7b709 100644 --- a/src/mds/SnapServer.cc +++ b/src/mds/SnapServer.cc @@ -266,7 +266,7 @@ bool SnapServer::_notify_prep(version_t tid) ceph_assert(version == tid); for (auto &p : active_clients) { - auto m = MMDSTableRequest::create(table, TABLESERVER_OP_NOTIFY_PREP, 0, version); + auto m = make_message(table, TABLESERVER_OP_NOTIFY_PREP, 0, version); m->bl = bl; mds->send_message_mds(m, p); } @@ -281,7 +281,7 @@ void SnapServer::handle_query(const cref_t &req) auto p = req->bl.cbegin(); decode(op, p); - auto reply = MMDSTableRequest::create(table, TABLESERVER_OP_QUERY_REPLY, req->reqid, version); + auto reply = make_message(table, TABLESERVER_OP_QUERY_REPLY, req->reqid, version); switch (op) { case 'F': // full @@ -353,7 +353,7 @@ void SnapServer::check_osd_map(bool force) if (!all_purge.empty()) { dout(10) << "requesting removal of " << all_purge << dendl; - auto m = MRemoveSnaps::create(all_purge); + auto m = make_message(all_purge); mon_client->send_mon_message(m.detach()); } diff --git a/src/mds/StrayManager.cc b/src/mds/StrayManager.cc index 444e4ccc1cc..efc4fe35273 100644 --- a/src/mds/StrayManager.cc +++ b/src/mds/StrayManager.cc @@ -659,7 +659,7 @@ void StrayManager::reintegrate_stray(CDentry *straydn, CDentry *rdn) filepath dst; rdn->make_path(dst); - auto req = MClientRequest::create(CEPH_MDS_OP_RENAME); + auto req = make_message(CEPH_MDS_OP_RENAME); req->set_filepath(dst); req->set_filepath2(src); req->set_tid(mds->issue_tid()); @@ -688,7 +688,7 @@ void StrayManager::migrate_stray(CDentry *dn, mds_rank_t to) dst.push_dentry(src[0]); dst.push_dentry(src[1]); - auto req = MClientRequest::create(CEPH_MDS_OP_RENAME); + auto req = make_message(CEPH_MDS_OP_RENAME); req->set_filepath(dst); req->set_filepath2(src); req->set_tid(mds->issue_tid()); diff --git a/src/messages/MAuth.h b/src/messages/MAuth.h index 8fd28ff029e..c7067859c25 100644 --- a/src/messages/MAuth.h +++ b/src/messages/MAuth.h @@ -23,17 +23,15 @@ #include "msg/MessageRef.h" #include "messages/PaxosServiceMessage.h" -class MAuth : public MessageInstance { +class MAuth : public PaxosServiceMessage { public: - friend factory; - __u32 protocol; ceph::buffer::list auth_payload; epoch_t monmap_epoch; /* if protocol == 0, then auth_payload is a set<__u32> listing protocols the client supports */ - MAuth() : MessageInstance(CEPH_MSG_AUTH, 0), protocol(0), monmap_epoch(0) { } + MAuth() : PaxosServiceMessage{CEPH_MSG_AUTH, 0}, protocol(0), monmap_epoch(0) { } private: ~MAuth() override {} diff --git a/src/messages/MAuthReply.h b/src/messages/MAuthReply.h index ec47ff2001c..f50fab59ddb 100644 --- a/src/messages/MAuthReply.h +++ b/src/messages/MAuthReply.h @@ -18,19 +18,17 @@ #include "msg/Message.h" #include "common/errno.h" -class MAuthReply : public MessageInstance { +class MAuthReply : public Message { public: - friend factory; - __u32 protocol; errorcode32_t result; uint64_t global_id; // if zero, meaningless std::string result_msg; ceph::buffer::list result_bl; - MAuthReply() : MessageInstance(CEPH_MSG_AUTH_REPLY), protocol(0), result(0), global_id(0) {} + MAuthReply() : Message(CEPH_MSG_AUTH_REPLY), protocol(0), result(0), global_id(0) {} MAuthReply(__u32 p, ceph::buffer::list *bl = NULL, int r = 0, uint64_t gid=0, const char *msg = "") : - MessageInstance(CEPH_MSG_AUTH_REPLY), + Message(CEPH_MSG_AUTH_REPLY), protocol(p), result(r), global_id(gid), result_msg(msg) { if (bl) diff --git a/src/messages/MBackfillReserve.h b/src/messages/MBackfillReserve.h index ab571c49f6d..9f9d38bce02 100644 --- a/src/messages/MBackfillReserve.h +++ b/src/messages/MBackfillReserve.h @@ -18,9 +18,7 @@ #include "msg/Message.h" #include "messages/MOSDPeeringOp.h" -class MBackfillReserve : public MessageInstance { -public: - friend factory; +class MBackfillReserve : public MOSDPeeringOp { private: static constexpr int HEAD_VERSION = 5; static constexpr int COMPAT_VERSION = 4; @@ -94,7 +92,7 @@ public: } MBackfillReserve() - : MessageInstance(MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION), + : MOSDPeeringOp{MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION}, query_epoch(0), type(-1), priority(-1), primary_num_bytes(0), shard_num_bytes(0) {} MBackfillReserve(int type, @@ -102,7 +100,7 @@ public: epoch_t query_epoch, unsigned prio = -1, int64_t primary_num_bytes = 0, int64_t shard_num_bytes = 0) - : MessageInstance(MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION), + : MOSDPeeringOp{MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION}, pgid(pgid), query_epoch(query_epoch), type(type), priority(prio), primary_num_bytes(primary_num_bytes), shard_num_bytes(shard_num_bytes) {} diff --git a/src/messages/MCacheExpire.h b/src/messages/MCacheExpire.h index d54bcaf5c1b..dede4f3fefe 100644 --- a/src/messages/MCacheExpire.h +++ b/src/messages/MCacheExpire.h @@ -21,9 +21,7 @@ #include "mds/mdstypes.h" -class MCacheExpire : public MessageInstance { -public: - friend factory; +class MCacheExpire : public Message { private: __s32 from; @@ -68,9 +66,9 @@ public: int get_from() const { return from; } protected: - MCacheExpire() : MessageInstance(MSG_MDS_CACHEEXPIRE), from(-1) {} + MCacheExpire() : Message{MSG_MDS_CACHEEXPIRE}, from(-1) {} MCacheExpire(int f) : - MessageInstance(MSG_MDS_CACHEEXPIRE), + Message{MSG_MDS_CACHEEXPIRE}, from(f) { } ~MCacheExpire() override {} @@ -106,6 +104,9 @@ public: encode(from, payload); encode(realms, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; WRITE_CLASS_ENCODER(MCacheExpire::realm) diff --git a/src/messages/MClientCapRelease.h b/src/messages/MClientCapRelease.h index 403169bdc5a..a5427bb74ce 100644 --- a/src/messages/MClientCapRelease.h +++ b/src/messages/MClientCapRelease.h @@ -18,10 +18,7 @@ #include "msg/Message.h" -class MClientCapRelease : public MessageInstance { -public: - friend factory; - +class MClientCapRelease : public Message { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -35,7 +32,7 @@ private: epoch_t osd_epoch_barrier; MClientCapRelease() : - MessageInstance(CEPH_MSG_CLIENT_CAPRELEASE, HEAD_VERSION, COMPAT_VERSION), + Message{CEPH_MSG_CLIENT_CAPRELEASE, HEAD_VERSION, COMPAT_VERSION}, osd_epoch_barrier(0) { memset(&head, 0, sizeof(head)); diff --git a/src/messages/MClientCaps.h b/src/messages/MClientCaps.h index fa069f18894..292eeeb1845 100644 --- a/src/messages/MClientCaps.h +++ b/src/messages/MClientCaps.h @@ -19,9 +19,7 @@ #include "mds/mdstypes.h" #include "include/ceph_features.h" -class MClientCaps : public MessageInstance { -public: - friend factory; +class MClientCaps : public Message { private: static constexpr int HEAD_VERSION = 11; @@ -131,7 +129,7 @@ private: protected: MClientCaps() - : MessageInstance(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION) {} + : Message{CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION} {} MClientCaps(int op, inodeno_t ino, inodeno_t realm, @@ -142,7 +140,7 @@ protected: int dirty, int mseq, epoch_t oeb) - : MessageInstance(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION), + : Message{CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION}, osd_epoch_barrier(oeb) { memset(&head, 0, sizeof(head)); head.op = op; @@ -159,7 +157,7 @@ protected: MClientCaps(int op, inodeno_t ino, inodeno_t realm, uint64_t id, int mseq, epoch_t oeb) - : MessageInstance(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION), + : Message{CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION}, osd_epoch_barrier(oeb) { memset(&head, 0, sizeof(head)); head.op = op; @@ -331,6 +329,9 @@ public: encode(nfiles, payload); encode(nsubdirs, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MClientLease.h b/src/messages/MClientLease.h index 5c2bf84bb57..f75cd26915b 100644 --- a/src/messages/MClientLease.h +++ b/src/messages/MClientLease.h @@ -20,10 +20,8 @@ #include "msg/Message.h" -class MClientLease : public MessageInstance { +class MClientLease : public Message { public: - friend factory; - struct ceph_mds_lease h; std::string dname; @@ -35,13 +33,13 @@ public: snapid_t get_last() const { return snapid_t(h.last); } protected: - MClientLease() : MessageInstance(CEPH_MSG_CLIENT_LEASE) {} + MClientLease() : Message(CEPH_MSG_CLIENT_LEASE) {} MClientLease(const MClientLease& m) : - MessageInstance(CEPH_MSG_CLIENT_LEASE), + Message(CEPH_MSG_CLIENT_LEASE), h(m.h), dname(m.dname) {} MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl) : - MessageInstance(CEPH_MSG_CLIENT_LEASE) { + Message(CEPH_MSG_CLIENT_LEASE) { h.action = ac; h.seq = seq; h.mask = m; @@ -51,7 +49,7 @@ protected: h.duration_ms = 0; } MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl, std::string_view d) : - MessageInstance(CEPH_MSG_CLIENT_LEASE), + Message(CEPH_MSG_CLIENT_LEASE), dname(d) { h.action = ac; h.seq = seq; @@ -88,6 +86,9 @@ public: encode(dname, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MClientQuota.h b/src/messages/MClientQuota.h index b1aed00bf60..0042f37fbff 100644 --- a/src/messages/MClientQuota.h +++ b/src/messages/MClientQuota.h @@ -3,17 +3,15 @@ #include "msg/Message.h" -class MClientQuota : public MessageInstance { +class MClientQuota : public Message { public: - friend factory; - inodeno_t ino; nest_info_t rstat; quota_info_t quota; protected: MClientQuota() : - MessageInstance(CEPH_MSG_CLIENT_QUOTA), + Message{CEPH_MSG_CLIENT_QUOTA}, ino(0) {} ~MClientQuota() override {} @@ -47,6 +45,9 @@ public: decode(quota, p); ceph_assert(p.end()); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MClientReclaim.h b/src/messages/MClientReclaim.h index ffb7609c31b..e98fee8e960 100644 --- a/src/messages/MClientReclaim.h +++ b/src/messages/MClientReclaim.h @@ -18,7 +18,7 @@ #include "msg/Message.h" -class MClientReclaim: public MessageInstance { +class MClientReclaim: public Message { public: static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -48,17 +48,19 @@ public: } protected: - friend factory; MClientReclaim() : - MessageInstance(CEPH_MSG_CLIENT_RECLAIM, HEAD_VERSION, COMPAT_VERSION) {} + Message{CEPH_MSG_CLIENT_RECLAIM, HEAD_VERSION, COMPAT_VERSION} {} MClientReclaim(std::string_view _uuid, uint32_t _flags) : - MessageInstance(CEPH_MSG_CLIENT_RECLAIM, HEAD_VERSION, COMPAT_VERSION), + Message{CEPH_MSG_CLIENT_RECLAIM, HEAD_VERSION, COMPAT_VERSION}, uuid(_uuid), flags(_flags) {} private: ~MClientReclaim() override {} std::string uuid; uint32_t flags = 0; + + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MClientReclaimReply.h b/src/messages/MClientReclaimReply.h index 288b88686fb..ef0b17de9e8 100644 --- a/src/messages/MClientReclaimReply.h +++ b/src/messages/MClientReclaimReply.h @@ -18,7 +18,7 @@ #include "msg/Message.h" -class MClientReclaimReply: public MessageInstance { +class MClientReclaimReply: public Message { public: static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -51,11 +51,11 @@ public: } protected: - friend factory; MClientReclaimReply() : - MessageInstance(CEPH_MSG_CLIENT_RECLAIM_REPLY, HEAD_VERSION, COMPAT_VERSION) {} + MClientReclaimReply{0, 0} + {} MClientReclaimReply(int r, epoch_t e=0) : - MessageInstance(CEPH_MSG_CLIENT_RECLAIM_REPLY, HEAD_VERSION, COMPAT_VERSION), + Message{CEPH_MSG_CLIENT_RECLAIM_REPLY, HEAD_VERSION, COMPAT_VERSION}, result(r), epoch(e) {} private: @@ -64,6 +64,9 @@ private: int32_t result; epoch_t epoch; entity_addrvec_t addrs; + + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MClientReconnect.h b/src/messages/MClientReconnect.h index ba3b0fb2cda..d631a697b57 100644 --- a/src/messages/MClientReconnect.h +++ b/src/messages/MClientReconnect.h @@ -20,9 +20,7 @@ #include "include/ceph_features.h" -class MClientReconnect : public MessageInstance { -public: - friend factory; +class MClientReconnect : public Message { private: static constexpr int HEAD_VERSION = 5; static constexpr int COMPAT_VERSION = 4; @@ -32,9 +30,9 @@ public: vector realms; bool more = false; - MClientReconnect() : - MessageInstance(CEPH_MSG_CLIENT_RECONNECT, HEAD_VERSION, COMPAT_VERSION) {} private: + MClientReconnect() : + Message{CEPH_MSG_CLIENT_RECONNECT, HEAD_VERSION, COMPAT_VERSION} {} ~MClientReconnect() override {} size_t cap_size = 0; @@ -168,6 +166,9 @@ public: } } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MClientReply.h b/src/messages/MClientReply.h index 4b10128154c..7754bae0723 100644 --- a/src/messages/MClientReply.h +++ b/src/messages/MClientReply.h @@ -260,10 +260,8 @@ struct InodeStat { }; -class MClientReply : public MessageInstance { +class MClientReply : public Message { public: - friend factory; - // reply data struct ceph_mds_reply_head head {}; bufferlist trace_bl; @@ -286,9 +284,9 @@ public: bool is_safe() const { return head.safe; } protected: - MClientReply() : MessageInstance(CEPH_MSG_CLIENT_REPLY) {} + MClientReply() : Message{CEPH_MSG_CLIENT_REPLY} {} MClientReply(const MClientRequest &req, int result = 0) : - MessageInstance(CEPH_MSG_CLIENT_REPLY) { + Message{CEPH_MSG_CLIENT_REPLY} { memset(&head, 0, sizeof(head)); header.tid = req.get_tid(); head.op = req.get_op(); @@ -353,6 +351,9 @@ public: const bufferlist& get_trace_bl() const { return trace_bl; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MClientRequest.h b/src/messages/MClientRequest.h index 602eff1d15b..20118cdd32a 100644 --- a/src/messages/MClientRequest.h +++ b/src/messages/MClientRequest.h @@ -48,9 +48,7 @@ // metadata ops. -class MClientRequest : public MessageInstance { -public: - friend factory; +class MClientRequest : public Message { private: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 1; @@ -91,9 +89,9 @@ public: protected: // cons MClientRequest() - : MessageInstance(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) {} + : Message(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) {} MClientRequest(int op) - : MessageInstance(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) { + : Message(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) { memset(&head, 0, sizeof(head)); head.op = op; } @@ -281,7 +279,9 @@ public: out << '}' << ")"; } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; WRITE_CLASS_ENCODER(MClientRequest::Release) diff --git a/src/messages/MClientRequestForward.h b/src/messages/MClientRequestForward.h index e3dc8071767..b92c49329e7 100644 --- a/src/messages/MClientRequestForward.h +++ b/src/messages/MClientRequestForward.h @@ -18,9 +18,7 @@ #include "msg/Message.h" -class MClientRequestForward : public MessageInstance { -public: - friend factory; +class MClientRequestForward : public Message { private: int32_t dest_mds; int32_t num_fwd; @@ -28,10 +26,10 @@ private: protected: MClientRequestForward() - : MessageInstance(CEPH_MSG_CLIENT_REQUEST_FORWARD), + : Message{CEPH_MSG_CLIENT_REQUEST_FORWARD}, dest_mds(-1), num_fwd(-1), client_must_resend(false) {} MClientRequestForward(ceph_tid_t t, int dm, int nf, bool cmr) : - MessageInstance(CEPH_MSG_CLIENT_REQUEST_FORWARD), + Message{CEPH_MSG_CLIENT_REQUEST_FORWARD}, dest_mds(dm), num_fwd(nf), client_must_resend(cmr) { ceph_assert(client_must_resend); header.tid = t; @@ -65,6 +63,9 @@ public: decode(num_fwd, p); decode(client_must_resend, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MClientSession.h b/src/messages/MClientSession.h index c7a2a3b503d..f1d4191726c 100644 --- a/src/messages/MClientSession.h +++ b/src/messages/MClientSession.h @@ -18,9 +18,7 @@ #include "msg/Message.h" #include "mds/mdstypes.h" -class MClientSession : public MessageInstance { -public: - friend factory; +class MClientSession : public Message { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 1; @@ -38,15 +36,15 @@ public: int get_max_leases() const { return head.max_leases; } protected: - MClientSession() : MessageInstance(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) { } + MClientSession() : Message{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION} { } MClientSession(int o, version_t s=0) : - MessageInstance(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) { + Message{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION} { memset(&head, 0, sizeof(head)); head.op = o; head.seq = s; } MClientSession(int o, utime_t st) : - MessageInstance(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) { + Message{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION} { memset(&head, 0, sizeof(head)); head.op = o; head.seq = 0; @@ -87,6 +85,9 @@ public: encode(supported_features, payload); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MClientSnap.h b/src/messages/MClientSnap.h index f0f96e4eb12..59f872fc1a3 100644 --- a/src/messages/MClientSnap.h +++ b/src/messages/MClientSnap.h @@ -17,10 +17,8 @@ #include "msg/Message.h" -class MClientSnap : public MessageInstance { +class MClientSnap : public Message { public: - friend factory; - ceph_mds_snap_head head; bufferlist bl; @@ -30,7 +28,7 @@ public: protected: MClientSnap(int o=0) : - MessageInstance(CEPH_MSG_CLIENT_SNAP) { + Message{CEPH_MSG_CLIENT_SNAP} { memset(&head, 0, sizeof(head)); head.op = o; } @@ -64,7 +62,9 @@ public: decode_nohead(head.trace_len, bl, p); ceph_assert(p.end()); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MCommand.h b/src/messages/MCommand.h index ce8fde106ed..fb421049a51 100644 --- a/src/messages/MCommand.h +++ b/src/messages/MCommand.h @@ -19,17 +19,15 @@ #include "msg/Message.h" -class MCommand : public MessageInstance { +class MCommand : public Message { public: - friend factory; - uuid_d fsid; std::vector cmd; MCommand() - : MessageInstance(MSG_COMMAND) {} + : Message{MSG_COMMAND} {} MCommand(const uuid_d &f) - : MessageInstance(MSG_COMMAND), + : Message{MSG_COMMAND}, fsid(f) { } private: diff --git a/src/messages/MCommandReply.h b/src/messages/MCommandReply.h index 09a6017d195..64594bb0664 100644 --- a/src/messages/MCommandReply.h +++ b/src/messages/MCommandReply.h @@ -20,21 +20,19 @@ #include "msg/Message.h" #include "MCommand.h" -class MCommandReply : public MessageInstance { +class MCommandReply : public Message { public: - friend factory; - errorcode32_t r; std::string rs; MCommandReply() - : MessageInstance(MSG_COMMAND_REPLY) {} + : Message{MSG_COMMAND_REPLY} {} MCommandReply(MCommand *m, int _r) - : MessageInstance(MSG_COMMAND_REPLY), r(_r) { + : Message{MSG_COMMAND_REPLY}, r(_r) { header.tid = m->get_tid(); } MCommandReply(int _r, std::string_view s) - : MessageInstance(MSG_COMMAND_REPLY), + : Message{MSG_COMMAND_REPLY}, r(_r), rs(s) { } private: ~MCommandReply() override {} diff --git a/src/messages/MConfig.h b/src/messages/MConfig.h index 6ea8d85e493..c97c706406d 100644 --- a/src/messages/MConfig.h +++ b/src/messages/MConfig.h @@ -5,22 +5,20 @@ #include "msg/Message.h" -class MConfig : public MessageInstance { +class MConfig : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; // use transparent comparator so we can lookup in it by std::string_view keys std::map> config; - MConfig() : MessageInstance(MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION) { } + MConfig() : Message{MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION} { } MConfig(const std::map>& c) - : MessageInstance(MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION}, config{c} {} MConfig(std::map>&& c) - : MessageInstance(MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION}, config{std::move(c)} {} std::string_view get_type_name() const override { diff --git a/src/messages/MDentryLink.h b/src/messages/MDentryLink.h index 75dea9baf45..293fe0d4c5c 100644 --- a/src/messages/MDentryLink.h +++ b/src/messages/MDentryLink.h @@ -20,9 +20,7 @@ #include "msg/Message.h" -class MDentryLink : public MessageInstance { -public: - friend factory; +class MDentryLink : public Message { private: dirfrag_t subtree; dirfrag_t dirfrag; @@ -39,9 +37,9 @@ private: protected: MDentryLink() : - MessageInstance(MSG_MDS_DENTRYLINK) { } + Message{MSG_MDS_DENTRYLINK} { } MDentryLink(dirfrag_t r, dirfrag_t df, std::string_view n, bool p) : - MessageInstance(MSG_MDS_DENTRYLINK), + Message{MSG_MDS_DENTRYLINK}, subtree(r), dirfrag(df), dn(n), @@ -70,6 +68,9 @@ public: encode(is_primary, payload); encode(bl, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MDentryUnlink.h b/src/messages/MDentryUnlink.h index 1d3d9715dc3..eed4ac47dba 100644 --- a/src/messages/MDentryUnlink.h +++ b/src/messages/MDentryUnlink.h @@ -20,11 +20,8 @@ #include "msg/Message.h" -class MDentryUnlink : public MessageInstance { -public: - friend factory; +class MDentryUnlink : public Message { private: - dirfrag_t dirfrag; string dn; @@ -37,9 +34,9 @@ private: protected: MDentryUnlink() : - MessageInstance(MSG_MDS_DENTRYUNLINK) { } + Message{MSG_MDS_DENTRYUNLINK} { } MDentryUnlink(dirfrag_t df, std::string_view n) : - MessageInstance(MSG_MDS_DENTRYUNLINK), + Message{MSG_MDS_DENTRYUNLINK}, dirfrag(df), dn(n) {} ~MDentryUnlink() override {} @@ -62,6 +59,9 @@ public: encode(dn, payload); encode(straybl, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MDirUpdate.h b/src/messages/MDirUpdate.h index c1154ac78d6..729e76b79b4 100644 --- a/src/messages/MDirUpdate.h +++ b/src/messages/MDirUpdate.h @@ -18,10 +18,8 @@ #include "msg/Message.h" -class MDirUpdate : public MessageInstance { +class MDirUpdate : public Message { public: - friend factory; - mds_rank_t get_source_mds() const { return from_mds; } dirfrag_t get_dirfrag() const { return dirfrag; } int get_dir_rep() const { return dir_rep; } @@ -59,19 +57,19 @@ public: protected: ~MDirUpdate() {} - MDirUpdate() : MessageInstance(MSG_MDS_DIRUPDATE) {} + MDirUpdate() : Message{MSG_MDS_DIRUPDATE} {} MDirUpdate(mds_rank_t f, dirfrag_t dirfrag, int dir_rep, const std::set& dir_rep_by, filepath& path, bool discover = false) : - MessageInstance(MSG_MDS_DIRUPDATE), from_mds(f), dirfrag(dirfrag), + Message{MSG_MDS_DIRUPDATE}, from_mds(f), dirfrag(dirfrag), dir_rep(dir_rep), dir_rep_by(dir_rep_by), path(path) { this->discover = discover ? 5 : 0; } MDirUpdate(const MDirUpdate& m) - : MessageInstance(MSG_MDS_DIRUPDATE), + : Message{MSG_MDS_DIRUPDATE}, from_mds(m.from_mds), dirfrag(m.dirfrag), dir_rep(m.dir_rep), @@ -88,6 +86,10 @@ protected: std::set dir_rep_by; filepath path; mutable int tried_discover = 0; // XXX HACK + +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MDiscover.h b/src/messages/MDiscover.h index f4418e615fc..3b0ac20214a 100644 --- a/src/messages/MDiscover.h +++ b/src/messages/MDiscover.h @@ -22,11 +22,8 @@ #include -class MDiscover : public MessageInstance { -public: - friend factory; +class MDiscover : public Message { private: - inodeno_t base_ino; // 1 -> root frag_t base_dir_frag; @@ -50,14 +47,14 @@ private: void set_base_dir_frag(frag_t f) { base_dir_frag = f; } protected: - MDiscover() : MessageInstance(MSG_MDS_DISCOVER) { } + MDiscover() : Message{MSG_MDS_DISCOVER} { } MDiscover(inodeno_t base_ino_, frag_t base_frag_, snapid_t s, filepath& want_path_, bool want_base_dir_ = true, bool discover_xlocks_ = false) : - MessageInstance(MSG_MDS_DISCOVER), + Message{MSG_MDS_DISCOVER}, base_ino(base_ino_), base_dir_frag(base_frag_), snapid(s), @@ -91,7 +88,9 @@ public: encode(want_base_dir, payload); encode(want_xlocked, payload); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MDiscoverReply.h b/src/messages/MDiscoverReply.h index bd4f3475442..978f1383e13 100644 --- a/src/messages/MDiscoverReply.h +++ b/src/messages/MDiscoverReply.h @@ -63,9 +63,7 @@ * */ -class MDiscoverReply : public MessageInstance { -public: - friend factory; +class MDiscoverReply : public Message { private: static constexpr int HEAD_VERSION = 2; @@ -111,9 +109,9 @@ private: void set_base_dir_frag(frag_t df) { base_dir_frag = df; } protected: - MDiscoverReply() : MessageInstance(MSG_MDS_DISCOVERREPLY, HEAD_VERSION) { } + MDiscoverReply() : Message{MSG_MDS_DISCOVERREPLY, HEAD_VERSION} { } MDiscoverReply(const MDiscover &dis) : - MessageInstance(MSG_MDS_DISCOVERREPLY, HEAD_VERSION), + Message{MSG_MDS_DISCOVERREPLY, HEAD_VERSION}, base_ino(dis.get_base_ino()), base_dir_frag(dis.get_base_dir_frag()), wanted_base_dir(dis.wants_base_dir()), @@ -128,7 +126,7 @@ protected: header.tid = dis.get_tid(); } MDiscoverReply(dirfrag_t df) : - MessageInstance(MSG_MDS_DISCOVERREPLY, HEAD_VERSION), + Message{MSG_MDS_DISCOVERREPLY, HEAD_VERSION}, base_ino(df.ino), base_dir_frag(df.frag), wanted_base_dir(false), @@ -207,6 +205,9 @@ public: encode(starts_with, payload); encode(trace, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportCaps.h b/src/messages/MExportCaps.h index 93e53b0f666..641d31aa3e9 100644 --- a/src/messages/MExportCaps.h +++ b/src/messages/MExportCaps.h @@ -19,9 +19,7 @@ #include "msg/Message.h" -class MExportCaps : public MessageInstance { -public: - friend factory; +class MExportCaps : public Message { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -33,7 +31,7 @@ public: protected: MExportCaps() : - MessageInstance(MSG_MDS_EXPORTCAPS, HEAD_VERSION, COMPAT_VERSION) {} + Message{MSG_MDS_EXPORTCAPS, HEAD_VERSION, COMPAT_VERSION} {} ~MExportCaps() override {} public: @@ -57,7 +55,9 @@ public: if (header.version >= 2) decode(client_metadata_map, p); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportCapsAck.h b/src/messages/MExportCapsAck.h index d159161eed0..df7e9839f1e 100644 --- a/src/messages/MExportCapsAck.h +++ b/src/messages/MExportCapsAck.h @@ -19,18 +19,16 @@ #include "msg/Message.h" -class MExportCapsAck : public MessageInstance { +class MExportCapsAck : public Message { public: - friend factory; - inodeno_t ino; bufferlist cap_bl; protected: MExportCapsAck() : - MessageInstance(MSG_MDS_EXPORTCAPSACK) {} + Message{MSG_MDS_EXPORTCAPSACK} {} MExportCapsAck(inodeno_t i) : - MessageInstance(MSG_MDS_EXPORTCAPSACK), ino(i) {} + Message{MSG_MDS_EXPORTCAPSACK}, ino(i) {} ~MExportCapsAck() override {} public: @@ -49,6 +47,9 @@ public: decode(ino, p); decode(cap_bl, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDir.h b/src/messages/MExportDir.h index 8f509e03179..3bd98a33873 100644 --- a/src/messages/MExportDir.h +++ b/src/messages/MExportDir.h @@ -19,18 +19,17 @@ #include "msg/Message.h" -class MExportDir : public MessageInstance { +class MExportDir : public Message { public: - friend factory; dirfrag_t dirfrag; bufferlist export_data; vector bounds; bufferlist client_map; protected: - MExportDir() : MessageInstance(MSG_MDS_EXPORTDIR) {} + MExportDir() : Message{MSG_MDS_EXPORTDIR} {} MExportDir(dirfrag_t df, uint64_t tid) : - MessageInstance(MSG_MDS_EXPORTDIR), dirfrag(df) { + Message{MSG_MDS_EXPORTDIR}, dirfrag(df) { set_tid(tid); } ~MExportDir() override {} @@ -59,7 +58,9 @@ public: decode(export_data, p); decode(client_map, p); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirAck.h b/src/messages/MExportDirAck.h index ff8be81637f..d0ffd01b9c9 100644 --- a/src/messages/MExportDirAck.h +++ b/src/messages/MExportDirAck.h @@ -18,19 +18,17 @@ #include "MExportDir.h" #include "msg/Message.h" -class MExportDirAck : public MessageInstance { +class MExportDirAck : public Message { public: - friend factory; - dirfrag_t dirfrag; bufferlist imported_caps; dirfrag_t get_dirfrag() const { return dirfrag; } protected: - MExportDirAck() : MessageInstance(MSG_MDS_EXPORTDIRACK) {} + MExportDirAck() : Message{MSG_MDS_EXPORTDIRACK} {} MExportDirAck(dirfrag_t df, uint64_t tid) : - MessageInstance(MSG_MDS_EXPORTDIRACK), dirfrag(df) { + Message{MSG_MDS_EXPORTDIRACK}, dirfrag(df) { set_tid(tid); } ~MExportDirAck() override {} @@ -51,7 +49,9 @@ public: encode(dirfrag, payload); encode(imported_caps, payload); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirCancel.h b/src/messages/MExportDirCancel.h index 56f2c4d16eb..c66cc1e4a0c 100644 --- a/src/messages/MExportDirCancel.h +++ b/src/messages/MExportDirCancel.h @@ -18,9 +18,7 @@ #include "msg/Message.h" #include "include/types.h" -class MExportDirCancel : public MessageInstance { -public: - friend factory; +class MExportDirCancel : public Message { private: dirfrag_t dirfrag; @@ -28,9 +26,9 @@ private: dirfrag_t get_dirfrag() const { return dirfrag; } protected: - MExportDirCancel() : MessageInstance(MSG_MDS_EXPORTDIRCANCEL) {} + MExportDirCancel() : Message{MSG_MDS_EXPORTDIRCANCEL} {} MExportDirCancel(dirfrag_t df, uint64_t tid) : - MessageInstance(MSG_MDS_EXPORTDIRCANCEL), dirfrag(df) { + Message{MSG_MDS_EXPORTDIRCANCEL}, dirfrag(df) { set_tid(tid); } ~MExportDirCancel() override {} @@ -49,6 +47,9 @@ public: auto p = payload.cbegin(); decode(dirfrag, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirDiscover.h b/src/messages/MExportDirDiscover.h index 74f298bc250..bd03fbb0f4d 100644 --- a/src/messages/MExportDirDiscover.h +++ b/src/messages/MExportDirDiscover.h @@ -18,9 +18,7 @@ #include "msg/Message.h" #include "include/types.h" -class MExportDirDiscover : public MessageInstance { -public: - friend factory; +class MExportDirDiscover : public Message { private: mds_rank_t from = -1; dirfrag_t dirfrag; @@ -36,10 +34,10 @@ private: protected: MExportDirDiscover() : - MessageInstance(MSG_MDS_EXPORTDIRDISCOVER), + Message{MSG_MDS_EXPORTDIRDISCOVER}, started(false) { } MExportDirDiscover(dirfrag_t df, filepath& p, mds_rank_t f, uint64_t tid) : - MessageInstance(MSG_MDS_EXPORTDIRDISCOVER), + Message{MSG_MDS_EXPORTDIRDISCOVER}, from(f), dirfrag(df), path(p), started(false) { set_tid(tid); } @@ -64,6 +62,9 @@ public: encode(dirfrag, payload); encode(path, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirDiscoverAck.h b/src/messages/MExportDirDiscoverAck.h index ba8fda5653c..4b0e5141e85 100644 --- a/src/messages/MExportDirDiscoverAck.h +++ b/src/messages/MExportDirDiscoverAck.h @@ -18,9 +18,7 @@ #include "msg/Message.h" #include "include/types.h" -class MExportDirDiscoverAck : public MessageInstance { -public: - friend factory; +class MExportDirDiscoverAck : public Message { private: dirfrag_t dirfrag; bool success; @@ -31,9 +29,9 @@ private: bool is_success() const { return success; } protected: - MExportDirDiscoverAck() : MessageInstance(MSG_MDS_EXPORTDIRDISCOVERACK) {} + MExportDirDiscoverAck() : Message{MSG_MDS_EXPORTDIRDISCOVERACK} {} MExportDirDiscoverAck(dirfrag_t df, uint64_t tid, bool s=true) : - MessageInstance(MSG_MDS_EXPORTDIRDISCOVERACK), + Message{MSG_MDS_EXPORTDIRDISCOVERACK}, dirfrag(df), success(s) { set_tid(tid); } @@ -59,6 +57,9 @@ public: encode(dirfrag, payload); encode(success, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirFinish.h b/src/messages/MExportDirFinish.h index 6cc35d0935f..9ed4f01064b 100644 --- a/src/messages/MExportDirFinish.h +++ b/src/messages/MExportDirFinish.h @@ -17,9 +17,7 @@ #include "msg/Message.h" -class MExportDirFinish : public MessageInstance { -public: - friend factory; +class MExportDirFinish : public Message { private: dirfrag_t dirfrag; bool last; @@ -31,7 +29,7 @@ private: protected: MExportDirFinish() : last(false) {} MExportDirFinish(dirfrag_t df, bool l, uint64_t tid) : - MessageInstance(MSG_MDS_EXPORTDIRFINISH), dirfrag(df), last(l) { + Message{MSG_MDS_EXPORTDIRFINISH}, dirfrag(df), last(l) { set_tid(tid); } ~MExportDirFinish() override {} @@ -52,7 +50,9 @@ public: decode(dirfrag, p); decode(last, p); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirNotify.h b/src/messages/MExportDirNotify.h index fbb7a30b0c6..03d8fc626eb 100644 --- a/src/messages/MExportDirNotify.h +++ b/src/messages/MExportDirNotify.h @@ -17,9 +17,7 @@ #include "msg/Message.h" -class MExportDirNotify : public MessageInstance { -public: - friend factory; +class MExportDirNotify : public Message { private: dirfrag_t base; bool ack; @@ -37,7 +35,7 @@ private: protected: MExportDirNotify() {} MExportDirNotify(dirfrag_t i, uint64_t tid, bool a, pair<__s32,__s32> oa, pair<__s32,__s32> na) : - MessageInstance(MSG_MDS_EXPORTDIRNOTIFY), + Message{MSG_MDS_EXPORTDIRNOTIFY}, base(i), ack(a), old_auth(oa), new_auth(na) { set_tid(tid); } @@ -79,6 +77,9 @@ public: decode(new_auth, p); decode(bounds, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirNotifyAck.h b/src/messages/MExportDirNotifyAck.h index 05f771675c5..2db26549587 100644 --- a/src/messages/MExportDirNotifyAck.h +++ b/src/messages/MExportDirNotifyAck.h @@ -17,9 +17,7 @@ #include "msg/Message.h" -class MExportDirNotifyAck : public MessageInstance { -public: - friend factory; +class MExportDirNotifyAck : public Message { private: dirfrag_t dirfrag; pair<__s32,__s32> new_auth; @@ -31,7 +29,7 @@ private: protected: MExportDirNotifyAck() {} MExportDirNotifyAck(dirfrag_t df, uint64_t tid, pair<__s32,__s32> na) : - MessageInstance(MSG_MDS_EXPORTDIRNOTIFYACK), dirfrag(df), new_auth(na) { + Message{MSG_MDS_EXPORTDIRNOTIFYACK}, dirfrag(df), new_auth(na) { set_tid(tid); } ~MExportDirNotifyAck() override {} @@ -53,7 +51,9 @@ public: decode(dirfrag, p); decode(new_auth, p); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirPrep.h b/src/messages/MExportDirPrep.h index e10d4f247a4..0061b9510d9 100644 --- a/src/messages/MExportDirPrep.h +++ b/src/messages/MExportDirPrep.h @@ -19,9 +19,7 @@ #include "msg/Message.h" #include "include/types.h" -class MExportDirPrep : public MessageInstance { -public: - friend factory; +class MExportDirPrep : public Message { private: dirfrag_t dirfrag; public: @@ -30,7 +28,7 @@ private: list traces; private: set bystanders; - bool b_did_assim; + bool b_did_assim = false; public: dirfrag_t get_dirfrag() const { return dirfrag; } @@ -41,12 +39,11 @@ public: void mark_assim() { b_did_assim = true; } protected: - MExportDirPrep() { - b_did_assim = false; - } + MExportDirPrep() = default; MExportDirPrep(dirfrag_t df, uint64_t tid) : - MessageInstance(MSG_MDS_EXPORTDIRPREP), - dirfrag(df), b_did_assim(false) { + Message{MSG_MDS_EXPORTDIRPREP}, + dirfrag(df) + { set_tid(tid); } ~MExportDirPrep() override {} @@ -85,6 +82,9 @@ public: encode(traces, payload); encode(bystanders, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MExportDirPrepAck.h b/src/messages/MExportDirPrepAck.h index 11e59a8d6a8..02ada30534b 100644 --- a/src/messages/MExportDirPrepAck.h +++ b/src/messages/MExportDirPrepAck.h @@ -18,9 +18,7 @@ #include "msg/Message.h" #include "include/types.h" -class MExportDirPrepAck : public MessageInstance { -public: - friend factory; +class MExportDirPrepAck : public Message { private: dirfrag_t dirfrag; bool success = false; @@ -31,7 +29,7 @@ private: protected: MExportDirPrepAck() {} MExportDirPrepAck(dirfrag_t df, bool s, uint64_t tid) : - MessageInstance(MSG_MDS_EXPORTDIRPREPACK), dirfrag(df), success(s) { + Message{MSG_MDS_EXPORTDIRPREPACK}, dirfrag(df), success(s) { set_tid(tid); } ~MExportDirPrepAck() override {} @@ -54,6 +52,9 @@ public: encode(dirfrag, payload); encode(success, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MFSMap.h b/src/messages/MFSMap.h index 99f241d53ae..8f77a41f8cb 100644 --- a/src/messages/MFSMap.h +++ b/src/messages/MFSMap.h @@ -20,10 +20,8 @@ #include "mds/FSMap.h" #include "include/ceph_features.h" -class MFSMap : public MessageInstance { +class MFSMap : public Message { public: - friend factory; - epoch_t epoch; bufferlist encoded; @@ -31,12 +29,12 @@ public: const FSMap& get_fsmap() const {return fsmap;} MFSMap() : - MessageInstance(CEPH_MSG_FS_MAP), epoch(0) {} + Message{CEPH_MSG_FS_MAP}, epoch(0) {} MFSMap(const uuid_d &f, const FSMap &fsmap_) : - MessageInstance(CEPH_MSG_FS_MAP), epoch(fsmap_.get_epoch()) - { - fsmap = fsmap_; - } + Message{CEPH_MSG_FS_MAP}, + epoch(fsmap_.get_epoch()), + fsmap{fsmap_} + {} private: FSMap fsmap; diff --git a/src/messages/MFSMapUser.h b/src/messages/MFSMapUser.h index 215b1211642..3b9cc34f832 100644 --- a/src/messages/MFSMapUser.h +++ b/src/messages/MFSMapUser.h @@ -19,22 +19,20 @@ #include "mds/FSMapUser.h" #include "include/ceph_features.h" -class MFSMapUser : public MessageInstance { +class MFSMapUser : public Message { public: - friend factory; - epoch_t epoch; version_t get_epoch() const { return epoch; } const FSMapUser& get_fsmap() const { return fsmap; } MFSMapUser() : - MessageInstance(CEPH_MSG_FS_MAP_USER), epoch(0) {} + Message{CEPH_MSG_FS_MAP_USER}, epoch(0) {} MFSMapUser(const uuid_d &f, const FSMapUser &fsmap_) : - MessageInstance(CEPH_MSG_FS_MAP_USER), epoch(fsmap_.epoch) - { - fsmap = fsmap_; - } + Message{CEPH_MSG_FS_MAP_USER}, + epoch(fsmap_.epoch), + fsmap{fsmap_} + {} private: FSMapUser fsmap; @@ -57,6 +55,9 @@ public: encode(epoch, payload); encode(fsmap, payload, features); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MForward.h b/src/messages/MForward.h index 7f552ca1d06..ac6aeba04f8 100644 --- a/src/messages/MForward.h +++ b/src/messages/MForward.h @@ -24,10 +24,8 @@ #include "include/encoding.h" #include "include/stringify.h" -class MForward : public MessageInstance { +class MForward : public Message { public: - friend factory; - uint64_t tid; uint8_t client_type; entity_addrvec_t client_addrs; @@ -42,11 +40,11 @@ public: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 4; - MForward() : MessageInstance(MSG_FORWARD, HEAD_VERSION, COMPAT_VERSION), + MForward() : Message{MSG_FORWARD, HEAD_VERSION, COMPAT_VERSION}, tid(0), con_features(0), msg(NULL) {} MForward(uint64_t t, PaxosServiceMessage *m, uint64_t feat, const MonCap& caps) : - MessageInstance(MSG_FORWARD, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_FORWARD, HEAD_VERSION, COMPAT_VERSION}, tid(t), client_caps(caps), msg(NULL) { client_type = m->get_source().type(); client_addrs = m->get_source_addrs(); @@ -151,6 +149,9 @@ public: << " tid " << tid << " con_features " << con_features << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MGatherCaps.h b/src/messages/MGatherCaps.h index fe8b4187c55..24dd46b64f8 100644 --- a/src/messages/MGatherCaps.h +++ b/src/messages/MGatherCaps.h @@ -4,16 +4,13 @@ #include "msg/Message.h" -class MGatherCaps : public MessageInstance { +class MGatherCaps : public Message { public: - friend factory; - - inodeno_t ino; protected: MGatherCaps() : - MessageInstance(MSG_MDS_GATHERCAPS) {} + Message{MSG_MDS_GATHERCAPS} {} ~MGatherCaps() override {} public: @@ -31,7 +28,9 @@ public: auto p = payload.cbegin(); decode(ino, p); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MGenericMessage.h b/src/messages/MGenericMessage.h index 49e906d6f0f..32699728ada 100644 --- a/src/messages/MGenericMessage.h +++ b/src/messages/MGenericMessage.h @@ -18,15 +18,13 @@ #include "msg/Message.h" -class MGenericMessage : public MessageInstance { -public: - friend factory; +class MGenericMessage : public Message { private: char tname[20]; //long pcid; public: - MGenericMessage(int t=0) : MessageInstance(t) { + MGenericMessage(int t=0) : Message{t} { snprintf(tname, sizeof(tname), "generic%d", get_type()); } diff --git a/src/messages/MGetConfig.h b/src/messages/MGetConfig.h index aa8429fc74b..2575aa4bce4 100644 --- a/src/messages/MGetConfig.h +++ b/src/messages/MGetConfig.h @@ -5,10 +5,8 @@ #include "msg/Message.h" -class MGetConfig : public MessageInstance { +class MGetConfig : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -16,9 +14,9 @@ public: std::string host; ///< our hostname std::string device_class; - MGetConfig() : MessageInstance(MSG_GET_CONFIG, HEAD_VERSION, COMPAT_VERSION) { } + MGetConfig() : Message{MSG_GET_CONFIG, HEAD_VERSION, COMPAT_VERSION} { } MGetConfig(const EntityName& n, const std::string& h) - : MessageInstance(MSG_GET_CONFIG, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_GET_CONFIG, HEAD_VERSION, COMPAT_VERSION}, name(n), host(h) {} diff --git a/src/messages/MGetPoolStats.h b/src/messages/MGetPoolStats.h index 50e40c788b3..51bc134a21f 100644 --- a/src/messages/MGetPoolStats.h +++ b/src/messages/MGetPoolStats.h @@ -18,16 +18,14 @@ #include "messages/PaxosServiceMessage.h" -class MGetPoolStats : public MessageInstance { +class MGetPoolStats : public PaxosServiceMessage { public: - friend factory; - uuid_d fsid; std::list pools; - MGetPoolStats() : MessageInstance(MSG_GETPOOLSTATS, 0) {} + MGetPoolStats() : PaxosServiceMessage{MSG_GETPOOLSTATS, 0} {} MGetPoolStats(const uuid_d& f, ceph_tid_t t, std::list& ls, version_t l) : - MessageInstance(MSG_GETPOOLSTATS, l), + PaxosServiceMessage{MSG_GETPOOLSTATS, l}, fsid(f), pools(ls) { set_tid(t); } diff --git a/src/messages/MGetPoolStatsReply.h b/src/messages/MGetPoolStatsReply.h index 076f3fde3e7..9a7ccb4cc46 100644 --- a/src/messages/MGetPoolStatsReply.h +++ b/src/messages/MGetPoolStatsReply.h @@ -16,16 +16,14 @@ #ifndef CEPH_MGETPOOLSTATSREPLY_H #define CEPH_MGETPOOLSTATSREPLY_H -class MGetPoolStatsReply : public MessageInstance { +class MGetPoolStatsReply : public PaxosServiceMessage { public: - friend factory; - uuid_d fsid; std::map pool_stats; - MGetPoolStatsReply() : MessageInstance(MSG_GETPOOLSTATSREPLY, 0) {} + MGetPoolStatsReply() : PaxosServiceMessage{MSG_GETPOOLSTATSREPLY, 0} {} MGetPoolStatsReply(uuid_d& f, ceph_tid_t t, version_t v) : - MessageInstance(MSG_GETPOOLSTATSREPLY, v), + PaxosServiceMessage{MSG_GETPOOLSTATSREPLY, v}, fsid(f) { set_tid(t); } @@ -52,6 +50,9 @@ public: decode(fsid, p); decode(pool_stats, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MHeartbeat.h b/src/messages/MHeartbeat.h index 50259619e90..0070fa39ecc 100644 --- a/src/messages/MHeartbeat.h +++ b/src/messages/MHeartbeat.h @@ -20,9 +20,7 @@ #include "msg/Message.h" #include "common/DecayCounter.h" -class MHeartbeat : public MessageInstance { -public: - friend factory; +class MHeartbeat : public Message { private: mds_load_t load; __s32 beat = 0; @@ -36,12 +34,12 @@ private: map& get_import_map() { return import_map; } protected: - MHeartbeat() : MessageInstance(MSG_MDS_HEARTBEAT), load(DecayRate()) {} + MHeartbeat() : Message(MSG_MDS_HEARTBEAT), load(DecayRate()) {} MHeartbeat(mds_load_t& load, int beat) - : MessageInstance(MSG_MDS_HEARTBEAT), - load(load) { - this->beat = beat; - } + : Message(MSG_MDS_HEARTBEAT), + load(load), + beat(beat) + {} ~MHeartbeat() override {} public: @@ -59,7 +57,9 @@ public: decode(beat, p); decode(import_map, p); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MInodeFileCaps.h b/src/messages/MInodeFileCaps.h index 0d32dcd720f..6bd636bf47d 100644 --- a/src/messages/MInodeFileCaps.h +++ b/src/messages/MInodeFileCaps.h @@ -18,9 +18,7 @@ #include "msg/Message.h" -class MInodeFileCaps : public MessageInstance { -public: - friend factory; +class MInodeFileCaps : public Message { private: inodeno_t ino; __u32 caps = 0; @@ -31,9 +29,9 @@ private: int get_caps() const { return caps; } protected: - MInodeFileCaps() : MessageInstance(MSG_MDS_INODEFILECAPS) {} + MInodeFileCaps() : Message{MSG_MDS_INODEFILECAPS} {} MInodeFileCaps(inodeno_t ino, int caps) : - MessageInstance(MSG_MDS_INODEFILECAPS) { + Message{MSG_MDS_INODEFILECAPS} { this->ino = ino; this->caps = caps; } @@ -56,6 +54,9 @@ public: decode(ino, p); decode(caps, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MLock.h b/src/messages/MLock.h index decaabae7be..cfa4b271985 100644 --- a/src/messages/MLock.h +++ b/src/messages/MLock.h @@ -20,9 +20,7 @@ #include "mds/locks.h" #include "mds/SimpleLock.h" -class MLock : public MessageInstance { -public: - friend factory; +class MLock : public Message { private: int32_t action = 0; // action type mds_rank_t asker = 0; // who is initiating this request @@ -45,19 +43,19 @@ public: MDSCacheObjectInfo &get_object_info() { return object_info; } protected: - MLock() : MessageInstance(MSG_MDS_LOCK) {} + MLock() : Message{MSG_MDS_LOCK} {} MLock(int ac, mds_rank_t as) : - MessageInstance(MSG_MDS_LOCK), + Message{MSG_MDS_LOCK}, action(ac), asker(as), lock_type(0) { } MLock(SimpleLock *lock, int ac, mds_rank_t as) : - MessageInstance(MSG_MDS_LOCK), + Message{MSG_MDS_LOCK}, action(ac), asker(as), lock_type(lock->get_type()) { lock->get_parent()->set_object_info(object_info); } MLock(SimpleLock *lock, int ac, mds_rank_t as, bufferlist& bl) : - MessageInstance(MSG_MDS_LOCK), + Message{MSG_MDS_LOCK}, action(ac), asker(as), lock_type(lock->get_type()) { lock->get_parent()->set_object_info(object_info); lockdata.claim(bl); @@ -97,7 +95,9 @@ public: encode(object_info, payload); encode(lockdata, payload); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MLog.h b/src/messages/MLog.h index d2c6e9e9914..0141bf2090b 100644 --- a/src/messages/MLog.h +++ b/src/messages/MLog.h @@ -20,17 +20,15 @@ #include -class MLog : public MessageInstance { +class MLog : public PaxosServiceMessage { public: - friend factory; - uuid_d fsid; std::deque entries; - MLog() : MessageInstance(MSG_LOG, 0) {} + MLog() : PaxosServiceMessage{MSG_LOG, 0} {} MLog(const uuid_d& f, const std::deque& e) - : MessageInstance(MSG_LOG, 0), fsid(f), entries(e) { } - MLog(const uuid_d& f) : MessageInstance(MSG_LOG, 0), fsid(f) { } + : PaxosServiceMessage{MSG_LOG, 0}, fsid(f), entries(e) { } + MLog(const uuid_d& f) : PaxosServiceMessage(MSG_LOG, 0), fsid(f) { } private: ~MLog() override {} diff --git a/src/messages/MLogAck.h b/src/messages/MLogAck.h index ac819e18409..977f909d01e 100644 --- a/src/messages/MLogAck.h +++ b/src/messages/MLogAck.h @@ -23,16 +23,14 @@ #include "msg/Message.h" -class MLogAck : public MessageInstance { +class MLogAck : public Message { public: - friend factory; - uuid_d fsid; version_t last = 0; std::string channel; - MLogAck() : MessageInstance(MSG_LOGACK) {} - MLogAck(uuid_d& f, version_t l) : MessageInstance(MSG_LOGACK), fsid(f), last(l) {} + MLogAck() : Message{MSG_LOGACK} {} + MLogAck(uuid_d& f, version_t l) : Message{MSG_LOGACK}, fsid(f), last(l) {} private: ~MLogAck() override {} @@ -56,6 +54,9 @@ public: if (!p.end()) decode(channel, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSBeacon.h b/src/messages/MMDSBeacon.h index 318109a8697..bfd52cb4b91 100644 --- a/src/messages/MMDSBeacon.h +++ b/src/messages/MMDSBeacon.h @@ -179,9 +179,7 @@ struct MDSHealth WRITE_CLASS_ENCODER(MDSHealth) -class MMDSBeacon : public MessageInstance { -public: - friend factory; +class MMDSBeacon : public PaxosServiceMessage { private: static constexpr int HEAD_VERSION = 7; @@ -203,12 +201,12 @@ private: uint64_t mds_features = 0; protected: - MMDSBeacon() : MessageInstance(MSG_MDS_BEACON, 0, HEAD_VERSION, COMPAT_VERSION) + MMDSBeacon() : PaxosServiceMessage(MSG_MDS_BEACON, 0, HEAD_VERSION, COMPAT_VERSION) { set_priority(CEPH_MSG_PRIO_HIGH); } MMDSBeacon(const uuid_d &f, mds_gid_t g, const string& n, epoch_t les, MDSMap::DaemonState st, version_t se, uint64_t feat) : - MessageInstance(MSG_MDS_BEACON, les, HEAD_VERSION, COMPAT_VERSION), + PaxosServiceMessage(MSG_MDS_BEACON, les, HEAD_VERSION, COMPAT_VERSION), fsid(f), global_id(g), name(n), state(st), seq(se), mds_features(feat) { set_priority(CEPH_MSG_PRIO_HIGH); @@ -296,6 +294,9 @@ public: state = MDSMap::STATE_STANDBY; } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSCacheRejoin.h b/src/messages/MMDSCacheRejoin.h index 985adb52407..61a9ea2622b 100644 --- a/src/messages/MMDSCacheRejoin.h +++ b/src/messages/MMDSCacheRejoin.h @@ -27,11 +27,8 @@ // sent from replica to auth -class MMDSCacheRejoin : public MessageInstance { -public: - friend factory; +class MMDSCacheRejoin : public Message { private: - static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -216,10 +213,10 @@ private: protected: MMDSCacheRejoin() : - MessageInstance(MSG_MDS_CACHEREJOIN, HEAD_VERSION, COMPAT_VERSION), - op(0) {} + MMDSCacheRejoin{0} + {} MMDSCacheRejoin(int o) : - MessageInstance(MSG_MDS_CACHEREJOIN, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_MDS_CACHEREJOIN, HEAD_VERSION, COMPAT_VERSION}, op(o) {} ~MMDSCacheRejoin() override {} @@ -355,7 +352,9 @@ public: if (header.version >= 2) decode(client_metadata_map, p); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; WRITE_CLASS_ENCODER(MMDSCacheRejoin::inode_strong) diff --git a/src/messages/MMDSFindIno.h b/src/messages/MMDSFindIno.h index a6d661b9471..e585d843e76 100644 --- a/src/messages/MMDSFindIno.h +++ b/src/messages/MMDSFindIno.h @@ -18,16 +18,14 @@ #include "msg/Message.h" #include "include/filepath.h" -class MMDSFindIno : public MessageInstance { +class MMDSFindIno : public Message { public: - friend factory; - ceph_tid_t tid {0}; inodeno_t ino; protected: - MMDSFindIno() : MessageInstance(MSG_MDS_FINDINO) {} - MMDSFindIno(ceph_tid_t t, inodeno_t i) : MessageInstance(MSG_MDS_FINDINO), tid(t), ino(i) {} + MMDSFindIno() : Message{MSG_MDS_FINDINO} {} + MMDSFindIno(ceph_tid_t t, inodeno_t i) : Message{MSG_MDS_FINDINO}, tid(t), ino(i) {} ~MMDSFindIno() override {} public: @@ -46,6 +44,9 @@ public: decode(tid, p); decode(ino, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSFindInoReply.h b/src/messages/MMDSFindInoReply.h index 10e003b3d14..f00cd933413 100644 --- a/src/messages/MMDSFindInoReply.h +++ b/src/messages/MMDSFindInoReply.h @@ -18,16 +18,14 @@ #include "msg/Message.h" #include "include/filepath.h" -class MMDSFindInoReply : public MessageInstance { +class MMDSFindInoReply : public Message { public: - friend factory; - ceph_tid_t tid = 0; filepath path; protected: - MMDSFindInoReply() : MessageInstance(MSG_MDS_FINDINOREPLY) {} - MMDSFindInoReply(ceph_tid_t t) : MessageInstance(MSG_MDS_FINDINOREPLY), tid(t) {} + MMDSFindInoReply() : Message{MSG_MDS_FINDINOREPLY} {} + MMDSFindInoReply(ceph_tid_t t) : Message{MSG_MDS_FINDINOREPLY}, tid(t) {} ~MMDSFindInoReply() override {} public: @@ -46,6 +44,9 @@ public: decode(tid, p); decode(path, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSFragmentNotify.h b/src/messages/MMDSFragmentNotify.h index 0baa874f95c..3a12ccb11e3 100644 --- a/src/messages/MMDSFragmentNotify.h +++ b/src/messages/MMDSFragmentNotify.h @@ -17,9 +17,7 @@ #include "msg/Message.h" -class MMDSFragmentNotify : public MessageInstance { -public: - friend factory; +class MMDSFragmentNotify : public Message { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -40,9 +38,9 @@ private: protected: MMDSFragmentNotify() : - MessageInstance(MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION) {} + Message{MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION} {} MMDSFragmentNotify(dirfrag_t df, int b, uint64_t tid) : - MessageInstance(MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION}, base_dirfrag(df), bits(b) { set_tid(tid); } @@ -69,7 +67,9 @@ public: if (header.version >= 2) decode(ack_wanted, p); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSFragmentNotifyAck.h b/src/messages/MMDSFragmentNotifyAck.h index e20a3089ec2..a067dfc36d2 100644 --- a/src/messages/MMDSFragmentNotifyAck.h +++ b/src/messages/MMDSFragmentNotifyAck.h @@ -17,9 +17,7 @@ #include "msg/Message.h" -class MMDSFragmentNotifyAck : public MessageInstance { -public: - friend factory; +class MMDSFragmentNotifyAck : public Message { private: dirfrag_t base_dirfrag; int8_t bits = 0; @@ -31,9 +29,9 @@ private: bufferlist basebl; protected: - MMDSFragmentNotifyAck() : MessageInstance(MSG_MDS_FRAGMENTNOTIFYACK) {} + MMDSFragmentNotifyAck() : Message{MSG_MDS_FRAGMENTNOTIFYACK} {} MMDSFragmentNotifyAck(dirfrag_t df, int b, uint64_t tid) : - MessageInstance(MSG_MDS_FRAGMENTNOTIFYACK), + Message{MSG_MDS_FRAGMENTNOTIFYACK}, base_dirfrag(df), bits(b) { set_tid(tid); } @@ -55,6 +53,9 @@ public: decode(base_dirfrag, p); decode(bits, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSLoadTargets.h b/src/messages/MMDSLoadTargets.h index 98d845de3b8..eb9edf21459 100644 --- a/src/messages/MMDSLoadTargets.h +++ b/src/messages/MMDSLoadTargets.h @@ -23,17 +23,15 @@ #include using std::map; -class MMDSLoadTargets : public MessageInstance { +class MMDSLoadTargets : public PaxosServiceMessage { public: - friend factory; - mds_gid_t global_id; set targets; protected: - MMDSLoadTargets() : MessageInstance(MSG_MDS_OFFLOAD_TARGETS, 0) {} + MMDSLoadTargets() : PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0) {} MMDSLoadTargets(mds_gid_t g, set& mds_targets) : - MessageInstance(MSG_MDS_OFFLOAD_TARGETS, 0), + PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0), global_id(g), targets(mds_targets) {} ~MMDSLoadTargets() override {} @@ -57,6 +55,9 @@ public: encode(global_id, payload); encode(targets, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSMap.h b/src/messages/MMDSMap.h index 726cfac52ef..ed10459ef62 100644 --- a/src/messages/MMDSMap.h +++ b/src/messages/MMDSMap.h @@ -20,9 +20,7 @@ #include "mds/MDSMap.h" #include "include/ceph_features.h" -class MMDSMap : public MessageInstance { -public: - friend factory; +class MMDSMap : public Message { private: static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -36,9 +34,9 @@ public: protected: MMDSMap() : - MessageInstance(CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION) {} + Message{CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION} {} MMDSMap(const uuid_d &f, const MDSMap &mm) : - MessageInstance(CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION), + Message{CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION}, fsid(f) { epoch = mm.get_epoch(); mm.encode(encoded, -1); // we will reencode with fewer features as necessary @@ -74,6 +72,9 @@ public: } encode(encoded, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSOpenIno.h b/src/messages/MMDSOpenIno.h index b9a068bed32..23605225ad2 100644 --- a/src/messages/MMDSOpenIno.h +++ b/src/messages/MMDSOpenIno.h @@ -17,17 +17,15 @@ #include "msg/Message.h" -class MMDSOpenIno : public MessageInstance { +class MMDSOpenIno : public Message { public: - friend factory; - inodeno_t ino; vector ancestors; protected: - MMDSOpenIno() : MessageInstance(MSG_MDS_OPENINO) {} + MMDSOpenIno() : Message{MSG_MDS_OPENINO} {} MMDSOpenIno(ceph_tid_t t, inodeno_t i, vector* pa) : - MessageInstance(MSG_MDS_OPENINO), ino(i) { + Message{MSG_MDS_OPENINO}, ino(i) { header.tid = t; if (pa) ancestors = *pa; @@ -50,6 +48,9 @@ public: decode(ino, p); decode(ancestors, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSOpenInoReply.h b/src/messages/MMDSOpenInoReply.h index 6f87e6a90e5..4cfca9aecb1 100644 --- a/src/messages/MMDSOpenInoReply.h +++ b/src/messages/MMDSOpenInoReply.h @@ -17,19 +17,17 @@ #include "msg/Message.h" -class MMDSOpenInoReply : public MessageInstance { +class MMDSOpenInoReply : public Message { public: - friend factory; - inodeno_t ino; vector ancestors; mds_rank_t hint; int32_t error; protected: - MMDSOpenInoReply() : MessageInstance(MSG_MDS_OPENINOREPLY), error(0) {} + MMDSOpenInoReply() : Message{MSG_MDS_OPENINOREPLY}, error(0) {} MMDSOpenInoReply(ceph_tid_t t, inodeno_t i, mds_rank_t h=MDS_RANK_NONE, int e=0) : - MessageInstance(MSG_MDS_OPENINOREPLY), ino(i), hint(h), error(e) { + Message{MSG_MDS_OPENINOREPLY}, ino(i), hint(h), error(e) { header.tid = t; } @@ -55,6 +53,9 @@ public: decode(hint, p); decode(error, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSResolve.h b/src/messages/MMDSResolve.h index 52fad12e7cd..68b9d4a218d 100644 --- a/src/messages/MMDSResolve.h +++ b/src/messages/MMDSResolve.h @@ -19,10 +19,8 @@ #include "include/types.h" -class MMDSResolve : public MessageInstance { +class MMDSResolve : public Message { public: - friend factory; - map > subtrees; map > ambiguous_imports; @@ -68,7 +66,8 @@ public: list table_clients; protected: - MMDSResolve() : MessageInstance(MSG_MDS_RESOLVE) {} + MMDSResolve() : Message{MSG_MDS_RESOLVE} + {} ~MMDSResolve() override {} public: @@ -118,6 +117,9 @@ public: decode(slave_requests, p); decode(table_clients, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; inline ostream& operator<<(ostream& out, const MMDSResolve::slave_request&) { diff --git a/src/messages/MMDSResolveAck.h b/src/messages/MMDSResolveAck.h index 42698834333..a754b3ca153 100644 --- a/src/messages/MMDSResolveAck.h +++ b/src/messages/MMDSResolveAck.h @@ -20,15 +20,13 @@ #include "include/types.h" -class MMDSResolveAck : public MessageInstance { +class MMDSResolveAck : public Message { public: - friend factory; - map commit; vector abort; protected: - MMDSResolveAck() : MessageInstance(MSG_MDS_RESOLVEACK) {} + MMDSResolveAck() : Message{MSG_MDS_RESOLVEACK} {} ~MMDSResolveAck() override {} public: @@ -58,6 +56,9 @@ public: decode(commit, p); decode(abort, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSSlaveRequest.h b/src/messages/MMDSSlaveRequest.h index f9be3af824f..3bdec7a095c 100644 --- a/src/messages/MMDSSlaveRequest.h +++ b/src/messages/MMDSSlaveRequest.h @@ -19,10 +19,8 @@ #include "msg/Message.h" #include "mds/mdstypes.h" -class MMDSSlaveRequest : public MessageInstance { +class MMDSSlaveRequest : public Message { public: - friend factory; - static constexpr int OP_XLOCK = 1; static constexpr int OP_XLOCKACK = -1; static constexpr int OP_UNXLOCK = 2; @@ -158,9 +156,9 @@ public: bufferlist& get_lock_data() { return inode_export; } protected: - MMDSSlaveRequest() : MessageInstance(MSG_MDS_SLAVE_REQUEST) { } + MMDSSlaveRequest() : Message{MSG_MDS_SLAVE_REQUEST} { } MMDSSlaveRequest(metareqid_t ri, __u32 att, int o) : - MessageInstance(MSG_MDS_SLAVE_REQUEST), + Message{MSG_MDS_SLAVE_REQUEST}, reqid(ri), attempt(att), op(o), flags(0), lock_type(0), inode_export_v(0), srcdn_auth(MDS_RANK_NONE) { } ~MMDSSlaveRequest() override {} @@ -214,7 +212,9 @@ public: << " " << get_opname(op) << ")"; } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSSnapUpdate.h b/src/messages/MMDSSnapUpdate.h index 06872cdc153..d63f1a55cc1 100644 --- a/src/messages/MMDSSnapUpdate.h +++ b/src/messages/MMDSSnapUpdate.h @@ -17,11 +17,8 @@ #include "msg/Message.h" -class MMDSSnapUpdate : public MessageInstance { -public: - friend factory; +class MMDSSnapUpdate : public Message { private: - inodeno_t ino; __s16 snap_op; @@ -32,9 +29,9 @@ public: bufferlist snap_blob; protected: - MMDSSnapUpdate() : MessageInstance(MSG_MDS_SNAPUPDATE) {} + MMDSSnapUpdate() : Message{MSG_MDS_SNAPUPDATE} {} MMDSSnapUpdate(inodeno_t i, version_t tid, int op) : - MessageInstance(MSG_MDS_SNAPUPDATE), ino(i), snap_op(op) { + Message{MSG_MDS_SNAPUPDATE}, ino(i), snap_op(op) { set_tid(tid); } ~MMDSSnapUpdate() override {} @@ -58,6 +55,9 @@ public: decode(snap_op, p); decode(snap_blob, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMDSTableRequest.h b/src/messages/MMDSTableRequest.h index 4a6e2ca97e4..0d929f7961a 100644 --- a/src/messages/MMDSTableRequest.h +++ b/src/messages/MMDSTableRequest.h @@ -19,19 +19,17 @@ #include "msg/Message.h" #include "mds/mds_table_types.h" -class MMDSTableRequest : public MessageInstance { +class MMDSTableRequest : public Message { public: - friend factory; - __u16 table = 0; __s16 op = 0; uint64_t reqid = 0; bufferlist bl; protected: - MMDSTableRequest() : MessageInstance(MSG_MDS_TABLE_REQUEST) {} + MMDSTableRequest() : Message{MSG_MDS_TABLE_REQUEST} {} MMDSTableRequest(int tab, int o, uint64_t r, version_t v=0) : - MessageInstance(MSG_MDS_TABLE_REQUEST), + Message{MSG_MDS_TABLE_REQUEST}, table(tab), op(o), reqid(r) { set_tid(v); } @@ -63,6 +61,9 @@ public: encode(reqid, payload); encode(bl, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMgrBeacon.h b/src/messages/MMgrBeacon.h index f3bb8384c1d..bf93b54ab0e 100644 --- a/src/messages/MMgrBeacon.h +++ b/src/messages/MMgrBeacon.h @@ -22,11 +22,8 @@ #include "include/types.h" -class MMgrBeacon : public MessageInstance { -public: - friend factory; +class MMgrBeacon : public PaxosServiceMessage { private: - static constexpr int HEAD_VERSION = 8; static constexpr int COMPAT_VERSION = 8; @@ -50,16 +47,15 @@ protected: public: MMgrBeacon() - : MessageInstance(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION}, gid(0), available(false) - { - } + {} MMgrBeacon(const uuid_d& fsid_, uint64_t gid_, const std::string &name_, entity_addrvec_t server_addrs_, bool available_, std::vector&& modules_, map&& metadata_) - : MessageInstance(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION}, gid(gid_), server_addrs(server_addrs_), available(available_), name(name_), fsid(fsid_), modules(std::move(modules_)), metadata(std::move(metadata_)) { @@ -179,6 +175,9 @@ public: decode(modules, p); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MMgrClose.h b/src/messages/MMgrClose.h index 47943d08f75..680ce273c13 100644 --- a/src/messages/MMgrClose.h +++ b/src/messages/MMgrClose.h @@ -5,9 +5,7 @@ #include "msg/Message.h" -class MMgrClose : public MessageInstance { -public: - friend factory; +class MMgrClose : public Message { private: static constexpr int HEAD_VERSION = 1; @@ -44,6 +42,10 @@ public: } MMgrClose() - : MessageInstance(MSG_MGR_CLOSE, HEAD_VERSION, COMPAT_VERSION) + : Message{MSG_MGR_CLOSE, HEAD_VERSION, COMPAT_VERSION} {} + +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MMgrConfigure.h b/src/messages/MMgrConfigure.h index 9e9f1af5908..55f8869954f 100644 --- a/src/messages/MMgrConfigure.h +++ b/src/messages/MMgrConfigure.h @@ -22,11 +22,8 @@ * This message is sent from ceph-mgr to MgrClient, instructing it * it about what data to send back to ceph-mgr at what frequency. */ -class MMgrConfigure : public MessageInstance { -public: - friend factory; +class MMgrConfigure : public Message { private: - static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 1; @@ -64,9 +61,12 @@ public: << ", threshold=" << stats_threshold << ")"; } +private: MMgrConfigure() - : MessageInstance(MSG_MGR_CONFIGURE, HEAD_VERSION, COMPAT_VERSION) + : Message{MSG_MGR_CONFIGURE, HEAD_VERSION, COMPAT_VERSION} {} + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMgrDigest.h b/src/messages/MMgrDigest.h index ec4800d4ab6..b92a8c291e4 100644 --- a/src/messages/MMgrDigest.h +++ b/src/messages/MMgrDigest.h @@ -22,16 +22,11 @@ * The mgr digest is a way for the mgr to subscribe to things * other than the cluster maps, which are needed by */ -class MMgrDigest : public MessageInstance { +class MMgrDigest : public Message { public: - friend factory; - bufferlist mon_status_json; bufferlist health_json; - MMgrDigest() : - MessageInstance(MSG_MGR_DIGEST) {} - std::string_view get_type_name() const override { return "mgrdigest"; } void print(ostream& out) const override { out << get_type_name(); @@ -49,8 +44,12 @@ public: } private: + MMgrDigest() : + Message{MSG_MGR_DIGEST} {} ~MMgrDigest() override {} + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMgrMap.h b/src/messages/MMgrMap.h index a0b63a7d46c..46c52ca9deb 100644 --- a/src/messages/MMgrMap.h +++ b/src/messages/MMgrMap.h @@ -19,24 +19,19 @@ #include "msg/Message.h" #include "mon/MgrMap.h" -class MMgrMap : public MessageInstance { -public: - friend factory; - +class MMgrMap : public Message { protected: MgrMap map; public: const MgrMap & get_map() {return map;} +private: MMgrMap() : - MessageInstance(MSG_MGR_MAP) {} + Message{MSG_MGR_MAP} {} MMgrMap(const MgrMap &map_) : - MessageInstance(MSG_MGR_MAP), map(map_) - { - } - -private: + Message{MSG_MGR_MAP}, map(map_) + {} ~MMgrMap() override {} public: @@ -53,6 +48,9 @@ public: using ceph::encode; encode(map, payload, features); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMgrOpen.h b/src/messages/MMgrOpen.h index 5d5983abe80..a55ebaa7661 100644 --- a/src/messages/MMgrOpen.h +++ b/src/messages/MMgrOpen.h @@ -17,11 +17,8 @@ #include "msg/Message.h" -class MMgrOpen : public MessageInstance { -public: - friend factory; +class MMgrOpen : public Message { private: - static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 1; @@ -87,9 +84,12 @@ public: out << ")"; } +private: MMgrOpen() - : MessageInstance(MSG_MGR_OPEN, HEAD_VERSION, COMPAT_VERSION) + : Message{MSG_MGR_OPEN, HEAD_VERSION, COMPAT_VERSION} {} + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMgrReport.h b/src/messages/MMgrReport.h index b203c449ed2..3de4720a9a9 100644 --- a/src/messages/MMgrReport.h +++ b/src/messages/MMgrReport.h @@ -71,11 +71,8 @@ public: }; WRITE_CLASS_ENCODER(PerfCounterType) -class MMgrReport : public MessageInstance { -public: - friend factory; +class MMgrReport : public Message { private: - static constexpr int HEAD_VERSION = 7; static constexpr int COMPAT_VERSION = 1; @@ -168,8 +165,11 @@ public: } MMgrReport() - : MessageInstance(MSG_MGR_REPORT, HEAD_VERSION, COMPAT_VERSION) + : Message{MSG_MGR_REPORT, HEAD_VERSION, COMPAT_VERSION} {} +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonCommand.h b/src/messages/MMonCommand.h index e652f24a32f..8b4c1af9e43 100644 --- a/src/messages/MMonCommand.h +++ b/src/messages/MMonCommand.h @@ -20,16 +20,14 @@ #include #include -class MMonCommand : public MessageInstance { +class MMonCommand : public PaxosServiceMessage { public: - friend factory; - uuid_d fsid; std::vector cmd; - MMonCommand() : MessageInstance(MSG_MON_COMMAND, 0) {} + MMonCommand() : PaxosServiceMessage{MSG_MON_COMMAND, 0} {} MMonCommand(const uuid_d &f) - : MessageInstance(MSG_MON_COMMAND, 0), + : PaxosServiceMessage{MSG_MON_COMMAND, 0}, fsid(f) { } @@ -60,6 +58,9 @@ public: decode(fsid, p); decode(cmd, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonCommandAck.h b/src/messages/MMonCommandAck.h index 9ea4035583e..0eea4d26cb7 100644 --- a/src/messages/MMonCommandAck.h +++ b/src/messages/MMonCommandAck.h @@ -17,17 +17,15 @@ #include "messages/PaxosServiceMessage.h" -class MMonCommandAck : public MessageInstance { +class MMonCommandAck : public PaxosServiceMessage { public: - friend factory; - std::vector cmd; errorcode32_t r; std::string rs; - MMonCommandAck() : MessageInstance(MSG_MON_COMMAND_ACK, 0) {} + MMonCommandAck() : PaxosServiceMessage{MSG_MON_COMMAND_ACK, 0} {} MMonCommandAck(std::vector& c, int _r, std::string s, version_t v) : - MessageInstance(MSG_MON_COMMAND_ACK, v), + PaxosServiceMessage{MSG_MON_COMMAND_ACK, v}, cmd(c), r(_r), rs(s) { } private: ~MMonCommandAck() override {} @@ -53,6 +51,9 @@ public: decode(rs, p); decode(cmd, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonElection.h b/src/messages/MMonElection.h index 0114ea12e77..869b2360fb4 100644 --- a/src/messages/MMonElection.h +++ b/src/messages/MMonElection.h @@ -20,10 +20,7 @@ #include "mon/MonMap.h" #include "mon/mon_types.h" -class MMonElection : public MessageInstance { -public: - friend factory; - +class MMonElection : public Message { private: static constexpr int HEAD_VERSION = 8; static constexpr int COMPAT_VERSION = 5; @@ -54,14 +51,14 @@ public: bufferlist sharing_bl; map metadata; - MMonElection() : MessageInstance(MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION), + MMonElection() : Message{MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION}, op(0), epoch(0), quorum_features(0), mon_features(0) { } MMonElection(int o, epoch_t e, MonMap *m) - : MessageInstance(MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION}, fsid(m->fsid), op(o), epoch(e), quorum_features(0), mon_features(0) @@ -126,7 +123,9 @@ public: else mon_release = infer_ceph_release_from_mon_features(mon_features); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonGetMap.h b/src/messages/MMonGetMap.h index 99950ef4aa4..5b81d1dc92e 100644 --- a/src/messages/MMonGetMap.h +++ b/src/messages/MMonGetMap.h @@ -19,11 +19,9 @@ #include "include/types.h" -class MMonGetMap : public MessageInstance { +class MMonGetMap : public Message { public: - friend factory; - - MMonGetMap() : MessageInstance(CEPH_MSG_MON_GET_MAP) { } + MMonGetMap() : Message{CEPH_MSG_MON_GET_MAP} { } private: ~MMonGetMap() override {} @@ -32,6 +30,10 @@ public: void encode_payload(uint64_t features) override { } void decode_payload() override { } + +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonGetOSDMap.h b/src/messages/MMonGetOSDMap.h index c842c619ad5..a9c8cbfa3ca 100644 --- a/src/messages/MMonGetOSDMap.h +++ b/src/messages/MMonGetOSDMap.h @@ -23,17 +23,14 @@ #include "include/types.h" -class MMonGetOSDMap : public MessageInstance { -public: - friend factory; +class MMonGetOSDMap : public PaxosServiceMessage { private: - epoch_t full_first, full_last; epoch_t inc_first, inc_last; public: MMonGetOSDMap() - : MessageInstance(CEPH_MSG_MON_GET_OSDMAP, 0), + : PaxosServiceMessage{CEPH_MSG_MON_GET_OSDMAP, 0}, full_first(0), full_last(0), inc_first(0), @@ -92,6 +89,9 @@ public: decode(inc_first, p); decode(inc_last, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonGetVersion.h b/src/messages/MMonGetVersion.h index 8768f47156b..bd454cf0bc3 100644 --- a/src/messages/MMonGetVersion.h +++ b/src/messages/MMonGetVersion.h @@ -25,11 +25,9 @@ * can be used to determine whether a pool actually does not exist, or * if it may have been created but the map was not received yet. */ -class MMonGetVersion : public MessageInstance { +class MMonGetVersion : public Message { public: - friend factory; - - MMonGetVersion() : MessageInstance(CEPH_MSG_MON_GET_VERSION) {} + MMonGetVersion() : Message{CEPH_MSG_MON_GET_VERSION} {} std::string_view get_type_name() const override { return "mon_get_version"; diff --git a/src/messages/MMonGetVersionReply.h b/src/messages/MMonGetVersionReply.h index 1187e8bfcf2..1f4dd7e43b1 100644 --- a/src/messages/MMonGetVersionReply.h +++ b/src/messages/MMonGetVersionReply.h @@ -24,14 +24,12 @@ * MMonGetVersion. The latest version of the requested thing is sent * back. */ -class MMonGetVersionReply : public MessageInstance { -public: - friend factory; +class MMonGetVersionReply : public Message { private: static constexpr int HEAD_VERSION = 2; public: - MMonGetVersionReply() : MessageInstance(CEPH_MSG_MON_GET_VERSION_REPLY, HEAD_VERSION) { } + MMonGetVersionReply() : Message{CEPH_MSG_MON_GET_VERSION_REPLY, HEAD_VERSION} { } std::string_view get_type_name() const override { return "mon_get_version_reply"; diff --git a/src/messages/MMonGlobalID.h b/src/messages/MMonGlobalID.h index 79535a6b7d8..dde000e7947 100644 --- a/src/messages/MMonGlobalID.h +++ b/src/messages/MMonGlobalID.h @@ -17,12 +17,11 @@ #include "messages/PaxosServiceMessage.h" -class MMonGlobalID : public MessageInstance { +class MMonGlobalID : public PaxosServiceMessage { public: - friend factory; - - uint64_t old_max_id; - MMonGlobalID() : MessageInstance(MSG_MON_GLOBAL_ID, 0), old_max_id(0) { } + uint64_t old_max_id = 0; + MMonGlobalID() : PaxosServiceMessage{MSG_MON_GLOBAL_ID, 0} + {} private: ~MMonGlobalID() override {} @@ -42,6 +41,9 @@ public: paxos_encode(); encode(old_max_id, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonHealth.h b/src/messages/MMonHealth.h index 1d8371842be..1d4fd73174c 100644 --- a/src/messages/MMonHealth.h +++ b/src/messages/MMonHealth.h @@ -18,10 +18,8 @@ #include "messages/MMonQuorumService.h" #include "mon/mon_types.h" -class MMonHealth : public MessageInstance { +class MMonHealth : public MMonQuorumService { public: - friend factory; - static constexpr int HEAD_VERSION = 1; int service_type = 0; @@ -30,7 +28,7 @@ public: // service specific data DataStats data_stats; - MMonHealth() : MessageInstance(MSG_MON_HEALTH, HEAD_VERSION) { } + MMonHealth() : MMonQuorumService{MSG_MON_HEALTH, HEAD_VERSION} { } private: ~MMonHealth() override { } @@ -59,7 +57,6 @@ public: encode(service_op, payload); encode(data_stats, payload); } - }; #endif /* CEPH_MMON_HEALTH_H */ diff --git a/src/messages/MMonHealthChecks.h b/src/messages/MMonHealthChecks.h index e9e611b1d4f..86a4fa0c920 100644 --- a/src/messages/MMonHealthChecks.h +++ b/src/messages/MMonHealthChecks.h @@ -7,22 +7,20 @@ #include "messages/PaxosServiceMessage.h" #include "mon/health_check.h" -class MMonHealthChecks : public MessageInstance { +class MMonHealthChecks : public PaxosServiceMessage { public: - friend factory; - static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; health_check_map_t health_checks; MMonHealthChecks() - : MessageInstance(MSG_MON_HEALTH_CHECKS, HEAD_VERSION, COMPAT_VERSION) { + : PaxosServiceMessage{MSG_MON_HEALTH_CHECKS, HEAD_VERSION, COMPAT_VERSION} { } MMonHealthChecks(health_check_map_t& m) - : MessageInstance(MSG_MON_HEALTH_CHECKS, HEAD_VERSION, COMPAT_VERSION), - health_checks(m) { - } + : PaxosServiceMessage{MSG_MON_HEALTH_CHECKS, HEAD_VERSION, COMPAT_VERSION}, + health_checks(m) + {} private: ~MMonHealthChecks() override { } @@ -44,7 +42,9 @@ public: paxos_encode(); encode(health_checks, payload); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonJoin.h b/src/messages/MMonJoin.h index 15d8ac94a9d..c5aaa9e7f04 100644 --- a/src/messages/MMonJoin.h +++ b/src/messages/MMonJoin.h @@ -20,10 +20,8 @@ #include using std::vector; -class MMonJoin : public MessageInstance { +class MMonJoin : public PaxosServiceMessage { public: - friend factory; - static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 2; @@ -31,9 +29,9 @@ public: string name; entity_addrvec_t addrs; - MMonJoin() : MessageInstance(MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION) {} + MMonJoin() : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION} {} MMonJoin(uuid_d &f, string n, const entity_addrvec_t& av) - : MessageInstance(MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION}, fsid(f), name(n), addrs(av) { } diff --git a/src/messages/MMonMap.h b/src/messages/MMonMap.h index 5f0f5eba4e2..e06eabc2500 100644 --- a/src/messages/MMonMap.h +++ b/src/messages/MMonMap.h @@ -21,14 +21,12 @@ #include "msg/MessageRef.h" #include "mon/MonMap.h" -class MMonMap : public MessageInstance { +class MMonMap : public Message { public: - friend factory; - ceph::buffer::list monmapbl; - MMonMap() : MessageInstance(CEPH_MSG_MON_MAP) { } - explicit MMonMap(ceph::buffer::list &bl) : MessageInstance(CEPH_MSG_MON_MAP) { + MMonMap() : Message{CEPH_MSG_MON_MAP} { } + explicit MMonMap(ceph::buffer::list &bl) : Message{CEPH_MSG_MON_MAP} { monmapbl.claim(bl); } private: @@ -56,6 +54,9 @@ public: auto p = payload.cbegin(); decode(monmapbl, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonMetadata.h b/src/messages/MMonMetadata.h index 70c517b42c5..3edc3e464c2 100644 --- a/src/messages/MMonMetadata.h +++ b/src/messages/MMonMetadata.h @@ -18,10 +18,8 @@ #include "mon/mon_types.h" #include "msg/Message.h" -class MMonMetadata : public MessageInstance { +class MMonMetadata : public Message { public: - friend factory; - Metadata data; private: @@ -30,10 +28,10 @@ private: public: MMonMetadata() : - MessageInstance(CEPH_MSG_MON_METADATA) + Message{CEPH_MSG_MON_METADATA} {} MMonMetadata(const Metadata& metadata) : - MessageInstance(CEPH_MSG_MON_METADATA, HEAD_VERSION), + Message{CEPH_MSG_MON_METADATA, HEAD_VERSION}, data(metadata) {} @@ -50,6 +48,9 @@ public: auto p = payload.cbegin(); decode(data, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonMgrReport.h b/src/messages/MMonMgrReport.h index 097fa014537..f695b78c7af 100644 --- a/src/messages/MMonMgrReport.h +++ b/src/messages/MMonMgrReport.h @@ -21,10 +21,7 @@ #include "mon/health_check.h" #include "mon/PGMap.h" -class MMonMgrReport - : public MessageInstance { -public: - friend factory; +class MMonMgrReport : public PaxosServiceMessage { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -36,7 +33,7 @@ public: std::map progress_events; MMonMgrReport() - : MessageInstance(MSG_MON_MGR_REPORT, 0, HEAD_VERSION, COMPAT_VERSION) + : PaxosServiceMessage{MSG_MON_MGR_REPORT, 0, HEAD_VERSION, COMPAT_VERSION} {} private: ~MMonMgrReport() override {} @@ -82,6 +79,9 @@ public: decode(progress_events, p); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonPaxos.h b/src/messages/MMonPaxos.h index b0fc1f70585..3452482c648 100644 --- a/src/messages/MMonPaxos.h +++ b/src/messages/MMonPaxos.h @@ -20,9 +20,7 @@ #include "mon/mon_types.h" #include "include/ceph_features.h" -class MMonPaxos : public MessageInstance { -public: - friend factory; +class MMonPaxos : public Message { private: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 3; @@ -67,9 +65,9 @@ private: bufferlist feature_map; - MMonPaxos() : MessageInstance(MSG_MON_PAXOS, HEAD_VERSION, COMPAT_VERSION) { } + MMonPaxos() : Message{MSG_MON_PAXOS, HEAD_VERSION, COMPAT_VERSION} { } MMonPaxos(epoch_t e, int o, utime_t now) : - MessageInstance(MSG_MON_PAXOS, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_MON_PAXOS, HEAD_VERSION, COMPAT_VERSION}, epoch(e), op(o), first_committed(0), last_committed(0), pn_from(0), pn(0), uncommitted_pn(0), @@ -128,6 +126,9 @@ public: decode(feature_map, p); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonProbe.h b/src/messages/MMonProbe.h index 8b878dfda04..bc4f2dcfa76 100644 --- a/src/messages/MMonProbe.h +++ b/src/messages/MMonProbe.h @@ -20,10 +20,8 @@ #include "msg/Message.h" #include "mon/MonMap.h" -class MMonProbe : public MessageInstance { +class MMonProbe : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 7; static constexpr int COMPAT_VERSION = 5; @@ -60,9 +58,9 @@ public: uint8_t mon_release = 0; MMonProbe() - : MessageInstance(MSG_MON_PROBE, HEAD_VERSION, COMPAT_VERSION) {} + : Message{MSG_MON_PROBE, HEAD_VERSION, COMPAT_VERSION} {} MMonProbe(const uuid_d& f, int o, const string& n, bool hej, uint8_t mr) - : MessageInstance(MSG_MON_PROBE, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_MON_PROBE, HEAD_VERSION, COMPAT_VERSION}, fsid(f), op(o), name(n), @@ -137,6 +135,9 @@ public: else mon_release = 0; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonScrub.h b/src/messages/MMonScrub.h index 8924bad9ff7..967588fd262 100644 --- a/src/messages/MMonScrub.h +++ b/src/messages/MMonScrub.h @@ -16,9 +16,7 @@ #include "msg/Message.h" #include "mon/mon_types.h" -class MMonScrub : public MessageInstance { -public: - friend factory; +class MMonScrub : public Message { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 2; @@ -44,12 +42,12 @@ public: pair key; MMonScrub() - : MessageInstance(MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION}, num_keys(-1) { } MMonScrub(op_type_t op, version_t v, int32_t num_keys) - : MessageInstance(MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION}, op(op), version(v), num_keys(num_keys) { } @@ -85,6 +83,9 @@ public: decode(num_keys, p); decode(key, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif /* CEPH_MMONSCRUB_H */ diff --git a/src/messages/MMonSubscribe.h b/src/messages/MMonSubscribe.h index c57ab5e8474..2872c0b46e1 100644 --- a/src/messages/MMonSubscribe.h +++ b/src/messages/MMonSubscribe.h @@ -29,17 +29,15 @@ struct ceph_mon_subscribe_item_old { WRITE_RAW_ENCODER(ceph_mon_subscribe_item_old) -class MMonSubscribe : public MessageInstance { +class MMonSubscribe : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 1; std::string hostname; std::map what; - MMonSubscribe() : MessageInstance(CEPH_MSG_MON_SUBSCRIBE, HEAD_VERSION, COMPAT_VERSION) { } + MMonSubscribe() : Message{CEPH_MSG_MON_SUBSCRIBE, HEAD_VERSION, COMPAT_VERSION} { } private: ~MMonSubscribe() override {} @@ -97,6 +95,9 @@ public: encode(what, payload); encode(hostname, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonSubscribeAck.h b/src/messages/MMonSubscribeAck.h index 3a68c158888..9aa2db0500f 100644 --- a/src/messages/MMonSubscribeAck.h +++ b/src/messages/MMonSubscribeAck.h @@ -17,17 +17,15 @@ #include "msg/Message.h" -class MMonSubscribeAck : public MessageInstance { +class MMonSubscribeAck : public Message { public: - friend factory; - __u32 interval; uuid_d fsid; - MMonSubscribeAck() : MessageInstance(CEPH_MSG_MON_SUBSCRIBE_ACK), + MMonSubscribeAck() : Message{CEPH_MSG_MON_SUBSCRIBE_ACK}, interval(0) { } - MMonSubscribeAck(uuid_d& f, int i) : MessageInstance(CEPH_MSG_MON_SUBSCRIBE_ACK), + MMonSubscribeAck(uuid_d& f, int i) : Message{CEPH_MSG_MON_SUBSCRIBE_ACK}, interval(i), fsid(f) { } private: ~MMonSubscribeAck() override {} @@ -49,6 +47,9 @@ public: encode(interval, payload); encode(fsid, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MMonSync.h b/src/messages/MMonSync.h index a4f8220790c..41832366f9e 100644 --- a/src/messages/MMonSync.h +++ b/src/messages/MMonSync.h @@ -15,9 +15,7 @@ #include "msg/Message.h" -class MMonSync : public MessageInstance { -public: - friend factory; +class MMonSync : public Message { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 2; @@ -63,11 +61,11 @@ public: entity_inst_t reply_to; MMonSync() - : MessageInstance(MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION) + : Message{MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION} { } MMonSync(uint32_t op, uint64_t c = 0) - : MessageInstance(MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION}, op(op), cookie(c), last_committed(0) @@ -109,6 +107,9 @@ public: decode(chunk_bl, p); decode(reply_to, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif /* CEPH_MMONSYNC_H */ diff --git a/src/messages/MOSDAlive.h b/src/messages/MOSDAlive.h index 47ed5f2a245..7b82d4fd172 100644 --- a/src/messages/MOSDAlive.h +++ b/src/messages/MOSDAlive.h @@ -19,14 +19,12 @@ #include "messages/PaxosServiceMessage.h" -class MOSDAlive : public MessageInstance { +class MOSDAlive : public PaxosServiceMessage { public: - friend factory; - epoch_t want = 0; - MOSDAlive(epoch_t h, epoch_t w) : MessageInstance(MSG_OSD_ALIVE, h), want(w) { } - MOSDAlive() : MessageInstance(MSG_OSD_ALIVE, 0) {} + MOSDAlive(epoch_t h, epoch_t w) : PaxosServiceMessage{MSG_OSD_ALIVE, h}, want(w) {} + MOSDAlive() : MOSDAlive{0, 0} {} private: ~MOSDAlive() override {} @@ -46,7 +44,9 @@ public: void print(ostream &out) const override { out << "osd_alive(want up_thru " << want << " have " << version << ")"; } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDBackoff.h b/src/messages/MOSDBackoff.h index 25b7096619f..82218d2fa43 100644 --- a/src/messages/MOSDBackoff.h +++ b/src/messages/MOSDBackoff.h @@ -19,10 +19,8 @@ #include "MOSDFastDispatchOp.h" #include "osd/osd_types.h" -class MOSDBackoff : public MessageInstance { +class MOSDBackoff : public MOSDFastDispatchOp { public: - friend factory; - static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -40,10 +38,10 @@ public: } MOSDBackoff() - : MessageInstance(CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION) {} + : MOSDFastDispatchOp{CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION} {} MOSDBackoff(spg_t pgid_, epoch_t ep, uint8_t op_, uint64_t id_, hobject_t begin_, hobject_t end_) - : MessageInstance(CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION}, pgid(pgid_), map_epoch(ep), op(op_), @@ -80,6 +78,9 @@ public: << " [" << begin << "," << end << ")" << " e" << map_epoch << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDBeacon.h b/src/messages/MOSDBeacon.h index 7614011968a..068858cbf96 100644 --- a/src/messages/MOSDBeacon.h +++ b/src/messages/MOSDBeacon.h @@ -5,18 +5,16 @@ #include "PaxosServiceMessage.h" -class MOSDBeacon : public MessageInstance { +class MOSDBeacon : public PaxosServiceMessage { public: - friend factory; - std::vector pgs; epoch_t min_last_epoch_clean = 0; MOSDBeacon() - : MessageInstance(MSG_OSD_BEACON, 0) + : PaxosServiceMessage{MSG_OSD_BEACON, 0} {} MOSDBeacon(epoch_t e, epoch_t min_lec) - : MessageInstance(MSG_OSD_BEACON, e), + : PaxosServiceMessage{MSG_OSD_BEACON, e}, min_last_epoch_clean(min_lec) {} void encode_payload(uint64_t features) override { @@ -38,4 +36,7 @@ public: << " lec " << min_last_epoch_clean << " v" << version << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MOSDBoot.h b/src/messages/MOSDBoot.h index ccd499918a5..4e2cdf0bd49 100644 --- a/src/messages/MOSDBoot.h +++ b/src/messages/MOSDBoot.h @@ -21,9 +21,7 @@ #include "include/types.h" #include "osd/osd_types.h" -class MOSDBoot : public MessageInstance { -public: - friend factory; +class MOSDBoot : public PaxosServiceMessage { private: static constexpr int HEAD_VERSION = 7; static constexpr int COMPAT_VERSION = 7; @@ -37,7 +35,7 @@ private: uint64_t osd_features; MOSDBoot() - : MessageInstance(MSG_OSD_BOOT, 0, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{MSG_OSD_BOOT, 0, HEAD_VERSION, COMPAT_VERSION}, boot_epoch(0), osd_features(0) { } MOSDBoot(OSDSuperblock& s, epoch_t e, epoch_t be, @@ -45,7 +43,7 @@ private: const entity_addrvec_t& hb_front_addr_ref, const entity_addrvec_t& cluster_addr_ref, uint64_t feat) - : MessageInstance(MSG_OSD_BOOT, e, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{MSG_OSD_BOOT, e, HEAD_VERSION, COMPAT_VERSION}, sb(s), hb_back_addrs(hb_back_addr_ref), hb_front_addrs(hb_front_addr_ref), @@ -115,6 +113,9 @@ public: decode(metadata, p); decode(osd_features, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDECSubOpRead.h b/src/messages/MOSDECSubOpRead.h index c006a85c2ed..ec97de62a27 100644 --- a/src/messages/MOSDECSubOpRead.h +++ b/src/messages/MOSDECSubOpRead.h @@ -18,9 +18,7 @@ #include "MOSDFastDispatchOp.h" #include "osd/ECMsgTypes.h" -class MOSDECSubOpRead : public MessageInstance { -public: - friend factory; +class MOSDECSubOpRead : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 1; @@ -44,7 +42,7 @@ public: } MOSDECSubOpRead() - : MessageInstance(MSG_OSD_EC_READ, HEAD_VERSION, COMPAT_VERSION) + : MOSDFastDispatchOp{MSG_OSD_EC_READ, HEAD_VERSION, COMPAT_VERSION} {} void decode_payload() override { @@ -77,6 +75,9 @@ public: << " " << op; out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDECSubOpReadReply.h b/src/messages/MOSDECSubOpReadReply.h index 091e53910ed..fb5e8011227 100644 --- a/src/messages/MOSDECSubOpReadReply.h +++ b/src/messages/MOSDECSubOpReadReply.h @@ -18,9 +18,7 @@ #include "MOSDFastDispatchOp.h" #include "osd/ECMsgTypes.h" -class MOSDECSubOpReadReply : public MessageInstance { -public: - friend factory; +class MOSDECSubOpReadReply : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -44,7 +42,7 @@ public: } MOSDECSubOpReadReply() - : MessageInstance(MSG_OSD_EC_READ_REPLY, HEAD_VERSION, COMPAT_VERSION) + : MOSDFastDispatchOp{MSG_OSD_EC_READ_REPLY, HEAD_VERSION, COMPAT_VERSION} {} void decode_payload() override { @@ -77,6 +75,9 @@ public: << " " << op; out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDECSubOpWrite.h b/src/messages/MOSDECSubOpWrite.h index 5b286cffb77..f5ccf652306 100644 --- a/src/messages/MOSDECSubOpWrite.h +++ b/src/messages/MOSDECSubOpWrite.h @@ -18,9 +18,7 @@ #include "MOSDFastDispatchOp.h" #include "osd/ECMsgTypes.h" -class MOSDECSubOpWrite : public MessageInstance { -public: - friend factory; +class MOSDECSubOpWrite : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -44,10 +42,10 @@ public: } MOSDECSubOpWrite() - : MessageInstance(MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION) + : MOSDFastDispatchOp{MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION} {} MOSDECSubOpWrite(ECSubWrite &in_op) - : MessageInstance(MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION) { + : MOSDFastDispatchOp{MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION} { op.claim(in_op); } @@ -86,6 +84,9 @@ public: op.t = ObjectStore::Transaction(); op.log_entries.clear(); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDECSubOpWriteReply.h b/src/messages/MOSDECSubOpWriteReply.h index dfcaf9ae36a..743180abe4d 100644 --- a/src/messages/MOSDECSubOpWriteReply.h +++ b/src/messages/MOSDECSubOpWriteReply.h @@ -18,9 +18,7 @@ #include "MOSDFastDispatchOp.h" #include "osd/ECMsgTypes.h" -class MOSDECSubOpWriteReply : public MessageInstance { -public: - friend factory; +class MOSDECSubOpWriteReply : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -44,8 +42,8 @@ public: } MOSDECSubOpWriteReply() - : MessageInstance(MSG_OSD_EC_WRITE_REPLY, HEAD_VERSION, COMPAT_VERSION) - {} + : MOSDFastDispatchOp{MSG_OSD_EC_WRITE_REPLY, HEAD_VERSION, COMPAT_VERSION} + {} void decode_payload() override { auto p = payload.cbegin(); @@ -77,6 +75,9 @@ public: << " " << op; out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDFailure.h b/src/messages/MOSDFailure.h index 27888dd45ae..0702034bd7b 100644 --- a/src/messages/MOSDFailure.h +++ b/src/messages/MOSDFailure.h @@ -19,9 +19,7 @@ #include "messages/PaxosServiceMessage.h" -class MOSDFailure : public MessageInstance { -public: - friend factory; +class MOSDFailure : public PaxosServiceMessage { private: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 4; @@ -40,10 +38,10 @@ private: epoch_t epoch = 0; int32_t failed_for = 0; // known to be failed since at least this long - MOSDFailure() : MessageInstance(MSG_OSD_FAILURE, 0, HEAD_VERSION) { } + MOSDFailure() : PaxosServiceMessage(MSG_OSD_FAILURE, 0, HEAD_VERSION) { } MOSDFailure(const uuid_d &fs, int osd, const entity_addrvec_t& av, int duration, epoch_t e) - : MessageInstance(MSG_OSD_FAILURE, e, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage(MSG_OSD_FAILURE, e, HEAD_VERSION, COMPAT_VERSION), fsid(fs), target_osd(osd), target_addrs(av), @@ -52,7 +50,7 @@ private: MOSDFailure(const uuid_d &fs, int osd, const entity_addrvec_t& av, int duration, epoch_t e, __u8 extra_flags) - : MessageInstance(MSG_OSD_FAILURE, e, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage(MSG_OSD_FAILURE, e, HEAD_VERSION, COMPAT_VERSION), fsid(fs), target_osd(osd), target_addrs(av), @@ -123,6 +121,9 @@ public: << " for " << failed_for << "sec e" << epoch << " v" << version << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDForceRecovery.h b/src/messages/MOSDForceRecovery.h index 9ee824a16e3..9e86c3320bd 100644 --- a/src/messages/MOSDForceRecovery.h +++ b/src/messages/MOSDForceRecovery.h @@ -31,10 +31,8 @@ static const int OFR_BACKFILL = 2; // cancel priority boost, requeue if necessary static const int OFR_CANCEL = 4; -class MOSDForceRecovery : public MessageInstance { +class MOSDForceRecovery : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 2; @@ -42,12 +40,12 @@ public: vector forced_pgs; uint8_t options = 0; - MOSDForceRecovery() : MessageInstance(MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION) {} + MOSDForceRecovery() : Message{MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION} {} MOSDForceRecovery(const uuid_d& f, char opts) : - MessageInstance(MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION}, fsid(f), options(opts) {} MOSDForceRecovery(const uuid_d& f, vector& pgs, char opts) : - MessageInstance(MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_OSD_FORCE_RECOVERY, HEAD_VERSION, COMPAT_VERSION}, fsid(f), forced_pgs(pgs), options(opts) {} private: ~MOSDForceRecovery() {} @@ -107,6 +105,9 @@ public: decode(forced_pgs, p); decode(options, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif /* CEPH_MOSDFORCERECOVERY_H_ */ diff --git a/src/messages/MOSDFull.h b/src/messages/MOSDFull.h index bfe0c24e4cb..bf6bd35c71c 100644 --- a/src/messages/MOSDFull.h +++ b/src/messages/MOSDFull.h @@ -11,10 +11,8 @@ // future this message could be generalized to other state bits, but // for now name it for its sole application. -class MOSDFull : public MessageInstance { +class MOSDFull : public PaxosServiceMessage { public: - friend factory; - epoch_t map_epoch = 0; uint32_t state = 0; @@ -23,9 +21,9 @@ private: public: MOSDFull(epoch_t e, unsigned s) - : MessageInstance(MSG_OSD_FULL, e), map_epoch(e), state(s) { } + : PaxosServiceMessage{MSG_OSD_FULL, e}, map_epoch(e), state(s) { } MOSDFull() - : MessageInstance(MSG_OSD_FULL, 0) {} + : PaxosServiceMessage{MSG_OSD_FULL, 0} {} public: void encode_payload(uint64_t features) { @@ -47,7 +45,9 @@ public: OSDMap::calc_state_set(state, states); out << "osd_full(e" << map_epoch << " " << states << " v" << version << ")"; } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDMap.h b/src/messages/MOSDMap.h index 3c2ef510a91..370de67df0d 100644 --- a/src/messages/MOSDMap.h +++ b/src/messages/MOSDMap.h @@ -20,14 +20,12 @@ #include "osd/OSDMap.h" #include "include/ceph_features.h" -class MOSDMap : public MessageInstance { -public: - friend factory; +class MOSDMap : public Message { private: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 3; - public: +public: uuid_d fsid; uint64_t encode_features = 0; std::map maps; @@ -65,9 +63,9 @@ private: } - MOSDMap() : MessageInstance(CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION) { } + MOSDMap() : Message{CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION} { } MOSDMap(const uuid_d &f, const uint64_t features) - : MessageInstance(CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION), + : Message{CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION}, fsid(f), encode_features(features), oldest_map(0), newest_map(0) { } private: @@ -165,6 +163,9 @@ public: out << " +gap_removed_snaps"; out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDMarkMeDown.h b/src/messages/MOSDMarkMeDown.h index 89c3d75cefd..b99008318c5 100644 --- a/src/messages/MOSDMarkMeDown.h +++ b/src/messages/MOSDMarkMeDown.h @@ -17,9 +17,7 @@ #include "messages/PaxosServiceMessage.h" -class MOSDMarkMeDown : public MessageInstance { -public: - friend factory; +class MOSDMarkMeDown : public PaxosServiceMessage { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 3; @@ -32,12 +30,12 @@ private: bool request_ack = false; // ack requested MOSDMarkMeDown() - : MessageInstance(MSG_OSD_MARK_ME_DOWN, 0, - HEAD_VERSION, COMPAT_VERSION) { } + : PaxosServiceMessage{MSG_OSD_MARK_ME_DOWN, 0, + HEAD_VERSION, COMPAT_VERSION} { } MOSDMarkMeDown(const uuid_d &fs, int osd, const entity_addrvec_t& av, epoch_t e, bool request_ack) - : MessageInstance(MSG_OSD_MARK_ME_DOWN, e, - HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{MSG_OSD_MARK_ME_DOWN, e, + HEAD_VERSION, COMPAT_VERSION}, fsid(fs), target_osd(osd), target_addrs(av), epoch(e), request_ack(request_ack) {} private: @@ -98,6 +96,9 @@ public: << ", fsid=" << fsid << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDOp.h b/src/messages/MOSDOp.h index b7f59390151..ad3a75a67ec 100644 --- a/src/messages/MOSDOp.h +++ b/src/messages/MOSDOp.h @@ -32,9 +32,7 @@ class OSD; -class MOSDOp : public MessageInstance { -public: - friend factory; +class MOSDOp : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 8; static constexpr int COMPAT_VERSION = 3; @@ -170,14 +168,14 @@ public: } MOSDOp() - : MessageInstance(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION), partial_decode_needed(true), final_decode_needed(true), bdata_encode(false) { } MOSDOp(int inc, long tid, const hobject_t& ho, spg_t& _pgid, epoch_t _osdmap_epoch, int _flags, uint64_t feat) - : MessageInstance(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION), client_inc(inc), osdmap_epoch(_osdmap_epoch), flags(_flags), retry_attempt(-1), hobj(ho), @@ -595,6 +593,10 @@ struct ceph_osd_request_head { } out << ")"; } + +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MOSDOpReply.h b/src/messages/MOSDOpReply.h index f14bd35e093..c35b7ace671 100644 --- a/src/messages/MOSDOpReply.h +++ b/src/messages/MOSDOpReply.h @@ -29,9 +29,7 @@ * */ -class MOSDOpReply : public MessageInstance { -public: - friend factory; +class MOSDOpReply : public Message { private: static constexpr int HEAD_VERSION = 8; static constexpr int COMPAT_VERSION = 2; @@ -128,13 +126,13 @@ public: public: MOSDOpReply() - : MessageInstance(CEPH_MSG_OSD_OPREPLY, HEAD_VERSION, COMPAT_VERSION), + : Message{CEPH_MSG_OSD_OPREPLY, HEAD_VERSION, COMPAT_VERSION}, bdata_encode(false) { do_redirect = false; } MOSDOpReply(const MOSDOp *req, int r, epoch_t e, int acktype, bool ignore_out_data) - : MessageInstance(CEPH_MSG_OSD_OPREPLY, HEAD_VERSION, COMPAT_VERSION), + : Message{CEPH_MSG_OSD_OPREPLY, HEAD_VERSION, COMPAT_VERSION}, oid(req->hobj.oid), pgid(req->pgid.pgid), ops(req->ops), bdata_encode(false) { @@ -334,6 +332,9 @@ public: out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MOSDPGBackfill.h b/src/messages/MOSDPGBackfill.h index 47d25b0c674..ee2eb82fe86 100644 --- a/src/messages/MOSDPGBackfill.h +++ b/src/messages/MOSDPGBackfill.h @@ -17,9 +17,7 @@ #include "MOSDFastDispatchOp.h" -class MOSDPGBackfill : public MessageInstance { -public: - friend factory; +class MOSDPGBackfill : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 3; @@ -91,9 +89,9 @@ public: } MOSDPGBackfill() - : MessageInstance(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION) {} + : MOSDFastDispatchOp{MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION} {} MOSDPGBackfill(__u32 o, epoch_t e, epoch_t qe, spg_t p) - : MessageInstance(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION}, op(o), map_epoch(e), query_epoch(e), pgid(p) {} @@ -109,6 +107,10 @@ public: << " lb " << last_backfill << ")"; } + +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGBackfillRemove.h b/src/messages/MOSDPGBackfillRemove.h index 359145183e6..5c70c386f3d 100644 --- a/src/messages/MOSDPGBackfillRemove.h +++ b/src/messages/MOSDPGBackfillRemove.h @@ -21,10 +21,8 @@ * instruct non-primary to remove some objects during backfill */ -class MOSDPGBackfillRemove : public MessageInstance { +class MOSDPGBackfillRemove : public MOSDFastDispatchOp { public: - friend factory; - static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -40,12 +38,13 @@ public: } MOSDPGBackfillRemove() - : MessageInstance(MSG_OSD_PG_BACKFILL_REMOVE, HEAD_VERSION, - COMPAT_VERSION) {} + : MOSDFastDispatchOp{MSG_OSD_PG_BACKFILL_REMOVE, HEAD_VERSION, + COMPAT_VERSION} + {} MOSDPGBackfillRemove(spg_t pgid, epoch_t map_epoch) - : MessageInstance(MSG_OSD_PG_BACKFILL_REMOVE, HEAD_VERSION, - COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_PG_BACKFILL_REMOVE, HEAD_VERSION, + COMPAT_VERSION}, pgid(pgid), map_epoch(map_epoch) {} @@ -71,8 +70,10 @@ public: decode(map_epoch, p); decode(ls, p); } -}; - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); +}; #endif diff --git a/src/messages/MOSDPGCreate.h b/src/messages/MOSDPGCreate.h index eef056ab860..09aa2e9c2e3 100644 --- a/src/messages/MOSDPGCreate.h +++ b/src/messages/MOSDPGCreate.h @@ -23,10 +23,8 @@ * PGCreate - instruct an OSD to create a pg, if it doesn't already exist */ -class MOSDPGCreate : public MessageInstance { +class MOSDPGCreate : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 3; @@ -35,10 +33,12 @@ public: map ctimes; MOSDPGCreate() - : MessageInstance(MSG_OSD_PG_CREATE, HEAD_VERSION, COMPAT_VERSION) {} + : MOSDPGCreate{0} + {} MOSDPGCreate(epoch_t e) - : MessageInstance(MSG_OSD_PG_CREATE, HEAD_VERSION, COMPAT_VERSION), - epoch(e) { } + : Message{MSG_OSD_PG_CREATE, HEAD_VERSION, COMPAT_VERSION}, + epoch(e) + {} private: ~MOSDPGCreate() override {} @@ -57,7 +57,6 @@ public: decode(mkpg, p); decode(ctimes, p); } - void print(ostream& out) const override { out << "osd_pg_create(e" << epoch; for (map::const_iterator i = mkpg.begin(); @@ -67,6 +66,9 @@ public: } out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGCreate2.h b/src/messages/MOSDPGCreate2.h index f232483f007..e2c6800e3b7 100644 --- a/src/messages/MOSDPGCreate2.h +++ b/src/messages/MOSDPGCreate2.h @@ -10,10 +10,8 @@ * PGCreate2 - instruct an OSD to create some pgs */ -class MOSDPGCreate2 : public MessageInstance { +class MOSDPGCreate2 : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -21,9 +19,9 @@ public: map> pgs; MOSDPGCreate2() - : MessageInstance(MSG_OSD_PG_CREATE2, HEAD_VERSION, COMPAT_VERSION) {} + : Message{MSG_OSD_PG_CREATE2, HEAD_VERSION, COMPAT_VERSION} {} MOSDPGCreate2(epoch_t e) - : MessageInstance(MSG_OSD_PG_CREATE2, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_OSD_PG_CREATE2, HEAD_VERSION, COMPAT_VERSION}, epoch(e) { } private: ~MOSDPGCreate2() override {} @@ -47,4 +45,7 @@ public: decode(epoch, p); decode(pgs, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MOSDPGCreated.h b/src/messages/MOSDPGCreated.h index 6ccb9f9789f..7ec6c34dc16 100644 --- a/src/messages/MOSDPGCreated.h +++ b/src/messages/MOSDPGCreated.h @@ -6,16 +6,14 @@ #include "osd/osd_types.h" #include "messages/PaxosServiceMessage.h" -class MOSDPGCreated : public MessageInstance { +class MOSDPGCreated : public PaxosServiceMessage { public: - friend factory; - pg_t pgid; MOSDPGCreated() - : MessageInstance(MSG_OSD_PG_CREATED, 0) + : PaxosServiceMessage{MSG_OSD_PG_CREATED, 0} {} MOSDPGCreated(pg_t pgid) - : MessageInstance(MSG_OSD_PG_CREATED, 0), + : PaxosServiceMessage{MSG_OSD_PG_CREATED, 0}, pgid(pgid) {} std::string_view get_type_name() const override { return "pg_created"; } @@ -32,4 +30,7 @@ public: paxos_decode(p); decode(pgid, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MOSDPGInfo.h b/src/messages/MOSDPGInfo.h index f7ba4aedf9f..0a4d92b5d63 100644 --- a/src/messages/MOSDPGInfo.h +++ b/src/messages/MOSDPGInfo.h @@ -19,9 +19,7 @@ #include "msg/Message.h" #include "osd/osd_types.h" -class MOSDPGInfo : public MessageInstance { -public: - friend factory; +class MOSDPGInfo : public Message { private: static constexpr int HEAD_VERSION = 5; static constexpr int COMPAT_VERSION = 5; @@ -41,7 +39,7 @@ public: : MOSDPGInfo(mv, {}) {} MOSDPGInfo(epoch_t mv, pg_list_t&& l) - : MessageInstance(MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_OSD_PG_INFO, HEAD_VERSION, COMPAT_VERSION}, epoch{mv}, pg_list{std::move(l)} { @@ -75,6 +73,9 @@ public: decode(epoch, p); decode(pg_list, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGLog.h b/src/messages/MOSDPGLog.h index e391183a268..8e3fd6ee00e 100644 --- a/src/messages/MOSDPGLog.h +++ b/src/messages/MOSDPGLog.h @@ -18,9 +18,7 @@ #include "messages/MOSDPeeringOp.h" -class MOSDPGLog : public MessageInstance { -public: - friend factory; +class MOSDPGLog : public MOSDPeeringOp { private: static constexpr int HEAD_VERSION = 5; static constexpr int COMPAT_VERSION = 5; @@ -68,12 +66,12 @@ public: false)); } - MOSDPGLog() : MessageInstance(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION) { + MOSDPGLog() : MOSDPeeringOp{MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION} { set_priority(CEPH_MSG_PRIO_HIGH); } MOSDPGLog(shard_id_t to, shard_id_t from, version_t mv, const pg_info_t& i, epoch_t query_epoch) - : MessageInstance(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION), + : MOSDPeeringOp{MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION}, epoch(mv), query_epoch(query_epoch), to(to), from(from), info(i) { @@ -120,6 +118,9 @@ public: decode(to, p); decode(from, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGNotify.h b/src/messages/MOSDPGNotify.h index 6ec25020556..dd1f49ce281 100644 --- a/src/messages/MOSDPGNotify.h +++ b/src/messages/MOSDPGNotify.h @@ -23,9 +23,7 @@ * PGNotify - notify primary of my PGs and versions. */ -class MOSDPGNotify : public MessageInstance { -public: - friend factory; +class MOSDPGNotify : public Message { private: static constexpr int HEAD_VERSION = 6; static constexpr int COMPAT_VERSION = 6; @@ -48,7 +46,7 @@ private: : MOSDPGNotify(0, {}) {} MOSDPGNotify(epoch_t e, pg_list_t&& l) - : MessageInstance(MSG_OSD_PG_NOTIFY, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_OSD_PG_NOTIFY, HEAD_VERSION, COMPAT_VERSION}, epoch(e), pg_list(std::move(l)) { set_priority(CEPH_MSG_PRIO_HIGH); @@ -82,6 +80,9 @@ public: out << " epoch " << epoch << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGPull.h b/src/messages/MOSDPGPull.h index 16eeca7ef74..8611e10bb6b 100644 --- a/src/messages/MOSDPGPull.h +++ b/src/messages/MOSDPGPull.h @@ -17,9 +17,7 @@ #include "MOSDFastDispatchOp.h" -class MOSDPGPull : public MessageInstance { -public: - friend factory; +class MOSDPGPull : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 2; @@ -30,7 +28,7 @@ public: pg_shard_t from; spg_t pgid; epoch_t map_epoch = 0, min_epoch = 0; - uint64_t cost; + uint64_t cost = 0; epoch_t get_map_epoch() const override { return map_epoch; @@ -50,9 +48,8 @@ public: } MOSDPGPull() - : MessageInstance(MSG_OSD_PG_PULL, HEAD_VERSION, COMPAT_VERSION), - cost(0) - {} + : MOSDFastDispatchOp{MSG_OSD_PG_PULL, HEAD_VERSION, COMPAT_VERSION} + {} void compute_cost(CephContext *cct) { cost = 0; @@ -101,6 +98,10 @@ public: << " cost " << cost << ")"; } + +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGPush.h b/src/messages/MOSDPGPush.h index 3960ad70ea3..01df5b81f06 100644 --- a/src/messages/MOSDPGPush.h +++ b/src/messages/MOSDPGPush.h @@ -17,9 +17,7 @@ #include "MOSDFastDispatchOp.h" -class MOSDPGPush : public MessageInstance { -public: - friend factory; +class MOSDPGPush : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 2; @@ -32,7 +30,7 @@ public: bool is_repair = false; private: - uint64_t cost; + uint64_t cost = 0; public: void compute_cost(CephContext *cct) { @@ -63,9 +61,8 @@ public: } MOSDPGPush() - : MessageInstance(MSG_OSD_PG_PUSH, HEAD_VERSION, COMPAT_VERSION), - cost(0) - {} + : MOSDFastDispatchOp{MSG_OSD_PG_PUSH, HEAD_VERSION, COMPAT_VERSION} + {} void decode_payload() override { auto p = payload.cbegin(); @@ -107,6 +104,10 @@ public: << " " << pushes; out << ")"; } + +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGPushReply.h b/src/messages/MOSDPGPushReply.h index b9b7687e8eb..f95555b7f41 100644 --- a/src/messages/MOSDPGPushReply.h +++ b/src/messages/MOSDPGPushReply.h @@ -17,9 +17,7 @@ #include "MOSDFastDispatchOp.h" -class MOSDPGPushReply : public MessageInstance { -public: - friend factory; +class MOSDPGPushReply : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 2; @@ -29,7 +27,7 @@ public: spg_t pgid; epoch_t map_epoch = 0, min_epoch = 0; vector replies; - uint64_t cost; + uint64_t cost = 0; epoch_t get_map_epoch() const override { return map_epoch; @@ -42,8 +40,7 @@ public: } MOSDPGPushReply() - : MessageInstance(MSG_OSD_PG_PUSH_REPLY, HEAD_VERSION, COMPAT_VERSION), - cost(0) + : MOSDFastDispatchOp{MSG_OSD_PG_PUSH_REPLY, HEAD_VERSION, COMPAT_VERSION} {} void compute_cost(CephContext *cct) { diff --git a/src/messages/MOSDPGQuery.h b/src/messages/MOSDPGQuery.h index c9f3f8e4e70..9d78e61ab90 100644 --- a/src/messages/MOSDPGQuery.h +++ b/src/messages/MOSDPGQuery.h @@ -23,9 +23,7 @@ * PGQuery - query another OSD as to the contents of their PGs */ -class MOSDPGQuery : public MessageInstance { -public: - friend factory; +class MOSDPGQuery : public Message { private: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 4; @@ -37,15 +35,15 @@ private: using pg_list_t = std::map; pg_list_t pg_list; - MOSDPGQuery() : MessageInstance(MSG_OSD_PG_QUERY, + MOSDPGQuery() : Message{MSG_OSD_PG_QUERY, HEAD_VERSION, - COMPAT_VERSION) { + COMPAT_VERSION} { set_priority(CEPH_MSG_PRIO_HIGH); } MOSDPGQuery(epoch_t e, pg_list_t&& ls) : - MessageInstance(MSG_OSD_PG_QUERY, + Message{MSG_OSD_PG_QUERY, HEAD_VERSION, - COMPAT_VERSION), + COMPAT_VERSION}, epoch(e), pg_list(std::move(ls)) { set_priority(CEPH_MSG_PRIO_HIGH); @@ -76,6 +74,9 @@ public: decode(epoch, p); decode(pg_list, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGReadyToMerge.h b/src/messages/MOSDPGReadyToMerge.h index b8c18095675..e8f3b81bb88 100644 --- a/src/messages/MOSDPGReadyToMerge.h +++ b/src/messages/MOSDPGReadyToMerge.h @@ -3,8 +3,7 @@ #pragma once -class MOSDPGReadyToMerge - : public MessageInstance { +class MOSDPGReadyToMerge : public PaxosServiceMessage { public: pg_t pgid; eversion_t source_version, target_version; @@ -13,11 +12,11 @@ public: bool ready = true; MOSDPGReadyToMerge() - : MessageInstance(MSG_OSD_PG_READY_TO_MERGE, 0) + : PaxosServiceMessage{MSG_OSD_PG_READY_TO_MERGE, 0} {} MOSDPGReadyToMerge(pg_t p, eversion_t sv, eversion_t tv, epoch_t les, epoch_t lec, bool r, epoch_t v) - : MessageInstance(MSG_OSD_PG_READY_TO_MERGE, v), + : PaxosServiceMessage{MSG_OSD_PG_READY_TO_MERGE, v}, pgid(p), source_version(sv), target_version(tv), @@ -55,4 +54,7 @@ public: << (ready ? " ready" : " NOT READY") << " v" << version << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MOSDPGRecoveryDelete.h b/src/messages/MOSDPGRecoveryDelete.h index c6fa1366916..88f82a6f5ab 100644 --- a/src/messages/MOSDPGRecoveryDelete.h +++ b/src/messages/MOSDPGRecoveryDelete.h @@ -10,10 +10,8 @@ * instruct non-primary to remove some objects during recovery */ -class MOSDPGRecoveryDelete : public MessageInstance { +class MOSDPGRecoveryDelete : public MOSDFastDispatchOp { public: - friend factory; - static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -23,7 +21,7 @@ public: list > objects; ///< objects to remove private: - uint64_t cost; + uint64_t cost = 0; public: int get_cost() const override { @@ -45,18 +43,19 @@ public: } MOSDPGRecoveryDelete() - : MessageInstance(MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION, - COMPAT_VERSION), cost(0) {} + : MOSDFastDispatchOp{MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION, + COMPAT_VERSION} + {} MOSDPGRecoveryDelete(pg_shard_t from, spg_t pgid, epoch_t map_epoch, epoch_t min_epoch) - : MessageInstance(MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION, - COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION, + COMPAT_VERSION}, from(from), pgid(pgid), map_epoch(map_epoch), - min_epoch(min_epoch), - cost(0) {} + min_epoch(min_epoch) + {} private: ~MOSDPGRecoveryDelete() {} @@ -86,8 +85,9 @@ public: decode(cost, p); decode(objects, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; - - #endif diff --git a/src/messages/MOSDPGRecoveryDeleteReply.h b/src/messages/MOSDPGRecoveryDeleteReply.h index e6401774167..e870e587f84 100644 --- a/src/messages/MOSDPGRecoveryDeleteReply.h +++ b/src/messages/MOSDPGRecoveryDeleteReply.h @@ -6,16 +6,15 @@ #include "MOSDFastDispatchOp.h" -class MOSDPGRecoveryDeleteReply : public MessageInstance { +class MOSDPGRecoveryDeleteReply : public MOSDFastDispatchOp { public: - friend factory; - static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; pg_shard_t from; spg_t pgid; - epoch_t map_epoch, min_epoch; + epoch_t map_epoch = 0; + epoch_t min_epoch = 0; list > objects; epoch_t get_map_epoch() const override { @@ -29,9 +28,8 @@ public: } MOSDPGRecoveryDeleteReply() - : MessageInstance(MSG_OSD_PG_RECOVERY_DELETE_REPLY, HEAD_VERSION, COMPAT_VERSION), - map_epoch(0), min_epoch(0) - {} + : MOSDFastDispatchOp{MSG_OSD_PG_RECOVERY_DELETE_REPLY, HEAD_VERSION, COMPAT_VERSION} + {} void decode_payload() override { auto p = payload.cbegin(); @@ -59,6 +57,10 @@ public: } std::string_view get_type_name() const override { return "recovery_delete_reply"; } + +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGRemove.h b/src/messages/MOSDPGRemove.h index 94e9885e9d9..b91c423a96c 100644 --- a/src/messages/MOSDPGRemove.h +++ b/src/messages/MOSDPGRemove.h @@ -20,9 +20,7 @@ #include "msg/Message.h" -class MOSDPGRemove : public MessageInstance { -public: - friend factory; +class MOSDPGRemove : public Message { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 3; @@ -35,9 +33,9 @@ private: epoch_t get_epoch() const { return epoch; } MOSDPGRemove() : - MessageInstance(MSG_OSD_PG_REMOVE, HEAD_VERSION, COMPAT_VERSION) {} + Message{MSG_OSD_PG_REMOVE, HEAD_VERSION, COMPAT_VERSION} {} MOSDPGRemove(epoch_t e, vector& l) : - MessageInstance(MSG_OSD_PG_REMOVE, HEAD_VERSION, COMPAT_VERSION) { + Message{MSG_OSD_PG_REMOVE, HEAD_VERSION, COMPAT_VERSION} { this->epoch = e; pg_list.swap(l); } @@ -66,6 +64,9 @@ public: } out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGScan.h b/src/messages/MOSDPGScan.h index 99f0b0bdd3f..9ed058e0643 100644 --- a/src/messages/MOSDPGScan.h +++ b/src/messages/MOSDPGScan.h @@ -17,9 +17,7 @@ #include "MOSDFastDispatchOp.h" -class MOSDPGScan : public MessageInstance { -public: - friend factory; +class MOSDPGScan : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 2; @@ -90,10 +88,10 @@ public: } MOSDPGScan() - : MessageInstance(MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION) {} + : MOSDFastDispatchOp{MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION} {} MOSDPGScan(__u32 o, pg_shard_t from, epoch_t e, epoch_t qe, spg_t p, hobject_t be, hobject_t en) - : MessageInstance(MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION}, op(o), map_epoch(e), query_epoch(qe), from(from), @@ -112,6 +110,9 @@ public: << " e " << map_epoch << "/" << query_epoch << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGTemp.h b/src/messages/MOSDPGTemp.h index 22a8602b2f2..3a247bd090c 100644 --- a/src/messages/MOSDPGTemp.h +++ b/src/messages/MOSDPGTemp.h @@ -19,16 +19,14 @@ #include "messages/PaxosServiceMessage.h" -class MOSDPGTemp : public MessageInstance { +class MOSDPGTemp : public PaxosServiceMessage { public: - friend factory; - epoch_t map_epoch = 0; map > pg_temp; bool forced = false; MOSDPGTemp(epoch_t e) - : MessageInstance(MSG_OSD_PGTEMP, e, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{MSG_OSD_PGTEMP, e, HEAD_VERSION, COMPAT_VERSION}, map_epoch(e) {} MOSDPGTemp() @@ -62,6 +60,9 @@ public: private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; + + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGTrim.h b/src/messages/MOSDPGTrim.h index e596d12bde7..22abef8ffb8 100644 --- a/src/messages/MOSDPGTrim.h +++ b/src/messages/MOSDPGTrim.h @@ -18,9 +18,7 @@ #include "msg/Message.h" #include "messages/MOSDPeeringOp.h" -class MOSDPGTrim : public MessageInstance { -public: - friend factory; +class MOSDPGTrim : public MOSDPeeringOp { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 2; @@ -47,9 +45,9 @@ public: MTrim(epoch, get_source().num(), pgid.shard, trim_to)); } - MOSDPGTrim() : MessageInstance(MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION) {} + MOSDPGTrim() : MOSDPeeringOp{MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION} {} MOSDPGTrim(version_t mv, spg_t p, eversion_t tt) : - MessageInstance(MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION), + MOSDPeeringOp{MSG_OSD_PG_TRIM, HEAD_VERSION, COMPAT_VERSION}, epoch(mv), pgid(p), trim_to(tt) { } private: ~MOSDPGTrim() override {} @@ -74,6 +72,9 @@ public: decode(trim_to, p); decode(pgid.shard, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGUpdateLogMissing.h b/src/messages/MOSDPGUpdateLogMissing.h index cbf9485e915..b661e414cef 100644 --- a/src/messages/MOSDPGUpdateLogMissing.h +++ b/src/messages/MOSDPGUpdateLogMissing.h @@ -18,14 +18,11 @@ #include "MOSDFastDispatchOp.h" -class MOSDPGUpdateLogMissing : public MessageInstance { -public: - friend factory; +class MOSDPGUpdateLogMissing : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 1; - public: epoch_t map_epoch = 0, min_epoch = 0; spg_t pgid; @@ -52,8 +49,8 @@ public: } MOSDPGUpdateLogMissing() - : MessageInstance(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION, - COMPAT_VERSION) { } + : MOSDFastDispatchOp{MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION, + COMPAT_VERSION} {} MOSDPGUpdateLogMissing( const mempool::osd_pglog::list &entries, spg_t pgid, @@ -63,8 +60,8 @@ public: ceph_tid_t rep_tid, eversion_t pg_trim_to, eversion_t pg_roll_forward_to) - : MessageInstance(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION, - COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION, + COMPAT_VERSION}, map_epoch(epoch), min_epoch(min_epoch), pgid(pgid), @@ -118,6 +115,9 @@ public: decode(pg_roll_forward_to, p); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPGUpdateLogMissingReply.h b/src/messages/MOSDPGUpdateLogMissingReply.h index 8d7050f2a56..1aa4fb6ab15 100644 --- a/src/messages/MOSDPGUpdateLogMissingReply.h +++ b/src/messages/MOSDPGUpdateLogMissingReply.h @@ -18,9 +18,7 @@ #include "MOSDFastDispatchOp.h" -class MOSDPGUpdateLogMissingReply : public MessageInstance { -public: - friend factory; +class MOSDPGUpdateLogMissingReply : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 1; @@ -52,11 +50,9 @@ public: } MOSDPGUpdateLogMissingReply() - : MessageInstance( - MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY, - HEAD_VERSION, - COMPAT_VERSION) - {} + : MOSDFastDispatchOp{MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY, HEAD_VERSION, + COMPAT_VERSION} + {} MOSDPGUpdateLogMissingReply( spg_t pgid, shard_id_t from, @@ -64,10 +60,8 @@ public: epoch_t min_epoch, ceph_tid_t rep_tid, eversion_t last_complete_ondisk) - : MessageInstance( - MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY, - HEAD_VERSION, - COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY, HEAD_VERSION, + COMPAT_VERSION}, map_epoch(epoch), min_epoch(min_epoch), pgid(pgid), @@ -112,6 +106,9 @@ public: decode(last_complete_ondisk, p); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDPing.h b/src/messages/MOSDPing.h index 6a2693a0df2..520f2416beb 100644 --- a/src/messages/MOSDPing.h +++ b/src/messages/MOSDPing.h @@ -32,9 +32,7 @@ #include "osd/osd_types.h" -class MOSDPing : public MessageInstance { -public: - friend factory; +class MOSDPing : public Message { private: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 4; @@ -64,14 +62,14 @@ private: epoch_t map_epoch = 0; __u8 op = 0; utime_t stamp; - uint32_t min_message_size; + uint32_t min_message_size = 0; MOSDPing(const uuid_d& f, epoch_t e, __u8 o, utime_t s, uint32_t min_message) - : MessageInstance(MSG_OSD_PING, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_OSD_PING, HEAD_VERSION, COMPAT_VERSION}, fsid(f), map_epoch(e), op(o), stamp(s), min_message_size(min_message) { } MOSDPing() - : MessageInstance(MSG_OSD_PING, HEAD_VERSION, COMPAT_VERSION), min_message_size(0) + : Message{MSG_OSD_PING, HEAD_VERSION, COMPAT_VERSION} {} private: ~MOSDPing() override {} @@ -125,6 +123,9 @@ public: << " stamp " << stamp << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDRepOp.h b/src/messages/MOSDRepOp.h index 94fca67b004..bafee6faac0 100644 --- a/src/messages/MOSDRepOp.h +++ b/src/messages/MOSDRepOp.h @@ -22,9 +22,7 @@ * OSD sub op - for internal ops on pobjects between primary and replicas(/stripes/whatever) */ -class MOSDRepOp : public MessageInstance { -public: - friend factory; +class MOSDRepOp : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -143,13 +141,13 @@ public: } MOSDRepOp() - : MessageInstance(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION}, map_epoch(0), final_decode_needed(true), acks_wanted (0) {} MOSDRepOp(osd_reqid_t r, pg_shard_t from, spg_t p, const hobject_t& po, int aw, epoch_t mape, epoch_t min_epoch, ceph_tid_t rtid, eversion_t v) - : MessageInstance(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION}, map_epoch(mape), min_epoch(min_epoch), reqid(r), @@ -176,7 +174,9 @@ public: } out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; - #endif diff --git a/src/messages/MOSDRepOpReply.h b/src/messages/MOSDRepOpReply.h index 3265dcb10f3..ddd90346cc0 100644 --- a/src/messages/MOSDRepOpReply.h +++ b/src/messages/MOSDRepOpReply.h @@ -26,9 +26,7 @@ * */ -class MOSDRepOpReply : public MessageInstance { -public: - friend factory; +class MOSDRepOpReply : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -119,7 +117,7 @@ public: MOSDRepOpReply( const MOSDRepOp *req, pg_shard_t from, int result_, epoch_t e, epoch_t mine, int at) : - MessageInstance(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION), + MOSDFastDispatchOp{MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION}, map_epoch(e), min_epoch(mine), reqid(req->reqid), @@ -131,7 +129,7 @@ public: set_tid(req->get_tid()); } MOSDRepOpReply() - : MessageInstance(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION}, map_epoch(0), min_epoch(0), ack_type(0), result(0), @@ -157,7 +155,9 @@ public: out << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; - #endif diff --git a/src/messages/MOSDRepScrub.h b/src/messages/MOSDRepScrub.h index 40867bedc66..6afbd4eb693 100644 --- a/src/messages/MOSDRepScrub.h +++ b/src/messages/MOSDRepScrub.h @@ -22,10 +22,8 @@ * instruct an OSD initiate a replica scrub on a specific PG */ -class MOSDRepScrub : public MessageInstance { +class MOSDRepScrub : public MOSDFastDispatchOp { public: - friend factory; - static constexpr int HEAD_VERSION = 9; static constexpr int COMPAT_VERSION = 6; @@ -52,14 +50,14 @@ public: } MOSDRepScrub() - : MessageInstance(MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION}, chunky(false), deep(false) { } MOSDRepScrub(spg_t pgid, eversion_t scrub_to, epoch_t map_epoch, epoch_t min_epoch, hobject_t start, hobject_t end, bool deep, bool preemption, int prio, bool highprio) - : MessageInstance(MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION}, pgid(pgid), scrub_to(scrub_to), map_epoch(map_epoch), diff --git a/src/messages/MOSDRepScrubMap.h b/src/messages/MOSDRepScrubMap.h index 984ebb4ffa6..4e46672102a 100644 --- a/src/messages/MOSDRepScrubMap.h +++ b/src/messages/MOSDRepScrubMap.h @@ -21,10 +21,8 @@ * pass a ScrubMap from a shard back to the primary */ -class MOSDRepScrubMap : public MessageInstance { +class MOSDRepScrubMap : public MOSDFastDispatchOp { public: - friend factory; - static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -42,10 +40,10 @@ public: } MOSDRepScrubMap() - : MessageInstance(MSG_OSD_REP_SCRUBMAP, HEAD_VERSION, COMPAT_VERSION) {} + : MOSDFastDispatchOp{MSG_OSD_REP_SCRUBMAP, HEAD_VERSION, COMPAT_VERSION} {} MOSDRepScrubMap(spg_t pgid, epoch_t map_epoch, pg_shard_t from) - : MessageInstance(MSG_OSD_REP_SCRUBMAP, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_REP_SCRUBMAP, HEAD_VERSION, COMPAT_VERSION}, pgid(pgid), map_epoch(map_epoch), from(from) {} @@ -77,7 +75,9 @@ public: decode(preempted, p); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; - #endif diff --git a/src/messages/MOSDScrub.h b/src/messages/MOSDScrub.h index 8df546701ea..646e5e33f52 100644 --- a/src/messages/MOSDScrub.h +++ b/src/messages/MOSDScrub.h @@ -22,10 +22,8 @@ * instruct an OSD to scrub some or all pg(s) */ -class MOSDScrub : public MessageInstance { +class MOSDScrub : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 2; @@ -34,12 +32,12 @@ public: bool repair = false; bool deep = false; - MOSDScrub() : MessageInstance(MSG_OSD_SCRUB, HEAD_VERSION, COMPAT_VERSION) {} + MOSDScrub() : Message{MSG_OSD_SCRUB, HEAD_VERSION, COMPAT_VERSION} {} MOSDScrub(const uuid_d& f, bool r, bool d) : - MessageInstance(MSG_OSD_SCRUB, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_OSD_SCRUB, HEAD_VERSION, COMPAT_VERSION}, fsid(f), repair(r), deep(d) {} MOSDScrub(const uuid_d& f, vector& pgs, bool r, bool d) : - MessageInstance(MSG_OSD_SCRUB, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_OSD_SCRUB, HEAD_VERSION, COMPAT_VERSION}, fsid(f), scrub_pgs(pgs), repair(r), deep(d) {} private: ~MOSDScrub() override {} @@ -73,6 +71,9 @@ public: decode(repair, p); decode(deep, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MOSDScrub2.h b/src/messages/MOSDScrub2.h index 98fb0f31a1d..d5156110629 100644 --- a/src/messages/MOSDScrub2.h +++ b/src/messages/MOSDScrub2.h @@ -9,10 +9,8 @@ * instruct an OSD to scrub some or all pg(s) */ -class MOSDScrub2 : public MessageInstance { +class MOSDScrub2 : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -22,9 +20,9 @@ public: bool repair = false; bool deep = false; - MOSDScrub2() : MessageInstance(MSG_OSD_SCRUB2, HEAD_VERSION, COMPAT_VERSION) {} + MOSDScrub2() : Message{MSG_OSD_SCRUB2, HEAD_VERSION, COMPAT_VERSION} {} MOSDScrub2(const uuid_d& f, epoch_t e, vector& pgs, bool r, bool d) : - MessageInstance(MSG_OSD_SCRUB2, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_OSD_SCRUB2, HEAD_VERSION, COMPAT_VERSION}, fsid(f), epoch(e), scrub_pgs(pgs), repair(r), deep(d) {} private: ~MOSDScrub2() override {} @@ -56,4 +54,7 @@ public: decode(repair, p); decode(deep, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MOSDScrubReserve.h b/src/messages/MOSDScrubReserve.h index a75796f9ae8..7f3eb64f1f4 100644 --- a/src/messages/MOSDScrubReserve.h +++ b/src/messages/MOSDScrubReserve.h @@ -17,9 +17,7 @@ #include "MOSDFastDispatchOp.h" -class MOSDScrubReserve : public MessageInstance { -public: - friend factory; +class MOSDScrubReserve : public MOSDFastDispatchOp { private: static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -43,13 +41,13 @@ public: } MOSDScrubReserve() - : MessageInstance(MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION}, map_epoch(0), type(-1) {} MOSDScrubReserve(spg_t pgid, epoch_t map_epoch, int type, pg_shard_t from) - : MessageInstance(MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION), + : MOSDFastDispatchOp{MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION}, pgid(pgid), map_epoch(map_epoch), type(type), from(from) {} @@ -92,6 +90,9 @@ public: encode(type, payload); encode(from, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MPGStats.h b/src/messages/MPGStats.h index dc4bd0a9c71..a605c95dcd8 100644 --- a/src/messages/MPGStats.h +++ b/src/messages/MPGStats.h @@ -18,21 +18,20 @@ #include "osd/osd_types.h" #include "messages/PaxosServiceMessage.h" -class MPGStats : public MessageInstance { +class MPGStats : public PaxosServiceMessage { static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; -public: - friend factory; +public: uuid_d fsid; std::map pg_stat; osd_stat_t osd_stat; std::map pool_stat; epoch_t epoch = 0; - MPGStats() : MessageInstance(MSG_PGSTATS, 0, HEAD_VERSION, COMPAT_VERSION) {} + MPGStats() : PaxosServiceMessage{MSG_PGSTATS, 0, HEAD_VERSION, COMPAT_VERSION} {} MPGStats(const uuid_d& f, epoch_t e) - : MessageInstance(MSG_PGSTATS, 0, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{MSG_PGSTATS, 0, HEAD_VERSION, COMPAT_VERSION}, fsid(f), epoch(e) {} diff --git a/src/messages/MPGStatsAck.h b/src/messages/MPGStatsAck.h index 5fe78bfc00e..5afbab580dd 100644 --- a/src/messages/MPGStatsAck.h +++ b/src/messages/MPGStatsAck.h @@ -17,13 +17,11 @@ #include "osd/osd_types.h" -class MPGStatsAck : public MessageInstance { +class MPGStatsAck : public Message { public: - friend factory; - map > pg_stat; - MPGStatsAck() : MessageInstance(MSG_PGSTATSACK) {} + MPGStatsAck() : Message{MSG_PGSTATSACK} {} private: ~MPGStatsAck() override {} @@ -42,6 +40,9 @@ public: auto p = payload.cbegin(); decode(pg_stat, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MPing.h b/src/messages/MPing.h index 4175a1d51fb..82730095cc4 100644 --- a/src/messages/MPing.h +++ b/src/messages/MPing.h @@ -18,11 +18,9 @@ #include "msg/Message.h" -class MPing : public MessageInstance { +class MPing : public Message { public: - friend factory; - - MPing() : MessageInstance(CEPH_MSG_PING) {} + MPing() : Message{CEPH_MSG_PING} {} private: ~MPing() override {} diff --git a/src/messages/MPoolOp.h b/src/messages/MPoolOp.h index 6fddc2638ec..bc46f93d1ff 100644 --- a/src/messages/MPoolOp.h +++ b/src/messages/MPoolOp.h @@ -18,9 +18,7 @@ #include "messages/PaxosServiceMessage.h" -class MPoolOp : public MessageInstance { -public: - friend factory; +class MPoolOp : public PaxosServiceMessage { private: static constexpr int HEAD_VERSION = 4; static constexpr int COMPAT_VERSION = 2; @@ -34,9 +32,9 @@ public: __s16 crush_rule = 0; MPoolOp() - : MessageInstance(CEPH_MSG_POOLOP, 0, HEAD_VERSION, COMPAT_VERSION) { } + : PaxosServiceMessage{CEPH_MSG_POOLOP, 0, HEAD_VERSION, COMPAT_VERSION} {} MPoolOp(const uuid_d& f, ceph_tid_t t, int p, std::string& n, int o, version_t v) - : MessageInstance(CEPH_MSG_POOLOP, v, HEAD_VERSION, COMPAT_VERSION), + : PaxosServiceMessage{CEPH_MSG_POOLOP, v, HEAD_VERSION, COMPAT_VERSION}, fsid(f), pool(p), name(n), op(o), snapid(0), crush_rule(0) { set_tid(t); @@ -92,6 +90,9 @@ public: } else crush_rule = -1; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MPoolOpReply.h b/src/messages/MPoolOpReply.h index f4584e1d2f4..df06525db78 100644 --- a/src/messages/MPoolOpReply.h +++ b/src/messages/MPoolOpReply.h @@ -17,19 +17,17 @@ #include "common/errno.h" -class MPoolOpReply : public MessageInstance { +class MPoolOpReply : public PaxosServiceMessage { public: - friend factory; - uuid_d fsid; __u32 replyCode = 0; epoch_t epoch = 0; ceph::buffer::list response_data; - MPoolOpReply() : MessageInstance(CEPH_MSG_POOLOP_REPLY, 0) + MPoolOpReply() : PaxosServiceMessage{CEPH_MSG_POOLOP_REPLY, 0} {} MPoolOpReply( uuid_d& f, ceph_tid_t t, int rc, int e, version_t v) : - MessageInstance(CEPH_MSG_POOLOP_REPLY, v), + PaxosServiceMessage{CEPH_MSG_POOLOP_REPLY, v}, fsid(f), replyCode(rc), epoch(e) { @@ -37,7 +35,7 @@ public: } MPoolOpReply(uuid_d& f, ceph_tid_t t, int rc, int e, version_t v, ceph::buffer::list *blp) : - MessageInstance(CEPH_MSG_POOLOP_REPLY, v), + PaxosServiceMessage{CEPH_MSG_POOLOP_REPLY, v}, fsid(f), replyCode(rc), epoch(e) { @@ -79,6 +77,9 @@ public: decode(response_data, p); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MRecoveryReserve.h b/src/messages/MRecoveryReserve.h index 2dc7d6c37c4..5c375601ba9 100644 --- a/src/messages/MRecoveryReserve.h +++ b/src/messages/MRecoveryReserve.h @@ -18,9 +18,7 @@ #include "msg/Message.h" #include "messages/MOSDPeeringOp.h" -class MRecoveryReserve : public MessageInstance { -public: - friend factory; +class MRecoveryReserve : public MOSDPeeringOp { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 2; @@ -74,13 +72,13 @@ public: } MRecoveryReserve() - : MessageInstance(MSG_OSD_RECOVERY_RESERVE, HEAD_VERSION, COMPAT_VERSION), + : MOSDPeeringOp{MSG_OSD_RECOVERY_RESERVE, HEAD_VERSION, COMPAT_VERSION}, query_epoch(0), type(-1) {} MRecoveryReserve(int type, spg_t pgid, epoch_t query_epoch, unsigned prio = 0) - : MessageInstance(MSG_OSD_RECOVERY_RESERVE, HEAD_VERSION, COMPAT_VERSION), + : MOSDPeeringOp{MSG_OSD_RECOVERY_RESERVE, HEAD_VERSION, COMPAT_VERSION}, pgid(pgid), query_epoch(query_epoch), type(type), priority(prio) {} @@ -125,6 +123,9 @@ public: encode(pgid.shard, payload); encode(priority, payload); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MRemoveSnaps.h b/src/messages/MRemoveSnaps.h index 96f1f2df722..c70aaf653a5 100644 --- a/src/messages/MRemoveSnaps.h +++ b/src/messages/MRemoveSnaps.h @@ -17,17 +17,15 @@ #include "messages/PaxosServiceMessage.h" -class MRemoveSnaps : public MessageInstance { +class MRemoveSnaps : public PaxosServiceMessage { public: - friend factory; - map > snaps; protected: MRemoveSnaps() : - MessageInstance(MSG_REMOVE_SNAPS, 0) { } + PaxosServiceMessage{MSG_REMOVE_SNAPS, 0} { } MRemoveSnaps(map >& s) : - MessageInstance(MSG_REMOVE_SNAPS, 0) { + PaxosServiceMessage{MSG_REMOVE_SNAPS, 0} { snaps.swap(s); } ~MRemoveSnaps() override {} @@ -49,7 +47,9 @@ public: decode(snaps, p); ceph_assert(p.end()); } - +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MRoute.h b/src/messages/MRoute.h index d0cf441e339..90f36ef49c5 100644 --- a/src/messages/MRoute.h +++ b/src/messages/MRoute.h @@ -20,10 +20,8 @@ #include "msg/Message.h" #include "include/encoding.h" -class MRoute : public MessageInstance { +class MRoute : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 3; @@ -31,12 +29,12 @@ public: Message *msg; epoch_t send_osdmap_first; - MRoute() : MessageInstance(MSG_ROUTE, HEAD_VERSION, COMPAT_VERSION), + MRoute() : Message{MSG_ROUTE, HEAD_VERSION, COMPAT_VERSION}, session_mon_tid(0), msg(NULL), send_osdmap_first(0) {} MRoute(uint64_t t, Message *m) - : MessageInstance(MSG_ROUTE, HEAD_VERSION, COMPAT_VERSION), + : Message{MSG_ROUTE, HEAD_VERSION, COMPAT_VERSION}, session_mon_tid(t), msg(m), send_osdmap_first(0) {} @@ -83,6 +81,9 @@ public: else o << " tid (none)"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MServiceMap.h b/src/messages/MServiceMap.h index 275acfcd342..45d50b67b69 100644 --- a/src/messages/MServiceMap.h +++ b/src/messages/MServiceMap.h @@ -6,15 +6,13 @@ #include "msg/Message.h" #include "mgr/ServiceMap.h" -class MServiceMap : public MessageInstance { +class MServiceMap : public Message { public: - friend factory; - ServiceMap service_map; - MServiceMap() : MessageInstance(MSG_SERVICE_MAP) { } + MServiceMap() : Message{MSG_SERVICE_MAP} { } explicit MServiceMap(const ServiceMap& sm) - : MessageInstance(MSG_SERVICE_MAP), + : Message{MSG_SERVICE_MAP}, service_map(sm) { } private: @@ -34,4 +32,7 @@ public: auto p = payload.cbegin(); decode(service_map, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MStatfs.h b/src/messages/MStatfs.h index f7b060bdd5b..bb5810fd0a8 100644 --- a/src/messages/MStatfs.h +++ b/src/messages/MStatfs.h @@ -19,9 +19,7 @@ #include /* or */ #include "messages/PaxosServiceMessage.h" -class MStatfs : public MessageInstance { -public: - friend factory; +class MStatfs : public PaxosServiceMessage { private: static constexpr int HEAD_VERSION = 2; static constexpr int COMPAT_VERSION = 1; @@ -30,11 +28,11 @@ public: uuid_d fsid; boost::optional data_pool; - MStatfs() : MessageInstance(CEPH_MSG_STATFS, 0, HEAD_VERSION, COMPAT_VERSION) {} + MStatfs() : PaxosServiceMessage{CEPH_MSG_STATFS, 0, HEAD_VERSION, COMPAT_VERSION} {} MStatfs(const uuid_d& f, ceph_tid_t t, boost::optional _data_pool, - version_t v) : MessageInstance(CEPH_MSG_STATFS, v, - HEAD_VERSION, COMPAT_VERSION), - fsid(f), data_pool(_data_pool) { + version_t v) + : PaxosServiceMessage{CEPH_MSG_STATFS, v, HEAD_VERSION, COMPAT_VERSION}, + fsid(f), data_pool(_data_pool) { set_tid(t); } @@ -65,6 +63,9 @@ public: data_pool = boost::optional (); } } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MStatfsReply.h b/src/messages/MStatfsReply.h index 181c2c64cc6..3bdcfe0a75c 100644 --- a/src/messages/MStatfsReply.h +++ b/src/messages/MStatfsReply.h @@ -16,14 +16,13 @@ #ifndef CEPH_MSTATFSREPLY_H #define CEPH_MSTATFSREPLY_H -class MStatfsReply : public MessageInstance { +class MStatfsReply : public Message { public: - friend factory; - struct ceph_mon_statfs_reply h{}; - MStatfsReply() : MessageInstance(CEPH_MSG_STATFS_REPLY) {} - MStatfsReply(uuid_d &f, ceph_tid_t t, epoch_t epoch) : MessageInstance(CEPH_MSG_STATFS_REPLY) { + MStatfsReply() : Message{CEPH_MSG_STATFS_REPLY} {} + MStatfsReply(uuid_d &f, ceph_tid_t t, epoch_t epoch) + : Message{CEPH_MSG_STATFS_REPLY} { memcpy(&h.fsid, f.bytes(), sizeof(h.fsid)); header.tid = t; h.version = epoch; @@ -42,6 +41,9 @@ public: auto p = payload.cbegin(); decode(h, p); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/messages/MTimeCheck.h b/src/messages/MTimeCheck.h index 994c6dd8bb5..fe96f5a0f11 100644 --- a/src/messages/MTimeCheck.h +++ b/src/messages/MTimeCheck.h @@ -15,10 +15,8 @@ #ifndef CEPH_MTIMECHECK_H #define CEPH_MTIMECHECK_H -class MTimeCheck : public MessageInstance { +class MTimeCheck : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 1; enum { @@ -35,14 +33,14 @@ public: map skews; map latencies; - MTimeCheck() : MessageInstance(MSG_TIMECHECK, HEAD_VERSION) { } + MTimeCheck() : Message{MSG_TIMECHECK, HEAD_VERSION} {} MTimeCheck(int op) : - MessageInstance(MSG_TIMECHECK, HEAD_VERSION), + Message{MSG_TIMECHECK, HEAD_VERSION}, op(op) - { } + {} private: - ~MTimeCheck() override { } + ~MTimeCheck() override {} public: std::string_view get_type_name() const override { return "time_check"; } @@ -85,6 +83,9 @@ public: encode(skews, payload, features); encode(latencies, payload, features); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif /* CEPH_MTIMECHECK_H */ diff --git a/src/messages/MTimeCheck2.h b/src/messages/MTimeCheck2.h index 1d93fcc916c..32f089c0926 100644 --- a/src/messages/MTimeCheck2.h +++ b/src/messages/MTimeCheck2.h @@ -14,10 +14,8 @@ #pragma once -class MTimeCheck2 : public MessageInstance { +class MTimeCheck2 : public Message { public: - friend factory; - static constexpr int HEAD_VERSION = 1; static constexpr int COMPAT_VERSION = 1; @@ -35,9 +33,9 @@ public: map skews; map latencies; - MTimeCheck2() : MessageInstance(MSG_TIMECHECK2, HEAD_VERSION, COMPAT_VERSION) { } + MTimeCheck2() : Message{MSG_TIMECHECK2, HEAD_VERSION, COMPAT_VERSION} { } MTimeCheck2(int op) : - MessageInstance(MSG_TIMECHECK2, HEAD_VERSION, COMPAT_VERSION), + Message{MSG_TIMECHECK2, HEAD_VERSION, COMPAT_VERSION}, op(op) { } @@ -85,4 +83,7 @@ public: encode(skews, payload, features); encode(latencies, payload, features); } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; diff --git a/src/messages/MWatchNotify.h b/src/messages/MWatchNotify.h index 63b4350c4f0..7a31ec8c56b 100644 --- a/src/messages/MWatchNotify.h +++ b/src/messages/MWatchNotify.h @@ -19,9 +19,7 @@ #include "msg/Message.h" -class MWatchNotify : public MessageInstance { -public: - friend factory; +class MWatchNotify : public Message { private: static constexpr int HEAD_VERSION = 3; static constexpr int COMPAT_VERSION = 1; @@ -36,9 +34,9 @@ private: uint64_t notifier_gid; ///< who sent the notify MWatchNotify() - : MessageInstance(CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION) { } + : Message{CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION} { } MWatchNotify(uint64_t c, uint64_t v, uint64_t i, uint8_t o, ceph::buffer::list b) - : MessageInstance(CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION), + : Message{CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION}, cookie(c), ver(v), notify_id(i), @@ -92,6 +90,9 @@ public: << " ret " << return_code << ")"; } +private: + template + friend boost::intrusive_ptr ceph::make_message(Args&&... args); }; #endif diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 0c47cfcd2ee..de867c620d7 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -2767,7 +2767,7 @@ void DaemonServer::_send_configure(ConnectionRef c) { ceph_assert(lock.is_locked_by_me()); - auto configure = new MMgrConfigure(); + auto configure = make_message(); configure->stats_period = g_conf().get_val("mgr_stats_period"); configure->stats_threshold = g_conf().get_val("mgr_stats_threshold"); @@ -2776,7 +2776,7 @@ void DaemonServer::_send_configure(ConnectionRef c) osd_perf_metric_collector.get_queries(); } - c->send_message(configure); + c->send_message2(configure); } OSDPerfMetricQueryID DaemonServer::add_osd_perf_query( diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 9ece47bbb92..d2ecd02ee22 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -184,7 +184,7 @@ void MgrClient::reconnect() void MgrClient::_send_open() { if (session && session->con) { - auto open = new MMgrOpen(); + auto open = make_message(); if (!service_name.empty()) { open->service_name = service_name; open->daemon_name = daemon_name; @@ -197,7 +197,7 @@ void MgrClient::_send_open() } cct->_conf.get_config_bl(0, &open->config_bl, &last_config_bl_version); cct->_conf.get_defaults_bl(&open->config_defaults_bl); - session->con->send_message(open); + session->con->send_message2(open); } } @@ -258,7 +258,7 @@ void MgrClient::_send_report() ceph_assert(session); report_callback = nullptr; - auto report = new MMgrReport(); + auto report = make_message(); auto pcc = cct->get_perfcounters_collection(); pcc->with_counters([this, report]( @@ -359,7 +359,7 @@ void MgrClient::_send_report() get_perf_report_cb(&report->osd_perf_metric_reports); } - session->con->send_message(report); + session->con->send_message2(report); } void MgrClient::send_pgstats() diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 6258c20f861..66903ec9b57 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -379,7 +379,7 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op) MDSMap null_map; null_map.epoch = fsmap.epoch; null_map.compat = fsmap.compat; - auto m = MMDSMap::create(mon->monmap->fsid, null_map); + auto m = make_message(mon->monmap->fsid, null_map); mon->send_reply(op, m.detach()); return true; } else { @@ -455,7 +455,7 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op) ceph_assert(effective_epoch > 0); _note_beacon(m); { - auto beacon = MMDSBeacon::create(mon->monmap->fsid, + auto beacon = make_message(mon->monmap->fsid, m->get_global_id(), m->get_name(), effective_epoch, state, seq, CEPH_FEATURES_SUPPORTED_DEFAULT); mon->send_reply(op, beacon.detach()); @@ -645,7 +645,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) MDSMap null_map; null_map.epoch = fsmap.epoch; null_map.compat = fsmap.compat; - auto m = MMDSMap::create(mon->monmap->fsid, null_map); + auto m = make_message(mon->monmap->fsid, null_map); mon->send_reply(op, m.detach()); } else { dispatch(op); // try again @@ -720,7 +720,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) last_beacon.erase(gid); // Respond to MDS, so that it knows it can continue to shut down - auto beacon = MMDSBeacon::create( + auto beacon = make_message( mon->monmap->fsid, m->get_global_id(), m->get_name(), pending.get_epoch(), state, seq, CEPH_FEATURES_SUPPORTED_DEFAULT); @@ -738,7 +738,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) request_proposal(mon->osdmon()); // Respond to MDS, so that it knows it can continue to shut down - auto beacon = MMDSBeacon::create(mon->monmap->fsid, + auto beacon = make_message(mon->monmap->fsid, m->get_global_id(), m->get_name(), pending.get_epoch(), state, seq, CEPH_FEATURES_SUPPORTED_DEFAULT); mon->send_reply(op, beacon.detach()); @@ -828,10 +828,10 @@ void MDSMonitor::_updated(MonOpRequestRef op) MDSMap null_map; null_map.epoch = fsmap.epoch; null_map.compat = fsmap.compat; - auto m = MMDSMap::create(mon->monmap->fsid, null_map); + auto m = make_message(mon->monmap->fsid, null_map); mon->send_reply(op, m.detach()); } else { - auto beacon = MMDSBeacon::create(mon->monmap->fsid, + auto beacon = make_message(mon->monmap->fsid, m->get_global_id(), m->get_name(), fsmap.get_epoch(), m->get_state(), m->get_seq(), CEPH_FEATURES_SUPPORTED_DEFAULT); mon->send_reply(op, beacon.detach()); @@ -1647,7 +1647,7 @@ void MDSMonitor::check_sub(Subscription *sub) if (sub->next > mds_map->epoch) { return; } - auto msg = MMDSMap::create(mon->monmap->fsid, *mds_map); + auto msg = make_message(mon->monmap->fsid, *mds_map); sub->session->con->send_message(msg.detach()); if (sub->onetime) { diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 453ac87aaaf..a9f935d29a1 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -584,7 +584,7 @@ void MgrMonitor::check_sub(Subscription *sub) if (sub->next <= map.get_epoch()) { dout(20) << "Sending map to subscriber " << sub->session->con << " " << sub->session->con->get_peer_addr() << dendl; - sub->session->con->send_message(new MMgrMap(map)); + sub->session->con->send_message2(make_message(map)); if (sub->onetime) { mon->session_map.remove_sub(sub); } else { @@ -626,7 +626,7 @@ void MgrMonitor::send_digests() for (auto sub : *(mon->session_map.subs[type])) { dout(10) << __func__ << " sending digest to subscriber " << sub->session->con << " " << sub->session->con->get_peer_addr() << dendl; - MMgrDigest *mdigest = new MMgrDigest; + auto mdigest = make_message(); JSONFormatter f; mon->get_health_status(true, &f, nullptr, nullptr, nullptr); @@ -638,7 +638,7 @@ void MgrMonitor::send_digests() f.flush(mdigest->mon_status_json); f.reset(); - sub->session->con->send_message(mdigest); + sub->session->con->send_message2(mdigest); } timer: diff --git a/src/msg/Message.cc b/src/msg/Message.cc index 77a65f005ae..b091da2b387 100644 --- a/src/msg/Message.cc +++ b/src/msg/Message.cc @@ -338,510 +338,510 @@ Message *decode_message(CephContext *cct, int crcflags, // -- with payload -- case MSG_PGSTATS: - m = MPGStats::create(); + m = make_message(); break; case MSG_PGSTATSACK: - m = MPGStatsAck::create(); + m = make_message(); break; case CEPH_MSG_STATFS: - m = MStatfs::create(); + m = make_message(); break; case CEPH_MSG_STATFS_REPLY: - m = MStatfsReply::create(); + m = make_message(); break; case MSG_GETPOOLSTATS: - m = MGetPoolStats::create(); + m = make_message(); break; case MSG_GETPOOLSTATSREPLY: - m = MGetPoolStatsReply::create(); + m = make_message(); break; case CEPH_MSG_POOLOP: - m = MPoolOp::create(); + m = make_message(); break; case CEPH_MSG_POOLOP_REPLY: - m = MPoolOpReply::create(); + m = make_message(); break; case MSG_MON_COMMAND: - m = MMonCommand::create(); + m = make_message(); break; case MSG_MON_COMMAND_ACK: - m = MMonCommandAck::create(); + m = make_message(); break; case MSG_MON_PAXOS: - m = MMonPaxos::create(); + m = make_message(); break; case MSG_CONFIG: - m = MConfig::create(); + m = make_message(); break; case MSG_GET_CONFIG: - m = MGetConfig::create(); + m = make_message(); break; case MSG_MON_PROBE: - m = MMonProbe::create(); + m = make_message(); break; case MSG_MON_JOIN: - m = MMonJoin::create(); + m = make_message(); break; case MSG_MON_ELECTION: - m = MMonElection::create(); + m = make_message(); break; case MSG_MON_SYNC: - m = MMonSync::create(); + m = make_message(); break; case MSG_MON_SCRUB: - m = MMonScrub::create(); + m = make_message(); break; case MSG_LOG: - m = MLog::create(); + m = make_message(); break; case MSG_LOGACK: - m = MLogAck::create(); + m = make_message(); break; case CEPH_MSG_PING: - m = MPing::create(); + m = make_message(); break; case MSG_COMMAND: - m = MCommand::create(); + m = make_message(); break; case MSG_COMMAND_REPLY: - m = MCommandReply::create(); + m = make_message(); break; case MSG_OSD_BACKFILL_RESERVE: - m = MBackfillReserve::create(); + m = make_message(); break; case MSG_OSD_RECOVERY_RESERVE: - m = MRecoveryReserve::create(); + m = make_message(); break; case MSG_OSD_FORCE_RECOVERY: - m = MOSDForceRecovery::create(); + m = make_message(); break; case MSG_ROUTE: - m = MRoute::create(); + m = make_message(); break; case MSG_FORWARD: - m = MForward::create(); + m = make_message(); break; case CEPH_MSG_MON_MAP: - m = MMonMap::create(); + m = make_message(); break; case CEPH_MSG_MON_GET_MAP: - m = MMonGetMap::create(); + m = make_message(); break; case CEPH_MSG_MON_GET_OSDMAP: - m = MMonGetOSDMap::create(); + m = make_message(); break; case CEPH_MSG_MON_GET_VERSION: - m = MMonGetVersion::create(); + m = make_message(); break; case CEPH_MSG_MON_GET_VERSION_REPLY: - m = MMonGetVersionReply::create(); + m = make_message(); break; case CEPH_MSG_MON_METADATA: - m = MMonMetadata::create(); + m = make_message(); break; case MSG_OSD_BOOT: - m = MOSDBoot::create(); + m = make_message(); break; case MSG_OSD_ALIVE: - m = MOSDAlive::create(); + m = make_message(); break; case MSG_OSD_BEACON: - m = MOSDBeacon::create(); + m = make_message(); break; case MSG_OSD_PGTEMP: - m = MOSDPGTemp::create(); + m = make_message(); break; case MSG_OSD_FAILURE: - m = MOSDFailure::create(); + m = make_message(); break; case MSG_OSD_MARK_ME_DOWN: - m = MOSDMarkMeDown::create(); + m = make_message(); break; case MSG_OSD_FULL: - m = MOSDFull::create(); + m = make_message(); break; case MSG_OSD_PING: - m = MOSDPing::create(); + m = make_message(); break; case CEPH_MSG_OSD_OP: - m = MOSDOp::create(); + m = make_message(); break; case CEPH_MSG_OSD_OPREPLY: - m = MOSDOpReply::create(); + m = make_message(); break; case MSG_OSD_REPOP: - m = MOSDRepOp::create(); + m = make_message(); break; case MSG_OSD_REPOPREPLY: - m = MOSDRepOpReply::create(); + m = make_message(); break; case MSG_OSD_PG_CREATED: - m = MOSDPGCreated::create(); + m = make_message(); break; case MSG_OSD_PG_UPDATE_LOG_MISSING: - m = MOSDPGUpdateLogMissing::create(); + m = make_message(); break; case MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY: - m = MOSDPGUpdateLogMissingReply::create(); + m = make_message(); break; case CEPH_MSG_OSD_BACKOFF: - m = MOSDBackoff::create(); + m = make_message(); break; case CEPH_MSG_OSD_MAP: - m = MOSDMap::create(); + m = make_message(); break; case CEPH_MSG_WATCH_NOTIFY: - m = MWatchNotify::create(); + m = make_message(); break; case MSG_OSD_PG_NOTIFY: - m = MOSDPGNotify::create(); + m = make_message(); break; case MSG_OSD_PG_QUERY: - m = MOSDPGQuery::create(); + m = make_message(); break; case MSG_OSD_PG_LOG: - m = MOSDPGLog::create(); + m = make_message(); break; case MSG_OSD_PG_REMOVE: - m = MOSDPGRemove::create(); + m = make_message(); break; case MSG_OSD_PG_INFO: - m = MOSDPGInfo::create(); + m = make_message(); break; case MSG_OSD_PG_CREATE: - m = MOSDPGCreate::create(); + m = make_message(); break; case MSG_OSD_PG_CREATE2: - m = MOSDPGCreate2::create(); + m = make_message(); break; case MSG_OSD_PG_TRIM: - m = MOSDPGTrim::create(); + m = make_message(); break; case MSG_OSD_SCRUB: - m = MOSDScrub::create(); + m = make_message(); break; case MSG_OSD_SCRUB2: - m = MOSDScrub2::create(); + m = make_message(); break; case MSG_OSD_SCRUB_RESERVE: - m = MOSDScrubReserve::create(); + m = make_message(); break; case MSG_REMOVE_SNAPS: - m = MRemoveSnaps::create(); + m = make_message(); break; case MSG_OSD_REP_SCRUB: - m = MOSDRepScrub::create(); + m = make_message(); break; case MSG_OSD_REP_SCRUBMAP: - m = MOSDRepScrubMap::create(); + m = make_message(); break; case MSG_OSD_PG_SCAN: - m = MOSDPGScan::create(); + m = make_message(); break; case MSG_OSD_PG_BACKFILL: - m = MOSDPGBackfill::create(); + m = make_message(); break; case MSG_OSD_PG_BACKFILL_REMOVE: - m = MOSDPGBackfillRemove::create(); + m = make_message(); break; case MSG_OSD_PG_PUSH: - m = MOSDPGPush::create(); + m = make_message(); break; case MSG_OSD_PG_PULL: - m = MOSDPGPull::create(); + m = make_message(); break; case MSG_OSD_PG_PUSH_REPLY: - m = MOSDPGPushReply::create(); + m = make_message(); break; case MSG_OSD_PG_RECOVERY_DELETE: - m = MOSDPGRecoveryDelete::create(); + m = make_message(); break; case MSG_OSD_PG_RECOVERY_DELETE_REPLY: - m = MOSDPGRecoveryDeleteReply::create(); + m = make_message(); break; case MSG_OSD_PG_READY_TO_MERGE: - m = MOSDPGReadyToMerge::create(); + m = make_message(); break; case MSG_OSD_EC_WRITE: - m = MOSDECSubOpWrite::create(); + m = make_message(); break; case MSG_OSD_EC_WRITE_REPLY: - m = MOSDECSubOpWriteReply::create(); + m = make_message(); break; case MSG_OSD_EC_READ: - m = MOSDECSubOpRead::create(); + m = make_message(); break; case MSG_OSD_EC_READ_REPLY: - m = MOSDECSubOpReadReply::create(); + m = make_message(); break; // auth case CEPH_MSG_AUTH: - m = MAuth::create(); + m = make_message(); break; case CEPH_MSG_AUTH_REPLY: - m = MAuthReply::create(); + m = make_message(); break; case MSG_MON_GLOBAL_ID: - m = MMonGlobalID::create(); + m = make_message(); break; // clients case CEPH_MSG_MON_SUBSCRIBE: - m = MMonSubscribe::create(); + m = make_message(); break; case CEPH_MSG_MON_SUBSCRIBE_ACK: - m = MMonSubscribeAck::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_SESSION: - m = MClientSession::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_RECONNECT: - m = MClientReconnect::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_REQUEST: - m = MClientRequest::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_REQUEST_FORWARD: - m = MClientRequestForward::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_REPLY: - m = MClientReply::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_RECLAIM: - m = MClientReclaim::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_RECLAIM_REPLY: - m = MClientReclaimReply::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_CAPS: - m = MClientCaps::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_CAPRELEASE: - m = MClientCapRelease::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_LEASE: - m = MClientLease::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_SNAP: - m = MClientSnap::create(); + m = make_message(); break; case CEPH_MSG_CLIENT_QUOTA: - m = MClientQuota::create(); + m = make_message(); break; // mds case MSG_MDS_SLAVE_REQUEST: - m = MMDSSlaveRequest::create(); + m = make_message(); break; case CEPH_MSG_MDS_MAP: - m = MMDSMap::create(); + m = make_message(); break; case CEPH_MSG_FS_MAP: - m = MFSMap::create(); + m = make_message(); break; case CEPH_MSG_FS_MAP_USER: - m = MFSMapUser::create(); + m = make_message(); break; case MSG_MDS_BEACON: - m = MMDSBeacon::create(); + m = make_message(); break; case MSG_MDS_OFFLOAD_TARGETS: - m = MMDSLoadTargets::create(); + m = make_message(); break; case MSG_MDS_RESOLVE: - m = MMDSResolve::create(); + m = make_message(); break; case MSG_MDS_RESOLVEACK: - m = MMDSResolveAck::create(); + m = make_message(); break; case MSG_MDS_CACHEREJOIN: - m = MMDSCacheRejoin::create(); + m = make_message(); break; case MSG_MDS_DIRUPDATE: - m = MDirUpdate::create(); + m = make_message(); break; case MSG_MDS_DISCOVER: - m = MDiscover::create(); + m = make_message(); break; case MSG_MDS_DISCOVERREPLY: - m = MDiscoverReply::create(); + m = make_message(); break; case MSG_MDS_FINDINO: - m = MMDSFindIno::create(); + m = make_message(); break; case MSG_MDS_FINDINOREPLY: - m = MMDSFindInoReply::create(); + m = make_message(); break; case MSG_MDS_OPENINO: - m = MMDSOpenIno::create(); + m = make_message(); break; case MSG_MDS_OPENINOREPLY: - m = MMDSOpenInoReply::create(); + m = make_message(); break; case MSG_MDS_SNAPUPDATE: - m = MMDSSnapUpdate::create(); + m = make_message(); break; case MSG_MDS_FRAGMENTNOTIFY: - m = MMDSFragmentNotify::create(); + m = make_message(); break; case MSG_MDS_FRAGMENTNOTIFYACK: - m = MMDSFragmentNotifyAck::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRDISCOVER: - m = MExportDirDiscover::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRDISCOVERACK: - m = MExportDirDiscoverAck::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRCANCEL: - m = MExportDirCancel::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIR: - m = MExportDir::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRACK: - m = MExportDirAck::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRFINISH: - m = MExportDirFinish::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRNOTIFY: - m = MExportDirNotify::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRNOTIFYACK: - m = MExportDirNotifyAck::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRPREP: - m = MExportDirPrep::create(); + m = make_message(); break; case MSG_MDS_EXPORTDIRPREPACK: - m = MExportDirPrepAck::create(); + m = make_message(); break; case MSG_MDS_EXPORTCAPS: - m = MExportCaps::create(); + m = make_message(); break; case MSG_MDS_EXPORTCAPSACK: - m = MExportCapsAck::create(); + m = make_message(); break; case MSG_MDS_GATHERCAPS: - m = MGatherCaps::create(); + m = make_message(); break; case MSG_MDS_DENTRYUNLINK: - m = MDentryUnlink::create(); + m = make_message(); break; case MSG_MDS_DENTRYLINK: - m = MDentryLink::create(); + m = make_message(); break; case MSG_MDS_HEARTBEAT: - m = MHeartbeat::create(); + m = make_message(); break; case MSG_MDS_CACHEEXPIRE: - m = MCacheExpire::create(); + m = make_message(); break; case MSG_MDS_TABLE_REQUEST: - m = MMDSTableRequest::create(); + m = make_message(); break; /* case MSG_MDS_INODEUPDATE: - m = MInodeUpdate::create(); + m = make_message(); break; */ case MSG_MDS_INODEFILECAPS: - m = MInodeFileCaps::create(); + m = make_message(); break; case MSG_MDS_LOCK: - m = MLock::create(); + m = make_message(); break; case MSG_MGR_BEACON: - m = MMgrBeacon::create(); + m = make_message(); break; case MSG_MON_MGR_REPORT: - m = MMonMgrReport::create(); + m = make_message(); break; case MSG_SERVICE_MAP: - m = MServiceMap::create(); + m = make_message(); break; case MSG_MGR_MAP: - m = MMgrMap::create(); + m = make_message(); break; case MSG_MGR_DIGEST: - m = MMgrDigest::create(); + m = make_message(); break; case MSG_MGR_OPEN: - m = MMgrOpen::create(); + m = make_message(); break; case MSG_MGR_CLOSE: - m = MMgrClose::create(); + m = make_message(); break; case MSG_MGR_REPORT: - m = MMgrReport::create(); + m = make_message(); break; case MSG_MGR_CONFIGURE: - m = MMgrConfigure::create(); + m = make_message(); break; case MSG_TIMECHECK: - m = MTimeCheck::create(); + m = make_message(); break; case MSG_TIMECHECK2: - m = MTimeCheck2::create(); + m = make_message(); break; case MSG_MON_HEALTH: - m = MMonHealth::create(); + m = make_message(); break; case MSG_MON_HEALTH_CHECKS: - m = MMonHealthChecks::create(); + m = make_message(); break; // -- simple messages without payload -- case CEPH_MSG_SHUTDOWN: - m = MGenericMessage::create(type); + m = make_message(type); break; default: diff --git a/src/msg/Message.h b/src/msg/Message.h index 0baac6ef62a..8686d1871b1 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -574,9 +574,9 @@ template boost::intrusive_ptr ref_cast(const boost::intrusive_ptr& r) noexcept { return static_cast(r.get()); } -template -boost::intrusive_ptr ref_cast(const boost::intrusive_ptr&& r) noexcept { - return {static_cast(r.detach()), false}; +template +boost::intrusive_ptr make_message(Args&&... args) { + return {new T(std::forward(args)...), false}; } } diff --git a/src/tools/ceph-dencoder/ceph_dencoder.cc b/src/tools/ceph-dencoder/ceph_dencoder.cc index cc7e4708f2e..2a17eef1b7a 100644 --- a/src/tools/ceph-dencoder/ceph_dencoder.cc +++ b/src/tools/ceph-dencoder/ceph_dencoder.cc @@ -218,7 +218,7 @@ class MessageDencoderImpl : public Dencoder { list> m_list; public: - MessageDencoderImpl() : m_object(T::create()) {} + MessageDencoderImpl() : m_object{make_message()} {} ~MessageDencoderImpl() override {} string decode(bufferlist bl, uint64_t seek) override {