From 1800a996ac4d21257c9a789aafced7b098034e52 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Tue, 28 Apr 2015 13:12:47 +0800 Subject: [PATCH] librbd: For format 2, don't forget set objectcache max objects. For format 2, before create object_cache, it call init_layout and set the max object for object cache. In the later ictx_refresh, it only set for format1. Now move set logic after creating object cache. Signed-off-by: Jianpeng Ma --- src/librbd/ImageCtx.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 0e6e190920c8..8bdeec9b9c0c 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -178,6 +178,16 @@ namespace librbd { cache_target_dirty, cache_max_dirty_age, cache_block_writes_upfront); + + // size object cache appropriately + uint64_t obj = cache_max_dirty_object; + if (!obj) { + obj = MIN(2000, MAX(10, cache_size / 100 / sizeof(ObjectCacher::Object))); + } + ldout(cct, 10) << " cache bytes " << cache_size + << " -> about " << obj << " objects" << dendl; + object_cacher->set_max_objects(obj); + object_set = new ObjectCacher::ObjectSet(NULL, data_ctx.get_id(), 0); object_set->return_enoent = true; object_cacher->start(); @@ -222,17 +232,6 @@ namespace librbd { snprintf(format_string, len, "%s.%%016llx", object_prefix.c_str()); } - // size object cache appropriately - if (object_cacher) { - uint64_t obj = cache_max_dirty_object; - if (!obj) { - obj = MIN(2000, MAX(10, cache_size / 100 / sizeof(ObjectCacher::Object))); - } - ldout(cct, 10) << " cache bytes " << cache_size - << " -> about " << obj << " objects" << dendl; - object_cacher->set_max_objects(obj); - } - ldout(cct, 10) << "init_layout stripe_unit " << stripe_unit << " stripe_count " << stripe_count << " object_size " << layout.fl_object_size -- 2.47.3