]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: localize or distribute parent (snap) reads
authorSage Weil <sage@inktank.com>
Thu, 31 Oct 2013 00:21:05 +0000 (17:21 -0700)
committerSage Weil <sage@inktank.com>
Tue, 24 Dec 2013 15:58:07 +0000 (07:58 -0800)
The parent is always a snapshot.  We may want to treat it differently
than other snaps by virtue of it (likely) being a more highly-shared
image.

By default, localize parent reads.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/config_opts.h
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/internal.cc

index 137e676b778739fa664b22ad7e25af3728b855ab..5f6ecdd78d42095cf9ce5a1527fc0275ea40c799 100644 (file)
@@ -643,6 +643,8 @@ OPTION(rbd_cache_block_writes_upfront, OPT_BOOL, false) // whether to block writ
 OPTION(rbd_concurrent_management_ops, OPT_INT, 10) // how many operations can be in flight for a management operation like deleting or resizing an image
 OPTION(rbd_balance_snap_reads, OPT_BOOL, false)
 OPTION(rbd_localize_snap_reads, OPT_BOOL, false)
+OPTION(rbd_balance_parent_reads, OPT_BOOL, false)
+OPTION(rbd_localize_parent_reads, OPT_BOOL, true)
 
 /*
  * The following options change the behavior for librbd's image creation methods that
index 41518b67698cdec5a750141703d574a523686e7d..6477e8dfd048b2e610be5960b8ea71ba283a4817 100644 (file)
@@ -45,6 +45,7 @@ namespace librbd {
       snap_lock("librbd::ImageCtx::snap_lock"),
       parent_lock("librbd::ImageCtx::parent_lock"),
       refresh_lock("librbd::ImageCtx::refresh_lock"),
+      extra_read_flags(0),
       old_format(true),
       order(0), size(0), features(0),
       format_string(NULL),
@@ -238,8 +239,12 @@ namespace librbd {
     delete perfcounter;
   }
 
+  void ImageCtx::set_read_flag(unsigned flag) {
+    extra_read_flags |= flag;
+  }
+
   int ImageCtx::get_read_flags(snap_t snap_id) {
-    int flags = librados::OPERATION_NOFLAG;
+    int flags = librados::OPERATION_NOFLAG | extra_read_flags;
     if (snap_id == LIBRADOS_SNAP_HEAD)
       return flags;
 
index c9e74393e13d4f3dc7478f8aa2dafed6276b498e..026a3e05a453764e713aafeb759dcdce48a2ee85 100644 (file)
@@ -69,6 +69,8 @@ namespace librbd {
     RWLock parent_lock; // protects parent_md and parent
     Mutex refresh_lock; // protects refresh_seq and last_refresh
 
+    unsigned extra_read_flags;
+
     bool old_format;
     uint8_t order;
     uint64_t size;
@@ -99,6 +101,7 @@ namespace librbd {
     void init_layout();
     void perf_start(std::string name);
     void perf_stop();
+    void set_read_flag(unsigned flag);
     int get_read_flags(librados::snap_t snap_id);
     int snap_set(std::string in_snap_name);
     void snap_unset();
index 84e5477dec82ea3f9e9331cdce47aae885c0ee3f..81b70dd310c34ee7b6a8e836e0a4c3c1cec292af 100644 (file)
@@ -1246,6 +1246,13 @@ reprotect_and_return_err:
     // since we don't know the image and snapshot name, set their ids and
     // reset the snap_name and snap_exists fields after we read the header
     ictx->parent = new ImageCtx("", parent_image_id, NULL, p_ioctx, true);
+
+    // set rados flags for reading the parent image
+    if (ictx->cct->_conf->rbd_balance_parent_reads)
+      ictx->parent->set_read_flag(librados::OPERATION_BALANCE_READS);
+    else if (ictx->cct->_conf->rbd_localize_parent_reads)
+      ictx->parent->set_read_flag(librados::OPERATION_LOCALIZE_READS);
+
     r = open_image(ictx->parent);
     if (r < 0) {
       lderr(ictx->cct) << "error opening parent image: " << cpp_strerror(r)