]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: track last_scrubbed in PG::Info::History
authorSage Weil <sage@newdream.net>
Wed, 10 Nov 2010 22:55:57 +0000 (14:55 -0800)
committerSage Weil <sage@newdream.net>
Thu, 11 Nov 2010 00:31:42 +0000 (16:31 -0800)
Share with peers and write to disk on scrub completion.

Signed-off-by: Sage Weil <sage@newdream.net>
src/osd/PG.cc
src/osd/PG.h
src/osd/ReplicatedPG.cc

index eb539b6d978b087850ba38d9fd31e5f4104f3e09..ccafff233aef8893718d7d0772a04bfd34aa0eab 100644 (file)
@@ -1960,6 +1960,8 @@ void PG::update_stats()
     info.stats.reported.inc(info.history.same_primary_since);
     info.stats.version = info.last_update;
     info.stats.created = info.history.epoch_created;
+    info.stats.last_scrub = info.history.last_scrub;
+    info.stats.last_scrub_stamp = info.history.last_scrub_stamp;
     pg_stats_valid = true;
     pg_stats_stable = info.stats;
     pg_stats_stable.state = state;
@@ -3160,9 +3162,17 @@ void PG::scrub()
   state_clear(PG_STATE_REPAIR);
 
   // finish up
-  info.stats.last_scrub = info.last_update;
-  info.stats.last_scrub_stamp = g_clock.now();
+  info.history.last_scrub = info.last_update;
+  info.history.last_scrub_stamp = g_clock.now();
 
+  {
+    ObjectStore::Transaction *t = new ObjectStore::Transaction;
+    write_info(*t);
+    int tr = osd->store->queue_transaction(&osr, t);
+    assert(tr == 0);
+  }
+
+  share_pg_info();
 
  out:
   state_clear(PG_STATE_SCRUBBING);
@@ -3176,6 +3186,20 @@ void PG::scrub()
   unlock();
 }
 
+void PG::share_pg_info()
+{
+  dout(10) << "share_pg_info" << dendl;
+
+  // share new PG::Info with replicas
+  for (unsigned i=1; i<acting.size(); i++) {
+    int peer = acting[i];
+    MOSDPGInfo *m = new MOSDPGInfo(osd->osdmap->get_epoch());
+    m->pg_info.push_back(info);
+    osd->cluster_messenger->send_message(m, osd->osdmap->get_cluster_inst(peer));
+  }
+}
+
+
 unsigned int PG::Missing::num_missing() const
 {
   return missing.size();
index 43de528586364f2b45a5a0ec0845bad4d52e205f..04fdc875530daec6e10ab13a292bf3f8c6a120e3 100644 (file)
@@ -121,6 +121,10 @@ public:
       epoch_t same_up_since;       // same acting set since
       epoch_t same_acting_since;   // same acting set since
       epoch_t same_primary_since;  // same primary at least back through this epoch.
+
+      eversion_t last_scrub;
+      utime_t last_scrub_stamp;
+
       History() :            
        epoch_created(0),
        last_epoch_started(0), last_epoch_split(0),
@@ -134,10 +138,14 @@ public:
          last_epoch_started = other.last_epoch_started;
        if (last_epoch_split < other.last_epoch_started)
          last_epoch_split = other.last_epoch_started;
+       if (other.last_scrub > last_scrub)
+         last_scrub = other.last_scrub;
+       if (other.last_scrub_stamp > last_scrub_stamp)
+         last_scrub_stamp = other.last_scrub_stamp;
       }
 
       void encode(bufferlist &bl) const {
-       __u8 struct_v = 1;
+       __u8 struct_v = 2;
        ::encode(struct_v, bl);
        ::encode(epoch_created, bl);
        ::encode(last_epoch_started, bl);
@@ -145,6 +153,8 @@ public:
        ::encode(same_acting_since, bl);
        ::encode(same_up_since, bl);
        ::encode(same_primary_since, bl);
+       ::encode(last_scrub, bl);
+       ::encode(last_scrub_stamp, bl);
       }
       void decode(bufferlist::iterator &bl) {
        __u8 struct_v;
@@ -155,6 +165,10 @@ public:
        ::decode(same_acting_since, bl);
        ::decode(same_up_since, bl);
        ::decode(same_primary_since, bl);
+       if (struct_v >= 2) {
+         ::decode(last_scrub, bl);
+         ::decode(last_scrub_stamp, bl);
+       }
       }
     } history;
     
@@ -949,6 +963,7 @@ public:
 
   void queue_snap_trim();
 
+  void share_pg_info();
 
 
   // abstract bits
index 424a5785e7b13e04f1693887adc286e91f54ee13..b50f8ba4c2b5542c83c7cbeb12ad5aee23d5d148 100644 (file)
@@ -701,14 +701,7 @@ bool ReplicatedPG::snap_trimmer()
     int tr = osd->store->queue_transaction(&osr, t);
     assert(tr == 0);
  
-    // share new PG::Info with replicas
-    for (unsigned i=1; i<acting.size(); i++) {
-      int peer = acting[i];
-      MOSDPGInfo *m = new MOSDPGInfo(osd->osdmap->get_epoch());
-      m->pg_info.push_back(info);
-      osd->cluster_messenger->
-       send_message(m, osd->osdmap->get_cluster_inst(peer));
-    }
+    share_pg_info();
 
     unlock();
     // flush, to make sure the collection adjustments we just made are