]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: add cache policy fields to pg_pool_t
authorSage Weil <sage@inktank.com>
Wed, 18 Dec 2013 21:40:54 +0000 (13:40 -0800)
committerSage Weil <sage@inktank.com>
Sun, 16 Feb 2014 06:08:12 +0000 (22:08 -0800)
Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/osd_types.cc
src/osd/osd_types.h

index fbc4aadffb33db194bac36452ce47f1917bed48a..2e43c51abcb750b5559b57d9b295c4ab58becdb2 100644 (file)
@@ -709,6 +709,14 @@ void pg_pool_t::dump(Formatter *f) const
   f->dump_int("read_tier", read_tier);
   f->dump_int("write_tier", write_tier);
   f->dump_string("cache_mode", get_cache_mode_name());
+  f->dump_unsigned("target_max_bytes", target_max_bytes);
+  f->dump_unsigned("target_max_objects", target_max_objects);
+  f->dump_unsigned("cache_target_dirty_ratio_micro",
+                  cache_target_dirty_ratio_micro);
+  f->dump_unsigned("cache_target_full_ratio_micro",
+                  cache_target_full_ratio_micro);
+  f->dump_unsigned("cache_min_flush_age", cache_min_flush_age);
+  f->dump_unsigned("cache_min_evict_age", cache_min_evict_age);
   f->open_object_section("properties");
   for (map<string,string>::const_iterator i = properties.begin();
        i != properties.end();
@@ -946,7 +954,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
   }
 
   __u8 encode_compat = 5;
-  ENCODE_START(12, encode_compat, bl);
+  ENCODE_START(13, encode_compat, bl);
   ::encode(type, bl);
   ::encode(size, bl);
   ::encode(crush_ruleset, bl);
@@ -980,12 +988,18 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
   ::encode(hit_set_period, bl);
   ::encode(hit_set_count, bl);
   ::encode(stripe_width, bl);
+  ::encode(target_max_bytes, bl);
+  ::encode(target_max_objects, bl);
+  ::encode(cache_target_dirty_ratio_micro, bl);
+  ::encode(cache_target_full_ratio_micro, bl);
+  ::encode(cache_min_flush_age, bl);
+  ::encode(cache_min_evict_age, bl);
   ENCODE_FINISH_NEW_COMPAT(bl, encode_compat);
 }
 
 void pg_pool_t::decode(bufferlist::iterator& bl)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(12, 5, 5, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(13, 5, 5, bl);
   ::decode(type, bl);
   ::decode(size, bl);
   ::decode(crush_ruleset, bl);
@@ -1064,6 +1078,23 @@ void pg_pool_t::decode(bufferlist::iterator& bl)
   } else {
     set_stripe_width(0);
   }
+  if (struct_v >= 13) {
+    ::decode(target_max_bytes, bl);
+    ::decode(target_max_objects, bl);
+    ::decode(cache_target_dirty_ratio_micro, bl);
+    ::decode(cache_target_full_ratio_micro, bl);
+    ::decode(cache_min_flush_age, bl);
+    ::decode(cache_min_evict_age, bl);
+  } else {
+    pg_pool_t def;
+    target_max_bytes = def.target_max_bytes;
+    target_max_objects = def.target_max_objects;
+    cache_target_dirty_ratio_micro = def.cache_target_dirty_ratio_micro;
+    cache_target_full_ratio_micro = def.cache_target_full_ratio_micro;
+    cache_min_flush_age = def.cache_min_flush_age;
+    cache_min_evict_age = def.cache_min_evict_age;
+  }
+
   DECODE_FINISH(bl);
   calc_pg_masks();
 }
@@ -1111,6 +1142,12 @@ void pg_pool_t::generate_test_instances(list<pg_pool_t*>& o)
   a.hit_set_period = 3600;
   a.hit_set_count = 8;
   a.set_stripe_width(12345);
+  a.target_max_bytes = 1238132132;
+  a.target_max_objects = 1232132;
+  a.cache_target_dirty_ratio_micro = 187232;
+  a.cache_target_full_ratio_micro = 987222;
+  a.cache_min_flush_age = 231;
+  a.cache_min_evict_age = 2321;
   o.push_back(new pg_pool_t(a));
 }
 
@@ -1143,6 +1180,10 @@ ostream& operator<<(ostream& out, const pg_pool_t& p)
     out << " write_tier " << p.write_tier;
   if (p.cache_mode)
     out << " cache_mode " << p.get_cache_mode_name();
+  if (p.target_max_bytes)
+    out << " target_bytes " << p.target_max_bytes;
+  if (p.target_max_objects)
+    out << " target_objects " << p.target_max_objects;
   if (p.hit_set_params.get_type() != HitSet::TYPE_NONE) {
     out << " hit_set " << p.hit_set_params
        << " " << p.hit_set_period << "s"
index 416535953907e03a02b40cf85e9a3f9851a49cc6..feabbd6e2ea5dad508a47ae72789bc681aa9bd5b 100644 (file)
@@ -827,6 +827,15 @@ public:
   bool has_write_tier() const { return write_tier >= 0; }
   void clear_write_tier() { write_tier = -1; }
 
+  uint64_t target_max_bytes;   ///< tiering: target max pool size
+  uint64_t target_max_objects; ///< tiering: target max pool size
+
+  uint32_t cache_target_dirty_ratio_micro; ///< cache: fraction of target to leave dirty
+  uint32_t cache_target_full_ratio_micro;  ///< cache: fraction of target to fill before we evict in earnest
+
+  uint32_t cache_min_flush_age;  ///< minimum age (seconds) before we can flush
+  uint32_t cache_min_evict_age;  ///< minimum age (seconds) before we can evict
+
   HitSet::Params hit_set_params; ///< The HitSet params to use on this pool
   uint32_t hit_set_period;      ///< periodicity of HitSet segments (seconds)
   uint32_t hit_set_count;       ///< number of periods to retain
@@ -845,6 +854,11 @@ public:
       pg_num_mask(0), pgp_num_mask(0),
       tier_of(-1), read_tier(-1), write_tier(-1),
       cache_mode(CACHEMODE_NONE),
+      target_max_bytes(0), target_max_objects(0),
+      cache_target_dirty_ratio_micro(400000),
+      cache_target_full_ratio_micro(800000),
+      cache_min_flush_age(0),
+      cache_min_evict_age(0),
       hit_set_params(),
       hit_set_period(0),
       hit_set_count(0),