From 8ce6544764452daa6581f12c7c83790b1dd54a5f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 18 Aug 2011 11:16:51 -0700 Subject: [PATCH] osd: fix _activate_committed() crash Do not dereference acting[0] unless we know it is still valid. Take a reference when scheduling the transaction, and drop it in the completion, to ensure that the PG isn't removed out from underneath us. Fixes: #1379 Signed-off-by: Sage Weil --- src/osd/PG.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 4fa0d169a2fac..d23251dcf43a7 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1540,6 +1540,7 @@ void PG::activate(ObjectStore::Transaction& t, list& tfin, clean_up_local(t); // find out when we commit + get(); // for callback tfin.push_back(new C_PG_ActivateCommitted(this, info.history.same_acting_since)); // initialize snap_trimq @@ -1714,10 +1715,6 @@ void PG::_activate_committed(epoch_t e) { osd->map_lock.get_read(); lock(); - epoch_t cur_epoch = osd->osdmap->get_epoch(); - entity_inst_t primary = osd->osdmap->get_cluster_inst(acting[0]); - osd->map_lock.put_read(); - if (e < last_warm_restart) { dout(10) << "_activate_committed " << e << ", that was an old interval" << dendl; } else if (is_primary()) { @@ -1729,13 +1726,17 @@ void PG::_activate_committed(epoch_t e) all_activated_and_committed(); } else { dout(10) << "_activate_committed " << e << " telling primary" << dendl; + epoch_t cur_epoch = osd->osdmap->get_epoch(); + entity_inst_t primary = osd->osdmap->get_cluster_inst(acting[0]); MOSDPGInfo *m = new MOSDPGInfo(cur_epoch); PG::Info i = info; i.history.last_epoch_started = e; m->pg_info.push_back(i); osd->cluster_messenger->send_message(m, primary); } + osd->map_lock.put_read(); unlock(); + put(); } /* -- 2.39.5