From: Dong Yuan Date: Wed, 12 Nov 2014 09:16:25 +0000 (+0000) Subject: osd: change ReplicatedPG::object_contexts to SharedLRU X-Git-Tag: v0.93~163^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=98110f652a3ce94606c4ec07fe30d49e1589105c;p=ceph.git osd: change ReplicatedPG::object_contexts to SharedLRU The ReplicatedPG now will cache the ObjectContext to avoid repeated construction using SharedLRU. The cache is per PG, and new config option osd_pg_object_context_cache_count which is 64 by default, is used to specify how many ObjectContexts will be cached for each PG. When the PG is not primary, the object_contexts cache will be cleared. Signed-off-by: Dong Yuan --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 276d4ec6c9f0..318e9428fd35 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -604,6 +604,8 @@ OPTION(osd_target_transaction_size, OPT_INT, 30) // to adjust various transa OPTION(osd_failsafe_full_ratio, OPT_FLOAT, .97) // what % full makes an OSD "full" (failsafe) OPTION(osd_failsafe_nearfull_ratio, OPT_FLOAT, .90) // what % full makes an OSD near full (failsafe) +OPTION(osd_pg_object_context_cache_count, OPT_INT, 64) + // determines whether PGLog::check() compares written out log to stored log OPTION(osd_debug_pg_log_writeout, OPT_BOOL, false) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index f088361b624f..4a598105f1dc 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1232,6 +1232,7 @@ ReplicatedPG::ReplicatedPG(OSDService *o, OSDMapRef curmap, pgbackend( PGBackend::build_pg_backend( _pool.info, curmap, this, coll_t(p), coll_t::make_temp_coll(p), o->store, cct)), + object_contexts(o->cct, g_conf->osd_pg_object_context_cache_count), snapset_contexts_lock("ReplicatedPG::snapset_contexts"), temp_seq(0), snap_trimmer_machine(this) @@ -9951,6 +9952,9 @@ void ReplicatedPG::on_pool_change() } hit_set_setup(); agent_setup(); + if (get_role() !=0) { + object_contexts.clear(); + } } // clear state. called on recovery completion AND cancellation. diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 51636cde49a8..f728aba02ec7 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -886,7 +886,7 @@ protected: friend struct C_OnPushCommit; // projected object info - SharedPtrRegistry object_contexts; + SharedLRU object_contexts; // map from oid.snapdir() to SnapSetContext * map snapset_contexts; Mutex snapset_contexts_lock;