]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add rbdcache max dirty object option
authorHaomai Wang <haomaiwang@gmail.com>
Mon, 14 Jul 2014 06:27:17 +0000 (14:27 +0800)
committerJosh Durgin <josh.durgin@inktank.com>
Sat, 9 Aug 2014 22:50:54 +0000 (15:50 -0700)
Librbd will calculate max dirty object according to rbd_cache_max_size, it
doesn't suitable for every case. If user set image order 24, the calculating
result is too small for reality. It will increase the overhead of trim call
which is called each read/write op.

Now we make it as option for tunning, by default this value is calculated.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
(cherry picked from commit 3c7229a2fea98b30627878c86b1410c8eef2b5d7)

src/common/config_opts.h
src/librbd/ImageCtx.cc

index 31905358df3d56bbe9b5578568e3c1a5237351a0..a7baee9e36dd6515c2051fc503ed1740452f8edb 100644 (file)
@@ -603,6 +603,7 @@ OPTION(rbd_cache_size, OPT_LONGLONG, 32<<20)         // cache size in bytes
 OPTION(rbd_cache_max_dirty, OPT_LONGLONG, 24<<20)    // dirty limit in bytes - set to 0 for write-through caching
 OPTION(rbd_cache_target_dirty, OPT_LONGLONG, 16<<20) // target dirty limit in bytes
 OPTION(rbd_cache_max_dirty_age, OPT_FLOAT, 1.0)      // seconds in cache before writeback starts
+OPTION(rbd_cache_max_dirty_object, OPT_INT, 0)       // dirty limit for objects - set to 0 for auto calculate from rbd_cache_size
 OPTION(rbd_cache_block_writes_upfront, OPT_BOOL, false) // whether to block writes to the cache before the aio_write call completes (true), or block before the aio completion is called (false)
 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)
index 025e5602c8189fdc173df2a8cec921878d617a6b..1c20b277a3af9da4b2b363a13550e0946f771dda 100644 (file)
@@ -184,10 +184,14 @@ namespace librbd {
 
     // size object cache appropriately
     if (object_cacher) {
-      uint64_t obj = cct->_conf->rbd_cache_size / (1ull << order);
+      uint64_t obj = cct->_conf->rbd_cache_max_dirty_object;
+      if (!obj) {
+        obj = cct->_conf->rbd_cache_size / (1ull << order);
+        obj = obj * 4 + 10;
+      }
       ldout(cct, 10) << " cache bytes " << cct->_conf->rbd_cache_size << " order " << (int)order
                     << " -> about " << obj << " objects" << dendl;
-      object_cacher->set_max_objects(obj * 4 + 10);
+      object_cacher->set_max_objects(obj);
     }
 
     ldout(cct, 10) << "init_layout stripe_unit " << stripe_unit
@@ -582,7 +586,7 @@ namespace librbd {
     cache_lock.Unlock();
     if (unclean) {
       lderr(cct) << "could not release all objects from cache: "
-                << unclean << " bytes remain" << dendl;
+                 << unclean << " bytes remain" << dendl;
       return -EBUSY;
     }
     return r;