From 3a0b197cd1682f2fc68b1b962d577ec44cba5944 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 17 Feb 2018 20:27:30 -0600 Subject: [PATCH] osd: fix pg removal vs _process race Signed-off-by: Sage Weil --- src/osd/OSD.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 85464d29a16..32cf018d25a 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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 -- 2.39.5