From 7248fb5ab9da2954bef2e9243db23b6280fd7416 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Tue, 1 Sep 2015 23:09:52 +0300 Subject: [PATCH] librbd: new config options to tweak journal settings Signed-off-by: Mykola Golub --- src/common/config_opts.h | 10 ++++++++++ src/librbd/ImageCtx.cc | 14 +++++++++++++- src/librbd/ImageCtx.h | 6 ++++++ src/librbd/Journal.cc | 20 ++++++++++---------- src/librbd/Journal.h | 3 ++- src/librbd/internal.cc | 7 +++++-- 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index a19cc5d8ff78f..7502422d09a8c 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -1019,6 +1019,16 @@ OPTION(rbd_default_features, OPT_INT, 3) // only applies to format 2 images OPTION(rbd_default_map_options, OPT_STR, "") // default rbd map -o / --options +/** + * RBD journal options. + */ +OPTION(rbd_journal_order, OPT_U32, 24) // bits to shift to compute journal object max size, between 12 and 64 +OPTION(rbd_journal_splay_width, OPT_U32, 4) // number of active journal objects +OPTION(rbd_journal_commit_age, OPT_DOUBLE, 5) // commit time interval, seconds +OPTION(rbd_journal_object_flush_interval, OPT_INT, 0) // maximum number of pending commits per journal object +OPTION(rbd_journal_object_flush_bytes, OPT_INT, 0) // maximum number of pending bytes per journal object +OPTION(rbd_journal_object_flush_age, OPT_DOUBLE, 0) // maximum age (in seconds) for pending commits + OPTION(nss_db_path, OPT_STR, "") // path to nss db diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index cb3f069fee9c4..dab2c6e29b218 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -927,7 +927,13 @@ struct C_InvalidateCache : public Context { "rbd_clone_copy_on_read", false)( "rbd_blacklist_on_break_lock", false)( "rbd_blacklist_expire_seconds", false)( - "rbd_request_timed_out_seconds", false); + "rbd_request_timed_out_seconds", false)( + "rbd_journal_order", false)( + "rbd_journal_splay_width", false)( + "rbd_journal_commit_age", false)( + "rbd_journal_object_flush_interval", false)( + "rbd_journal_object_flush_bytes", false)( + "rbd_journal_object_flush_age", false); string start = METADATA_CONF_PREFIX; int r = 0, j = 0; @@ -997,6 +1003,12 @@ struct C_InvalidateCache : public Context { ASSIGN_OPTION(blacklist_expire_seconds); ASSIGN_OPTION(request_timed_out_seconds); ASSIGN_OPTION(enable_alloc_hint); + ASSIGN_OPTION(journal_order); + ASSIGN_OPTION(journal_splay_width); + ASSIGN_OPTION(journal_commit_age); + ASSIGN_OPTION(journal_object_flush_interval); + ASSIGN_OPTION(journal_object_flush_bytes); + ASSIGN_OPTION(journal_object_flush_age); } void ImageCtx::open_journal() { diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 4e00fe5a45969..ec7783c5e6c99 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -175,6 +175,12 @@ namespace librbd { uint32_t blacklist_expire_seconds; uint32_t request_timed_out_seconds; bool enable_alloc_hint; + uint8_t journal_order; + uint8_t journal_splay_width; + double journal_commit_age; + int journal_object_flush_interval; + uint64_t journal_object_flush_bytes; + double journal_object_flush_age; LibrbdAdminSocketHook *asok_hook; diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index 797349e8bb530..041568f8d6156 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -90,15 +90,14 @@ bool Journal::is_journal_supported(ImageCtx &image_ctx) { !image_ctx.read_only && image_ctx.snap_id == CEPH_NOSNAP); } -int Journal::create(librados::IoCtx &io_ctx, const std::string &image_id) { +int Journal::create(librados::IoCtx &io_ctx, const std::string &image_id, + double commit_age, uint8_t order, uint8_t splay_width) { CephContext *cct = reinterpret_cast(io_ctx.cct()); ldout(cct, 5) << __func__ << ": image=" << image_id << dendl; - // TODO configurable commit flush interval - ::journal::Journaler journaler(io_ctx, image_id, "", 5); + ::journal::Journaler journaler(io_ctx, image_id, "", commit_age); - // TODO order / splay width via config / image metadata / data pool - int r = journaler.create(24, 4, io_ctx.get_id()); + int r = journaler.create(order, splay_width, io_ctx.get_id()); if (r < 0) { lderr(cct) << "failed to create journal: " << cpp_strerror(r) << dendl; return r; @@ -116,8 +115,8 @@ int Journal::remove(librados::IoCtx &io_ctx, const std::string &image_id) { CephContext *cct = reinterpret_cast(io_ctx.cct()); ldout(cct, 5) << __func__ << ": image=" << image_id << dendl; - // TODO configurable commit flush interval - ::journal::Journaler journaler(io_ctx, image_id, "", 5); + ::journal::Journaler journaler(io_ctx, image_id, "", + cct->_conf->rbd_journal_commit_age); bool journal_exists; int r = journaler.exists(&journal_exists); @@ -407,7 +406,7 @@ void Journal::create_journaler() { // TODO allow alternate pool for journal objects and commit flush interval m_close_pending = false; m_journaler = new ::journal::Journaler(m_image_ctx.md_ctx, m_image_ctx.id, "", - 5); + m_image_ctx.journal_commit_age); m_journaler->init(new C_InitJournal(this)); transition_state(STATE_INITIALIZING); @@ -533,8 +532,9 @@ void Journal::handle_replay_complete(int r) { return; } - // TODO configurable flush interval, flush bytes, and flush age - m_journaler->start_append(0, 0, 0); + m_journaler->start_append(m_image_ctx.journal_object_flush_interval, + m_image_ctx.journal_object_flush_bytes, + m_image_ctx.journal_object_flush_age); transition_state(STATE_RECORDING); unblock_writes(); diff --git a/src/librbd/Journal.h b/src/librbd/Journal.h index 29f4d2a01645f..acbab5baeeec3 100644 --- a/src/librbd/Journal.h +++ b/src/librbd/Journal.h @@ -42,7 +42,8 @@ public: ~Journal(); static bool is_journal_supported(ImageCtx &image_ctx); - static int create(librados::IoCtx &io_ctx, const std::string &image_id); + static int create(librados::IoCtx &io_ctx, const std::string &image_id, + double commit_age, uint8_t order, uint8_t splay_width); static int remove(librados::IoCtx &io_ctx, const std::string &image_id); bool is_journal_ready() const; diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 72e4ebb4659a8..d644c4469e97e 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -1204,7 +1204,9 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type, goto err_remove_object_map; } - r = Journal::create(io_ctx, id); + r = Journal::create(io_ctx, id, cct->_conf->rbd_journal_commit_age, + cct->_conf->rbd_journal_order, + cct->_conf->rbd_journal_splay_width); if (r < 0) { lderr(cct) << "error creating journal: " << cpp_strerror(r) << dendl; goto err_remove_object_map; @@ -1753,7 +1755,8 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type, } features_mask |= RBD_FEATURE_EXCLUSIVE_LOCK; - r = Journal::create(ictx->md_ctx, ictx->id); + r = Journal::create(ictx->md_ctx, ictx->id, ictx->journal_commit_age, + ictx->journal_order, ictx->journal_splay_width); if (r < 0) { lderr(cct) << "error creating image journal: " << cpp_strerror(r) << dendl; -- 2.39.5