]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: updated cache max objects calculation 4497/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 22 Apr 2015 15:27:35 +0000 (11:27 -0400)
committerLoic Dachary <ldachary@redhat.com>
Wed, 29 Apr 2015 17:54:35 +0000 (19:54 +0200)
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>
(cherry picked from commit 0b378942c4f1b79cb65967f2d3466728ca1c8d5b)

Conflicts:
src/librbd/ImageCtx.cc
        because hammer has cct->_conf->rbd_cache_size
        instead of cache_size

src/librbd/ImageCtx.cc

index 564f3437f0bd981a420362f87b1fbcd01cc75486..fd120fa4d06befbfbf3ad1d9a46f06a131882185 100644 (file)
@@ -218,10 +218,9 @@ namespace librbd {
     if (object_cacher) {
       uint64_t obj = cct->_conf->rbd_cache_max_dirty_object;
       if (!obj) {
-        obj = cct->_conf->rbd_cache_size / (1ull << order);
-        obj = obj * 4 + 10;
+        obj = MIN(2000, MAX(10, cct->_conf->rbd_cache_size / 100 / sizeof(ObjectCacher::Object)));
       }
-      ldout(cct, 10) << " cache bytes " << cct->_conf->rbd_cache_size << " order " << (int)order
+      ldout(cct, 10) << " cache bytes " << cct->_conf->rbd_cache_size
                     << " -> about " << obj << " objects" << dendl;
       object_cacher->set_max_objects(obj);
     }