]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: simplify share_pg_log
authorSage Weil <sage@newdream.net>
Thu, 13 Oct 2011 19:57:54 +0000 (12:57 -0700)
committerSage Weil <sage@newdream.net>
Sat, 15 Oct 2011 04:02:32 +0000 (21:02 -0700)
Use Log::copy_after().  Drop the useless argument.  Strip out the broken
LOST logic.

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

index 1908c4adb924ac7fbd588adcfd8fedbcee3c8875..cf8c127436959bc26396e832c097f3e5ae0f9a24 100644 (file)
@@ -3325,17 +3325,13 @@ void PG::share_pg_info()
 }
 
 /*
- * Share some of this PG's log with some replicas.
- *
- * The log will be shared from the current version (last_update) back to
- * 'oldver.'
+ * Share a new segment of this PG's log with some replicas, after PG is active.
  *
  * Updates peer_missing and peer_info.
  */
-void PG::share_pg_log(const eversion_t &oldver)
+void PG::share_pg_log()
 {
   dout(10) << __func__ << dendl;
-
   assert(is_primary());
 
   vector<int>::const_iterator a = acting.begin();
@@ -3343,41 +3339,19 @@ void PG::share_pg_log(const eversion_t &oldver)
   vector<int>::const_iterator end = acting.end();
   while (++a != end) {
     int peer(*a);
+    PG::Missing& pmissing(peer_missing[peer]);
+    PG::Info& pinfo(peer_info[peer]);
+
     MOSDPGLog *m = new MOSDPGLog(info.last_update.epoch, info);
-    m->log.head = log.head;
-    m->log.tail = log.tail;
-    for (list<Log::Entry>::const_reverse_iterator i = log.log.rbegin();
-        i != log.log.rend();
-        ++i) {
-      if (i->version <= oldver) {
-       m->log.tail = i->version;
-       break;
-      }
-      const Log::Entry &entry(*i);
-      switch (entry.op) {
-       case Log::Entry::LOST_MARK: {
-         PG::Missing& pmissing(peer_missing[peer]);
-         pmissing.add(entry.soid, entry.version, eversion_t());
-         dout(20) << " peer osd." << peer << " now missing " << entry.soid
-                  << " v" << entry.version << " (lost)" << dendl;
-         break;
-        }
-       default: {
-         // To do this right, you need to figure out what impact this log
-         // entry has on the peer missing and the peer info
-         assert(0);
-         break;
-        }
-      }
+    m->log.copy_after(log, pinfo.last_update);
 
-      m->log.log.push_front(*i);
+    for (list<Log::Entry>::const_iterator i = m->log.log.begin();
+        i != m->log.log.end();
+        ++i) {
+      pmissing.add_next_event(*i, pinfo);
     }
-    PG::Info& pinfo(peer_info[peer]);
-    pinfo.last_update = log.head;
-    // shouldn't move pinfo.log.tail
-    // no change in pinfo.last_complete
+    pinfo.last_update = m->log.head;
 
-    m->missing = missing;
     osd->cluster_messenger->send_message(m, osd->osdmap->get_cluster_inst(peer));
   }
 }
index 59792eb0756acafaa78ea8fc50ceb14c4e271b3c..0a06cf7faf3ea5ae53c3bc1fa22eb6d2c85de8f6 100644 (file)
@@ -1632,8 +1632,10 @@ public:
   void queue_snap_trim();
   bool queue_scrub();
 
+  /// share pg info after a pg is active
   void share_pg_info();
-  void share_pg_log(const eversion_t &oldver);
+  /// share new pg log entries after a pg is active
+  void share_pg_log();
 
   void start_peering_interval(const OSDMap *lastmap,
                              const vector<int>& newup,
index 7ff461fe3442d4464430b22e8d61665be285cc88..124a91fe5cc0d8a30f70c29752743e0697afd709 100644 (file)
@@ -4542,7 +4542,7 @@ void ReplicatedPG::mark_all_unfound_lost()
              
   // Send out the PG log to all replicas
   // So that they know what is lost
-  share_pg_log(old_last_update);
+  share_pg_log();
 
   // queue ourselves so that we push the (now-lost) object_infos to replicas.
   osd->queue_for_recovery(this);