From c0ce4a5e32abf79564876dc14f85a4fd65b7860d Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Mon, 8 Dec 2014 12:03:49 +0800 Subject: [PATCH] Cleanup:Use get_type()instead of get_header().type Cleanup the code ,use get_type() instead of get_header().type for messages. Signed-off-by: Xiaoxi Chen --- src/osd/OSD.cc | 28 ++++++++++++++-------------- src/osd/PG.cc | 16 ++++++++-------- src/osd/ReplicatedBackend.cc | 2 +- src/osd/ReplicatedPG.cc | 30 +++++++++++++++--------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index f1c28457cb6a3..2c3f0fe10bd67 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1205,7 +1205,7 @@ void OSDService::reply_op_error(OpRequestRef op, int err, eversion_t v, version_t uv) { MOSDOp *m = static_cast(op->get_req()); - assert(m->get_header().type == CEPH_MSG_OSD_OP); + assert(m->get_type() == CEPH_MSG_OSD_OP); int flags; flags = m->get_flags() & (CEPH_OSD_FLAG_ACK|CEPH_OSD_FLAG_ONDISK); @@ -1218,7 +1218,7 @@ void OSDService::reply_op_error(OpRequestRef op, int err, eversion_t v, void OSDService::handle_misdirected_op(PG *pg, OpRequestRef op) { MOSDOp *m = static_cast(op->get_req()); - assert(m->get_header().type == CEPH_MSG_OSD_OP); + assert(m->get_type() == CEPH_MSG_OSD_OP); assert(m->get_map_epoch() >= pg->info.history.same_primary_since); @@ -5541,7 +5541,7 @@ template epoch_t replica_op_required_epoch(OpRequestRef op) { T *m = static_cast(op->get_req()); - assert(m->get_header().type == MSGTYPE); + assert(m->get_type() == MSGTYPE); return m->map_epoch; } @@ -6801,7 +6801,7 @@ void OSD::split_pgs( void OSD::handle_pg_create(OpRequestRef op) { MOSDPGCreate *m = (MOSDPGCreate*)op->get_req(); - assert(m->get_header().type == MSG_OSD_PG_CREATE); + assert(m->get_type() == MSG_OSD_PG_CREATE); dout(10) << "handle_pg_create " << *m << dendl; @@ -7217,7 +7217,7 @@ void OSD::do_infos(mapget_req(); - assert(m->get_header().type == MSG_OSD_PG_NOTIFY); + assert(m->get_type() == MSG_OSD_PG_NOTIFY); dout(7) << "handle_pg_notify from " << m->get_source() << dendl; int from = m->get_source().num(); @@ -7255,7 +7255,7 @@ void OSD::handle_pg_notify(OpRequestRef op) void OSD::handle_pg_log(OpRequestRef op) { MOSDPGLog *m = (MOSDPGLog*) op->get_req(); - assert(m->get_header().type == MSG_OSD_PG_LOG); + assert(m->get_type() == MSG_OSD_PG_LOG); dout(7) << "handle_pg_log " << *m << " from " << m->get_source() << dendl; if (!require_osd_peer(op)) @@ -7285,7 +7285,7 @@ void OSD::handle_pg_log(OpRequestRef op) void OSD::handle_pg_info(OpRequestRef op) { MOSDPGInfo *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_INFO); + assert(m->get_type() == MSG_OSD_PG_INFO); dout(7) << "handle_pg_info " << *m << " from " << m->get_source() << dendl; if (!require_osd_peer(op)) @@ -7322,7 +7322,7 @@ void OSD::handle_pg_info(OpRequestRef op) void OSD::handle_pg_trim(OpRequestRef op) { MOSDPGTrim *m = (MOSDPGTrim *)op->get_req(); - assert(m->get_header().type == MSG_OSD_PG_TRIM); + assert(m->get_type() == MSG_OSD_PG_TRIM); dout(7) << "handle_pg_trim " << *m << " from " << m->get_source() << dendl; @@ -7380,7 +7380,7 @@ void OSD::handle_pg_trim(OpRequestRef op) void OSD::handle_pg_backfill_reserve(OpRequestRef op) { MBackfillReserve *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_BACKFILL_RESERVE); + assert(m->get_type() == MSG_OSD_BACKFILL_RESERVE); if (!require_osd_peer(op)) return; @@ -7429,7 +7429,7 @@ void OSD::handle_pg_backfill_reserve(OpRequestRef op) void OSD::handle_pg_recovery_reserve(OpRequestRef op) { MRecoveryReserve *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_RECOVERY_RESERVE); + assert(m->get_type() == MSG_OSD_RECOVERY_RESERVE); if (!require_osd_peer(op)) return; @@ -7485,7 +7485,7 @@ void OSD::handle_pg_query(OpRequestRef op) assert(osd_lock.is_locked()); MOSDPGQuery *m = (MOSDPGQuery*)op->get_req(); - assert(m->get_header().type == MSG_OSD_PG_QUERY); + assert(m->get_type() == MSG_OSD_PG_QUERY); if (!require_osd_peer(op)) return; @@ -7592,7 +7592,7 @@ void OSD::handle_pg_query(OpRequestRef op) void OSD::handle_pg_remove(OpRequestRef op) { MOSDPGRemove *m = (MOSDPGRemove *)op->get_req(); - assert(m->get_header().type == MSG_OSD_PG_REMOVE); + assert(m->get_type() == MSG_OSD_PG_REMOVE); assert(osd_lock.is_locked()); if (!require_osd_peer(op)) @@ -7911,7 +7911,7 @@ struct send_map_on_destruct { void OSD::handle_op(OpRequestRef& op, OSDMapRef& osdmap) { MOSDOp *m = static_cast(op->get_req()); - assert(m->get_header().type == CEPH_MSG_OSD_OP); + assert(m->get_type() == CEPH_MSG_OSD_OP); if (op_is_discardable(m)) { dout(10) << " discardable " << *m << dendl; return; @@ -8063,7 +8063,7 @@ template void OSD::handle_replica_op(OpRequestRef& op, OSDMapRef& osdmap) { T *m = static_cast(op->get_req()); - assert(m->get_header().type == MSGTYPE); + assert(m->get_type() == MSGTYPE); dout(10) << __func__ << " " << *m << " epoch " << m->map_epoch << dendl; epoch_t up_epoch = service.get_up_epoch(); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 49b7c9d4f5808..9de4b822c288e 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3152,7 +3152,7 @@ void PG::unreg_next_scrub() void PG::sub_op_scrub_map(OpRequestRef op) { MOSDSubOp *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_SUBOP); + assert(m->get_type() == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_map" << dendl; if (m->map_epoch < info.history.same_interval_since) { @@ -3212,7 +3212,7 @@ void PG::_request_scrub_map( void PG::sub_op_scrub_reserve(OpRequestRef op) { MOSDSubOp *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_SUBOP); + assert(m->get_type() == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_reserve" << dendl; if (scrubber.reserved) { @@ -3233,7 +3233,7 @@ void PG::sub_op_scrub_reserve(OpRequestRef op) void PG::sub_op_scrub_reserve_reply(OpRequestRef op) { MOSDSubOpReply *reply = static_cast(op->get_req()); - assert(reply->get_header().type == MSG_OSD_SUBOPREPLY); + assert(reply->get_type() == MSG_OSD_SUBOPREPLY); dout(7) << "sub_op_scrub_reserve_reply" << dendl; if (!scrubber.reserved) { @@ -3265,7 +3265,7 @@ void PG::sub_op_scrub_reserve_reply(OpRequestRef op) void PG::sub_op_scrub_unreserve(OpRequestRef op) { - assert(op->get_req()->get_header().type == MSG_OSD_SUBOP); + assert(op->get_req()->get_type() == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_unreserve" << dendl; op->mark_started(); @@ -3278,7 +3278,7 @@ void PG::sub_op_scrub_stop(OpRequestRef op) op->mark_started(); MOSDSubOp *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_SUBOP); + assert(m->get_type() == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_stop" << dendl; // see comment in sub_op_scrub_reserve @@ -4973,7 +4973,7 @@ template bool PG::can_discard_replica_op(OpRequestRef& op) { T *m = static_cast(op->get_req()); - assert(m->get_header().type == MSGTYPE); + assert(m->get_type() == MSGTYPE); /* Mostly, this overlaps with the old_peering_msg * condition. An important exception is pushes @@ -4998,7 +4998,7 @@ bool PG::can_discard_replica_op(OpRequestRef& op) bool PG::can_discard_scan(OpRequestRef op) { MOSDPGScan *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_SCAN); + assert(m->get_type() == MSG_OSD_PG_SCAN); if (old_peering_msg(m->map_epoch, m->query_epoch)) { dout(10) << " got old scan, ignoring" << dendl; @@ -5010,7 +5010,7 @@ bool PG::can_discard_scan(OpRequestRef op) bool PG::can_discard_backfill(OpRequestRef op) { MOSDPGBackfill *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_BACKFILL); + assert(m->get_type() == MSG_OSD_PG_BACKFILL); if (old_peering_msg(m->map_epoch, m->query_epoch)) { dout(10) << " got old backfill, ignoring" << dendl; diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 2940dc8dcd49b..c1192aff6343f 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -626,7 +626,7 @@ void ReplicatedBackend::op_commit( void ReplicatedBackend::sub_op_modify_reply(OpRequestRef op) { MOSDSubOpReply *r = static_cast(op->get_req()); - assert(r->get_header().type == MSG_OSD_SUBOPREPLY); + assert(r->get_type() == MSG_OSD_SUBOPREPLY); op->mark_started(); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 5f3a7117a8609..1893e1b367e7c 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -789,7 +789,7 @@ bool ReplicatedPG::pg_op_must_wait(MOSDOp *op) void ReplicatedPG::do_pg_op(OpRequestRef op) { MOSDOp *m = static_cast(op->get_req()); - assert(m->get_header().type == CEPH_MSG_OSD_OP); + assert(m->get_type() == CEPH_MSG_OSD_OP); dout(10) << "do_pg_op " << *m << dendl; op->mark_started(); @@ -1369,7 +1369,7 @@ bool ReplicatedPG::check_src_targ(const hobject_t& soid, const hobject_t& toid) void ReplicatedPG::do_op(OpRequestRef& op) { MOSDOp *m = static_cast(op->get_req()); - assert(m->get_header().type == CEPH_MSG_OSD_OP); + assert(m->get_type() == CEPH_MSG_OSD_OP); if (op->includes_pg_op()) { if (pg_op_must_wait(m)) { wait_for_all_missing(op); @@ -2211,7 +2211,7 @@ void ReplicatedPG::do_sub_op(OpRequestRef op) { MOSDSubOp *m = static_cast(op->get_req()); assert(have_same_or_newer_map(m->map_epoch)); - assert(m->get_header().type == MSG_OSD_SUBOP); + assert(m->get_type() == MSG_OSD_SUBOP); dout(15) << "do_sub_op " << *op->get_req() << dendl; OSDOp *first = NULL; @@ -2249,7 +2249,7 @@ void ReplicatedPG::do_sub_op(OpRequestRef op) void ReplicatedPG::do_sub_op_reply(OpRequestRef op) { MOSDSubOpReply *r = static_cast(op->get_req()); - assert(r->get_header().type == MSG_OSD_SUBOPREPLY); + assert(r->get_type() == MSG_OSD_SUBOPREPLY); if (r->ops.size() >= 1) { OSDOp& first = r->ops[0]; switch (first.op.op) { @@ -2265,7 +2265,7 @@ void ReplicatedPG::do_scan( ThreadPool::TPHandle &handle) { MOSDPGScan *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_SCAN); + assert(m->get_type() == MSG_OSD_PG_SCAN); dout(10) << "do_scan " << *m << dendl; op->mark_started(); @@ -2350,7 +2350,7 @@ void ReplicatedPG::do_scan( void ReplicatedBackend::_do_push(OpRequestRef op) { MOSDPGPush *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_PUSH); + assert(m->get_type() == MSG_OSD_PG_PUSH); pg_shard_t from = m->from; vector replies; @@ -2409,7 +2409,7 @@ struct C_ReplicatedBackend_OnPullComplete : GenContext { void ReplicatedBackend::_do_pull_response(OpRequestRef op) { MOSDPGPush *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_PUSH); + assert(m->get_type() == MSG_OSD_PG_PUSH); pg_shard_t from = m->from; vector replies(1); @@ -2457,7 +2457,7 @@ void ReplicatedBackend::_do_pull_response(OpRequestRef op) void ReplicatedBackend::do_pull(OpRequestRef op) { MOSDPGPull *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_PULL); + assert(m->get_type() == MSG_OSD_PG_PULL); pg_shard_t from = m->from; map > replies; @@ -2473,7 +2473,7 @@ void ReplicatedBackend::do_pull(OpRequestRef op) void ReplicatedBackend::do_push_reply(OpRequestRef op) { MOSDPGPushReply *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_PUSH_REPLY); + assert(m->get_type() == MSG_OSD_PG_PUSH_REPLY); pg_shard_t from = m->from; vector replies(1); @@ -2494,7 +2494,7 @@ void ReplicatedBackend::do_push_reply(OpRequestRef op) void ReplicatedPG::do_backfill(OpRequestRef op) { MOSDPGBackfill *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_PG_BACKFILL); + assert(m->get_type() == MSG_OSD_PG_BACKFILL); dout(10) << "do_backfill " << *m << dendl; op->mark_started(); @@ -7930,7 +7930,7 @@ void ReplicatedPG::put_snapset_context(SnapSetContext *ssc) void ReplicatedBackend::sub_op_modify(OpRequestRef op) { MOSDSubOp *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_SUBOP); + assert(m->get_type() == MSG_OSD_SUBOP); const hobject_t& soid = m->poid; @@ -8038,7 +8038,7 @@ void ReplicatedBackend::sub_op_modify_applied(RepModifyRef rm) dout(10) << "sub_op_modify_applied on " << rm << " op " << *rm->op->get_req() << dendl; MOSDSubOp *m = static_cast(rm->op->get_req()); - assert(m->get_header().type == MSG_OSD_SUBOP); + assert(m->get_type() == MSG_OSD_SUBOP); if (!rm->committed) { // send ack to acker only if we haven't sent a commit already @@ -9021,7 +9021,7 @@ void ReplicatedBackend::sub_op_push_reply(OpRequestRef op) { MOSDSubOpReply *reply = static_cast(op->get_req()); const hobject_t& soid = reply->get_poid(); - assert(reply->get_header().type == MSG_OSD_SUBOPREPLY); + assert(reply->get_type() == MSG_OSD_SUBOPREPLY); dout(10) << "sub_op_push_reply from " << reply->get_source() << " " << *reply << dendl; pg_shard_t peer = reply->from; @@ -9115,7 +9115,7 @@ void ReplicatedPG::finish_degraded_object(const hobject_t& oid) void ReplicatedBackend::sub_op_pull(OpRequestRef op) { MOSDSubOp *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_SUBOP); + assert(m->get_type() == MSG_OSD_SUBOP); op->mark_started(); @@ -9387,7 +9387,7 @@ void ReplicatedBackend::_failed_push(pg_shard_t from, const hobject_t &soid) void ReplicatedPG::sub_op_remove(OpRequestRef op) { MOSDSubOp *m = static_cast(op->get_req()); - assert(m->get_header().type == MSG_OSD_SUBOP); + assert(m->get_type() == MSG_OSD_SUBOP); dout(7) << "sub_op_remove " << m->poid << dendl; op->mark_started(); -- 2.39.5