From 0c860c17ba078098ebc4c0c191bf11a5c685c29d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 28 Apr 2012 20:57:02 -0700 Subject: [PATCH] osd: fix dirty_info check for advance/activate paths Previously we would check and write dirty_info *without the pg lock* after doing the advance and activate map calls. This was unlikely to race with anything because the queues were drained, but definitely not right. Instead, do the write in activate_map, or explicitly if activate_map is not called (so that we record our progress after handling maps when we are not up). Signed-off-by: Sage Weil --- src/osd/OSD.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 203ac047ddfe7..93e8d19e37ae8 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -3284,6 +3284,17 @@ void OSD::handle_osd_map(MOSDMap *m) // yay! activate_map(t, fin->contexts); + } else { + // write updated pg state to store + for (hash_map::iterator i = pg_map.begin(); + i != pg_map.end(); + i++) { + PG *pg = i->second; + pg->lock_with_map_lock_held(); + if (pg->dirty_info) + pg->write_info(t); + pg->unlock(); + } } bool do_shutdown = false; @@ -3338,15 +3349,6 @@ void OSD::handle_osd_map(MOSDMap *m) // process waiters take_waiters(waiting_for_osdmap); - // write updated pg state to store - for (hash_map::iterator i = pg_map.begin(); - i != pg_map.end(); - i++) { - PG *pg = i->second; - if (pg->dirty_info) - pg->write_info(t); - } - // note in the superblock that we were clean thru the prior epoch if (boot_epoch && boot_epoch >= superblock.mounted) { superblock.mounted = boot_epoch; @@ -3606,6 +3608,9 @@ void OSD::activate_map(ObjectStore::Transaction& t, list& tfin) PG::RecoveryCtx rctx(&query_map, &info_map, ¬ify_list, &tfin, &t); pg->handle_activate_map(&rctx); + + if (pg->dirty_info) + pg->write_info(t); pg->unlock(); } -- 2.39.5