|
|
545b23 |
From 5f7f6c3c6aa3640162e5dc91d4e648b2c17e74d2 Mon Sep 17 00:00:00 2001
|
|
|
545b23 |
From: Jason Dillaman <dillaman@redhat.com>
|
|
|
545b23 |
Date: Wed, 8 Apr 2015 17:24:08 -0400
|
|
|
545b23 |
Subject: [PATCH 14/22] librbd: add task pool / work queue for AIO requests
|
|
|
545b23 |
|
|
|
545b23 |
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
|
|
|
545b23 |
(cherry picked from commit afb896d91f886b647baf38f7ec94cc3739f6d2a9)
|
|
|
545b23 |
(cherry picked from commit 9faaeae4c181944636b4119c0a797181ded0651f)
|
|
|
545b23 |
|
|
|
545b23 |
Conflicts:
|
|
|
545b23 |
src/librbd/ImageCtx.cc: removed refs to pending AIO
|
|
|
545b23 |
src/librbd/ImageCtx.h: removed refs to pending AIO
|
|
|
545b23 |
src/librbd/internal.cc: removed refs to pending AIO
|
|
|
545b23 |
---
|
|
|
545b23 |
src/common/config_opts.h | 2 ++
|
|
|
545b23 |
src/librbd/ImageCtx.cc | 30 +++++++++++++++++++++++++++++-
|
|
|
545b23 |
src/librbd/ImageCtx.h | 3 +++
|
|
|
545b23 |
src/librbd/internal.cc | 4 ++++
|
|
|
545b23 |
4 files changed, 38 insertions(+), 1 deletion(-)
|
|
|
545b23 |
|
|
|
545b23 |
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
|
|
|
545b23 |
index da9bcdf..f024011 100644
|
|
|
545b23 |
--- a/src/common/config_opts.h
|
|
|
545b23 |
+++ b/src/common/config_opts.h
|
|
|
545b23 |
@@ -719,6 +719,8 @@ OPTION(journal_ignore_corruption, OPT_BOOL, false) // assume journal is not corr
|
|
|
545b23 |
OPTION(rados_mon_op_timeout, OPT_DOUBLE, 0) // how many seconds to wait for a response from the monitor before returning an error from a rados operation. 0 means on limit.
|
|
|
545b23 |
OPTION(rados_osd_op_timeout, OPT_DOUBLE, 0) // how many seconds to wait for a response from osds before returning an error from a rados operation. 0 means no limit.
|
|
|
545b23 |
|
|
|
545b23 |
+OPTION(rbd_op_threads, OPT_INT, 1)
|
|
|
545b23 |
+OPTION(rbd_op_thread_timeout, OPT_INT, 60)
|
|
|
545b23 |
OPTION(rbd_cache, OPT_BOOL, false) // whether to enable caching (writeback unless rbd_cache_max_dirty is 0)
|
|
|
545b23 |
OPTION(rbd_cache_writethrough_until_flush, OPT_BOOL, false) // whether to make writeback caching writethrough until flush is called, to be sure the user of librbd will send flushs so that writeback is safe
|
|
|
545b23 |
OPTION(rbd_cache_size, OPT_LONGLONG, 32<<20) // cache size in bytes
|
|
|
545b23 |
diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc
|
|
|
545b23 |
index b5c2db6..4850b9a 100644
|
|
|
545b23 |
--- a/src/librbd/ImageCtx.cc
|
|
|
545b23 |
+++ b/src/librbd/ImageCtx.cc
|
|
|
545b23 |
@@ -6,6 +6,7 @@
|
|
|
545b23 |
#include "common/dout.h"
|
|
|
545b23 |
#include "common/errno.h"
|
|
|
545b23 |
#include "common/perf_counters.h"
|
|
|
545b23 |
+#include "common/WorkQueue.h"
|
|
|
545b23 |
|
|
|
545b23 |
#include "librbd/internal.h"
|
|
|
545b23 |
#include "librbd/WatchCtx.h"
|
|
|
545b23 |
@@ -27,6 +28,23 @@ using librados::snap_t;
|
|
|
545b23 |
using librados::IoCtx;
|
|
|
545b23 |
|
|
|
545b23 |
namespace librbd {
|
|
|
545b23 |
+
|
|
|
545b23 |
+namespace {
|
|
|
545b23 |
+
|
|
|
545b23 |
+class ThreadPoolSingleton : public ThreadPool {
|
|
|
545b23 |
+public:
|
|
|
545b23 |
+ ThreadPoolSingleton(CephContext *cct)
|
|
|
545b23 |
+ : ThreadPool(cct, "librbd::thread_pool", cct->_conf->rbd_op_threads,
|
|
|
545b23 |
+ "rbd_op_threads") {
|
|
|
545b23 |
+ start();
|
|
|
545b23 |
+ }
|
|
|
545b23 |
+ virtual ~ThreadPoolSingleton() {
|
|
|
545b23 |
+ stop();
|
|
|
545b23 |
+ }
|
|
|
545b23 |
+};
|
|
|
545b23 |
+
|
|
|
545b23 |
+} // anonymous namespace
|
|
|
545b23 |
+
|
|
|
545b23 |
ImageCtx::ImageCtx(const string &image_name, const string &image_id,
|
|
|
545b23 |
const char *snap, IoCtx& p, bool ro)
|
|
|
545b23 |
: cct((CephContext*)p.cct()),
|
|
|
545b23 |
@@ -51,7 +69,8 @@ namespace librbd {
|
|
|
545b23 |
format_string(NULL),
|
|
|
545b23 |
id(image_id), parent(NULL),
|
|
|
545b23 |
stripe_unit(0), stripe_count(0),
|
|
|
545b23 |
- object_cacher(NULL), writeback_handler(NULL), object_set(NULL)
|
|
|
545b23 |
+ object_cacher(NULL), writeback_handler(NULL), object_set(NULL),
|
|
|
545b23 |
+ aio_work_queue(NULL)
|
|
|
545b23 |
{
|
|
|
545b23 |
md_ctx.dup(p);
|
|
|
545b23 |
data_ctx.dup(p);
|
|
|
545b23 |
@@ -96,6 +115,13 @@ namespace librbd {
|
|
|
545b23 |
object_set->return_enoent = true;
|
|
|
545b23 |
object_cacher->start();
|
|
|
545b23 |
}
|
|
|
545b23 |
+
|
|
|
545b23 |
+ ThreadPoolSingleton *thread_pool_singleton;
|
|
|
545b23 |
+ cct->lookup_or_create_singleton_object<ThreadPoolSingleton>(
|
|
|
545b23 |
+ thread_pool_singleton, "librbd::thread_pool");
|
|
|
545b23 |
+ aio_work_queue = new ContextWQ("librbd::aio_work_queue",
|
|
|
545b23 |
+ cct->_conf->rbd_op_thread_timeout,
|
|
|
545b23 |
+ thread_pool_singleton);
|
|
|
545b23 |
}
|
|
|
545b23 |
|
|
|
545b23 |
ImageCtx::~ImageCtx() {
|
|
|
545b23 |
@@ -113,6 +139,8 @@ namespace librbd {
|
|
|
545b23 |
object_set = NULL;
|
|
|
545b23 |
}
|
|
|
545b23 |
delete[] format_string;
|
|
|
545b23 |
+
|
|
|
545b23 |
+ delete aio_work_queue;
|
|
|
545b23 |
}
|
|
|
545b23 |
|
|
|
545b23 |
int ImageCtx::init() {
|
|
|
545b23 |
diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h
|
|
|
545b23 |
index 83ed044..218527a 100644
|
|
|
545b23 |
--- a/src/librbd/ImageCtx.h
|
|
|
545b23 |
+++ b/src/librbd/ImageCtx.h
|
|
|
545b23 |
@@ -25,6 +25,7 @@
|
|
|
545b23 |
#include "librbd/parent_types.h"
|
|
|
545b23 |
|
|
|
545b23 |
class CephContext;
|
|
|
545b23 |
+class ContextWQ;
|
|
|
545b23 |
class PerfCounters;
|
|
|
545b23 |
|
|
|
545b23 |
namespace librbd {
|
|
|
545b23 |
@@ -89,6 +90,8 @@ namespace librbd {
|
|
|
545b23 |
LibrbdWriteback *writeback_handler;
|
|
|
545b23 |
ObjectCacher::ObjectSet *object_set;
|
|
|
545b23 |
|
|
|
545b23 |
+ ContextWQ *aio_work_queue;
|
|
|
545b23 |
+
|
|
|
545b23 |
/**
|
|
|
545b23 |
* Either image_name or image_id must be set.
|
|
|
545b23 |
* If id is not known, pass the empty std::string,
|
|
|
545b23 |
diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc
|
|
|
545b23 |
index afa4660..b0c8ebc 100644
|
|
|
545b23 |
--- a/src/librbd/internal.cc
|
|
|
545b23 |
+++ b/src/librbd/internal.cc
|
|
|
545b23 |
@@ -9,6 +9,7 @@
|
|
|
545b23 |
#include "common/dout.h"
|
|
|
545b23 |
#include "common/errno.h"
|
|
|
545b23 |
#include "common/Throttle.h"
|
|
|
545b23 |
+#include "common/WorkQueue.h"
|
|
|
545b23 |
#include "cls/lock/cls_lock_client.h"
|
|
|
545b23 |
#include "include/stringify.h"
|
|
|
545b23 |
|
|
|
545b23 |
@@ -2118,6 +2119,9 @@ reprotect_and_return_err:
|
|
|
545b23 |
void close_image(ImageCtx *ictx)
|
|
|
545b23 |
{
|
|
|
545b23 |
ldout(ictx->cct, 20) << "close_image " << ictx << dendl;
|
|
|
545b23 |
+
|
|
|
545b23 |
+ ictx->aio_work_queue->drain();
|
|
|
545b23 |
+
|
|
|
545b23 |
if (ictx->object_cacher)
|
|
|
545b23 |
ictx->shutdown_cache(); // implicitly flushes
|
|
|
545b23 |
else
|
|
|
545b23 |
--
|
|
|
545b23 |
2.1.0
|
|
|
545b23 |
|