]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: For format 2, don't forget set objectcache max objects. 4514/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Tue, 28 Apr 2015 05:12:47 +0000 (13:12 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Mon, 4 May 2015 02:55:01 +0000 (10:55 +0800)
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 <jianpeng.ma@intel.com>
src/librbd/ImageCtx.cc

index 0e6e190920c8e4ac698e0a4edd7e630b35764f3c..8bdeec9b9c0cf098e35bfa4d1d5f4f9bfc337bce 100644 (file)
@@ -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