From: Venky Shankar Date: Fri, 24 Jun 2016 08:20:52 +0000 (+0530) Subject: librbd / ImageCtx: singleton thread pool instance helper X-Git-Tag: ses5-milestone5~161^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=21e6573d49997cccc96e197d784aeacf10bdc919;p=ceph.git librbd / ImageCtx: singleton thread pool instance helper Introduce static member function in ImageCtx to fetch (and initialize) singleton thread pool. Signed-off-by: Venky Shankar --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index df1d837a106b..56989fa1c974 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -181,9 +181,7 @@ struct C_InvalidateCache : public Context { memset(&header, 0, sizeof(header)); - ThreadPoolSingleton *thread_pool_singleton; - cct->lookup_or_create_singleton_object( - thread_pool_singleton, "librbd::thread_pool"); + ThreadPool *thread_pool_singleton = get_thread_pool_instance(cct); aio_work_queue = new AioImageRequestWQ(this, "librbd::aio_work_queue", cct->_conf->rbd_op_thread_timeout, thread_pool_singleton); @@ -1044,4 +1042,11 @@ struct C_InvalidateCache : public Context { delete journal_policy; journal_policy = policy; } + + ThreadPool *ImageCtx::get_thread_pool_instance(CephContext *cct) { + ThreadPoolSingleton *thread_pool_singleton; + cct->lookup_or_create_singleton_object( + thread_pool_singleton, "librbd::thread_pool"); + return thread_pool_singleton; + } } diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 7660f6e55467..fd580d9cc9fa 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -32,6 +32,7 @@ class CephContext; class ContextWQ; class Finisher; class PerfCounters; +class ThreadPool; namespace librbd { @@ -300,6 +301,8 @@ namespace librbd { journal::Policy *get_journal_policy() const; void set_journal_policy(journal::Policy *policy); + + static ThreadPool *get_thread_pool_instance(CephContext *cct); }; }