]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Revert "librbd: remove limit on number of objects in the cache"
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 3 Mar 2014 17:03:29 +0000 (09:03 -0800)
committerJosh Durgin <josh.durgin@inktank.com>
Mon, 3 Mar 2014 17:04:00 +0000 (09:04 -0800)
Disabling this limit causes too much memory usage in some
workloads.

This reverts commit 0559d31db29ea83bdb6cec72b830d16b44e3cd35.

src/librbd/ImageCtx.cc

index decddf485be32d28324f78e99906df83272da127..6477e8dfd048b2e610be5960b8ea71ba283a4817 100644 (file)
@@ -87,7 +87,7 @@ namespace librbd {
       object_cacher = new ObjectCacher(cct, pname, *writeback_handler, cache_lock,
                                       NULL, NULL,
                                       cct->_conf->rbd_cache_size,
-                                      (uint64_t) -1, // unlimited number of objects
+                                      10,  /* reset this in init */
                                       init_max_dirty,
                                       cct->_conf->rbd_cache_target_dirty,
                                       cct->_conf->rbd_cache_max_dirty_age,
@@ -183,6 +183,14 @@ namespace librbd {
       snprintf(format_string, len, "%s.%%016llx", object_prefix.c_str());
     }
 
+    // size object cache appropriately
+    if (object_cacher) {
+      uint64_t obj = cct->_conf->rbd_cache_size / (1ull << order);
+      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);
+    }
+
     ldout(cct, 10) << "init_layout stripe_unit " << stripe_unit
                   << " stripe_count " << stripe_count
                   << " object_size " << layout.fl_object_size