From 8c2f8bf54b90337421b99a1bc100e2ae896ddd99 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Wed, 29 Jul 2015 16:20:00 +0800 Subject: [PATCH] osd: no bother to create RecoveryCtx if no recovery op is started If there is no recovery op started, there is no need to create a RecoveryCtx and later delete all of the things in it. Signed-off-by: Zhiqiang Wang --- src/osd/OSD.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index b9f307c4cad..0c092a60ac0 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -7839,12 +7839,17 @@ void OSD::do_recovery(PG *pg, ThreadPool::TPHandle &handle) dout(20) << " active was " << recovery_oids[pg->info.pgid] << dendl; #endif - PG::RecoveryCtx rctx = create_context(); - rctx.handle = &handle; - int started; bool more = pg->start_recovery_ops(max, handle, &started); dout(10) << "do_recovery started " << started << "/" << max << " on " << *pg << dendl; + // If no recovery op is started, don't bother to manipulate the RecoveryCtx + if (!started && (more || !pg->have_unfound())) { + pg->unlock(); + goto out; + } + + PG::RecoveryCtx rctx = create_context(); + rctx.handle = &handle; /* * if we couldn't start any recovery ops and things are still -- 2.47.3