]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/: Move PG::_prepare_write_info into osd_types prepare_info_keymap 28048/head
authorsjust@redhat.com <sjust@redhat.com>
Mon, 6 May 2019 22:43:15 +0000 (15:43 -0700)
committerSamuel Just <sjust@redhat.com>
Fri, 10 May 2019 00:22:34 +0000 (17:22 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/osd/pg_meta.cc
src/osd/PG.cc
src/osd/PG.h
src/osd/osd_types.cc
src/osd/osd_types.h
src/tools/ceph_objectstore_tool.cc

index 9861ba6c803cbfff5f9db74437a64288a5bb9686..979f38f661308495985b38aef5daa0a7c77f90c6 100644 (file)
@@ -8,12 +8,6 @@
 // prefix pgmeta_oid keys with _ so that PGLog::read_log_and_missing() can
 // easily skip them
 
-static const string_view infover_key = "_infover"sv;
-static const string_view info_key = "_info"sv;
-static const string_view biginfo_key = "_biginfo"sv;
-static const string_view epoch_key = "_epoch"sv;
-static const string_view fastinfo_key = "_fastinfo"sv;
-
 using ceph::os::CyanStore;
 
 PGMeta::PGMeta(CyanStore* store, spg_t pgid)
index d8b86cd581befa86b40d60c4279c04460f8af5c1..a44766b98acea28afca1ca7fa96981b125f8a948 100644 (file)
 #undef dout_prefix
 #define dout_prefix _prefix(_dout, this)
 
-// prefix pgmeta_oid keys with _ so that PGLog::read_log_and_missing() can
-// easily skip them
-const string infover_key("_infover");
-const string info_key("_info");
-const string biginfo_key("_biginfo");
-const string epoch_key("_epoch");
-const string fastinfo_key("_fastinfo");
-
 template <class T>
 static ostream& _prefix(std::ostream *_dout, T *t)
 {
@@ -893,7 +885,7 @@ void PG::upgrade(ObjectStore *store)
   if (info_struct_v < latest_struct_v) {
     map<string,bufferlist> v;
     __u8 ver = latest_struct_v;
-    encode(ver, v[infover_key]);
+    encode(ver, v[string(infover_key)]);
     t.omap_setkeys(coll, pgmeta_oid, v);
   }
 
@@ -917,73 +909,6 @@ void PG::upgrade(ObjectStore *store)
 #pragma GCC diagnostic pop
 #pragma GCC diagnostic warning "-Wpragmas"
 
-int PG::_prepare_write_info(CephContext* cct,
-                           map<string,bufferlist> *km,
-                           epoch_t epoch,
-                           pg_info_t &info,
-                           pg_info_t &last_written_info,
-                           PastIntervals &past_intervals,
-                           bool dirty_big_info,
-                           bool dirty_epoch,
-                           bool try_fast_info,
-                           PerfCounters *logger)
-{
-  if (dirty_epoch) {
-    encode(epoch, (*km)[epoch_key]);
-  }
-
-  if (logger)
-    logger->inc(l_osd_pg_info);
-
-  // try to do info efficiently?
-  if (!dirty_big_info && try_fast_info &&
-      info.last_update > last_written_info.last_update) {
-    pg_fast_info_t fast;
-    fast.populate_from(info);
-    bool did = fast.try_apply_to(&last_written_info);
-    ceph_assert(did);  // we verified last_update increased above
-    if (info == last_written_info) {
-      encode(fast, (*km)[fastinfo_key]);
-      if (logger)
-       logger->inc(l_osd_pg_fastinfo);
-      return 0;
-    }
-    generic_dout(30) << __func__ << " fastinfo failed, info:\n";
-    {
-      JSONFormatter jf(true);
-      jf.dump_object("info", info);
-      jf.flush(*_dout);
-    }
-    {
-      *_dout << "\nlast_written_info:\n";
-      JSONFormatter jf(true);
-      jf.dump_object("last_written_info", last_written_info);
-      jf.flush(*_dout);
-    }
-    *_dout << dendl;
-  }
-
-  last_written_info = info;
-
-  // info.  store purged_snaps separately.
-  interval_set<snapid_t> purged_snaps;
-  purged_snaps.swap(info.purged_snaps);
-  encode(info, (*km)[info_key]);
-  purged_snaps.swap(info.purged_snaps);
-
-  if (dirty_big_info) {
-    // potentially big stuff
-    bufferlist& bigbl = (*km)[biginfo_key];
-    encode(past_intervals, bigbl);
-    encode(info.purged_snaps, bigbl);
-    //dout(20) << "write_info bigbl " << bigbl.length() << dendl;
-    if (logger)
-      logger->inc(l_osd_pg_biginfo);
-  }
-
-  return 0;
-}
-
 void PG::_create(ObjectStore::Transaction& t, spg_t pgid, int bits)
 {
   coll_t coll(pgid);
@@ -1009,7 +934,7 @@ void PG::_init(ObjectStore::Transaction& t, spg_t pgid, const pg_pool_t *pool)
   t.touch(coll, pgmeta_oid);
   map<string,bufferlist> values;
   __u8 struct_v = latest_struct_v;
-  encode(struct_v, values[infover_key]);
+  encode(struct_v, values[string(infover_key)]);
   t.omap_setkeys(coll, pgmeta_oid, values);
 }
 
@@ -1027,7 +952,7 @@ void PG::prepare_write(
   unstable_stats.clear();
   map<string,bufferlist> km;
   if (dirty_big_info || dirty_info) {
-    int ret = _prepare_write_info(
+    int ret = prepare_info_keymap(
       cct,
       &km,
       get_osdmap_epoch(),
@@ -1037,7 +962,8 @@ void PG::prepare_write(
       dirty_big_info,
       need_write_epoch,
       cct->_conf->osd_fast_info,
-      osd->logger);
+      osd->logger,
+      this);
     ceph_assert(ret == 0);
   }
   pglog.write_log_and_missing(
@@ -1083,8 +1009,8 @@ int PG::peek_map_epoch(ObjectStore *store,
 
   // try for v8
   set<string> keys;
-  keys.insert(infover_key);
-  keys.insert(epoch_key);
+  keys.insert(string(infover_key));
+  keys.insert(string(epoch_key));
   map<string,bufferlist> values;
   auto ch = store->open_collection(coll);
   ceph_assert(ch);
@@ -1093,13 +1019,13 @@ int PG::peek_map_epoch(ObjectStore *store,
     ceph_assert(values.size() == 2);
 
     // sanity check version
-    auto bp = values[infover_key].cbegin();
+    auto bp = values[string(infover_key)].cbegin();
     __u8 struct_v = 0;
     decode(struct_v, bp);
     ceph_assert(struct_v >= 8);
 
     // get epoch
-    bp = values[epoch_key].begin();
+    bp = values[string(epoch_key)].begin();
     decode(cur_epoch, bp);
   } else {
     // probably bug 10617; see OSD::load_pgs()
@@ -1143,10 +1069,10 @@ int PG::read_info(
   __u8 &struct_v)
 {
   set<string> keys;
-  keys.insert(infover_key);
-  keys.insert(info_key);
-  keys.insert(biginfo_key);
-  keys.insert(fastinfo_key);
+  keys.insert(string(infover_key));
+  keys.insert(string(info_key));
+  keys.insert(string(biginfo_key));
+  keys.insert(string(fastinfo_key));
   ghobject_t pgmeta_oid(pgid.make_pgmeta_oid());
   map<string,bufferlist> values;
   auto ch = store->open_collection(coll);
@@ -1156,18 +1082,18 @@ int PG::read_info(
   ceph_assert(values.size() == 3 ||
         values.size() == 4);
 
-  auto p = values[infover_key].cbegin();
+  auto p = values[string(infover_key)].cbegin();
   decode(struct_v, p);
   ceph_assert(struct_v >= 10);
 
-  p = values[info_key].begin();
+  p = values[string(info_key)].begin();
   decode(info, p);
 
-  p = values[biginfo_key].begin();
+  p = values[string(biginfo_key)].begin();
   decode(past_intervals, p);
   decode(info.purged_snaps, p);
 
-  p = values[fastinfo_key].begin();
+  p = values[string(fastinfo_key)].begin();
   if (!p.end()) {
     pg_fast_info_t fast;
     decode(fast, p);
@@ -1211,6 +1137,7 @@ void PG::read_state(ObjectStore *store)
 
       if (oss.tellp())
        osd->clog->error() << oss.str();
+      return 0;
     });
 
   if (info_struct_v < latest_struct_v) {
index e712ae54b8b50f6439666f695cebf8eb2d69db43..83ab6b7d98539e870303f95f0662e6d984308f3d 100644 (file)
@@ -1421,18 +1421,6 @@ public:
     bool need_write_epoch,
     ObjectStore::Transaction &t) override;
 
-  static int _prepare_write_info(
-    CephContext* cct,
-    map<string,bufferlist> *km,
-    epoch_t epoch,
-    pg_info_t &info,
-    pg_info_t &last_written_info,
-    PastIntervals &past_intervals,
-    bool dirty_big_info,
-    bool dirty_epoch,
-    bool try_fast_info,
-    PerfCounters *logger = nullptr);
-
   void write_if_dirty(PeeringCtx &rctx) {
     write_if_dirty(rctx.transaction);
   }
index 897a9034b815e87dea8461a7edb3d734a75dc7ff..1e2aee4f790e1a28e07c1847a5b937f6f7fb73f0 100644 (file)
@@ -6420,3 +6420,75 @@ void OSDOp::clear_data(vector<OSDOp>& ops)
     }
   }
 }
+
+int prepare_info_keymap(
+  CephContext* cct,
+  map<string,bufferlist> *km,
+  epoch_t epoch,
+  pg_info_t &info,
+  pg_info_t &last_written_info,
+  PastIntervals &past_intervals,
+  bool dirty_big_info,
+  bool dirty_epoch,
+  bool try_fast_info,
+  PerfCounters *logger,
+  DoutPrefixProvider *dpp)
+{
+  if (dirty_epoch) {
+    encode(epoch, (*km)[string(epoch_key)]);
+  }
+
+  if (logger)
+    logger->inc(l_osd_pg_info);
+
+  // try to do info efficiently?
+  if (!dirty_big_info && try_fast_info &&
+      info.last_update > last_written_info.last_update) {
+    pg_fast_info_t fast;
+    fast.populate_from(info);
+    bool did = fast.try_apply_to(&last_written_info);
+    ceph_assert(did);  // we verified last_update increased above
+    if (info == last_written_info) {
+      encode(fast, (*km)[string(fastinfo_key)]);
+      if (logger)
+       logger->inc(l_osd_pg_fastinfo);
+      return 0;
+    }
+    if (dpp) {
+      ldpp_dout(dpp, 30) << __func__ << " fastinfo failed, info:\n";
+      {
+       JSONFormatter jf(true);
+       jf.dump_object("info", info);
+       jf.flush(*_dout);
+      }
+      {
+       *_dout << "\nlast_written_info:\n";
+       JSONFormatter jf(true);
+       jf.dump_object("last_written_info", last_written_info);
+       jf.flush(*_dout);
+      }
+      *_dout << dendl;
+    }
+  }
+
+  last_written_info = info;
+
+  // info.  store purged_snaps separately.
+  interval_set<snapid_t> purged_snaps;
+  purged_snaps.swap(info.purged_snaps);
+  encode(info, (*km)[string(info_key)]);
+  purged_snaps.swap(info.purged_snaps);
+
+  if (dirty_big_info) {
+    // potentially big stuff
+    bufferlist& bigbl = (*km)[string(biginfo_key)];
+    encode(past_intervals, bigbl);
+    encode(info.purged_snaps, bigbl);
+    //dout(20) << "write_info bigbl " << bigbl.length() << dendl;
+    if (logger)
+      logger->inc(l_osd_pg_biginfo);
+  }
+
+  return 0;
+}
+
index 5aeb0443d2791c9268535a7d4538a1575707e3ac..87401c7279de59c0aff5472a05bb96c2f2255008 100644 (file)
@@ -47,6 +47,7 @@
 #include "include/cmp.h"
 #include "librados/ListObjectImpl.h"
 #include "compressor/Compressor.h"
+#include "osd_perf_counters.h"
 
 #define CEPH_OSD_ONDISK_MAGIC "ceph osd volume v026"
 
@@ -5925,6 +5926,27 @@ struct pool_pg_num_history_t {
 };
 WRITE_CLASS_ENCODER(pool_pg_num_history_t)
 
+// prefix pgmeta_oid keys with _ so that PGLog::read_log_and_missing() can
+// easily skip them
+static const string_view infover_key = "_infover"sv;
+static const string_view info_key = "_info"sv;
+static const string_view biginfo_key = "_biginfo"sv;
+static const string_view epoch_key = "_epoch"sv;
+static const string_view fastinfo_key = "_fastinfo"sv;
+
+int prepare_info_keymap(
+  CephContext* cct,
+  map<string,bufferlist> *km,
+  epoch_t epoch,
+  pg_info_t &info,
+  pg_info_t &last_written_info,
+  PastIntervals &past_intervals,
+  bool dirty_big_info,
+  bool dirty_epoch,
+  bool try_fast_info,
+  PerfCounters *logger = nullptr,
+  DoutPrefixProvider *dpp = nullptr);
+
 // omap specific stats
 struct omap_stat_t {
  int large_omap_objects;
index 1ba6075d157ecef6e6d767a69956cc1188be3f17..305f652d17e9e8b8170d4952543f0e67d69a54c9 100644 (file)
@@ -461,7 +461,7 @@ int write_info(ObjectStore::Transaction &t, epoch_t epoch, pg_info_t &info,
   ghobject_t pgmeta_oid(info.pgid.make_pgmeta_oid());
   map<string,bufferlist> km;
   pg_info_t last_written_info;
-  int ret = PG::_prepare_write_info(
+  int ret = prepare_info_keymap(
     g_ceph_context,
     &km, epoch,
     info,