diff options
author | Joao Eduardo Luis <joao.luis@inktank.com> | 2013-06-02 16:15:02 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-06-24 16:16:40 -0700 |
commit | 054e96d96533b1c4078402e43184f13b97329905 (patch) | |
tree | 7932b95f0190ce5c7f13cf39734bf6bec154d3a0 | |
parent | 265212a7384399bf85e15e6978bc7543824c0e92 (diff) | |
download | ceph-054e96d96533b1c4078402e43184f13b97329905.tar.gz |
mon/PaxosService: cache {first,last}_committed
Refresh the in-memory values when we are told the on-disk paxos state
may have changed.
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
(cherry picked from commit 2fccb300bdf6ffd44db3462eb05115da11322ed4)
-rw-r--r-- | src/mon/PaxosService.cc | 5 | ||||
-rw-r--r-- | src/mon/PaxosService.h | 34 |
2 files changed, 36 insertions, 3 deletions
diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 4cbdb0fee3c..cf08ec46811 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -106,7 +106,12 @@ bool PaxosService::dispatch(PaxosServiceMessage *m) void PaxosService::refresh() { + // update cached versions + cached_first_committed = mon->store->get(get_service_name(), first_committed_name); + cached_last_committed = mon->store->get(get_service_name(), last_committed_name); + dout(10) << __func__ << dendl; + update_from_paxos(); } diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index 158eda7def8..9ca926292b7 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -196,7 +196,8 @@ public: first_committed_name("first_committed"), last_accepted_name("last_accepted"), mkfs_name("mkfs"), - full_version_name("full"), full_latest_name("latest") + full_version_name("full"), full_latest_name("latest"), + cached_first_committed(0), cached_last_committed(0) { proposing.set(0); } @@ -474,6 +475,22 @@ public: */ /** + * @defgroup PaxosService_h_version_cache Variables holding cached values + * for the most used versions (first + * and last committed); we only have + * to read them when the store is + * updated, so in-between updates we + * may very well use cached versions + * and avoid the overhead. + * @{ + */ + version_t cached_first_committed; + version_t cached_last_committed; + /** + * @} + */ + + /** * Callback list to be used whenever we are running a proposal through * Paxos. These callbacks will be awaken whenever the said proposal * finishes. @@ -874,13 +891,19 @@ public: * the back store for reading purposes * @{ */ + + /** + * @defgroup PaxosService_h_version_cache Obtain cached versions for this + * service. + * @{ + */ /** * Get the first committed version * * @returns Our first committed version (that is available) */ version_t get_first_committed() { - return mon->store->get(get_service_name(), first_committed_name); + return cached_first_committed; } /** * Get the last committed version @@ -888,7 +911,7 @@ public: * @returns Our last committed version */ version_t get_last_committed() { - return mon->store->get(get_service_name(), last_committed_name); + return cached_last_committed; } /** * Get our current version @@ -898,6 +921,11 @@ public: version_t get_version() { return get_last_committed(); } + + /** + * @} + */ + /** * Get the contents of a given version @p ver * |