From 87d1cdb5f4ce75d516efa8ab898e050ee3cc937e Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 20 Jun 2012 18:55:29 -0700 Subject: [PATCH] OSD: _remove_pg not ruin iterator consistency Signed-off-by: Samuel Just --- src/osd/OSD.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 1c69668bf4a..29de2935138 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -3579,6 +3579,8 @@ void OSD::activate_map() epoch_t oldest_last_clean = osdmap->get_epoch(); + list to_remove; + // scan pg's for (hash_map::iterator it = pg_map.begin(); it != pg_map.end(); @@ -3598,9 +3600,8 @@ void OSD::activate_map() if (!osdmap->have_pg_pool(pg->info.pgid.pool())) { //pool is deleted! pg->get(); - _remove_pg(pg); + to_remove.push_back(pg); pg->unlock(); - pg->put(); continue; } else { pg->queue_null(osdmap->get_epoch(), osdmap->get_epoch()); @@ -3608,6 +3609,16 @@ void OSD::activate_map() pg->unlock(); } + + for (list::iterator i = to_remove.begin(); + i != to_remove.end(); + ++i) { + (*i)->lock(); + _remove_pg((*i)); + (*i)->unlock(); + (*i)->put(); + } + logger->set(l_osd_pg, pg_map.size()); logger->set(l_osd_pg_primary, num_pg_primary); logger->set(l_osd_pg_replica, num_pg_replica);