diff options
author | Dan Mick <dan.mick@inktank.com> | 2013-07-23 17:24:52 -0700 |
---|---|---|
committer | Dan Mick <dan.mick@inktank.com> | 2013-07-26 13:51:00 -0700 |
commit | ba6ca5829a6ec20c4cdbc990f1e27a0709ec5a41 (patch) | |
tree | 78c7922c1b993bede62f27ac0d13b30952bcf1a4 | |
parent | c7c4c23e5faea2182b8f9d18d12a31608e428f28 (diff) | |
download | ceph-ba6ca5829a6ec20c4cdbc990f1e27a0709ec5a41.tar.gz |
In general, flush in caller of dump worker rather than worker
This allows easier refactoring of workers (no dual flushes when code
changes).
Signed-off-by: Dan Mick <dan.mick@inktank.com>
-rw-r--r-- | src/common/ceph_context.cc | 6 | ||||
-rw-r--r-- | src/common/perf_counters.cc | 4 | ||||
-rw-r--r-- | src/common/perf_counters.h | 2 | ||||
-rw-r--r-- | src/osd/OSD.cc | 9 | ||||
-rw-r--r-- | src/osd/OpRequest.cc | 6 | ||||
-rw-r--r-- | src/osd/OpRequest.h | 4 | ||||
-rw-r--r-- | src/test/bench/small_io_bench_fs.cc | 3 |
7 files changed, 15 insertions, 19 deletions
diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index e0fcf530222..6b227d8689e 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -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; }; diff --git a/src/common/perf_counters.cc b/src/common/perf_counters.cc index 46f55fae51b..86fb531f737 100644 --- a/src/common/perf_counters.cc +++ b/src/common/perf_counters.cc @@ -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); } // --------------------------- diff --git a/src/common/perf_counters.h b/src/common/perf_counters.h index 125d84c04e3..ec10f9a9282 100644 --- a/src/common/perf_counters.h +++ b/src/common/perf_counters.h @@ -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; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index dd9a5b7293f..c767a2c0fe5 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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; } diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index c0d167a5f0a..a6cdc9ecffb 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -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) diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 67ee26b02ec..a2014472432 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -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); diff --git a/src/test/bench/small_io_bench_fs.cc b/src/test/bench/small_io_bench_fs.cc index 138757f7304..a37a7e71153 100644 --- a/src/test/bench/small_io_bench_fs.cc +++ b/src/test/bench/small_io_bench_fs.cc @@ -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; |