From: Sage Weil Date: Mon, 20 Feb 2017 17:23:50 +0000 (-0500) Subject: osd: add some const to MOSDPGLog handling; document non-constness of log X-Git-Tag: v12.0.1~279^2~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6fd447b8b4553f416975db53e481762f806718d0;p=ceph.git osd: add some const to MOSDPGLog handling; document non-constness of log The PGLog (merge) code stills the pg_log_t entries, but operator<< (called by the message printer) doesn't look at it. Document. Signed-off-by: Sage Weil --- diff --git a/src/messages/MOSDPGLog.h b/src/messages/MOSDPGLog.h index 66764256d2e3..6dafb789cd39 100644 --- a/src/messages/MOSDPGLog.h +++ b/src/messages/MOSDPGLog.h @@ -38,9 +38,9 @@ public: pg_missing_t missing; pg_interval_map_t past_intervals; - epoch_t get_epoch() { return epoch; } - spg_t get_pgid() { return spg_t(info.pgid.pgid, to); } - epoch_t get_query_epoch() { return query_epoch; } + epoch_t get_epoch() const { return epoch; } + spg_t get_pgid() const { return spg_t(info.pgid.pgid, to); } + epoch_t get_query_epoch() const { return query_epoch; } MOSDPGLog() : Message(MSG_OSD_PG_LOG, HEAD_VERSION, COMPAT_VERSION) { set_priority(CEPH_MSG_PRIO_HIGH); @@ -67,6 +67,8 @@ private: public: const char *get_type_name() const { return "PGlog"; } void print(ostream& out) const { + // NOTE: log is not const, but operator<< doesn't touch fields + // swapped out by OSD code. out << "pg_log(" << info.pgid << " epoch " << epoch << " log " << log << " query_epoch " << query_epoch << ")"; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index fc7561685677..b7cc4b1ddcd6 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8128,7 +8128,7 @@ void OSD::handle_pg_notify(OpRequestRef op) void OSD::handle_pg_log(OpRequestRef op) { - MOSDPGLog *m = (MOSDPGLog*) op->get_req(); + MOSDPGLog *m = static_cast(op->get_nonconst_req()); assert(m->get_type() == MSG_OSD_PG_LOG); dout(7) << "handle_pg_log " << *m << " from " << m->get_source() << dendl; diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c70ad9f5d58c..06aecc370fcf 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -341,7 +341,9 @@ void PG::proc_master_log( void PG::proc_replica_log( ObjectStore::Transaction& t, - pg_info_t &oinfo, pg_log_t &olog, pg_missing_t& omissing, + pg_info_t &oinfo, + const pg_log_t &olog, + pg_missing_t& omissing, pg_shard_t from) { dout(10) << "proc_replica_log for osd." << from << ": " @@ -7112,7 +7114,7 @@ boost::statechart::result PG::RecoveryState::ReplicaActive::react(const MLogRec& PG *pg = context< RecoveryMachine >().pg; ldout(pg->cct, 10) << "received log from " << logevt.from << dendl; ObjectStore::Transaction* t = context().get_cur_transaction(); - pg->merge_log(*t,logevt.msg->info, logevt.msg->log, logevt.from); + pg->merge_log(*t, logevt.msg->info, logevt.msg->log, logevt.from); assert(pg->pg_log.get_head() == pg->info.last_update); return discard_event(); diff --git a/src/osd/PG.h b/src/osd/PG.h index 74aa9631af1e..fc972d5be501 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -925,7 +925,8 @@ public: virtual void calc_trim_to() = 0; - void proc_replica_log(ObjectStore::Transaction& t, pg_info_t &oinfo, pg_log_t &olog, + void proc_replica_log(ObjectStore::Transaction& t, + pg_info_t &oinfo, const pg_log_t &olog, pg_missing_t& omissing, pg_shard_t from); void proc_master_log(ObjectStore::Transaction& t, pg_info_t &oinfo, pg_log_t &olog, pg_missing_t& omissing, pg_shard_t from); diff --git a/src/osd/PGLog.cc b/src/osd/PGLog.cc index 0b9d7b75f908..239faee2412b 100644 --- a/src/osd/PGLog.cc +++ b/src/osd/PGLog.cc @@ -131,7 +131,9 @@ void PGLog::trim( void PGLog::proc_replica_log( ObjectStore::Transaction& t, - pg_info_t &oinfo, const pg_log_t &olog, pg_missing_t& omissing, + pg_info_t &oinfo, + const pg_log_t &olog, + pg_missing_t& omissing, pg_shard_t from) const { dout(10) << "proc_replica_log for osd." << from << ": " diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index d9ced79c3ba0..8cfaa484144e 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -703,7 +703,9 @@ public: log.last_requested = 0; } - void proc_replica_log(ObjectStore::Transaction& t, pg_info_t &oinfo, const pg_log_t &olog, + void proc_replica_log(ObjectStore::Transaction& t, + pg_info_t &oinfo, + const pg_log_t &olog, pg_missing_t& omissing, pg_shard_t from) const; protected: @@ -972,7 +974,9 @@ public: pg_info_t &info, LogEntryHandler *rollbacker, bool &dirty_info, bool &dirty_big_info); - void merge_log(ObjectStore::Transaction& t, pg_info_t &oinfo, pg_log_t &olog, + void merge_log(ObjectStore::Transaction& t, + pg_info_t &oinfo, + pg_log_t &olog, pg_shard_t from, pg_info_t &info, LogEntryHandler *rollbacker, bool &dirty_info, bool &dirty_big_info);