]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG: send entire stats on OP_BACKFILL_FINISH
authorSamuel Just <sam.just@inktank.com>
Tue, 26 Mar 2013 22:10:37 +0000 (15:10 -0700)
committerSamuel Just <sam.just@inktank.com>
Thu, 28 Mar 2013 18:58:27 +0000 (11:58 -0700)
Otherwise, we update the stat.stat structure, but not the
stat.invalid_stats part.  This will result in a recently
split primary propogating the invalid stats but not the
invalid marker.  Sending the whole pg_stat_t structure
also mirrors MOSDSubOp.

Fixes: #4557
Backport: bobtail
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 76b296f01fd0d337c8fc9f79013883e62146f0c6)

src/messages/MOSDPGBackfill.h
src/osd/ReplicatedPG.cc

index bc2a696b6ce79759a3eb776c45bf842216b73abd..5700f9675268f00ba1a396b4276dc7361e076a63 100644 (file)
@@ -19,6 +19,8 @@
 #include "osd/osd_types.h"
 
 class MOSDPGBackfill : public Message {
+  static const int HEAD_VERSION = 2;
+  static const int COMPAT_VERSION = 1;
 public:
   enum {
     OP_BACKFILL_PROGRESS = 2,
@@ -38,7 +40,8 @@ public:
   epoch_t map_epoch, query_epoch;
   pg_t pgid;
   hobject_t last_backfill;
-  object_stat_collection_t stats;
+  bool compat_stat_sum;
+  pg_stat_t stats;
 
   virtual void decode_payload() {
     bufferlist::iterator p = payload.begin();
@@ -47,7 +50,15 @@ public:
     ::decode(query_epoch, p);
     ::decode(pgid, p);
     ::decode(last_backfill, p);
-    ::decode(stats, p);
+
+    // For compatibility with version 1
+    ::decode(stats.stats, p);
+
+    if (header.version >= 2) {
+      ::decode(stats, p);
+    } else {
+      compat_stat_sum = true;
+    }
 
     // Handle hobject_t format change
     if (!last_backfill.is_max() &&
@@ -61,16 +72,22 @@ public:
     ::encode(query_epoch, payload);
     ::encode(pgid, payload);
     ::encode(last_backfill, payload);
+
+    // For compatibility with version 1
+    ::encode(stats.stats, payload);
+
     ::encode(stats, payload);
   }
 
-  MOSDPGBackfill() : Message(MSG_OSD_PG_BACKFILL) {}
+  MOSDPGBackfill() :
+    Message(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION),
+    compat_stat_sum(false) {}
   MOSDPGBackfill(__u32 o, epoch_t e, epoch_t qe, pg_t p)
-    : Message(MSG_OSD_PG_BACKFILL),
+    : Message(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION),
       op(o),
       map_epoch(e), query_epoch(e),
-      pgid(p) {
-  }
+      pgid(p),
+      compat_stat_sum(false) {}
 private:
   ~MOSDPGBackfill() {}
 
index 5a27ea4a8ae14bb38d78acb5fe7a8c38d42170a2..bbc8dffd3b8300783bfa2edb96a75da59eed60ff 100644 (file)
@@ -1256,7 +1256,11 @@ void ReplicatedPG::do_backfill(OpRequestRef op)
       assert(g_conf->osd_kill_backfill_at != 2);
 
       info.last_backfill = m->last_backfill;
-      info.stats.stats = m->stats;
+      if (m->compat_stat_sum) {
+       info.stats.stats = m->stats.stats; // Previously, we only sent sum
+      } else {
+       info.stats = m->stats;
+      }
 
       ObjectStore::Transaction *t = new ObjectStore::Transaction;
       write_info(*t);
@@ -6980,7 +6984,7 @@ int ReplicatedPG::recover_backfill(int max)
       // Use default priority here, must match sub_op priority
     }
     m->last_backfill = bound;
-    m->stats = pinfo.stats.stats;
+    m->stats = pinfo.stats;
     osd->send_message_osd_cluster(backfill_target, m, get_osdmap()->get_epoch());
   }