]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: dirty_info if history.merge updated anything
authorSage Weil <sage.weil@dreamhost.com>
Sun, 29 Apr 2012 05:31:23 +0000 (22:31 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Sun, 29 Apr 2012 05:31:23 +0000 (22:31 -0700)
In proc_replica_info and proc_primary_info, we may or may not update
the pg_info_t.  If we do, set dirty_info, so that it will be recorded.
Same goes for when the primary pushes out updated stats to us.

Also, do not write a purged_snaps() update directory; rely on the caller
to write out dirty info.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/osd/PG.cc
src/osd/osd_types.h

index 7c27ed7f9926eb5bda58fa33f4519c996d57b741..cfe0698bd0c4656b35f733cf30bace9593fb6b4c 100644 (file)
@@ -235,7 +235,8 @@ bool PG::proc_replica_info(int from, pg_info_t &oinfo)
   might_have_unfound.insert(from);
   
   osd->unreg_last_pg_scrub(info.pgid, info.history.last_scrub_stamp);
-  info.history.merge(oinfo.history);
+  if (info.history.merge(oinfo.history))
+    dirty_info = true;
   osd->reg_last_pg_scrub(info.pgid, info.history.last_scrub_stamp);
   
   // stray?
@@ -3632,11 +3633,14 @@ void PG::proc_primary_info(ObjectStore::Transaction &t, const pg_info_t &oinfo)
   assert(!is_primary());
   assert(is_stray() || is_active());
 
-  if (info.last_backfill.is_max())
+  if (info.last_backfill.is_max()) {
     info.stats = oinfo.stats;
+    dirty_info = true;
+  }
 
   osd->unreg_last_pg_scrub(info.pgid, info.history.last_scrub_stamp);
-  info.history.merge(oinfo.history);
+  if (info.history.merge(oinfo.history))
+    dirty_info = true;
   osd->reg_last_pg_scrub(info.pgid, info.history.last_scrub_stamp);
 
   // Handle changes to purged_snaps ONLY IF we have caught up
@@ -3651,7 +3655,7 @@ void PG::proc_primary_info(ObjectStore::Transaction &t, const pg_info_t &oinfo)
               << " removed " << p << dendl;
       adjust_local_snaps();
     }
-    write_info(t);
+    dirty_info = true;
   }
 }
 
index 4381b1dec6bb5b50aefbac00d134c30e4f8bee0d..b3493180862e4413e20e6fb82c020518c6500bec 100644 (file)
@@ -940,20 +940,34 @@ struct pg_history_t {
       last_epoch_started(0), last_epoch_clean(0), last_epoch_split(0),
       same_up_since(0), same_interval_since(0), same_primary_since(0) {}
   
-  void merge(const pg_history_t &other) {
+  bool merge(const pg_history_t &other) {
     // Here, we only update the fields which cannot be calculated from the OSDmap.
-    if (epoch_created < other.epoch_created)
+    bool modified = false;
+    if (epoch_created < other.epoch_created) {
       epoch_created = other.epoch_created;
-    if (last_epoch_started < other.last_epoch_started)
+      modified = true;
+    }
+    if (last_epoch_started < other.last_epoch_started) {
       last_epoch_started = other.last_epoch_started;
-    if (last_epoch_clean < other.last_epoch_clean)
+      modified = true;
+    }
+    if (last_epoch_clean < other.last_epoch_clean) {
       last_epoch_clean = other.last_epoch_clean;
-    if (last_epoch_split < other.last_epoch_started)
-      last_epoch_split = other.last_epoch_started;
-    if (other.last_scrub > last_scrub)
+      modified = true;
+    }
+    if (last_epoch_split < other.last_epoch_started) {
+      last_epoch_split = other.last_epoch_started; 
+      modified = true;
+    }
+    if (other.last_scrub > last_scrub) {
       last_scrub = other.last_scrub;
-    if (other.last_scrub_stamp > last_scrub_stamp)
+      modified = true;
+    }
+    if (other.last_scrub_stamp > last_scrub_stamp) {
       last_scrub_stamp = other.last_scrub_stamp;
+      modified = true;
+    }
+    return modified;
   }
 
   void encode(bufferlist& bl) const;