]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: new config options to tweak journal settings
authorMykola Golub <mgolub@mirantis.com>
Tue, 1 Sep 2015 20:09:52 +0000 (23:09 +0300)
committerMykola Golub <mgolub@mirantis.com>
Fri, 4 Dec 2015 11:15:02 +0000 (13:15 +0200)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/common/config_opts.h
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/Journal.cc
src/librbd/Journal.h
src/librbd/internal.cc

index a19cc5d8ff78f3255a5c91f49223d8a8cedf5163..7502422d09a8c880a87951c2cffbcfe3cbb419a8 100644 (file)
@@ -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
 
 
index cb3f069fee9c45b508a2c26fe8bafe9e8c7fb237..dab2c6e29b21859c32243b5bfc991b235f2b4680 100644 (file)
@@ -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() {
index 4e00fe5a4596979f88cfb4533c94f1cbf887d94d..ec7783c5e6c99bc101e525642accaac192f3549e 100644 (file)
@@ -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;
 
index 797349e8bb530c5cdfceb32cc76a9fe8b67f13bf..041568f8d6156a6e312d5193f5839880f5c19bf2 100644 (file)
@@ -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<CephContext *>(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<CephContext *>(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();
index 29f4d2a01645fd1071905811d8100ff3c87dd6fa..acbab5baeeec36a6bef2c0d01f563213244a3ff2 100644 (file)
@@ -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;
index 72e4ebb4659a89297375b7c8485e002a5c34296f..d644c4469e97ecbab5ce442941141f9ac4b175b5 100644 (file)
@@ -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;