]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: don't update unneccessary epoch for pg
authorNing Yao <zay11022@gmail.com>
Wed, 25 Nov 2015 15:00:52 +0000 (23:00 +0800)
committerNing Yao <zay11022@gmail.com>
Thu, 26 Nov 2015 02:02:54 +0000 (10:02 +0800)
epoch always remains unless state of cluster changes. Therefore, avoid update epoch for every Op in order to same cpu cost and disk bandwidth.

Signed-off-by: Ning Yao <zay11022@gmail.com>
src/osd/PG.cc
src/osd/PG.h
src/tools/ceph_objectstore_tool.cc

index b5a743bf3f8dafad70adf6549e937c17acc0601a..2d4b51c174b0ceb1e2b38dd4a080f20944d0aceb 100644 (file)
@@ -218,7 +218,8 @@ PG::PG(OSDService *o, OSDMapRef curmap,
   peer_features(CEPH_FEATURES_SUPPORTED_DEFAULT),
   acting_features(CEPH_FEATURES_SUPPORTED_DEFAULT),
   upacting_features(CEPH_FEATURES_SUPPORTED_DEFAULT),
-  do_sort_bitwise(false)
+  do_sort_bitwise(false),
+  last_epoch(0)
 {
 #ifdef PG_DEBUG_REFS
   osd->add_pgid(p, this);
@@ -2657,11 +2658,13 @@ int PG::_prepare_write_info(map<string,bufferlist> *km,
                            pg_info_t &info, coll_t coll,
                            map<epoch_t,pg_interval_t> &past_intervals,
                            ghobject_t &pgmeta_oid,
-                           bool dirty_big_info)
+                           bool dirty_big_info,
+                           bool dirty_epoch)
 {
   // info.  store purged_snaps separately.
   interval_set<snapid_t> purged_snaps;
-  ::encode(epoch, (*km)[epoch_key]);
+  if (dirty_epoch)
+    ::encode(epoch, (*km)[epoch_key]);
   purged_snaps.swap(info.purged_snaps);
   ::encode(info, (*km)[info_key]);
   purged_snaps.swap(info.purged_snaps);
@@ -2711,10 +2714,13 @@ void PG::prepare_write_info(map<string,bufferlist> *km)
   info.stats.stats.add(unstable_stats);
   unstable_stats.clear();
 
+  bool need_update_epoch = last_epoch < get_osdmap()->get_epoch();
   int ret = _prepare_write_info(km, get_osdmap()->get_epoch(), info, coll,
                                past_intervals, pgmeta_oid,
-                               dirty_big_info);
+                               dirty_big_info, need_update_epoch);
   assert(ret == 0);
+  if (need_update_epoch)
+    last_epoch = get_osdmap()->get_epoch();
   last_persisted_osdmap_ref = osdmap_ref;
 
   dirty_info = false;
index 4f8ef48e21dbd784b4335a98ed1a8e40d6fb2636..24b7fd15503b59888b343e815b670680592da006 100644 (file)
@@ -2043,6 +2043,7 @@ public:
   uint64_t upacting_features;
 
   bool do_sort_bitwise;
+  epoch_t last_epoch;
 
  public:
   const spg_t&      get_pgid() const { return pg_id; }
@@ -2161,7 +2162,8 @@ public:
     pg_info_t &info, coll_t coll,
     map<epoch_t,pg_interval_t> &past_intervals,
     ghobject_t &pgmeta_oid,
-    bool dirty_big_info);
+    bool dirty_big_info,
+    bool dirty_epoch);
   void write_if_dirty(ObjectStore::Transaction& t);
 
   eversion_t get_next_version() const {
index 11de3bc32b4816ca7eb9b16c67958d6a4d03baf6..8eb7dcf534b523dc8836b00a3c9370ea93680329 100644 (file)
@@ -530,7 +530,7 @@ int write_info(ObjectStore::Transaction &t, epoch_t epoch, pg_info_t &info,
     info, coll,
     past_intervals,
     pgmeta_oid,
-    true);
+    true, true);
   if (ret) cerr << "Failed to write info" << std::endl;
   t.omap_setkeys(coll, pgmeta_oid, km);
   return ret;