]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
In general, flush in caller of dump worker rather than worker
authorDan Mick <dan.mick@inktank.com>
Wed, 24 Jul 2013 00:24:52 +0000 (17:24 -0700)
committerDan Mick <dan.mick@inktank.com>
Fri, 26 Jul 2013 20:51:00 +0000 (13:51 -0700)
This allows easier refactoring of workers (no dual flushes when code
changes).

Signed-off-by: Dan Mick <dan.mick@inktank.com>
src/common/ceph_context.cc
src/common/perf_counters.cc
src/common/perf_counters.h
src/osd/OSD.cc
src/osd/OpRequest.cc
src/osd/OpRequest.h
src/test/bench/small_io_bench_fs.cc

index e0fcf530222f4cc5ac2dff76ecd4ce4349d49ba0..6b227d8689e31b1e448c5c81022eae825cbc80ed 100644 (file)
@@ -170,11 +170,11 @@ void CephContext::do_command(std::string command, std::string args,
   lgeneric_dout(this, 1) << "do_command '" << command << "' '" << args << "'" << dendl;
   if (command == "perfcounters_dump" || command == "1" ||
       command == "perf dump") {
-    _perf_counters_collection->dump_formatted(f, *out, false);
+    _perf_counters_collection->dump_formatted(f, false);
   }
   else if (command == "perfcounters_schema" || command == "2" ||
     command == "perf schema") {
-    _perf_counters_collection->dump_formatted(f, *out, true);
+    _perf_counters_collection->dump_formatted(f, true);
   }
   else {
     f->open_object_section(command.c_str());
@@ -221,8 +221,8 @@ void CephContext::do_command(std::string command, std::string args,
       assert(0 == "registered under wrong command?");    
     }
     f->close_section();
-    f->flush(*out);
   }
+  f->flush(*out);
   delete f;
   lgeneric_dout(this, 1) << "do_command '" << command << "' '" << args << "' result is " << out->length() << " bytes" << dendl;
 };
index 46f55fae51bfcb7cde0db717e1b54e91c70a9ca4..86fb531f737c81ed5b6af3f6014039c2fb63628d 100644 (file)
@@ -73,8 +73,7 @@ void PerfCountersCollection::clear()
   }
 }
 
-void PerfCountersCollection::dump_formatted(Formatter *f, bufferlist &bl,
-                                           bool schema)
+void PerfCountersCollection::dump_formatted(Formatter *f, bool schema)
 {
   Mutex::Locker lck(m_lock);
   f->open_object_section("perfcounter_collection");
@@ -88,7 +87,6 @@ void PerfCountersCollection::dump_formatted(Formatter *f, bufferlist &bl,
     }
   }
   f->close_section();
-  f->flush(bl);
 }
 
 // ---------------------------
index 125d84c04e34a0f28a58e7164277ae64064a7286..ec10f9a9282865325b038f96a6c3061022f4fa4a 100644 (file)
@@ -136,7 +136,7 @@ public:
   void add(class PerfCounters *l);
   void remove(class PerfCounters *l);
   void clear();
-  void dump_formatted(ceph::Formatter *f, bufferlist &bl, bool schema);
+  void dump_formatted(ceph::Formatter *f, bool schema);
 private:
   CephContext *m_cct;
 
index dd9a5b7293f33a36a6374a433de67265cdd083c4..c767a2c0fe5f6719a5c3c687b23ce77c9122963f 100644 (file)
@@ -1012,14 +1012,13 @@ bool OSD::asok_command(string command, string args, string format, ostream& ss)
     format = "json-pretty";
   Formatter *f = new_formatter(format);
   if (command == "dump_ops_in_flight") {
-    op_tracker.dump_ops_in_flight(f, ss);
+    op_tracker.dump_ops_in_flight(f);
   } else if (command == "dump_historic_ops") {
-    op_tracker.dump_historic_ops(f, ss);
+    op_tracker.dump_historic_ops(f);
   } else if (command == "dump_op_pq_state") {
     f->open_object_section("pq");
     op_wq.dump(f);
     f->close_section();
-    f->flush(ss);
   } else if (command == "dump_blacklist") {
     list<pair<entity_addr_t,utime_t> > bl;
     OSDMapRef curmap = service.get_osdmap();
@@ -1036,7 +1035,6 @@ bool OSD::asok_command(string command, string args, string format, ostream& ss)
       f->close_section(); //entry
     }
     f->close_section(); //blacklist
-    f->flush(ss);
   } else if (command == "dump_watchers") {
     list<obj_watch_item_t> watchers;
     osd_lock.Lock();
@@ -1078,10 +1076,11 @@ bool OSD::asok_command(string command, string args, string format, ostream& ss)
     }
 
     f->close_section(); //watches
-    f->flush(ss);
   } else {
     assert(0 == "broken asok registration");
   }
+  f->flush(ss);
+  delete f;
   return true;
 }
 
index c0d167a5f0ad1aeb049a6c295a5b8af0b78bd7e0..a6cdc9ecffb5ed9dc9fa55fd3cbeeae188e4772f 100644 (file)
@@ -76,15 +76,14 @@ void OpHistory::dump_ops(utime_t now, Formatter *f)
   f->close_section();
 }
 
-void OpTracker::dump_historic_ops(Formatter *f, ostream &ss)
+void OpTracker::dump_historic_ops(Formatter *f)
 {
   Mutex::Locker locker(ops_in_flight_lock);
   utime_t now = ceph_clock_now(g_ceph_context);
   history.dump_ops(now, f);
-  f->flush(ss);
 }
 
-void OpTracker::dump_ops_in_flight(Formatter *f, ostream &ss)
+void OpTracker::dump_ops_in_flight(Formatter *f)
 {
   Mutex::Locker locker(ops_in_flight_lock);
   f->open_object_section("ops_in_flight"); // overall dump
@@ -98,7 +97,6 @@ void OpTracker::dump_ops_in_flight(Formatter *f, ostream &ss)
   }
   f->close_section(); // list of OpRequests
   f->close_section(); // overall dump
-  f->flush(ss);
 }
 
 void OpTracker::register_inflight_op(xlist<OpRequest*>::item *i)
index 67ee26b02ec140e2346053d50e7c5737a315e8d9..a2014472432daf7f68285dd0d229860ad6704cb0 100644 (file)
@@ -59,8 +59,8 @@ class OpTracker {
 
 public:
   OpTracker() : seq(0), ops_in_flight_lock("OpTracker mutex") {}
-  void dump_ops_in_flight(Formatter *f, std::ostream& ss);
-  void dump_historic_ops(Formatter *f, std::ostream& ss);
+  void dump_ops_in_flight(Formatter *f);
+  void dump_historic_ops(Formatter *f);
   void register_inflight_op(xlist<OpRequest*>::item *i);
   void unregister_inflight_op(OpRequest *i);
 
index 138757f7304c11e3370f28ecd5b4988104458b55..a37a7e71153a67ae80e87ff166fc45e1ed43ff18 100644 (file)
@@ -33,7 +33,8 @@ struct MorePrinting : public DetailedStatCollector::AdditionalPrinting {
   void operator()(std::ostream *out) {
     bufferlist bl;
     Formatter *f = new_formatter("json-pretty");
-    cct->get_perfcounters_collection()->dump_formatted(f, bl, 0);
+    cct->get_perfcounters_collection()->dump_formatted(f, 0);
+    f->flush(bl);
     delete f;
     bl.append('\0');
     *out << bl.c_str() << std::endl;