m_remote_io_ctx,
"global image id",
"local mirror uuid",
- "local image id",
+ "local image id", {},
&remote_mirror_uuid,
&remote_image_id,
&remote_journaler,
m_remote_io_ctx,
"global image id",
"local mirror uuid",
- "local image id",
+ "local image id", {},
&remote_mirror_uuid,
&remote_image_id,
&remote_journaler,
m_remote_io_ctx,
"global image id",
"local mirror uuid",
- "",
+ "", {},
&remote_mirror_uuid,
&remote_image_id,
&remote_journaler,
m_remote_io_ctx,
"global image id",
"local mirror uuid",
- "",
+ "", {},
&remote_mirror_uuid,
&remote_image_id,
&remote_journaler,
m_remote_io_ctx,
"global image id",
"local mirror uuid",
- "local image id",
+ "local image id", {},
&remote_mirror_uuid,
&remote_image_id,
&remote_journaler,
m_remote_io_ctx,
"global image id",
"local mirror uuid",
- "local image id",
+ "local image id", {},
&remote_mirror_uuid,
&remote_image_id,
&remote_journaler,
TestImageReplayer()
: m_local_cluster(new librados::Rados()), m_watch_handle(0)
{
- EXPECT_EQ(0, g_ceph_context->_conf.get_val("rbd_mirror_journal_commit_age",
- &m_journal_commit_age));
- EXPECT_EQ(0, g_ceph_context->_conf.set_val("rbd_mirror_journal_commit_age",
- "0.1"));
-
EXPECT_EQ("", connect_cluster_pp(*m_local_cluster.get()));
EXPECT_EQ(0, m_local_cluster->conf_set("rbd_cache", "false"));
EXPECT_EQ(0, m_local_cluster->conf_set("rbd_mirror_journal_poll_age", "1"));
-
+ EXPECT_EQ(0, m_local_cluster->conf_set("rbd_mirror_journal_commit_age",
+ "0.1"));
m_local_pool_name = get_temp_pool_name();
EXPECT_EQ(0, m_local_cluster->pool_create(m_local_pool_name.c_str()));
EXPECT_EQ(0, m_local_cluster->ioctx_create(m_local_pool_name.c_str(),
EXPECT_EQ(0, m_remote_cluster.pool_delete(m_remote_pool_name.c_str()));
EXPECT_EQ(0, m_local_cluster->pool_delete(m_local_pool_name.c_str()));
- EXPECT_EQ(0, g_ceph_context->_conf.set_val("rbd_mirror_journal_commit_age",
- m_journal_commit_age));
}
template <typename ImageReplayerT = rbd::mirror::ImageReplayer<> >
const std::string &global_image_id,
const std::string &local_mirror_uuid,
const std::string &local_image_id,
+ const journal::Settings &settings,
std::string *remote_mirror_uuid,
std::string *remote_image_id,
::journal::MockJournalerProxy **remote_journaler,
};
TEST_F(TestMockImageSyncThrottler, Single_Sync) {
- MockImageSyncThrottler throttler;
+ MockImageSyncThrottler throttler(g_ceph_context);
C_SaferCond on_start;
throttler.start_op("id", &on_start);
ASSERT_EQ(0, on_start.wait());
}
TEST_F(TestMockImageSyncThrottler, Multiple_Syncs) {
- MockImageSyncThrottler throttler;
+ MockImageSyncThrottler throttler(g_ceph_context);
throttler.set_max_concurrent_syncs(2);
C_SaferCond on_start1;
}
TEST_F(TestMockImageSyncThrottler, Cancel_Running_Sync) {
- MockImageSyncThrottler throttler;
+ MockImageSyncThrottler throttler(g_ceph_context);
C_SaferCond on_start;
throttler.start_op("id", &on_start);
ASSERT_EQ(0, on_start.wait());
}
TEST_F(TestMockImageSyncThrottler, Cancel_Waiting_Sync) {
- MockImageSyncThrottler throttler;
+ MockImageSyncThrottler throttler(g_ceph_context);
throttler.set_max_concurrent_syncs(1);
C_SaferCond on_start1;
TEST_F(TestMockImageSyncThrottler, Cancel_Running_Sync_Start_Waiting) {
- MockImageSyncThrottler throttler;
+ MockImageSyncThrottler throttler(g_ceph_context);
throttler.set_max_concurrent_syncs(1);
C_SaferCond on_start1;
}
TEST_F(TestMockImageSyncThrottler, Increase_Max_Concurrent_Syncs) {
- MockImageSyncThrottler throttler;
+ MockImageSyncThrottler throttler(g_ceph_context);
throttler.set_max_concurrent_syncs(2);
C_SaferCond on_start1;
}
TEST_F(TestMockImageSyncThrottler, Decrease_Max_Concurrent_Syncs) {
- MockImageSyncThrottler throttler;
+ MockImageSyncThrottler throttler(g_ceph_context);
throttler.set_max_concurrent_syncs(4);
C_SaferCond on_start1;
struct ImageSyncThrottler<librbd::MockTestImageCtx> {
static ImageSyncThrottler* s_instance;
- static ImageSyncThrottler *create() {
+ static ImageSyncThrottler *create(CephContext *cct) {
ceph_assert(s_instance != nullptr);
return s_instance;
}
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
+#include "librbd/api/Config.h"
#include "test/librbd/mock/MockImageCtx.h"
#include "test/librados_test_stub/MockTestMemCluster.h"
#include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
} // anonymous namespace
+namespace api {
+
+template <>
+class Config<MockTestImageCtx> {
+public:
+ static int list(librados::IoCtx& io_ctx,
+ std::vector<config_option_t> *options) {
+ return 0;
+ }
+};
+
+}
+
} // namespace librbd
namespace rbd {
void ImageDeleter<I>::remove_images() {
dout(10) << dendl;
- uint64_t max_concurrent_deletions = g_ceph_context->_conf.get_val<uint64_t>(
+ auto cct = reinterpret_cast<CephContext *>(m_local_io_ctx.cct());
+ uint64_t max_concurrent_deletions = cct->_conf.get_val<uint64_t>(
"rbd_mirror_concurrent_image_deletions");
Mutex::Locker locker(m_lock);
image_deleter::ERROR_RESULT_RETRY_IMMEDIATELY) {
enqueue_failed_delete(&delete_info, r, m_busy_interval);
} else {
- double failed_interval = g_ceph_context->_conf.get_val<double>(
+ auto cct = reinterpret_cast<CephContext *>(m_local_io_ctx.cct());
+ double failed_interval = cct->_conf.get_val<double>(
"rbd_mirror_delete_retry_interval");
enqueue_failed_delete(&delete_info, r, failed_interval);
}
ceph_assert(!m_peers.empty());
m_remote_image = {*m_peers.begin()};
+ auto cct = static_cast<CephContext *>(m_local->cct());
+ journal::Settings journal_settings;
+ journal_settings.commit_interval = cct->_conf.get_val<double>(
+ "rbd_mirror_journal_commit_age");
+ journal_settings.max_fetch_bytes = cct->_conf.get_val<Option::size_t>(
+ "rbd_mirror_journal_max_fetch_bytes");
+
Context *ctx = create_context_callback<
ImageReplayer, &ImageReplayer<I>::handle_prepare_remote_image>(this);
auto req = PrepareRemoteImageRequest<I>::create(
m_threads, m_remote_image.io_ctx, m_global_image_id, m_local_mirror_uuid,
- m_local_image_id, &m_remote_image.mirror_uuid, &m_remote_image.image_id,
- &m_remote_journaler, &m_client_state, &m_client_meta, ctx);
+ m_local_image_id, journal_settings, &m_remote_image.mirror_uuid,
+ &m_remote_image.image_id, &m_remote_journaler, &m_client_state,
+ &m_client_meta, ctx);
req->send();
}
namespace mirror {
template <typename I>
-ImageSyncThrottler<I>::ImageSyncThrottler()
- : m_lock(librbd::util::unique_lock_name("rbd::mirror::ImageSyncThrottler",
+ImageSyncThrottler<I>::ImageSyncThrottler(CephContext *cct)
+ : m_cct(cct),
+ m_lock(librbd::util::unique_lock_name("rbd::mirror::ImageSyncThrottler",
this)),
- m_max_concurrent_syncs(g_ceph_context->_conf.get_val<uint64_t>(
+ m_max_concurrent_syncs(cct->_conf.get_val<uint64_t>(
"rbd_mirror_concurrent_image_syncs")) {
dout(20) << "max_concurrent_syncs=" << m_max_concurrent_syncs << dendl;
- g_ceph_context->_conf.add_observer(this);
+ m_cct->_conf.add_observer(this);
}
template <typename I>
ImageSyncThrottler<I>::~ImageSyncThrottler() {
- g_ceph_context->_conf.remove_observer(this);
+ m_cct->_conf.remove_observer(this);
Mutex::Locker locker(m_lock);
ceph_assert(m_inflight_ops.empty());
#include "common/Mutex.h"
#include "common/config_obs.h"
+class CephContext;
class Context;
namespace ceph { class Formatter; }
template <typename ImageCtxT = librbd::ImageCtx>
class ImageSyncThrottler : public md_config_obs_t {
public:
- static ImageSyncThrottler *create() {
- return new ImageSyncThrottler();
+ static ImageSyncThrottler *create(CephContext *cct) {
+ return new ImageSyncThrottler(cct);
}
void destroy() {
delete this;
}
- ImageSyncThrottler();
+ ImageSyncThrottler(CephContext *cct);
~ImageSyncThrottler() override;
void set_max_concurrent_syncs(uint32_t max);
void print_status(Formatter *f, std::stringstream *ss);
private:
+ CephContext *m_cct;
Mutex m_lock;
uint32_t m_max_concurrent_syncs;
std::list<std::pair<std::string, Context *>> m_queue;
queue_start_image_replayers();
});
- int after = g_ceph_context->_conf.get_val<int64_t>(
+ auto cct = static_cast<CephContext *>(m_local_rados->cct());
+ int after = cct->_conf.get_val<int64_t>(
"rbd_mirror_image_state_check_interval");
dout(10) << "scheduling image state check after " << after << " sec (task "
Mutex::Locker locker(m_lock);
ceph_assert(m_image_sync_throttler == nullptr);
- m_image_sync_throttler = ImageSyncThrottler<I>::create();
+ m_image_sync_throttler = ImageSyncThrottler<I>::create(m_cct);
m_leader_instance_id = m_instance_id;
unsuspend_notify_requests();
#include "librbd/internal.h"
#include "librbd/Utils.h"
#include "librbd/Watcher.h"
+#include "librbd/api/Config.h"
#include "librbd/api/Mirror.h"
#include "ImageMap.h"
#include "InstanceReplayer.h"
return;
}
+ std::vector<librbd::config_option_t> options;
+ r = librbd::api::Config<I>::list(m_local_io_ctx, &options);
+ if (r < 0) {
+ derr << "error listing local pool config overrides: " << cpp_strerror(r)
+ << dendl;
+ return;
+ }
+ auto cct = reinterpret_cast<CephContext *>(m_local_io_ctx.cct());
+ for (auto &option : options) {
+ if (option.source == RBD_CONFIG_SOURCE_POOL) {
+ r = cct->_conf.set_val(option.name.c_str(), option.value);
+ assert(r == 0);
+ }
+ }
+
std::string local_mirror_uuid;
r = librbd::cls_client::mirror_uuid_get(&m_local_io_ctx,
&local_mirror_uuid);
#include "common/errno.h"
#include "common/WorkQueue.h"
#include "journal/Journaler.h"
-#include "journal/Settings.h"
#include "librbd/ImageCtx.h"
#include "librbd/Utils.h"
#include "librbd/journal/Types.h"
void PrepareRemoteImageRequest<I>::get_client() {
dout(20) << dendl;
- journal::Settings settings;
- settings.commit_interval = g_ceph_context->_conf.get_val<double>(
- "rbd_mirror_journal_commit_age");
- settings.max_fetch_bytes = g_ceph_context->_conf.get_val<Option::size_t>(
- "rbd_mirror_journal_max_fetch_bytes");
-
ceph_assert(*m_remote_journaler == nullptr);
*m_remote_journaler = new Journaler(m_threads->work_queue, m_threads->timer,
&m_threads->timer_lock, m_remote_io_ctx,
*m_remote_image_id, m_local_mirror_uuid,
- settings);
+ m_journal_settings);
Context *ctx = create_async_context_callback(
m_threads->work_queue, create_context_callback<
#include "include/buffer.h"
#include "cls/journal/cls_journal_types.h"
+#include "journal/Settings.h"
#include "librbd/journal/TypeTraits.h"
#include <string>
namespace journal { class Journaler; }
+namespace journal { class Settings; }
namespace librados { struct IoCtx; }
namespace librbd { struct ImageCtx; }
namespace librbd { namespace journal { struct MirrorPeerClientMeta; } }
const std::string &global_image_id,
const std::string &local_mirror_uuid,
const std::string &local_image_id,
+ const journal::Settings &settings,
std::string *remote_mirror_uuid,
std::string *remote_image_id,
Journaler **remote_journaler,
Context *on_finish) {
return new PrepareRemoteImageRequest(threads, remote_io_ctx,
global_image_id, local_mirror_uuid,
- local_image_id, remote_mirror_uuid,
- remote_image_id, remote_journaler,
- client_state, client_meta, on_finish);
+ local_image_id, settings,
+ remote_mirror_uuid, remote_image_id,
+ remote_journaler, client_state,
+ client_meta, on_finish);
}
PrepareRemoteImageRequest(Threads<ImageCtxT> *threads,
const std::string &global_image_id,
const std::string &local_mirror_uuid,
const std::string &local_image_id,
+ const journal::Settings &journal_settings,
std::string *remote_mirror_uuid,
std::string *remote_image_id,
Journaler **remote_journaler,
std::string m_global_image_id;
std::string m_local_mirror_uuid;
std::string m_local_image_id;
+ journal::Settings m_journal_settings;
std::string *m_remote_mirror_uuid;
std::string *m_remote_image_id;
Journaler **m_remote_journaler;