From: Joao Eduardo Luis Date: Fri, 28 Sep 2012 15:10:29 +0000 (+0100) Subject: mon: PaxosService: rework full version stashing X-Git-Tag: v0.59~150^2~1^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cd4de773ec07306a05ef25cbf97e28110dcc671d;p=ceph.git mon: PaxosService: rework full version stashing Signed-off-by: Joao Eduardo Luis --- diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 92bbb0a30ea3..d577cf60db2c 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -245,20 +245,29 @@ void AuthMonitor::encode_pending(MonitorDBStore::Transaction *t) version_t version = get_version() + 1; put_version(t, version, bl); put_last_committed(t, version); +} + +void AuthMonitor::encode_full(MonitorDBStore::Transaction *t) +{ + version_t version = mon->key_server.get_ver(); + dout(10) << __func__ << " auth v " << version << dendl; + assert(get_version() == version); bufferlist full_bl; Mutex::Locker l(mon->key_server.get_lock()); if (mon->key_server.has_secrets()) { - dout(10) << __func__ << " key server has secrets!" << dendl; - v = 1; + dout(20) << __func__ << " key server has secrets!" << dendl; + __u8 v = 1; ::encode(v, full_bl); ::encode(max_global_id, full_bl); ::encode(mon->key_server, full_bl); put_version_full(t, version, full_bl); put_version_latest_full(t, version); - } else - dout(10) << __func__ << " key server has no secrets; do not put them in tx" << dendl; + } else { + dout(20) << __func__ + << " key server has no secrets; do not put them in tx" << dendl; + } } void AuthMonitor::update_trim() diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h index f6e3e3c8f995..256da24b1599 100644 --- a/src/mon/AuthMonitor.h +++ b/src/mon/AuthMonitor.h @@ -134,6 +134,7 @@ private: uint64_t assign_global_id(MAuth *m, bool should_increase_max); // propose pending update to peers void encode_pending(MonitorDBStore::Transaction *t); + virtual void encode_full(MonitorDBStore::Transaction *t); void update_trim(); bool preprocess_query(PaxosServiceMessage *m); // true if processed. diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index fcb67d1c3038..31b593423821 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -196,14 +196,20 @@ void LogMonitor::encode_pending(MonitorDBStore::Transaction *t) for (p = pending_log.begin(); p != pending_log.end(); p++) p->second.encode(bl); - bufferlist summary_bl; - ::encode(summary, summary_bl); - put_version(t, version, bl); put_last_committed(t, version); +} + +void LogMonitor::encode_full(MonitorDBStore::Transaction *t) +{ + dout(10) << __func__ << " log v " << summary.version << dendl; + assert(get_version() == summary.version); + + bufferlist summary_bl; + ::encode(summary, summary_bl); - put_version_full(t, version, summary_bl); - put_version_latest_full(t, version); + put_version_full(t, summary.version, summary_bl); + put_version_latest_full(t, summary.version); } void LogMonitor::update_trim() diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index 60215dec6152..6f1c4469f264 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -38,6 +38,7 @@ private: void create_pending(); // prepare a new pending // propose pending update to peers void encode_pending(MonitorDBStore::Transaction *t); + virtual void encode_full(MonitorDBStore::Transaction *t); void update_trim(); bool preprocess_query(PaxosServiceMessage *m); // true if processed. bool prepare_update(PaxosServiceMessage *m); diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index e55d0097cb77..4aee6ef8ca10 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -75,6 +75,8 @@ class MDSMonitor : public PaxosService { void update_from_paxos(); void create_pending(); void encode_pending(MonitorDBStore::Transaction *t); + // we don't require full versions; don't encode any. + virtual void encode_full(MonitorDBStore::Transaction *t) { } bool should_trim() { return false; } void encode_trim(MonitorDBStore::Transaction *t) { } diff --git a/src/mon/MonmapMonitor.h b/src/mon/MonmapMonitor.h index b3a5ab5c01dc..2861fbbd34f9 100644 --- a/src/mon/MonmapMonitor.h +++ b/src/mon/MonmapMonitor.h @@ -51,6 +51,8 @@ class MonmapMonitor : public PaxosService { void create_pending(); void encode_pending(MonitorDBStore::Transaction *t); + // we always encode the full map; we have no use for full versions + virtual void encode_full(MonitorDBStore::Transaction *t) { } void on_active(); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e02060863d51..c046d4c125f7 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -476,14 +476,19 @@ void OSDMonitor::encode_pending(MonitorDBStore::Transaction *t) /* put everything in the transaction */ put_version(t, pending_inc.epoch, bl); put_last_committed(t, pending_inc.epoch); +} +void OSDMonitor::encode_full(MonitorDBStore::Transaction *t) +{ + dout(10) << __func__ << " osdmap e " << osdmap.epoch << dendl; + assert(get_version() == osdmap.epoch); + bufferlist osdmap_bl; osdmap.encode(osdmap_bl); - put_version_full(t, pending_inc.epoch, osdmap_bl); - put_version_latest_full(t, pending_inc.epoch); + put_version_full(t, osdmap.epoch, osdmap_bl); + put_version_latest_full(t, osdmap.epoch); } - void OSDMonitor::share_map_with_random_osd() { if (osdmap.get_num_up_osds() == 0) { diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index db4d14c51145..c9b9dcf12cad 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -138,6 +138,7 @@ private: void update_from_paxos(); void create_pending(); // prepare a new pending void encode_pending(MonitorDBStore::Transaction *t); + virtual void encode_full(MonitorDBStore::Transaction *t); void on_active(); void update_msgr_features(); diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 3cf969d55459..8f830bd92750 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -259,14 +259,20 @@ void PGMonitor::encode_pending(MonitorDBStore::Transaction *t) bufferlist bl; pending_inc.encode(bl, mon->get_quorum_features()); - bufferlist full_bl; - pg_map.encode(full_bl, mon->get_quorum_features()); - put_version(t, version, bl); put_last_committed(t, version); +} + +void PGMonitor::encode_full(MonitorDBStore::Transaction *t) +{ + dout(10) << __func__ << " pgmap v " << pg_map.version << dendl; + assert(get_version() == pg_map.version); + + bufferlist full_bl; + pg_map.encode(full_bl, mon->get_quorum_features()); - put_version_full(t, version, full_bl); - put_version_latest_full(t, version); + put_version_full(t, pg_map.version, full_bl); + put_version_latest_full(t, pg_map.version); } void PGMonitor::update_trim() diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 1affefbc2bf0..75c810d39ad1 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -56,6 +56,7 @@ private: // propose pending update to peers void update_trim(); void encode_pending(MonitorDBStore::Transaction *t); + virtual void encode_full(MonitorDBStore::Transaction *t); void update_logger(); bool preprocess_query(PaxosServiceMessage *m); // true if processed. diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index d5d14c01ed06..c8230529428c 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -126,6 +126,10 @@ void PaxosService::propose_pending() MonitorDBStore::Transaction t; bufferlist bl; + update_trim(); + if (should_stash_full()) + encode_full(&t); + if (should_trim()) { encode_trim(&t); set_trim_to(0); @@ -148,7 +152,16 @@ void PaxosService::propose_pending() paxos->propose_new_value(bl, new C_Committed(this)); } - +bool PaxosService::should_stash_full() +{ + version_t latest_full = get_version_latest_full(); + /* @note The first member of the condition is moot and it is here just for + * clarity's sake. The second member would end up returing true + * nonetheless because, in that event, + * latest_full == get_trim_to() == 0. + */ + return (!latest_full || (latest_full <= get_trim_to())); +} void PaxosService::restart() { diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index e1de779bac0d..3231af859ddd 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -622,7 +622,27 @@ public: /** * @} */ - + /** + * @defgroup PaxosService_h_Stash_Full + * @{ + */ + bool should_stash_full(); + /** + * Encode a full version on @p t + * + * @note We force every service to implement this function, since we strongly + * desire the encoding of full versions. + * @note Services that do not trim their state, will be bound to only create + * one full version. Full version stashing is determined/controled by + * trimming: we stash a version each time a trim is bound to erase the + * latest full version. + * + * @param t Transaction on which the full version shall be encoded. + */ + virtual void encode_full(MonitorDBStore::Transaction *t) = 0; + /** + * @} + */ /** * Cancel events.