From: Sage Weil Date: Mon, 18 Jan 2016 16:07:28 +0000 (-0500) Subject: osd: associate a CollectionHandle with each PG X-Git-Tag: v10.0.4~153^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f3de2b87ad43f002487b877a9df39d830cbbff94;p=ceph.git osd: associate a CollectionHandle with each PG Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index dffd7a3712990..55736486fe0f4 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2946,6 +2946,8 @@ void OSD::load_pgs() } // there can be no waiters here, so we don't call wake_pg_waiters + pg->ch = store->open_collection(pg->coll); + // read pg state, log pg->read_state(store, bl); @@ -7077,6 +7079,7 @@ void OSD::split_pgs( PG* child = _make_pg(nextmap, *i); child->lock(true); out_pgs->insert(child); + rctx->created_pgs.insert(child); unsigned split_bits = i->get_split_bits(pg_num); dout(10) << "pg_num is " << pg_num << dendl; @@ -7238,10 +7241,27 @@ PG::RecoveryCtx OSD::create_context() return rctx; } +struct C_OpenPGs : public Context { + set pgs; + ObjectStore *store; + C_OpenPGs(set& p, ObjectStore *s) : store(s) { + pgs.swap(p); + } + void finish(int r) { + for (auto p : pgs) { + p->ch = store->open_collection(p->coll); + assert(p->ch); + } + } +}; + void OSD::dispatch_context_transaction(PG::RecoveryCtx &ctx, PG *pg, ThreadPool::TPHandle *handle) { if (!ctx.transaction->empty()) { + if (!ctx.created_pgs.empty()) { + ctx.on_applied->add(new C_OpenPGs(ctx.created_pgs, store)); + } ctx.on_applied->add(new ObjectStore::C_DeleteTransaction(ctx.transaction)); int tr = store->queue_transaction( pg->osr.get(), @@ -7268,11 +7288,16 @@ void OSD::dispatch_context(PG::RecoveryCtx &ctx, PG *pg, OSDMapRef curmap, delete ctx.info_map; if ((ctx.on_applied->empty() && ctx.on_safe->empty() && - ctx.transaction->empty()) || !pg) { + ctx.transaction->empty() && + ctx.created_pgs.empty()) || !pg) { delete ctx.transaction; delete ctx.on_applied; delete ctx.on_safe; + assert(ctx.created_pgs.empty()); } else { + if (!ctx.created_pgs.empty()) { + ctx.on_applied->add(new C_OpenPGs(ctx.created_pgs, store)); + } ctx.on_applied->add(new ObjectStore::C_DeleteTransaction(ctx.transaction)); int tr = store->queue_transaction( pg->osr.get(), diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 88b42d061e233..64d550055f888 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -5446,6 +5446,7 @@ void PG::handle_loaded(RecoveryCtx *rctx) void PG::handle_create(RecoveryCtx *rctx) { dout(10) << "handle_create" << dendl; + rctx->created_pgs.insert(this); Initialize evt; recovery_state.handle_event(evt, rctx); ActMap evt2; diff --git a/src/osd/PG.h b/src/osd/PG.h index c5f1c12ff7af4..8265f463cddef 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -298,6 +298,7 @@ public: void upgrade(ObjectStore *store); const coll_t coll; + ObjectStore::CollectionHandle ch; PGLog pg_log; static string get_info_key(spg_t pgid) { return stringify(pgid) + "_info"; @@ -530,6 +531,7 @@ public: map > *query_map; map > > *info_map; map > > *notify_list; + set created_pgs; C_Contexts *on_applied; C_Contexts *on_safe; ObjectStore::Transaction *transaction;