From: Xinze Chi Date: Mon, 7 Nov 2016 00:05:58 +0000 (+0800) Subject: OSD: do not open pgs when the pg is not in pg_map X-Git-Tag: v11.1.0~290^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3c1526e6058cd97107b6cb1b6e885fd099005a11;p=ceph.git OSD: do not open pgs when the pg is not in pg_map the pg may be removed before the C_OpenPGs callbacked by finisher Fixes: http://tracker.ceph.com/issues/17806 Signed-off-by: Xinze Chi --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 3f01634a7c0d..c63aab800002 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -7738,13 +7738,17 @@ PG::RecoveryCtx OSD::create_context() struct C_OpenPGs : public Context { set pgs; ObjectStore *store; - C_OpenPGs(set& p, ObjectStore *s) : store(s) { + OSD *osd; + C_OpenPGs(set& p, ObjectStore *s, OSD* o) : store(s), osd(o) { pgs.swap(p); } void finish(int r) { + RWLock::RLocker l(osd->pg_map_lock); for (auto p : pgs) { - p->ch = store->open_collection(p->coll); - assert(p->ch); + if (osd->pg_map.count(p->info.pgid)) { + p->ch = store->open_collection(p->coll); + assert(p->ch); + } } } }; @@ -7754,7 +7758,7 @@ void OSD::dispatch_context_transaction(PG::RecoveryCtx &ctx, PG *pg, { 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 C_OpenPGs(ctx.created_pgs, store, this)); } int tr = store->queue_transaction( pg->osr.get(), @@ -7790,7 +7794,7 @@ void OSD::dispatch_context(PG::RecoveryCtx &ctx, PG *pg, OSDMapRef curmap, 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 C_OpenPGs(ctx.created_pgs, store, this)); } int tr = store->queue_transaction( pg->osr.get(), diff --git a/src/osd/OSD.h b/src/osd/OSD.h index a08a34f45462..20500b2ec2db 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -222,6 +222,7 @@ class OpsFlightSocketHook; class HistoricOpsSocketHook; class TestOpsSocketHook; struct C_CompleteSplits; +struct C_OpenPGs; class LogChannel; class CephContext; typedef ceph::shared_ptr SequencerRef; @@ -1740,6 +1741,7 @@ private: friend class TestOpsSocketHook; TestOpsSocketHook *test_ops_hook; friend struct C_CompleteSplits; + friend struct C_OpenPGs; // -- op queue -- enum io_queue {