]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: discard waiting ops when pg mapping changes
authorSage Weil <sage@newdream.net>
Thu, 9 Feb 2012 00:19:30 +0000 (16:19 -0800)
committerSage Weil <sage@newdream.net>
Thu, 9 Feb 2012 00:19:30 +0000 (16:19 -0800)
If the pg mapping changes away from us, we can safely discard messages we
have waiting for the PG to be created.

Fixes: #2013
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
Reviewed-by: Josh Durgin <josh.durgin@dreamhost.com>
src/osd/OSD.cc

index 98961cf98549a41a972c32cc13d2f41ce5c99647..2e1235ed94887de271e6e742f3217de3dd5c9378 100644 (file)
@@ -3644,6 +3644,27 @@ void OSD::advance_map(ObjectStore::Transaction& t)
     pg->handle_advance_map(osdmap, lastmap, newup, newacting, 0);
     pg->unlock();
   }
+
+  // scan pgs with waiters
+  map<pg_t, list<OpRequest*> >::iterator p = waiting_for_pg.begin();
+  while (p != waiting_for_pg.end()) {
+    pg_t pgid = p->first;
+
+    // am i still primary?
+    vector<int> acting;
+    int nrep = osdmap->pg_to_acting_osds(pgid, acting);
+    int role = osdmap->calc_pg_role(whoami, acting, nrep);
+    if (role >= 0) {
+      ++p;  // still me
+    } else {
+      dout(10) << " discarding waiting ops for " << pgid << dendl;
+      while (!p->second.empty()) {
+       p->second.front()->put();
+       p->second.pop_front();
+      }
+      waiting_for_pg.erase(p++);
+    }
+  }
 }
 
 void OSD::activate_map(ObjectStore::Transaction& t, list<Context*>& tfin)