]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: updated cache max objects calculation 4434/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 22 Apr 2015 15:27:35 +0000 (11:27 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 22 Apr 2015 15:27:35 +0000 (11:27 -0400)
The previous calculation was based upon the image's object size.
Since the cache stores smaller bufferheads, the object size is not
a good indicator of cache usage and was resulting in objects being
evicted from the cache too often.  Instead, base the max number of
objects on the memory load required to store the extra metadata
for the objects.

Fixes: #7385
Backport: firefly, hammer
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ImageCtx.cc

index 5f9ba89546e21574a2ec390b29a180f1d20a41d7..c7174864932b4ab8ce25fa44d564c751511223e4 100644 (file)
@@ -226,10 +226,9 @@ namespace librbd {
     if (object_cacher) {
       uint64_t obj = cache_max_dirty_object;
       if (!obj) {
-        obj = cache_size / (1ull << order);
-        obj = obj * 4 + 10;
+        obj = MIN(2000, MAX(10, cache_size / 100 / sizeof(ObjectCacher::Object)));
       }
-      ldout(cct, 10) << " cache bytes " << cache_size << " order " << (int)order
+      ldout(cct, 10) << " cache bytes " << cache_size
                     << " -> about " << obj << " objects" << dendl;
       object_cacher->set_max_objects(obj);
     }