]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: add pg_num_pending to pg_pool_t
authorSage Weil <sage@redhat.com>
Fri, 16 Feb 2018 03:12:47 +0000 (21:12 -0600)
committerSage Weil <sage@redhat.com>
Fri, 7 Sep 2018 17:07:56 +0000 (12:07 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/OSDMonitor.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index 7403a9a903c60bc46ff1c25014e5779cb89eeb54..c8b9811cddc06281895a9c0bfb68e31da93bbeb4 100644 (file)
@@ -6588,6 +6588,7 @@ int OSDMonitor::prepare_new_pool(string& name,
   pi->expected_num_objects = expected_num_objects;
   pi->object_hash = CEPH_STR_HASH_RJENKINS;
   pi->set_pg_num(pg_num);
+  pi->set_pg_num_pending(pg_num, pending_inc.epoch);
   pi->set_pgp_num(pgp_num);
   pi->last_change = pending_inc.epoch;
   pi->auid = 0;
index 81ce073814f2d0b1d0c60e55a1361546c9ee51c0..1f8db32480e9454de8281819441872c6afd3dc0f 100644 (file)
@@ -1195,6 +1195,10 @@ void pg_pool_t::dump(Formatter *f) const
   f->dump_int("object_hash", get_object_hash());
   f->dump_unsigned("pg_num", get_pg_num());
   f->dump_unsigned("pg_placement_num", get_pgp_num());
+  f->dump_unsigned("pg_placement_num_target", get_pgp_num_target());
+  f->dump_unsigned("pg_num_target", get_pg_num_target());
+  f->dump_unsigned("pg_num_pending", get_pg_num_pending());
+  f->dump_unsigned("pg_num_pending_dec_epoch", get_pg_num_pending_dec_epoch());
   f->dump_stream("last_change") << get_last_change();
   f->dump_stream("last_force_op_resend") << get_last_force_op_resend();
   f->dump_stream("last_force_op_resend_preluminous")
@@ -1577,7 +1581,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
     return;
   }
 
-  uint8_t v = 27;
+  uint8_t v = 28;
   // NOTE: any new encoding dependencies must be reflected by
   // SIGNIFICANT_FEATURES
   if (!(features & CEPH_FEATURE_NEW_OSDOP_ENCODING)) {
@@ -1588,6 +1592,8 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
     v = 24;
   } else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
     v = 26;
+  } else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
+    v = 27;
   }
 
   ENCODE_START(v, 5, bl);
@@ -1666,12 +1672,18 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
   if (v >= 27) {
     encode(create_time, bl);
   }
+  if (v >= 28) {
+    encode(pg_num_target, bl);
+    encode(pgp_num_target, bl);
+    encode(pg_num_pending, bl);
+    encode(pg_num_pending_dec_epoch, bl);
+  }
   ENCODE_FINISH(bl);
 }
 
 void pg_pool_t::decode(bufferlist::const_iterator& bl)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(27, 5, 5, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(28, 5, 5, bl);
   decode(type, bl);
   decode(size, bl);
   decode(crush_rule, bl);
@@ -1824,6 +1836,16 @@ void pg_pool_t::decode(bufferlist::const_iterator& bl)
   if (struct_v >= 27) {
     decode(create_time, bl);
   }
+  if (struct_v >= 28) {
+    decode(pg_num_target, bl);
+    decode(pgp_num_target, bl);
+    decode(pg_num_pending, bl);
+    decode(pg_num_pending_dec_epoch, bl);
+  } else {
+    pg_num_target = pg_num;
+    pgp_num_target = pgp_num;
+    pg_num_pending = pg_num;
+  }
   DECODE_FINISH(bl);
   calc_pg_masks();
   calc_grade_table();
@@ -1840,7 +1862,11 @@ void pg_pool_t::generate_test_instances(list<pg_pool_t*>& o)
   a.crush_rule = 3;
   a.object_hash = 4;
   a.pg_num = 6;
-  a.pgp_num = 5;
+  a.pgp_num = 4;
+  a.pgp_num_target = 4;
+  a.pg_num_target = 5;
+  a.pg_num_pending = 5;
+  a.pg_num_pending_dec_epoch = 2;
   a.last_change = 9;
   a.last_force_op_resend = 123823;
   a.last_force_op_resend_preluminous = 123824;
@@ -1902,8 +1928,18 @@ ostream& operator<<(ostream& out, const pg_pool_t& p)
       << " crush_rule " << p.get_crush_rule()
       << " object_hash " << p.get_object_hash_name()
       << " pg_num " << p.get_pg_num()
-      << " pgp_num " << p.get_pgp_num()
-      << " last_change " << p.get_last_change();
+      << " pgp_num " << p.get_pgp_num();
+  if (p.get_pg_num_target() != p.get_pg_num()) {
+    out << " pg_num_target " << p.get_pg_num_target();
+  }
+  if (p.get_pgp_num_target() != p.get_pgp_num()) {
+    out << " pgp_num_target " << p.get_pgp_num_target();
+  }
+  if (p.get_pg_num_pending() != p.get_pg_num()) {
+    out << " pg_num_pending " << p.get_pg_num_pending()
+       << "(e" << p.get_pg_num_pending_dec_epoch() << ")";
+  }
+  out << " last_change " << p.get_last_change();
   if (p.get_last_force_op_resend() ||
       p.get_last_force_op_resend_preluminous())
     out << " lfor " << p.get_last_force_op_resend() << "/"
index 02133ab1fb5160e356e02aae541f2710e2f1d3bf..e8422d851e2565a4e3075f7ee425ad71bcf2f0e0 100644 (file)
@@ -1316,8 +1316,10 @@ struct pg_pool_t {
   __u8 crush_rule;          ///< crush placement rule
   __u8 object_hash;         ///< hash mapping object name to ps
 private:
-  __u32 pg_num, pgp_num;    ///< number of pgs
-
+  __u32 pg_num = 0, pgp_num = 0;  ///< number of pgs
+  __u32 pg_num_pending = 0;       ///< pg_num we are about to merge down to
+  __u32 pg_num_target = 0;        ///< pg_num we should converge toward
+  __u32 pgp_num_target = 0;       ///< pgp_num we should converge toward
 
 public:
   map<string,string> properties;  ///< OBSOLETE
@@ -1326,6 +1328,7 @@ public:
   epoch_t last_force_op_resend; ///< last epoch that forced clients to resend
   /// last epoch that forced clients to resend (pre-luminous clients only)
   epoch_t last_force_op_resend_preluminous;
+  epoch_t pg_num_pending_dec_epoch = 0;  ///< epoch pg_num_pending decremented
   snapid_t snap_seq;        ///< seq for per-pool snapshot
   epoch_t snap_epoch;       ///< osdmap epoch of last snap
   uint64_t auid;            ///< who owns the pg
@@ -1439,7 +1442,6 @@ public:
   pg_pool_t()
     : flags(0), type(0), size(0), min_size(0),
       crush_rule(0), object_hash(0),
-      pg_num(0), pgp_num(0),
       last_change(0),
       last_force_op_resend(0),
       last_force_op_resend_preluminous(0),
@@ -1538,6 +1540,12 @@ public:
 
   unsigned get_pg_num() const { return pg_num; }
   unsigned get_pgp_num() const { return pgp_num; }
+  unsigned get_pg_num_target() const { return pg_num_target; }
+  unsigned get_pgp_num_target() const { return pgp_num_target; }
+  unsigned get_pg_num_pending() const { return pg_num_pending; }
+  epoch_t get_pg_num_pending_dec_epoch() const {
+    return pg_num_pending_dec_epoch;
+  }
 
   unsigned get_pg_num_mask() const { return pg_num_mask; }
   unsigned get_pgp_num_mask() const { return pgp_num_mask; }
@@ -1549,12 +1557,28 @@ public:
 
   void set_pg_num(int p) {
     pg_num = p;
+    pg_num_pending = p;
     calc_pg_masks();
   }
   void set_pgp_num(int p) {
     pgp_num = p;
     calc_pg_masks();
   }
+  void set_pg_num_pending(int p, epoch_t e) {
+    pg_num_pending = p;
+    pg_num_pending_dec_epoch = e;
+    calc_pg_masks();
+  }
+  void set_pg_num_target(int p) {
+    pg_num_target = p;
+  }
+  void set_pgp_num_target(int p) {
+    pgp_num_target = p;
+  }
+  void dec_pg_num() {
+    --pg_num;
+    calc_pg_masks();
+  }
 
   void set_quota_max_bytes(uint64_t m) {
     quota_max_bytes = m;