From: Sage Weil Date: Sat, 27 Oct 2012 00:12:44 +0000 (-0700) Subject: librbd: size max objects based on actual image object order size X-Git-Tag: v0.55~130^2~55^2^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=86de1faa2c1d9e4e8e84e4cdb6bfe3bddbd42e09;p=ceph.git librbd: size max objects based on actual image object order size This has to happen after we open the image. Signed-off-by: Sage Weil --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 273aa6eb392b..430c526a9001 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -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