summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <joao.luis@inktank.com>2013-06-02 16:15:02 -0700
committerSage Weil <sage@inktank.com>2013-06-17 14:24:44 -0700
commit2ff8cf2051660cb4cec8d72ba03b9e24655af527 (patch)
tree03d81af2ea0aa37e555118c8401466f8f5d87289
parent65e63ba252f3ce336485b066f2d0367331280325 (diff)
downloadceph-2ff8cf2051660cb4cec8d72ba03b9e24655af527.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>
-rw-r--r--src/mon/PaxosService.cc5
-rw-r--r--src/mon/PaxosService.h34
2 files changed, 36 insertions, 3 deletions
diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc
index 8dc1b42bec5..30b3b6e767c 100644
--- a/src/mon/PaxosService.cc
+++ b/src/mon/PaxosService.cc
@@ -111,7 +111,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 31f5ee89619..ce232e559d3 100644
--- a/src/mon/PaxosService.h
+++ b/src/mon/PaxosService.h
@@ -197,7 +197,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)
{
}
@@ -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
*