]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: size max objects based on actual image object order size
authorSage Weil <sage@inktank.com>
Sat, 27 Oct 2012 00:12:44 +0000 (17:12 -0700)
committerSage Weil <sage@inktank.com>
Sat, 27 Oct 2012 00:12:44 +0000 (17:12 -0700)
This has to happen after we open the image.

Signed-off-by: Sage Weil <sage@inktank.com>
src/librbd/ImageCtx.cc

index 273aa6eb392be5d46d7e4927fc65e46e16531551..430c526a9001530afbba93458aafb7981ca00235 100644 (file)
@@ -73,7 +73,7 @@ namespace librbd {
       object_cacher = new ObjectCacher(cct, pname, *writeback_handler, cache_lock,
                                       NULL, NULL,
                                       cct->_conf->rbd_cache_size,
-                                      cct->_conf->rbd_cache_size / (4 << 20) * 2 + 10,
+                                      10,  /* reset this in init */
                                       cct->_conf->rbd_cache_max_dirty,
                                       cct->_conf->rbd_cache_target_dirty,
                                       cct->_conf->rbd_cache_max_dirty_age);
@@ -167,6 +167,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