]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix pg removal vs _process race
authorSage Weil <sage@redhat.com>
Sun, 18 Feb 2018 02:27:30 +0000 (20:27 -0600)
committerSage Weil <sage@redhat.com>
Wed, 4 Apr 2018 13:26:55 +0000 (08:26 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc

index 85464d29a1622a16982845b3c20875d599d75585..32cf018d25a94ef65307e32f328bec6f5cd17405 100644 (file)
@@ -9593,10 +9593,22 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb)
   sdata->sdata_op_ordering_lock.Lock();
 
   auto q = sdata->pg_slots.find(token);
-  assert(q != sdata->pg_slots.end());
+  if (q == sdata->pg_slots.end()) {
+    // this can happen if we race with pg removal.
+    dout(20) << __func__ << " slot " << token << " no longer there" << dendl;
+    pg->unlock();
+    sdata->sdata_op_ordering_lock.Unlock();
+    return;
+  }
   auto *slot = q->second.get();
   --slot->num_running;
 
+  if (pg && !slot->pg) {
+    // this can happen if we race with pg removal.
+    dout(20) << __func__ << " slot " << token << " no longer attached" << dendl;
+    pg->unlock();
+    pg = nullptr;
+  }
   if (slot->to_process.empty()) {
     // raced with wake_pg_waiters or consume_map
     dout(20) << __func__ << " " << token