]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: only enable object map if enabled in ceph config
authorJason Dillaman <dillaman@redhat.com>
Sat, 24 Jan 2015 09:44:09 +0000 (04:44 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 29 Jan 2015 02:12:52 +0000 (21:12 -0500)
As a way to introduce the RBD object map as an optional tech
preview, only enable it for new images/clones if the
rbd_object_map configuration parameter is enabled.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/common/config_opts.h
src/rbd.cc

index d7f53cebf24c737b56b1960a87d0b1e3630c4646..add8176272e3d92731fc52b8e1bf53b1efada70c 100644 (file)
@@ -855,6 +855,7 @@ OPTION(rbd_readahead_trigger_requests, OPT_INT, 10) // number of sequential requ
 OPTION(rbd_readahead_max_bytes, OPT_LONGLONG, 512 * 1024) // set to 0 to disable readahead
 OPTION(rbd_readahead_disable_after_bytes, OPT_LONGLONG, 50 * 1024 * 1024) // how many bytes are read in total before readahead is disabled
 OPTION(rbd_clone_copy_on_read, OPT_BOOL, false)
+OPTION(rbd_object_map, OPT_BOOL, false) // whether to enable the RBD object map
 
 /*
  * The following options change the behavior for librbd's image creation methods that
index da35e8c2e7bdb4b50e3289b1afa5af774aeb4680..866906c900bee14a4f6868a684a1b6786cb4d0e7 100644 (file)
@@ -439,8 +439,10 @@ static int do_create(librbd::RBD &rbd, librados::IoCtx& io_ctx,
     r = rbd.create(io_ctx, imgname, size, order);
   } else {
     if (features == 0) {
-      features = RBD_FEATURE_LAYERING | RBD_FEATURE_EXCLUSIVE_LOCK |
-                RBD_FEATURE_OBJECT_MAP;
+      features = RBD_FEATURE_LAYERING | RBD_FEATURE_EXCLUSIVE_LOCK;
+    }
+    if (g_conf->rbd_object_map) {
+      features |= RBD_FEATURE_OBJECT_MAP;
     }
     if ((stripe_unit || stripe_count) &&
        (stripe_unit != (1ull << *order) && stripe_count != 1)) {
@@ -459,10 +461,15 @@ static int do_clone(librbd::RBD &rbd, librados::IoCtx &p_ioctx,
                    librados::IoCtx &c_ioctx, const char *c_name,
                    uint64_t features, int *c_order)
 {
-  if (features == 0)
-    features = RBD_FEATURES_ALL;
-  else if ((features & RBD_FEATURE_LAYERING) != RBD_FEATURE_LAYERING)
+  if (features == 0) {
+    features = (RBD_FEATURES_ALL & ~RBD_FEATURE_OBJECT_MAP);
+  }
+  else if ((features & RBD_FEATURE_LAYERING) != RBD_FEATURE_LAYERING) {
     return -EINVAL;
+  }
+  if (g_conf->rbd_object_map) {
+    features |= RBD_FEATURE_OBJECT_MAP;
+  }
 
   return rbd.clone(p_ioctx, p_name, p_snapname, c_ioctx, c_name, features,
                    c_order);
@@ -2472,8 +2479,7 @@ int main(int argc, const char **argv)
   bool format_specified = false,
     output_format_specified = false;
   int format = 1;
-  uint64_t features = RBD_FEATURE_LAYERING | RBD_FEATURE_EXCLUSIVE_LOCK |
-                     RBD_FEATURE_OBJECT_MAP;
+  uint64_t features = RBD_FEATURE_LAYERING | RBD_FEATURE_EXCLUSIVE_LOCK;
   const char *imgname = NULL, *snapname = NULL, *destname = NULL,
     *dest_poolname = NULL, *dest_snapname = NULL, *path = NULL,
     *devpath = NULL, *lock_cookie = NULL, *lock_client = NULL,