]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: allow alternate pool for journal objects
authorMykola Golub <mgolub@mirantis.com>
Sun, 6 Sep 2015 14:06:44 +0000 (17:06 +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 7502422d09a8c880a87951c2cffbcfe3cbb419a8..011732384969d03da83c43cb5003b16084df53d5 100644 (file)
@@ -1028,6 +1028,7 @@ 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(rbd_journal_pool, OPT_STR, "") // pool for journal objects
 
 OPTION(nss_db_path, OPT_STR, "") // path to nss db
 
index dab2c6e29b21859c32243b5bfc991b235f2b4680..5faad48cf5392f900e61b1d17dedbeacc21710ac 100644 (file)
@@ -933,7 +933,8 @@ struct C_InvalidateCache : public Context {
         "rbd_journal_commit_age", false)(
         "rbd_journal_object_flush_interval", false)(
         "rbd_journal_object_flush_bytes", false)(
-        "rbd_journal_object_flush_age", false);
+        "rbd_journal_object_flush_age", false)(
+        "rbd_journal_pool", false);
 
     string start = METADATA_CONF_PREFIX;
     int r = 0, j = 0;
@@ -1009,6 +1010,7 @@ struct C_InvalidateCache : public Context {
     ASSIGN_OPTION(journal_object_flush_interval);
     ASSIGN_OPTION(journal_object_flush_bytes);
     ASSIGN_OPTION(journal_object_flush_age);
+    ASSIGN_OPTION(journal_pool);
   }
 
   void ImageCtx::open_journal() {
index ec7783c5e6c99bc101e525642accaac192f3549e..d49dadf3347356d97bbdbfc277f7248cf0507c82 100644 (file)
@@ -181,6 +181,7 @@ namespace librbd {
     int journal_object_flush_interval;
     uint64_t journal_object_flush_bytes;
     double journal_object_flush_age;
+    std::string journal_pool;
 
     LibrbdAdminSocketHook *asok_hook;
 
index 2fb745ce9600887db7d9a872ed11b4195f99c222..f38bb86af3f07dcf9a4feea6831f4118bf14a923 100644 (file)
@@ -91,13 +91,28 @@ bool Journal::is_journal_supported(ImageCtx &image_ctx) {
 }
 
 int Journal::create(librados::IoCtx &io_ctx, const std::string &image_id,
-                   double commit_age, uint8_t order, uint8_t splay_width) {
+                   double commit_age, uint8_t order, uint8_t splay_width,
+                   const std::string &object_pool) {
   CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
   ldout(cct, 5) << __func__ << ": image=" << image_id << dendl;
 
+  int64_t pool_id = -1;
+  if (!object_pool.empty()) {
+    librados::Rados rados(io_ctx);
+    IoCtx data_io_ctx;
+    int r = rados.ioctx_create(object_pool.c_str(), data_io_ctx);
+    if (r != 0) {
+      lderr(cct) << "failed to create journal: "
+                << "error opening journal objects pool '" << object_pool
+                << "': " << cpp_strerror(r) << dendl;
+      return r;
+    }
+    pool_id = data_io_ctx.get_id();
+  }
+
   ::journal::Journaler journaler(io_ctx, image_id, "", commit_age);
 
-  int r = journaler.create(order, splay_width, io_ctx.get_id());
+  int r = journaler.create(order, splay_width, pool_id);
   if (r < 0) {
     lderr(cct) << "failed to create journal: " << cpp_strerror(r) << dendl;
     return r;
@@ -404,11 +419,9 @@ void Journal::create_journaler() {
   assert(m_state == STATE_UNINITIALIZED);
   assert(m_journaler == NULL);
 
-  // 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, "",
                                          m_image_ctx.journal_commit_age);
-
   m_journaler->init(new C_InitJournal(this));
   transition_state(STATE_INITIALIZING);
 }
index acbab5baeeec36a6bef2c0d01f563213244a3ff2..d694cf41810063393e0eeae0bb29c8fe3e94ed96 100644 (file)
@@ -43,7 +43,8 @@ public:
 
   static bool is_journal_supported(ImageCtx &image_ctx);
   static int create(librados::IoCtx &io_ctx, const std::string &image_id,
-                   double commit_age, uint8_t order, uint8_t splay_width);
+                   double commit_age, uint8_t order, uint8_t splay_width,
+                   const std::string &object_pool);
   static int remove(librados::IoCtx &io_ctx, const std::string &image_id);
 
   bool is_journal_ready() const;
index d644c4469e97ecbab5ce442941141f9ac4b175b5..985b16f24e809e49f135d29b2acfadf6ec51216f 100644 (file)
@@ -1206,7 +1206,8 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type,
 
       r = Journal::create(io_ctx, id, cct->_conf->rbd_journal_commit_age,
                          cct->_conf->rbd_journal_order,
-                         cct->_conf->rbd_journal_splay_width);
+                         cct->_conf->rbd_journal_splay_width,
+                         cct->_conf->rbd_journal_pool);
       if (r < 0) {
         lderr(cct) << "error creating journal: " << cpp_strerror(r) << dendl;
         goto err_remove_object_map;
@@ -1756,7 +1757,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, ictx->journal_commit_age,
-                           ictx->journal_order, ictx->journal_splay_width);
+                           ictx->journal_order, ictx->journal_splay_width,
+                           ictx->journal_pool);
         if (r < 0) {
           lderr(cct) << "error creating image journal: " << cpp_strerror(r)
                      << dendl;