]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Revert "librbd: remove limit on number of objects in the cache"
authorSage Weil <sage@inktank.com>
Sat, 15 Feb 2014 07:52:06 +0000 (23:52 -0800)
committerSage Weil <sage@inktank.com>
Sat, 15 Feb 2014 07:52:06 +0000 (23:52 -0800)
This reverts commit 367cf1bbf86233eb20ff2304e7d6caab77b84fcc.

Removing the limit on objects means we leak memory, since Objects without
any buffers can exist in the cache.

src/librbd/ImageCtx.cc

index 77cb8503ad63f807bb875cd6b658692249eb7853..41518b67698cdec5a750141703d574a523686e7d 100644 (file)
@@ -86,7 +86,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,
@@ -182,6 +182,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