From 6c58da04f6e8a2c1ed35ac9e6734346d7d3d0a87 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Fri, 10 Jun 2011 13:06:09 -0700 Subject: [PATCH] include/Context.h: de-globalize Signed-off-by: Colin McCabe --- src/client/SyntheticClient.cc | 2 +- src/include/Context.h | 40 +++++++++++++++++++++-------------- src/mds/CDir.cc | 4 ++-- src/mds/CInode.cc | 2 +- src/mds/Locker.cc | 4 ++-- src/mds/MDCache.cc | 19 ++++++++++------- src/mds/MDLog.cc | 2 +- src/mds/MDS.cc | 14 ++++++------ src/mds/MDSTable.cc | 2 +- src/mds/Migrator.cc | 2 +- src/mds/Server.cc | 4 ++-- src/mds/SessionMap.cc | 4 ++-- src/mds/journal.cc | 28 ++++++++++++------------ src/mds/mdstypes.h | 2 +- src/mon/Paxos.cc | 34 ++++++++++++++--------------- src/os/FileStore.cc | 2 +- src/osd/OSD.cc | 12 +++++------ src/osd/ReplicatedPG.cc | 2 +- src/osdc/Filer.h | 8 +++---- src/osdc/Journaler.cc | 10 ++++----- src/osdc/ObjectCacher.cc | 16 +++++++------- src/osdc/Objecter.h | 6 +++--- src/test/gather.cc | 8 +++---- 23 files changed, 119 insertions(+), 108 deletions(-) diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 98e2fc7b47be1..540b226c99095 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1040,7 +1040,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) Cond cond; bool ack; bool safe; - C_Gather *safeg = new C_Gather(new C_SafeCond(&lock, &cond, &safe)); + C_Gather *safeg = new C_Gather(&g_ceph_context, new C_SafeCond(&lock, &cond, &safe)); Context *safegref = safeg->new_sub(); // take a ref while (!t.end()) { diff --git a/src/include/Context.h b/src/include/Context.h index f4c795ab540d8..46e09bad81f82 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -39,7 +39,7 @@ class Context { /* * finish and destroy a list of Contexts */ -inline void finish_contexts(std::list& finished, +inline void finish_contexts(CephContext *cct, std::list& finished, int result = 0) { if (finished.empty()) @@ -48,18 +48,18 @@ inline void finish_contexts(std::list& finished, list ls; ls.swap(finished); // swap out of place to avoid weird loops - dout(10) << ls.size() << " contexts to finish with " << result << dendl; + ldout(cct,10) << ls.size() << " contexts to finish with " << result << dendl; for (std::list::iterator it = ls.begin(); it != ls.end(); it++) { Context *c = *it; - dout(10) << "---- " << c << dendl; + ldout(cct,10) << "---- " << c << dendl; c->finish(result); delete c; } } -inline void finish_contexts(std::vector& finished, +inline void finish_contexts(CephContext *cct, std::vector& finished, int result = 0) { if (finished.empty()) @@ -68,12 +68,12 @@ inline void finish_contexts(std::vector& finished, vector ls; ls.swap(finished); // swap out of place to avoid weird loops - dout(10) << ls.size() << " contexts to finish with " << result << dendl; + ldout(cct,10) << ls.size() << " contexts to finish with " << result << dendl; for (std::vector::iterator it = ls.begin(); it != ls.end(); it++) { Context *c = *it; - dout(10) << "---- " << c << dendl; + ldout(cct,10) << "---- " << c << dendl; c->finish(result); delete c; } @@ -90,8 +90,14 @@ public: */ class C_Contexts : public Context { public: + CephContext *cct; std::list contexts; + C_Contexts(CephContext *cct_) + : cct(cct_) + { + } + void add(Context* c) { contexts.push_back(c); } @@ -99,7 +105,7 @@ public: contexts.splice(contexts.end(), ls); } void finish(int r) { - finish_contexts(contexts, r); + finish_contexts(cct, contexts, r); } }; @@ -113,6 +119,7 @@ public: */ class C_Gather : public Context { private: + CephContext *cct; int result; Context *onfinish; #ifdef DEBUG_GATHER @@ -132,7 +139,7 @@ private: #endif --sub_existing_count; - dout(10) << "C_Gather " << this << ".sub_finish(r=" << r << ") " << sub + ldout(cct,10) << "C_Gather " << this << ".sub_finish(r=" << r << ") " << sub #ifdef DEBUG_GATHER << " (remaining " << waitfor << ")" #endif @@ -182,15 +189,16 @@ private: }; public: - C_Gather(Context *f=0, bool an=false) : result(0), onfinish(f), sub_created_count(0), - sub_existing_count(0), - lock("C_Gather::lock", true, false), //disable lockdep - any(an), - activated(onfinish ? true : false) { - dout(10) << "C_Gather " << this << ".new" << dendl; + C_Gather(CephContext *cct_, Context *f=0, bool an=false) + : cct(cct_), result(0), onfinish(f), sub_created_count(0), + sub_existing_count(0), + lock("C_Gather::lock", true, false), //disable lockdep + any(an), activated(onfinish ? true : false) + { + ldout(cct,10) << "C_Gather " << this << ".new" << dendl; } ~C_Gather() { - dout(10) << "C_Gather " << this << ".delete" << dendl; + ldout(cct,10) << "C_Gather " << this << ".delete" << dendl; assert(sub_existing_count == 0); #ifdef DEBUG_GATHER assert(waitfor.empty()); @@ -212,7 +220,7 @@ public: #ifdef DEBUG_GATHER waitfor.insert(s); #endif - dout(10) << "C_Gather " << this << ".new_sub is " << sub_created_count << " " << s << dendl; + ldout(cct,10) << "C_Gather " << this << ".new_sub is " << sub_created_count << " " << s << dendl; return s; } void rm_sub(Context *s) { diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index bfb6cf3944f03..f40e70ed05cae 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -1169,7 +1169,7 @@ void CDir::finish_waiting(uint64_t mask, int result) list finished; take_waiting(mask, finished); if (result < 0) - finish_contexts(finished, result); + finish_contexts(&g_ceph_context, finished, result); else cache->mds->queue_waiters(finished); } @@ -1956,7 +1956,7 @@ void CDir::_commit(version_t want) new C_Dir_Committed(this, get_version(), inode->inode.last_renamed_version)); else { // send in a different Context - C_Gather *gather = new C_Gather(new C_Dir_Committed(this, get_version(), + C_Gather *gather = new C_Gather(&g_ceph_context, new C_Dir_Committed(this, get_version(), inode->inode.last_renamed_version)); while (committed_dn != items.end()) { ObjectOperation n = ObjectOperation(); diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index ca2b52e36caae..5276929266eac 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -995,7 +995,7 @@ void CInode::fetch(Context *fin) dout(10) << "fetch" << dendl; C_Inode_Fetched *c = new C_Inode_Fetched(this, fin); - C_Gather *gather = new C_Gather(c); + C_Gather *gather = new C_Gather(&g_ceph_context, c); object_t oid = CInode::get_object_name(ino(), frag_t(), ""); object_locator_t oloc(mdcache->mds->mdsmap->get_metadata_pg_pool()); diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index b6cce0a4a9fc2..f496ef0cbf93b 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -799,7 +799,7 @@ void Locker::eval_cap_gather(CInode *in, set *issue_set) issue_caps(in); } - finish_contexts(finishers); + finish_contexts(&g_ceph_context, finishers); } void Locker::eval_scatter_gathers(CInode *in) @@ -820,7 +820,7 @@ void Locker::eval_scatter_gathers(CInode *in) if (need_issue && in->is_head()) issue_caps(in); - finish_contexts(finishers); + finish_contexts(&g_ceph_context, finishers); } void Locker::eval(SimpleLock *lock, bool *need_issue) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 7e301bea8ea49..e8ba93389627e 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -3607,7 +3607,7 @@ C_Gather *MDCache::parallel_fetch(map& pathmap, set fetch_queue; @@ -4603,7 +4603,7 @@ void MDCache::open_snap_parents() dout(10) << "open_snap_parents" << dendl; map splits; - C_Gather *gather = new C_Gather; + C_Gather *gather = new C_Gather(&g_ceph_context); map > >::iterator p = missing_snap_parents.begin(); while (p != missing_snap_parents.end()) { @@ -4673,7 +4673,7 @@ void MDCache::open_undef_dirfrags() p++) { CDir *dir = *p; if (!gather) - gather = new C_Gather(new C_MDC_OpenUndefDirfragsFinish(this)); + gather = new C_Gather(&g_ceph_context, new C_MDC_OpenUndefDirfragsFinish(this)); dir->fetch(gather->new_sub()); } @@ -8785,7 +8785,7 @@ void MDCache::handle_discover_reply(MDiscoverReply *m) } // waiters - finish_contexts(error, -ENOENT); // finish errors directly + finish_contexts(&g_ceph_context, error, -ENOENT); // finish errors directly mds->queue_waiters(finished); // done @@ -9436,7 +9436,7 @@ void MDCache::split_dir(CDir *dir, int bits) return; } - C_Gather *gather = new C_Gather(new C_MDC_FragmentFrozen(this, dirs, dir->get_frag(), bits)); + C_Gather *gather = new C_Gather(&g_ceph_context, new C_MDC_FragmentFrozen(this, dirs, dir->get_frag(), bits)); fragment_freeze_dirs(dirs, gather); // initial mark+complete pass @@ -9470,7 +9470,7 @@ void MDCache::merge_dir(CInode *diri, frag_t frag) int bits = first->get_frag().bits() - frag.bits(); dout(10) << " we are merginb by " << bits << " bits" << dendl; - C_Gather *gather = new C_Gather(new C_MDC_FragmentFrozen(this, dirs, frag, bits)); + C_Gather *gather = new C_Gather(&g_ceph_context, new C_MDC_FragmentFrozen(this, dirs, frag, bits)); fragment_freeze_dirs(dirs, gather); // initial mark+complete pass @@ -9514,7 +9514,8 @@ void MDCache::fragment_mark_and_complete(list& dirs) if (!dir->is_complete()) { dout(15) << " fetching incomplete " << *dir << dendl; if (!gather) - gather = new C_Gather(new C_MDC_FragmentMarking(this, dirs)); + gather = new C_Gather(&g_ceph_context, + new C_MDC_FragmentMarking(this, dirs)); dir->fetch(gather->new_sub(), true); // ignore authpinnability } @@ -9640,7 +9641,9 @@ void MDCache::fragment_frozen(list& dirs, frag_t basefrag, int bits) */ // freeze, journal, and store resulting frags - C_Gather *gather = new C_Gather(new C_MDC_FragmentLoggedAndStored(this, mut, resultfrags, basefrag, bits)); + C_Gather *gather = new C_Gather(&g_ceph_context, + new C_MDC_FragmentLoggedAndStored(this, mut, + resultfrags, basefrag, bits)); for (list::iterator p = resultfrags.begin(); p != resultfrags.end(); diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc index 400dc097a7013..e588cf97d2b40 100644 --- a/src/mds/MDLog.cc +++ b/src/mds/MDLog.cc @@ -573,7 +573,7 @@ void MDLog::_replay_thread() } dout(10) << "_replay_thread kicking waiters" << dendl; - finish_contexts(waitfor_replay, 0); + finish_contexts(&g_ceph_context, waitfor_replay, 0); dout(10) << "_replay_thread finish" << dendl; mds->mds_lock.Unlock(); diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 80aab34dcc1ce..0d55aea673b38 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -1112,7 +1112,7 @@ void MDS::boot_create() { dout(3) << "boot_create" << dendl; - C_Gather *fin = new C_Gather(new C_MDS_CreateFinish(this)); + C_Gather *fin = new C_Gather(&g_ceph_context, new C_MDS_CreateFinish(this)); mdcache->init_layouts(); @@ -1188,7 +1188,7 @@ void MDS::boot_start(int step, int r) case 1: { - C_Gather *gather = new C_Gather(new C_MDS_BootStart(this, 2)); + C_Gather *gather = new C_Gather(&g_ceph_context, new C_MDS_BootStart(this, 2)); dout(2) << "boot_start " << step << ": opening inotable" << dendl; inotable->load(gather->new_sub()); @@ -1212,7 +1212,7 @@ void MDS::boot_start(int step, int r) { dout(2) << "boot_start " << step << ": loading/discovering base inodes" << dendl; - C_Gather *gather = new C_Gather(new C_MDS_BootStart(this, 3)); + C_Gather *gather = new C_Gather(&g_ceph_context, new C_MDS_BootStart(this, 3)); mdcache->open_mydir_inode(gather->new_sub()); @@ -1429,7 +1429,7 @@ void MDS::reconnect_start() reopen_log(); server->reconnect_clients(); - finish_contexts(waiting_for_reconnect); + finish_contexts(&g_ceph_context, waiting_for_reconnect); } void MDS::reconnect_done() { @@ -1464,7 +1464,7 @@ void MDS::rejoin_done() void MDS::clientreplay_start() { dout(1) << "clientreplay_start" << dendl; - finish_contexts(waiting_for_replay); // kick waiters + finish_contexts(&g_ceph_context, waiting_for_replay); // kick waiters queue_one_replay(); } @@ -1483,8 +1483,8 @@ void MDS::active_start() mdcache->clean_open_file_lists(); mdcache->scan_stray_dir(); - finish_contexts(waiting_for_replay); // kick waiters - finish_contexts(waiting_for_active); // kick waiters + finish_contexts(&g_ceph_context, waiting_for_replay); // kick waiters + finish_contexts(&g_ceph_context, waiting_for_active); // kick waiters } diff --git a/src/mds/MDSTable.cc b/src/mds/MDSTable.cc index b0ada8459f9de..403a837792130 100644 --- a/src/mds/MDSTable.cc +++ b/src/mds/MDSTable.cc @@ -83,7 +83,7 @@ void MDSTable::save_2(version_t v) ls.splice(ls.end(), waitfor_save.begin()->second); waitfor_save.erase(waitfor_save.begin()); } - finish_contexts(ls,0); + finish_contexts(&g_ceph_context, ls,0); } diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 50a25cc7ea734..93df2c20779c4 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -1481,7 +1481,7 @@ void Migrator::export_finish(CDir *dir) assert(g_conf->mds_kill_export_at != 13); // finish export (adjust local cache state) - C_Contexts *fin = new C_Contexts; + C_Contexts *fin = new C_Contexts(&g_ceph_context); finish_export_dir(dir, fin->contexts, g_clock.now()); dir->add_waiter(CDir::WAIT_UNFREEZE, fin); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index e0234df4a5f59..e8b06d912e597 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4933,7 +4933,7 @@ void Server::handle_client_rename(MDRequest *mdr) vector trace; destdn->make_anchor_trace(trace, srcdnl->get_inode()); - anchorgather = new C_Gather(new C_MDS_RetryRequest(mdcache, mdr)); + anchorgather = new C_Gather(&g_ceph_context, new C_MDS_RetryRequest(mdcache, mdr)); mds->anchorclient->prepare_update(srcdnl->get_inode()->ino(), trace, &mdr->more()->src_reanchor_atid, anchorgather->new_sub()); } @@ -4947,7 +4947,7 @@ void Server::handle_client_rename(MDRequest *mdr) straydn->make_anchor_trace(trace, destdnl->get_inode()); if (!anchorgather) - anchorgather = new C_Gather(new C_MDS_RetryRequest(mdcache, mdr)); + anchorgather = new C_Gather(&g_ceph_context, new C_MDS_RetryRequest(mdcache, mdr)); mds->anchorclient->prepare_update(destdnl->get_inode()->ino(), trace, &mdr->more()->dst_reanchor_atid, anchorgather->new_sub()); } diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc index 07dba4773c01b..b6adb41fb06ad 100644 --- a/src/mds/SessionMap.cc +++ b/src/mds/SessionMap.cc @@ -84,7 +84,7 @@ void SessionMap::_load_finish(int r, bufferlist &bl) << dendl; projected = committing = committed = version; dump(); - finish_contexts(waiting_for_load); + finish_contexts(&g_ceph_context, waiting_for_load); } @@ -132,7 +132,7 @@ void SessionMap::_save_finish(version_t v) dout(10) << "_save_finish v" << v << dendl; committed = v; - finish_contexts(commit_waiters[v]); + finish_contexts(&g_ceph_context, commit_waiters[v]); commit_waiters.erase(v); } diff --git a/src/mds/journal.cc b/src/mds/journal.cc index b24e1619f89bb..b4b7bb960def1 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -102,14 +102,14 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) dout(20) << " dirty_inode " << **p << dendl; assert((*p)->is_auth()); if ((*p)->is_base()) { - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); (*p)->store(gather->new_sub()); } else commit.insert((*p)->get_parent_dn()->get_dir()); } if (!commit.empty()) { - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); for (set::iterator p = commit.begin(); p != commit.end(); @@ -131,7 +131,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) p != uncommitted_masters.end(); p++) { dout(10) << "try_to_expire waiting for slaves to ack commit on " << *p << dendl; - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); mds->mdcache->wait_for_uncommitted_master(*p, gather->new_sub()); } @@ -139,19 +139,19 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) for (elist::iterator p = dirty_dirfrag_dir.begin(); !p.end(); ++p) { CInode *in = *p; dout(10) << "try_to_expire waiting for dirlock flush on " << *in << dendl; - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); mds->locker->scatter_nudge(&in->filelock, gather->new_sub()); } for (elist::iterator p = dirty_dirfrag_dirfragtree.begin(); !p.end(); ++p) { CInode *in = *p; dout(10) << "try_to_expire waiting for dirfragtreelock flush on " << *in << dendl; - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); mds->locker->scatter_nudge(&in->dirfragtreelock, gather->new_sub()); } for (elist::iterator p = dirty_dirfrag_nest.begin(); !p.end(); ++p) { CInode *in = *p; dout(10) << "try_to_expire waiting for nest flush on " << *in << dendl; - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); mds->locker->scatter_nudge(&in->nestlock, gather->new_sub()); } @@ -195,7 +195,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) } } if (le) { - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); mds->mdlog->submit_entry(le, gather->new_sub()); dout(10) << "try_to_expire waiting for open files to rejournal" << dendl; } @@ -206,7 +206,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) CInode *in = *p; dout(10) << "try_to_expire waiting for dir parent pointer update on " << *in << dendl; assert(in->state_test(CInode::STATE_DIRTYPARENT)); - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); in->store_parent(gather->new_sub()); } @@ -217,7 +217,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) MDSlaveUpdate *su = *p; dout(10) << "try_to_expire waiting on slave update " << su << dendl; assert(su->waiter == 0); - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); su->waiter = gather->new_sub(); } @@ -227,7 +227,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) << ", committed is " << mds->inotable->get_committed_version() << " (" << mds->inotable->get_committing_version() << ")" << dendl; - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); mds->inotable->save(gather->new_sub(), inotablev); } @@ -237,7 +237,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) << ", committed is " << mds->sessionmap.committed << " (" << mds->sessionmap.committing << ")" << dendl; - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); mds->sessionmap.save(gather->new_sub(), sessionmapv); } @@ -249,7 +249,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) for (hash_set::iterator q = p->second.begin(); q != p->second.end(); ++q) { - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); dout(10) << "try_to_expire " << get_mdstable_name(p->first) << " transaction " << *q << " pending commit (not yet acked), waiting" << dendl; assert(!client->has_committed(*q)); @@ -265,7 +265,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) if (p->second > server->get_committed_version()) { dout(10) << "try_to_expire waiting for " << get_mdstable_name(p->first) << " to save, need " << p->second << dendl; - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); server->save(gather->new_sub()); } } @@ -275,7 +275,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) p != truncating_inodes.end(); p++) { dout(10) << "try_to_expire waiting for truncate of " << **p << dendl; - if (!gather) gather = new C_Gather; + if (!gather) gather = new C_Gather(&g_ceph_context); (*p)->add_waiter(CInode::WAIT_TRUNC, gather->new_sub()); } diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 2f142d6b64a1f..f9c97b6f17ef0 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -1497,7 +1497,7 @@ protected: void finish_waiting(uint64_t mask, int result = 0) { list finished; take_waiting(mask, finished); - finish_contexts(finished, result); + finish_contexts(&g_ceph_context, finished, result); } diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 4afc0a86a92d3..b0ad7b1d14ab2 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -294,9 +294,9 @@ void Paxos::handle_last(MMonPaxos *last) extend_lease(); // wake people up - finish_contexts(waiting_for_active); - finish_contexts(waiting_for_readable); - finish_contexts(waiting_for_writeable); + finish_contexts(&g_ceph_context, waiting_for_active); + finish_contexts(&g_ceph_context, waiting_for_readable); + finish_contexts(&g_ceph_context, waiting_for_writeable); } } } else { @@ -344,10 +344,10 @@ void Paxos::begin(bufferlist& v) // we're alone, take it easy commit(); state = STATE_ACTIVE; - finish_contexts(waiting_for_active); - finish_contexts(waiting_for_commit); - finish_contexts(waiting_for_readable); - finish_contexts(waiting_for_writeable); + finish_contexts(&g_ceph_context, waiting_for_active); + finish_contexts(&g_ceph_context, waiting_for_commit); + finish_contexts(&g_ceph_context, waiting_for_readable); + finish_contexts(&g_ceph_context, waiting_for_writeable); update_observers(); return; } @@ -450,10 +450,10 @@ void Paxos::handle_accept(MMonPaxos *accept) extend_lease(); // wake people up - finish_contexts(waiting_for_active); - finish_contexts(waiting_for_commit); - finish_contexts(waiting_for_readable); - finish_contexts(waiting_for_writeable); + finish_contexts(&g_ceph_context, waiting_for_active); + finish_contexts(&g_ceph_context, waiting_for_commit); + finish_contexts(&g_ceph_context, waiting_for_readable); + finish_contexts(&g_ceph_context, waiting_for_writeable); } accept->put(); } @@ -518,7 +518,7 @@ void Paxos::handle_commit(MMonPaxos *commit) commit->put(); - finish_contexts(waiting_for_commit); + finish_contexts(&g_ceph_context, waiting_for_commit); } void Paxos::extend_lease() @@ -619,9 +619,9 @@ void Paxos::handle_lease(MMonPaxos *lease) trim_to(lease->first_committed); // kick waiters - finish_contexts(waiting_for_active); + finish_contexts(&g_ceph_context, waiting_for_active); if (is_readable()) - finish_contexts(waiting_for_readable); + finish_contexts(&g_ceph_context, waiting_for_readable); lease->put(); } @@ -780,8 +780,8 @@ void Paxos::peon_init() dout(10) << "peon_init -- i am a peon" << dendl; // no chance to write now! - finish_contexts(waiting_for_writeable, -1); - finish_contexts(waiting_for_commit, -1); + finish_contexts(&g_ceph_context, waiting_for_writeable, -1); + finish_contexts(&g_ceph_context, waiting_for_commit, -1); } void Paxos::election_starting() @@ -790,7 +790,7 @@ void Paxos::election_starting() cancel_events(); new_value.clear(); - finish_contexts(waiting_for_commit, -1); + finish_contexts(&g_ceph_context, waiting_for_commit, -1); } diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index e2b41e207f15c..3f81adde33185 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -3153,7 +3153,7 @@ void FileStore::sync_entry() } lock.Lock(); - finish_contexts(fin, 0); + finish_contexts(&g_ceph_context, fin, 0); fin.clear(); if (!sync_waiters.empty()) { dout(10) << "sync_entry more waiters, committing again" << dendl; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 1830694cef086..91ec36e14d08a 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1169,7 +1169,7 @@ PG *OSD::get_or_create_pg(const PG::Info& info, epoch_t epoch, int from, int& cr // ok, create PG locally using provided Info and History *pt = new ObjectStore::Transaction; - *pfin = new C_Contexts; + *pfin = new C_Contexts(&g_ceph_context); if (create) { pg = _create_lock_new_pg(info.pgid, acting, **pt); } else { @@ -1201,7 +1201,7 @@ PG *OSD::get_or_create_pg(const PG::Info& info, epoch_t epoch, int from, int& cr return NULL; } *pt = new ObjectStore::Transaction; - *pfin = new C_Contexts; + *pfin = new C_Contexts(&g_ceph_context); } return pg; } @@ -3189,7 +3189,7 @@ void OSD::handle_osd_map(MOSDMap *m) had_map_since = g_clock.now(); } - C_Contexts *fin = new C_Contexts; + C_Contexts *fin = new C_Contexts(&g_ceph_context); if (osdmap->is_up(whoami) && osdmap->get_addr(whoami) == client_messenger->get_myaddr()) { @@ -3802,7 +3802,7 @@ void OSD::kick_pg_split_queue() // create and lock children ObjectStore::Transaction *t = new ObjectStore::Transaction; - C_Contexts *fin = new C_Contexts; + C_Contexts *fin = new C_Contexts(&g_ceph_context); map children; for (set::iterator q = p->second.begin(); q != p->second.end(); @@ -4042,7 +4042,7 @@ void OSD::handle_pg_create(MOSDPGCreate *m) if (can_create_pg(pgid)) { ObjectStore::Transaction *t = new ObjectStore::Transaction; - C_Contexts *fin = new C_Contexts; + C_Contexts *fin = new C_Contexts(&g_ceph_context); PG *pg = _create_lock_new_pg(pgid, creating_pgs[pgid].acting, *t); creating_pgs.erase(pgid); @@ -4673,7 +4673,7 @@ void OSD::generate_backlog(PG *pg) map< int, map > query_map; map< int, MOSDPGInfo* > info_map; ObjectStore::Transaction *t = new ObjectStore::Transaction; - C_Contexts *fin = new C_Contexts; + C_Contexts *fin = new C_Contexts(&g_ceph_context); PG::RecoveryCtx rctx(&query_map, &info_map, 0, &fin->contexts, t); if (!pg->generate_backlog_epoch) { diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 3e6ccb7a17580..82e86a01d3691 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4373,7 +4373,7 @@ int ReplicatedPG::start_recovery_ops(int max) dout(10) << __func__ << ": all OSDs in the PG are up-to-date!" << dendl; log.reset_recovery_pointers(); ObjectStore::Transaction *t = new ObjectStore::Transaction; - C_Contexts *fin = new C_Contexts; + C_Contexts *fin = new C_Contexts(&g_ceph_context); finish_recovery(*t, fin->contexts); int tr = osd->store->queue_transaction(&osr, t, new ObjectStore::C_DeleteTransaction(t), fin); assert(tr == 0); diff --git a/src/osdc/Filer.h b/src/osdc/Filer.h index af9b20d785f8c..536d63fac7e33 100644 --- a/src/osdc/Filer.h +++ b/src/osdc/Filer.h @@ -194,9 +194,9 @@ class Filer { } else { C_Gather *gack = 0, *gcom = 0; if (onack) - gack = new C_Gather(onack); + gack = new C_Gather(&g_ceph_context, onack); if (oncommit) - gcom = new C_Gather(oncommit); + gcom = new C_Gather(&g_ceph_context, oncommit); for (vector::iterator p = extents.begin(); p != extents.end(); p++) { vector ops(1); ops[0].op.op = CEPH_OSD_OP_TRIMTRUNC; @@ -231,9 +231,9 @@ class Filer { } else { C_Gather *gack = 0, *gcom = 0; if (onack) - gack = new C_Gather(onack); + gack = new C_Gather(&g_ceph_context, onack); if (oncommit) - gcom = new C_Gather(oncommit); + gcom = new C_Gather(&g_ceph_context, oncommit); for (vector::iterator p = extents.begin(); p != extents.end(); p++) { if (p->offset == 0 && p->length == layout->fl_object_size) objecter->remove(p->oid, p->oloc, diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index a7b8cd13deb0e..f2a46811d0193 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -195,7 +195,7 @@ void Journaler::_finish_read_head(int r, bufferlist& bl) state = STATE_ACTIVE; list ls; ls.swap(waitfor_recover); - finish_contexts(ls, 0); + finish_contexts(&g_ceph_context, ls, 0); return; } @@ -209,7 +209,7 @@ void Journaler::_finish_read_head(int r, bufferlist& bl) << magic << "'" << dendl; list ls; ls.swap(waitfor_recover); - finish_contexts(ls, -EINVAL); + finish_contexts(&g_ceph_context, ls, -EINVAL); return; } @@ -283,7 +283,7 @@ void Journaler::_finish_probe_end(int r, uint64_t end) // done. list ls; ls.swap(waitfor_recover); - finish_contexts(ls, 0); + finish_contexts(&g_ceph_context, ls, 0); } class Journaler::C_RereadHeadProbe : public Context @@ -408,7 +408,7 @@ void Journaler::_finish_flush(int r, uint64_t start, utime_t stamp) while (!waitfor_safe.empty()) { if (waitfor_safe.begin()->first > safe_pos) break; - finish_contexts(waitfor_safe.begin()->second); + finish_contexts(&g_ceph_context, waitfor_safe.begin()->second); waitfor_safe.erase(waitfor_safe.begin()); } } @@ -1010,7 +1010,7 @@ void Journaler::_trim_finish(int r, uint64_t to) // finishers? while (!waitfor_trim.empty() && waitfor_trim.begin()->first <= trimmed_pos) { - finish_contexts(waitfor_trim.begin()->second, 0); + finish_contexts(&g_ceph_context, waitfor_trim.begin()->second, 0); waitfor_trim.erase(waitfor_trim.begin()); } } diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index e64d85d7c0658..f713afa726db7 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -520,7 +520,7 @@ void ObjectCacher::bh_read_finish(int poolid, sobject_t oid, loff_t start, uint6 p++) ls.splice(ls.end(), p->second); bh->waitfor_read.clear(); - finish_contexts(ls); + finish_contexts(&g_ceph_context, ls); // clean up? ob->try_merge_bh(bh); @@ -617,7 +617,7 @@ void ObjectCacher::lock_ack(int poolid, list& oids, tid_t tid) << " tid " << tid << " obsolete" << dendl; } - finish_contexts(ls); + finish_contexts(&g_ceph_context, ls); } } @@ -678,7 +678,7 @@ void ObjectCacher::bh_write_ack(int poolid, sobject_t oid, loff_t start, uint64_ list ls; ls.splice(ls.begin(), ob->waitfor_ack[tid]); ob->waitfor_ack.erase(tid); - finish_contexts(ls); + finish_contexts(&g_ceph_context, ls); } // is the entire object set now clean? @@ -713,7 +713,7 @@ void ObjectCacher::bh_write_commit(int poolid, sobject_t oid, loff_t start, uint list ls; ls.splice(ls.begin(), ob->waitfor_commit[tid]); ob->waitfor_commit.erase(tid); - finish_contexts(ls); + finish_contexts(&g_ceph_context, ls); } // is the entire object set now clean and fully committed? @@ -1488,7 +1488,7 @@ bool ObjectCacher::flush_set(ObjectSet *oset, Context *onfinish) if (!flush(ob)) { // we'll need to gather... if (!gather && onfinish) - gather = new C_Gather(onfinish); + gather = new C_Gather(&g_ceph_context, onfinish); safe = false; dout(10) << "flush_set " << oset << " will wait for ack tid " @@ -1535,7 +1535,7 @@ bool ObjectCacher::commit_set(ObjectSet *oset, Context *onfinish) dout(10) << "commit_set " << oset << " " << *ob << " will finish on commit tid " << ob->last_write_tid << dendl; - if (!gather && onfinish) gather = new C_Gather(onfinish); + if (!gather && onfinish) gather = new C_Gather(&g_ceph_context, onfinish); safe = false; if (gather) ob->waitfor_commit[ob->last_write_tid].push_back( gather->new_sub() ); @@ -1735,7 +1735,7 @@ void ObjectCacher::kick_sync_writers(ObjectSet *oset) ls.splice(ls.begin(), ob->waitfor_wr); } - finish_contexts(ls); + finish_contexts(&g_ceph_context, ls); } void ObjectCacher::kick_sync_readers(ObjectSet *oset) @@ -1756,7 +1756,7 @@ void ObjectCacher::kick_sync_readers(ObjectSet *oset) ls.splice(ls.begin(), ob->waitfor_rd); } - finish_contexts(ls); + finish_contexts(&g_ceph_context, ls); } diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 75f60a82ab033..cfa17ea83ce70 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1061,7 +1061,7 @@ public: read_trunc(extents[0].oid, extents[0].oloc, extents[0].offset, extents[0].length, snap, bl, flags, trunc_size, trunc_seq, onfinish); } else { - C_Gather *g = new C_Gather; + C_Gather *g = new C_Gather(&g_ceph_context); vector resultbl(extents.size()); int i=0; for (vector::iterator p = extents.begin(); p != extents.end(); p++) { @@ -1085,9 +1085,9 @@ public: } else { C_Gather *gack = 0, *gcom = 0; if (onack) - gack = new C_Gather(onack); + gack = new C_Gather(&g_ceph_context, onack); if (oncommit) - gcom = new C_Gather(oncommit); + gcom = new C_Gather(&g_ceph_context, oncommit); for (vector::iterator p = extents.begin(); p != extents.end(); p++) { bufferlist cur; for (map<__u32,__u32>::iterator bit = p->buffer_extents.begin(); diff --git a/src/test/gather.cc b/src/test/gather.cc index a065e19f3e2f8..5b64aecd54b3b 100644 --- a/src/test/gather.cc +++ b/src/test/gather.cc @@ -25,7 +25,7 @@ public: }; TEST(ContextGather, Constructor) { - C_Gather *gather = new C_Gather(); + C_Gather *gather = new C_Gather(&g_ceph_context ); EXPECT_TRUE(gather->empty()); EXPECT_EQ(0, gather->get_num()); EXPECT_EQ(0, gather->get_num_remaining()); @@ -33,7 +33,7 @@ TEST(ContextGather, Constructor) { } TEST(ContextGather, OneSub) { - C_Gather *gather = new C_Gather(); + C_Gather *gather = new C_Gather(&g_ceph_context); Context *sub = gather->new_sub(); EXPECT_EQ(1, gather->get_num()); EXPECT_EQ(1, gather->get_num_remaining()); @@ -50,7 +50,7 @@ TEST(ContextGather, OneSub) { } TEST(ContextGather, ManySubs) { - C_Gather *gather = new C_Gather(); + C_Gather *gather = new C_Gather(&g_ceph_context); int sub_count = 8; bool finish_called = false; int result = 0; @@ -81,7 +81,7 @@ TEST(ContextGather, ManySubs) { } TEST(ContextGather, AlternatingSubCreateFinish) { - C_Gather *gather = new C_Gather(); + C_Gather *gather = new C_Gather(&g_ceph_context); int sub_count = 8; bool finish_called = false; int result = 0; -- 2.39.5