From: Sage Weil Date: Sat, 13 Jan 2018 17:59:01 +0000 (-0600) Subject: osd: synchronously open collection handles X-Git-Tag: v13.0.2~222^2~25 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4044b4574cb7a9c543dc5f019d1ed1fa67bb01f5;p=ceph.git osd: synchronously open collection handles bluestore and memstore are the only backends to implement open_collection, and both of them can issue a handle immediately after queue_transaction. Do that! Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 892b3a09b13..9e715413820 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8229,37 +8229,21 @@ PG::RecoveryCtx OSD::create_context() return rctx; } -struct C_OpenPGs : public Context { - set pgs; - ObjectStore *store; - OSD *osd; - C_OpenPGs(set& p, ObjectStore *s, OSD* o) : store(s), osd(o) { - pgs.swap(p); - } - void finish(int r) override { - RWLock::RLocker l(osd->pg_map_lock); - for (auto p : pgs) { - if (osd->pg_map.count(p->get_pgid())) { - 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, this)); - } int tr = store->queue_transaction( pg->ch, std::move(*ctx.transaction), ctx.on_applied, ctx.on_safe, NULL, TrackedOpRef(), handle); - delete (ctx.transaction); assert(tr == 0); + delete (ctx.transaction); + for (auto pg : ctx.created_pgs) { + pg->ch = store->open_collection(pg->coll); + assert(pg->ch); + } + ctx.created_pgs.clear(); ctx.transaction = new ObjectStore::Transaction; ctx.on_applied = new C_Contexts(cct); ctx.on_safe = new C_Contexts(cct); @@ -8287,13 +8271,15 @@ void OSD::dispatch_context(PG::RecoveryCtx &ctx, PG *pg, OSDMapRef curmap, 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, this)); - } int tr = store->queue_transaction( pg->ch, std::move(*ctx.transaction), ctx.on_applied, ctx.on_safe, NULL, TrackedOpRef(), handle); + for (auto pg : ctx.created_pgs) { + pg->ch = store->open_collection(pg->coll); + assert(pg->ch); + } + ctx.created_pgs.clear(); delete (ctx.transaction); assert(tr == 0); }