]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: PaxosService: rework full version stashing
authorJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 28 Sep 2012 15:10:29 +0000 (16:10 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Thu, 21 Feb 2013 18:02:22 +0000 (18:02 +0000)
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
12 files changed:
src/mon/AuthMonitor.cc
src/mon/AuthMonitor.h
src/mon/LogMonitor.cc
src/mon/LogMonitor.h
src/mon/MDSMonitor.h
src/mon/MonmapMonitor.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/mon/PGMonitor.cc
src/mon/PGMonitor.h
src/mon/PaxosService.cc
src/mon/PaxosService.h

index 92bbb0a30ea380f0437b440652719a5baf28426b..d577cf60db2c37441b01645dcf30a643b11d2f4c 100644 (file)
@@ -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()
index f6e3e3c8f995c085da0e2f08ee0d64b3872797e5..256da24b1599cf9e980878866fe7580f0d5a799d 100644 (file)
@@ -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.
index fcb67d1c30381a51896252ebad08e465f84f7593..31b59342382179ba96716862d0080d804a852263 100644 (file)
@@ -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()
index 60215dec6152240521d9b31d341b7ba396f21a81..6f1c4469f2647c7695d899f3b0446eea34259e92 100644 (file)
@@ -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);
index e55d0097cb77d12d4195a0876a848451a01cf0af..4aee6ef8ca101c7ea239c94187b7a75e35dd89ac 100644 (file)
@@ -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) { }
index b3a5ab5c01dc7b9dd26c3700fa54c4690871199c..2861fbbd34f9b5fea1ceb9856a712a4bad99a1da 100644 (file)
@@ -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();
 
index e02060863d51805ee5e5c243991cca97b90bad2f..c046d4c125f77cf5afd41da7e57632155cbe1a4a 100644 (file)
@@ -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) {
index db4d14c51145fa004cb82a7ff9d2b2ca1f558686..c9b9dcf12cad4fb83e6d5705a87eef22348bf81f 100644 (file)
@@ -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();
index 3cf969d554595d85be0c38b5b602cf42cc767449..8f830bd92750abe594d9fdb06a6c83375c85c028 100644 (file)
@@ -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()
index 1affefbc2bf05e6fc76f97bcdda97676c2b14fc3..75c810d39ad1e53582513147b0cc433b7267316f 100644 (file)
@@ -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.
index d5d14c01ed063fbe1cb6d9913eb7caec46e9e441..c8230529428c73f0e2aa17ece1dfae01ffa2781a 100644 (file)
@@ -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()
 {
index e1de779bac0de237d1981eb321800ea7456adb92..3231af859dddf0686811e71f3816456d67b32411 100644 (file)
@@ -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.