From 53e17c2a6f6287f8d742f568bef3bfbe8d389183 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 14:52:14 -0700 Subject: osd: move pow2_hist_t out of osd_types and into include/ This has only been used for the OSD so far, but as with the rest of the OpRequest stuff, it's actually pretty generic. Signed-off-by: Greg Farnum --- src/include/histogram.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++ src/mon/PGMonitor.h | 1 + src/osd/OpRequest.h | 1 + src/osd/osd_types.h | 62 +------------------------------------- src/test/encoding/types.h | 4 ++- 5 files changed, 82 insertions(+), 62 deletions(-) create mode 100644 src/include/histogram.h diff --git a/src/include/histogram.h b/src/include/histogram.h new file mode 100644 index 00000000000..c817b1ec175 --- /dev/null +++ b/src/include/histogram.h @@ -0,0 +1,76 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * Copyright 2013 Inktank + */ + +#ifndef HISTOGRAM_H_ +#define HISTOGRAM_H_ + +/** + * power of 2 histogram + */ +struct pow2_hist_t { // + /** + * histogram + * + * bin size is 2^index + * value is count of elements that are <= the current bin but > the previous bin. + */ + vector h; + +private: + /// expand to at least another's size + void _expand_to(unsigned s) { + if (s > h.size()) + h.resize(s, 0); + } + /// drop useless trailing 0's + void _contract() { + unsigned p = h.size(); + while (p > 0 && h[p-1] == 0) + --p; + h.resize(p); + } + +public: + void clear() { + h.clear(); + } + void set(int bin, int32_t v) { + _expand_to(bin + 1); + h[bin] = v; + _contract(); + } + + void add(const pow2_hist_t& o) { + _expand_to(o.h.size()); + for (unsigned p = 0; p < o.h.size(); ++p) + h[p] += o.h[p]; + _contract(); + } + void sub(const pow2_hist_t& o) { + _expand_to(o.h.size()); + for (unsigned p = 0; p < o.h.size(); ++p) + h[p] -= o.h[p]; + _contract(); + } + + int32_t upper_bound() const { + return 1 << h.size(); + } + + void dump(Formatter *f) const; + void encode(bufferlist &bl) const; + void decode(bufferlist::iterator &bl); + static void generate_test_instances(std::list& o); +}; +WRITE_CLASS_ENCODER(pow2_hist_t) + +#endif /* HISTOGRAM_H_ */ diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 44015395e94..d29f47c1c43 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -28,6 +28,7 @@ using namespace std; #include "PaxosService.h" #include "include/types.h" #include "include/utime.h" +#include "include/histogram.h" #include "msg/Messenger.h" #include "common/config.h" #include "mon/MonitorDBStore.h" diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 50ade71a1b9..3f740aac6e8 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -19,6 +19,7 @@ #include #include "common/Mutex.h" +#include "include/histogram.h" #include "include/xlist.h" #include "msg/Message.h" #include diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 091b2b95e8f..c2876fdc1cd 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -23,6 +23,7 @@ #include "include/types.h" #include "include/utime.h" #include "include/CompatSet.h" +#include "include/histogram.h" #include "include/interval_set.h" #include "common/snap_types.h" #include "common/Formatter.h" @@ -553,67 +554,6 @@ inline ostream& operator<<(ostream& out, const eversion_t e) { return out << e.epoch << "'" << e.version; } - -/** - * power of 2 histogram - */ -struct pow2_hist_t { - /** - * histogram - * - * bin size is 2^index - * value is count of elements that are <= the current bin but > the previous bin. - */ - vector h; - -private: - /// expand to at least another's size - void _expand_to(unsigned s) { - if (s > h.size()) - h.resize(s, 0); - } - /// drop useless trailing 0's - void _contract() { - unsigned p = h.size(); - while (p > 0 && h[p-1] == 0) - --p; - h.resize(p); - } - -public: - void clear() { - h.clear(); - } - void set(int bin, int32_t v) { - _expand_to(bin + 1); - h[bin] = v; - _contract(); - } - - void add(const pow2_hist_t& o) { - _expand_to(o.h.size()); - for (unsigned p = 0; p < o.h.size(); ++p) - h[p] += o.h[p]; - _contract(); - } - void sub(const pow2_hist_t& o) { - _expand_to(o.h.size()); - for (unsigned p = 0; p < o.h.size(); ++p) - h[p] -= o.h[p]; - _contract(); - } - - int32_t upper_bound() const { - return 1 << h.size(); - } - - void dump(Formatter *f) const; - void encode(bufferlist &bl) const; - void decode(bufferlist::iterator &bl); - static void generate_test_instances(std::list& o); -}; -WRITE_CLASS_ENCODER(pow2_hist_t) - /** * filestore_perf_stat_t * diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index fe17f077d8e..d9a16240d5a 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -29,13 +29,15 @@ TYPEWITHSTRAYDATA(OSDMap::Incremental) #include "crush/CrushWrapper.h" TYPE(CrushWrapper) +#include "include/histogram.h" +TYPE(pow2_hist_t) + #include "osd/osd_types.h" TYPE(osd_reqid_t) TYPE(object_locator_t) TYPE(request_redirect_t) TYPE(pg_t) TYPE(coll_t) -TYPE(pow2_hist_t) TYPE(filestore_perf_stat_t) TYPE(osd_stat_t) TYPE(OSDSuperblock) -- cgit v1.2.1 From 0678dcdd3cc02ef6a1aec383b41a68d50a933071 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 17:57:34 -0700 Subject: OpRequest: remove obsolete comment about ref-counting (use OpRequestRef!) Signed-off-by: Greg Farnum --- src/osd/OpRequest.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 3f740aac6e8..d429e6e717f 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -98,9 +98,6 @@ public: /** * The OpRequest takes in a Message* and takes over a single reference * to it, which it puts() when destroyed. - * OpRequest is itself ref-counted. The expectation is that you get a Message - * you want to track, create an OpRequest with it, and then pass around that OpRequest - * the way you used to pass around the Message. */ struct OpRequest : public TrackedOp { friend class OpTracker; -- cgit v1.2.1 From 24c33896f9b43e37a014d8dc31045af5ea79a792 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 11 Sep 2013 17:31:17 -0700 Subject: OpTracker: start making the OpTracker into a generic We're starting by templating the create_request function and having the OpTracker work in terms of TrackedOp[Ref]s intead of OpRequest[Ref]s. This involves moving a bunch of stuff into the base-class TrackedOp. Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 34 ++++++++++++++++++++++++++- src/osd/OSD.cc | 2 +- src/osd/OpRequest.cc | 55 ++++++++++++++----------------------------- src/osd/OpRequest.h | 64 +++++++++++++++++++++++++++----------------------- 4 files changed, 87 insertions(+), 68 deletions(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 753331df7f3..835cf86e9d3 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -22,9 +22,41 @@ #include class TrackedOp { +protected: + list > events; /// list of events and their times + Mutex lock; /// to protect the events list public: - virtual void mark_event(const string &event) = 0; + // move these to private once friended OpTracker + Message *request; + xlist::item xitem; + utime_t received_time; + // figure out how to get rid of this one? + uint8_t warn_interval_multiplier; + string current; + uint64_t seq; + + TrackedOp(Message *req) : + lock("TrackedOp::lock"), + request(req), + xitem(this), + warn_interval_multiplier(1), + seq(0) {} + virtual ~TrackedOp() {} + + utime_t get_arrived() const { + return received_time; + } + // This function maybe needs some work; assumes last event is completion time + double get_duration() const { + return events.size() ? + (events.rbegin()->first - received_time) : + 0.0; + } + + virtual void mark_event(const string &event) = 0; + virtual const char *state_string() const = 0; + virtual void dump(utime_t now, Formatter *f) const = 0; }; typedef std::tr1::shared_ptr TrackedOpRef; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index ff1276969d8..d51e9dc4434 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4724,7 +4724,7 @@ void OSD::_dispatch(Message *m) default: { - OpRequestRef op = op_tracker.create_request(m); + OpRequestRef op = op_tracker.create_request(m); op->mark_event("waiting_for_osdmap"); // no map? starting up? if (!osdmap) { diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index 1ffe3073051..388faf36763 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -21,13 +21,10 @@ static ostream& _prefix(std::ostream* _dout) } OpRequest::OpRequest(Message *req, OpTracker *tracker) : - request(req), xitem(this), + TrackedOp(req), rmw_flags(0), - warn_interval_multiplier(1), - lock("OpRequest::lock"), tracker(tracker), - hit_flag_points(0), latest_flag_point(0), - seq(0) { + hit_flag_points(0), latest_flag_point(0) { received_time = request->get_recv_stamp(); tracker->register_inflight_op(&xitem); if (req->get_priority() < tracker->cct->_conf->osd_client_op_priority) { @@ -43,7 +40,7 @@ void OpHistory::on_shutdown() shutdown = true; } -void OpHistory::insert(utime_t now, OpRequestRef op) +void OpHistory::insert(utime_t now, TrackedOpRef op) { if (shutdown) return; @@ -79,7 +76,7 @@ void OpHistory::dump_ops(utime_t now, Formatter *f) f->dump_int("duration to keep", tracker->cct->_conf->osd_op_history_duration); { f->open_array_section("Ops"); - for (set >::const_iterator i = + for (set >::const_iterator i = arrived.begin(); i != arrived.end(); ++i) { @@ -104,32 +101,32 @@ void OpTracker::dump_ops_in_flight(Formatter *f) Mutex::Locker locker(ops_in_flight_lock); f->open_object_section("ops_in_flight"); // overall dump f->dump_int("num_ops", ops_in_flight.size()); - f->open_array_section("ops"); // list of OpRequests + f->open_array_section("ops"); // list of TrackedOps utime_t now = ceph_clock_now(cct); - for (xlist::iterator p = ops_in_flight.begin(); !p.end(); ++p) { + for (xlist::iterator p = ops_in_flight.begin(); !p.end(); ++p) { f->open_object_section("op"); (*p)->dump(now, f); - f->close_section(); // this OpRequest + f->close_section(); // this TrackedOp } - f->close_section(); // list of OpRequests + f->close_section(); // list of TrackedOps f->close_section(); // overall dump } -void OpTracker::register_inflight_op(xlist::item *i) +void OpTracker::register_inflight_op(xlist::item *i) { Mutex::Locker locker(ops_in_flight_lock); ops_in_flight.push_back(i); ops_in_flight.back()->seq = seq++; } -void OpTracker::unregister_inflight_op(OpRequest *i) +void OpTracker::unregister_inflight_op(TrackedOp *i) { Mutex::Locker locker(ops_in_flight_lock); assert(i->xitem.get_list() == &ops_in_flight); utime_t now = ceph_clock_now(cct); i->xitem.remove_myself(); i->request->clear_data(); - history.insert(now, OpRequestRef(i)); + history.insert(now, TrackedOpRef(i)); } bool OpTracker::check_ops_in_flight(std::vector &warning_vector) @@ -151,7 +148,7 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) if (oldest_secs < cct->_conf->osd_op_complaint_time) return false; - xlist::iterator i = ops_in_flight.begin(); + xlist::iterator i = ops_in_flight.begin(); warning_vector.reserve(cct->_conf->osd_op_log_threshold + 1); int slow = 0; // total slow @@ -205,7 +202,7 @@ void OpTracker::get_age_ms_histogram(pow2_hist_t *h) unsigned bin = 30; uint32_t lb = 1 << (bin-1); // lower bound for this bin int count = 0; - for (xlist::iterator i = ops_in_flight.begin(); !i.end(); ++i) { + for (xlist::iterator i = ops_in_flight.begin(); !i.end(); ++i) { utime_t age = now - (*i)->received_time; uint32_t ms = (long)(age * 1000.0); if (ms >= lb) { @@ -257,44 +254,28 @@ void OpRequest::dump(utime_t now, Formatter *f) const } } -void OpTracker::mark_event(OpRequest *op, const string &dest) +void OpTracker::mark_event(TrackedOp *op, const string &dest) { utime_t now = ceph_clock_now(cct); return _mark_event(op, dest, now); } -void OpTracker::_mark_event(OpRequest *op, const string &evt, +void OpTracker::_mark_event(TrackedOp *op, const string &evt, utime_t time) { Mutex::Locker locker(ops_in_flight_lock); - dout(5) << "reqid: " << op->get_reqid() << ", seq: " << op->seq + dout(5) << //"reqid: " << op->get_reqid() << + ", seq: " << op->seq << ", time: " << time << ", event: " << evt << ", request: " << *op->request << dendl; } -void OpTracker::RemoveOnDelete::operator()(OpRequest *op) { +void OpTracker::RemoveOnDelete::operator()(TrackedOp *op) { op->mark_event("done"); tracker->unregister_inflight_op(op); // Do not delete op, unregister_inflight_op took control } -OpRequestRef OpTracker::create_request(Message *ref) -{ - OpRequestRef retval(new OpRequest(ref, this), - RemoveOnDelete(this)); - - if (ref->get_type() == CEPH_MSG_OSD_OP) { - retval->reqid = static_cast(ref)->get_reqid(); - } else if (ref->get_type() == MSG_OSD_SUBOP) { - retval->reqid = static_cast(ref)->reqid; - } - _mark_event(retval.get(), "header_read", ref->get_recv_stamp()); - _mark_event(retval.get(), "throttled", ref->get_throttle_stamp()); - _mark_event(retval.get(), "all_read", ref->get_recv_complete_stamp()); - _mark_event(retval.get(), "dispatched", ref->get_dispatch_stamp()); - return retval; -} - void OpRequest::mark_event(const string &event) { utime_t now = ceph_clock_now(tracker->cct); diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index d429e6e717f..f501c649699 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -25,13 +25,14 @@ #include #include "common/TrackedOp.h" #include "osd/osd_types.h" +// FIXME: augh, get these outta here! +#include "messages/MOSDOp.h" +#include "messages/MOSDSubOp.h" -struct OpRequest; class OpTracker; -typedef std::tr1::shared_ptr OpRequestRef; class OpHistory { - set > arrived; - set > duration; + set > arrived; + set > duration; void cleanup(utime_t now); bool shutdown; OpTracker *tracker; @@ -42,7 +43,7 @@ public: assert(arrived.empty()); assert(duration.empty()); } - void insert(utime_t now, OpRequestRef op); + void insert(utime_t now, TrackedOpRef op); void dump_ops(utime_t now, Formatter *f); void on_shutdown(); }; @@ -52,14 +53,14 @@ class OpTracker { OpTracker *tracker; public: RemoveOnDelete(OpTracker *tracker) : tracker(tracker) {} - void operator()(OpRequest *op); + void operator()(TrackedOp *op); }; friend class RemoveOnDelete; friend class OpRequest; friend class OpHistory; uint64_t seq; Mutex ops_in_flight_lock; - xlist ops_in_flight; + xlist ops_in_flight; OpHistory history; protected: @@ -69,8 +70,8 @@ public: OpTracker(CephContext *cct_) : seq(0), ops_in_flight_lock("OpTracker mutex"), history(this), cct(cct_) {} void dump_ops_in_flight(Formatter *f); void dump_historic_ops(Formatter *f); - void register_inflight_op(xlist::item *i); - void unregister_inflight_op(OpRequest *i); + void register_inflight_op(xlist::item *i); + void unregister_inflight_op(TrackedOp *i); void get_age_ms_histogram(pow2_hist_t *h); @@ -83,9 +84,9 @@ public: * @return True if there are any Ops to warn on, false otherwise. */ bool check_ops_in_flight(std::vector &warning_strings); - void mark_event(OpRequest *op, const string &evt); - void _mark_event(OpRequest *op, const string &evt, utime_t now); - OpRequestRef create_request(Message *req); + void mark_event(TrackedOp *op, const string &evt); + void _mark_event(TrackedOp *op, const string &evt, utime_t now); + void on_shutdown() { Mutex::Locker l(ops_in_flight_lock); history.on_shutdown(); @@ -93,6 +94,24 @@ public: ~OpTracker() { assert(ops_in_flight.empty()); } + + template + TRef create_request(Message *ref) + { + TRef retval(new T(ref, this), + RemoveOnDelete(this)); + + if (ref->get_type() == CEPH_MSG_OSD_OP) { + retval->reqid = static_cast(ref)->get_reqid(); + } else if (ref->get_type() == MSG_OSD_SUBOP) { + retval->reqid = static_cast(ref)->reqid; + } + _mark_event(retval.get(), "header_read", ref->get_recv_stamp()); + _mark_event(retval.get(), "throttled", ref->get_throttle_stamp()); + _mark_event(retval.get(), "all_read", ref->get_recv_complete_stamp()); + _mark_event(retval.get(), "dispatched", ref->get_dispatch_stamp()); + return retval; + } }; /** @@ -102,8 +121,6 @@ public: struct OpRequest : public TrackedOp { friend class OpTracker; friend class OpHistory; - Message *request; - xlist::item xitem; // rmw flags int rmw_flags; @@ -132,28 +149,13 @@ struct OpRequest : public TrackedOp { void set_class_write() { rmw_flags |= CEPH_OSD_RMW_FLAG_CLASS_WRITE; } void set_pg_op() { rmw_flags |= CEPH_OSD_RMW_FLAG_PGOP; } - utime_t received_time; - uint8_t warn_interval_multiplier; - utime_t get_arrived() const { - return received_time; - } - double get_duration() const { - return events.size() ? - (events.rbegin()->first - received_time) : - 0.0; - } - void dump(utime_t now, Formatter *f) const; private: - list > events; - string current; - Mutex lock; OpTracker *tracker; osd_reqid_t reqid; uint8_t hit_flag_points; uint8_t latest_flag_point; - uint64_t seq; static const uint8_t flag_queued_for_pg=1 << 0; static const uint8_t flag_reached_pg = 1 << 1; static const uint8_t flag_delayed = 1 << 2; @@ -162,6 +164,7 @@ private: static const uint8_t flag_commit_sent = 1 << 5; OpRequest(Message *req, OpTracker *tracker); + public: ~OpRequest() { assert(request); @@ -237,4 +240,7 @@ public: } }; +typedef std::tr1::shared_ptr OpRequestRef; + + #endif /* OPREQUEST_H_ */ -- cgit v1.2.1 From 5fdaccd2d7fdceef402ec2536eff3992f6b28833 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 26 Mar 2013 13:11:21 -0700 Subject: OpTracker: add an init_from_message() to the TrackedOp interface This can be used for the concrete implementations to gather any extra data out of the message and do whatever extra setup based on that they want. The OpTracker will call this after doing all its internal setup but before anybody else gets to see the TrackedOp. Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 2 ++ src/osd/OpRequest.cc | 9 +++++++++ src/osd/OpRequest.h | 13 +++++-------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 835cf86e9d3..7a7b66396f6 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -42,6 +42,8 @@ public: warn_interval_multiplier(1), seq(0) {} + virtual void init_from_message() {}; + virtual ~TrackedOp() {} utime_t get_arrived() const { diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index 388faf36763..5a9abd63cf6 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -285,3 +285,12 @@ void OpRequest::mark_event(const string &event) } tracker->mark_event(this, event); } + +void OpRequest::init_from_message() +{ + if (request->get_type() == CEPH_MSG_OSD_OP) { + reqid = static_cast(request)->get_reqid(); + } else if (request->get_type() == MSG_OSD_SUBOP) { + reqid = static_cast(request)->reqid; + } +} diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index f501c649699..7dc8e78afa5 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -25,9 +25,6 @@ #include #include "common/TrackedOp.h" #include "osd/osd_types.h" -// FIXME: augh, get these outta here! -#include "messages/MOSDOp.h" -#include "messages/MOSDSubOp.h" class OpTracker; class OpHistory { @@ -101,15 +98,13 @@ public: TRef retval(new T(ref, this), RemoveOnDelete(this)); - if (ref->get_type() == CEPH_MSG_OSD_OP) { - retval->reqid = static_cast(ref)->get_reqid(); - } else if (ref->get_type() == MSG_OSD_SUBOP) { - retval->reqid = static_cast(ref)->reqid; - } _mark_event(retval.get(), "header_read", ref->get_recv_stamp()); _mark_event(retval.get(), "throttled", ref->get_throttle_stamp()); _mark_event(retval.get(), "all_read", ref->get_recv_complete_stamp()); _mark_event(retval.get(), "dispatched", ref->get_dispatch_stamp()); + + retval->init_from_message(); + return retval; } }; @@ -238,6 +233,8 @@ public: osd_reqid_t get_reqid() const { return reqid; } + + void init_from_message(); }; typedef std::tr1::shared_ptr OpRequestRef; -- cgit v1.2.1 From 3cb6abec4b9384e0a78ab9f8310f7dc6cda7fc90 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 17:29:40 -0700 Subject: OpTracker: move the OpTracker and OpHistory into common/TrackedOp.[h|cc] Signed-off-by: Greg Farnum --- src/common/TrackedOp.cc | 249 ++++++++++++++++++++++++++++++++++++++++++++++++ src/common/TrackedOp.h | 90 ++++++++++++++++- src/osd/Makefile.am | 1 + src/osd/OpRequest.cc | 227 ------------------------------------------- src/osd/OpRequest.h | 86 ----------------- 5 files changed, 338 insertions(+), 315 deletions(-) create mode 100644 src/common/TrackedOp.cc diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc new file mode 100644 index 00000000000..3056db7eeb4 --- /dev/null +++ b/src/common/TrackedOp.cc @@ -0,0 +1,249 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * Copyright 2013 Inktank + */ + +#include "TrackedOp.h" +#include "common/Formatter.h" +#include +#include +#include "common/debug.h" +#include "common/config.h" +#include "msg/Message.h" +#include "include/assert.h" + +#define dout_subsys ceph_subsys_optracker +#undef dout_prefix +#define dout_prefix _prefix(_dout) + +static ostream& _prefix(std::ostream* _dout) +{ + return *_dout << "-- op tracker -- "; +} + +void OpHistory::on_shutdown() +{ + arrived.clear(); + duration.clear(); + shutdown = true; +} + +void OpHistory::insert(utime_t now, TrackedOpRef op) +{ + if (shutdown) + return; + duration.insert(make_pair(op->get_duration(), op)); + arrived.insert(make_pair(op->get_arrived(), op)); + cleanup(now); +} + +void OpHistory::cleanup(utime_t now) +{ + while (arrived.size() && + (now - arrived.begin()->first > + (double)(tracker->cct->_conf->osd_op_history_duration))) { + duration.erase(make_pair( + arrived.begin()->second->get_duration(), + arrived.begin()->second)); + arrived.erase(arrived.begin()); + } + + while (duration.size() > tracker->cct->_conf->osd_op_history_size) { + arrived.erase(make_pair( + duration.begin()->second->get_arrived(), + duration.begin()->second)); + duration.erase(duration.begin()); + } +} + +void OpHistory::dump_ops(utime_t now, Formatter *f) +{ + cleanup(now); + f->open_object_section("OpHistory"); + f->dump_int("num to keep", tracker->cct->_conf->osd_op_history_size); + f->dump_int("duration to keep", tracker->cct->_conf->osd_op_history_duration); + { + f->open_array_section("Ops"); + for (set >::const_iterator i = + arrived.begin(); + i != arrived.end(); + ++i) { + f->open_object_section("Op"); + i->second->dump(now, f); + f->close_section(); + } + f->close_section(); + } + f->close_section(); +} + +void OpTracker::dump_historic_ops(Formatter *f) +{ + Mutex::Locker locker(ops_in_flight_lock); + utime_t now = ceph_clock_now(cct); + history.dump_ops(now, f); +} + +void OpTracker::dump_ops_in_flight(Formatter *f) +{ + Mutex::Locker locker(ops_in_flight_lock); + f->open_object_section("ops_in_flight"); // overall dump + f->dump_int("num_ops", ops_in_flight.size()); + f->open_array_section("ops"); // list of TrackedOps + utime_t now = ceph_clock_now(cct); + for (xlist::iterator p = ops_in_flight.begin(); !p.end(); ++p) { + f->open_object_section("op"); + (*p)->dump(now, f); + f->close_section(); // this TrackedOp + } + f->close_section(); // list of TrackedOps + f->close_section(); // overall dump +} + +void OpTracker::register_inflight_op(xlist::item *i) +{ + Mutex::Locker locker(ops_in_flight_lock); + ops_in_flight.push_back(i); + ops_in_flight.back()->seq = seq++; +} + +void OpTracker::unregister_inflight_op(TrackedOp *i) +{ + Mutex::Locker locker(ops_in_flight_lock); + assert(i->xitem.get_list() == &ops_in_flight); + utime_t now = ceph_clock_now(cct); + i->xitem.remove_myself(); + i->request->clear_data(); + history.insert(now, TrackedOpRef(i)); +} + +bool OpTracker::check_ops_in_flight(std::vector &warning_vector) +{ + Mutex::Locker locker(ops_in_flight_lock); + if (!ops_in_flight.size()) + return false; + + utime_t now = ceph_clock_now(cct); + utime_t too_old = now; + too_old -= cct->_conf->osd_op_complaint_time; + + utime_t oldest_secs = now - ops_in_flight.front()->received_time; + + dout(10) << "ops_in_flight.size: " << ops_in_flight.size() + << "; oldest is " << oldest_secs + << " seconds old" << dendl; + + if (oldest_secs < cct->_conf->osd_op_complaint_time) + return false; + + xlist::iterator i = ops_in_flight.begin(); + warning_vector.reserve(cct->_conf->osd_op_log_threshold + 1); + + int slow = 0; // total slow + int warned = 0; // total logged + while (!i.end() && (*i)->received_time < too_old) { + slow++; + + // exponential backoff of warning intervals + if (((*i)->received_time + + (cct->_conf->osd_op_complaint_time * + (*i)->warn_interval_multiplier)) < now) { + // will warn + if (warning_vector.empty()) + warning_vector.push_back(""); + warned++; + if (warned > cct->_conf->osd_op_log_threshold) + break; + + utime_t age = now - (*i)->received_time; + stringstream ss; + ss << "slow request " << age << " seconds old, received at " << (*i)->received_time + << ": " << *((*i)->request) << " currently " + << ((*i)->current.size() ? (*i)->current : (*i)->state_string()); + warning_vector.push_back(ss.str()); + + // only those that have been shown will backoff + (*i)->warn_interval_multiplier *= 2; + } + ++i; + } + + // only summarize if we warn about any. if everything has backed + // off, we will stay silent. + if (warned > 0) { + stringstream ss; + ss << slow << " slow requests, " << warned << " included below; oldest blocked for > " + << oldest_secs << " secs"; + warning_vector[0] = ss.str(); + } + + return warning_vector.size(); +} + +void OpTracker::get_age_ms_histogram(pow2_hist_t *h) +{ + Mutex::Locker locker(ops_in_flight_lock); + + h->clear(); + + utime_t now = ceph_clock_now(NULL); + unsigned bin = 30; + uint32_t lb = 1 << (bin-1); // lower bound for this bin + int count = 0; + for (xlist::iterator i = ops_in_flight.begin(); !i.end(); ++i) { + utime_t age = now - (*i)->received_time; + uint32_t ms = (long)(age * 1000.0); + if (ms >= lb) { + count++; + continue; + } + if (count) + h->set(bin, count); + while (lb > ms) { + bin--; + lb >>= 1; + } + count = 1; + } + if (count) + h->set(bin, count); +} + +void OpTracker::mark_event(TrackedOp *op, const string &dest) +{ + utime_t now = ceph_clock_now(cct); + return _mark_event(op, dest, now); +} + +void OpTracker::_mark_event(TrackedOp *op, const string &evt, + utime_t time) +{ + Mutex::Locker locker(ops_in_flight_lock); + dout(5) << //"reqid: " << op->get_reqid() << + ", seq: " << op->seq + << ", time: " << time << ", event: " << evt + << ", request: " << *op->request << dendl; +} + +void OpTracker::RemoveOnDelete::operator()(TrackedOp *op) { + op->mark_event("done"); + tracker->unregister_inflight_op(op); + // Do not delete op, unregister_inflight_op took control +} + +void TrackedOp::mark_event(const string &event) +{ + utime_t now = ceph_clock_now(g_ceph_context); + { + Mutex::Locker l(lock); + events.push_back(make_pair(now, event)); + } + tracker->mark_event(this, event); +} diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 7a7b66396f6..644fc0a6182 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -17,10 +17,97 @@ #include #include #include "common/Mutex.h" +#include "include/histogram.h" #include "include/xlist.h" #include "msg/Message.h" #include +class TrackedOp; +typedef std::tr1::shared_ptr TrackedOpRef; + +class OpTracker; +class OpHistory { + set > arrived; + set > duration; + void cleanup(utime_t now); + bool shutdown; + OpTracker *tracker; + +public: + OpHistory(OpTracker *tracker_) : shutdown(false), tracker(tracker_) {} + ~OpHistory() { + assert(arrived.empty()); + assert(duration.empty()); + } + void insert(utime_t now, TrackedOpRef op); + void dump_ops(utime_t now, Formatter *f); + void on_shutdown(); +}; + +class OpTracker { + class RemoveOnDelete { + OpTracker *tracker; + public: + RemoveOnDelete(OpTracker *tracker) : tracker(tracker) {} + void operator()(TrackedOp *op); + }; + friend class RemoveOnDelete; + friend class OpRequest; + friend class OpHistory; + uint64_t seq; + Mutex ops_in_flight_lock; + xlist ops_in_flight; + OpHistory history; + +protected: + CephContext *cct; + +public: + OpTracker(CephContext *cct_) : seq(0), ops_in_flight_lock("OpTracker mutex"), history(this), cct(cct_) {} + void dump_ops_in_flight(Formatter *f); + void dump_historic_ops(Formatter *f); + void register_inflight_op(xlist::item *i); + void unregister_inflight_op(TrackedOp *i); + + void get_age_ms_histogram(pow2_hist_t *h); + + /** + * Look for Ops which are too old, and insert warning + * strings for each Op that is too old. + * + * @param warning_strings A vector reference which is filled + * with a warning string for each old Op. + * @return True if there are any Ops to warn on, false otherwise. + */ + bool check_ops_in_flight(std::vector &warning_strings); + void mark_event(TrackedOp *op, const string &evt); + void _mark_event(TrackedOp *op, const string &evt, utime_t now); + + void on_shutdown() { + Mutex::Locker l(ops_in_flight_lock); + history.on_shutdown(); + } + ~OpTracker() { + assert(ops_in_flight.empty()); + } + + template + TRef create_request(Message *ref) + { + TRef retval(new T(ref, this), + RemoveOnDelete(this)); + + _mark_event(retval.get(), "header_read", ref->get_recv_stamp()); + _mark_event(retval.get(), "throttled", ref->get_throttle_stamp()); + _mark_event(retval.get(), "all_read", ref->get_recv_complete_stamp()); + _mark_event(retval.get(), "dispatched", ref->get_dispatch_stamp()); + + retval->init_from_message(); + + return retval; + } +}; + class TrackedOp { protected: list > events; /// list of events and their times @@ -56,10 +143,9 @@ public: 0.0; } - virtual void mark_event(const string &event) = 0; + virtual void mark_event(const string &event); virtual const char *state_string() const = 0; virtual void dump(utime_t now, Formatter *f) const = 0; }; -typedef std::tr1::shared_ptr TrackedOpRef; #endif diff --git a/src/osd/Makefile.am b/src/osd/Makefile.am index ea7c036f858..d6d0e363dbb 100644 --- a/src/osd/Makefile.am +++ b/src/osd/Makefile.am @@ -15,6 +15,7 @@ libosd_la_SOURCES = \ osd/Watch.cc \ osd/ClassHandler.cc \ osd/OpRequest.cc \ + common/TrackedOp.cc \ osd/SnapMapper.cc \ osd/osd_types.cc \ objclass/class_api.cc diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index 5a9abd63cf6..81980ed2a57 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -11,14 +11,7 @@ #include "messages/MOSDSubOp.h" #include "include/assert.h" -#define dout_subsys ceph_subsys_optracker -#undef dout_prefix -#define dout_prefix _prefix(_dout) -static ostream& _prefix(std::ostream* _dout) -{ - return *_dout << "--OSD::tracker-- "; -} OpRequest::OpRequest(Message *req, OpTracker *tracker) : TrackedOp(req), @@ -33,194 +26,6 @@ OpRequest::OpRequest(Message *req, OpTracker *tracker) : } } -void OpHistory::on_shutdown() -{ - arrived.clear(); - duration.clear(); - shutdown = true; -} - -void OpHistory::insert(utime_t now, TrackedOpRef op) -{ - if (shutdown) - return; - duration.insert(make_pair(op->get_duration(), op)); - arrived.insert(make_pair(op->get_arrived(), op)); - cleanup(now); -} - -void OpHistory::cleanup(utime_t now) -{ - while (arrived.size() && - (now - arrived.begin()->first > - (double)(tracker->cct->_conf->osd_op_history_duration))) { - duration.erase(make_pair( - arrived.begin()->second->get_duration(), - arrived.begin()->second)); - arrived.erase(arrived.begin()); - } - - while (duration.size() > tracker->cct->_conf->osd_op_history_size) { - arrived.erase(make_pair( - duration.begin()->second->get_arrived(), - duration.begin()->second)); - duration.erase(duration.begin()); - } -} - -void OpHistory::dump_ops(utime_t now, Formatter *f) -{ - cleanup(now); - f->open_object_section("OpHistory"); - f->dump_int("num to keep", tracker->cct->_conf->osd_op_history_size); - f->dump_int("duration to keep", tracker->cct->_conf->osd_op_history_duration); - { - f->open_array_section("Ops"); - for (set >::const_iterator i = - arrived.begin(); - i != arrived.end(); - ++i) { - f->open_object_section("Op"); - i->second->dump(now, f); - f->close_section(); - } - f->close_section(); - } - f->close_section(); -} - -void OpTracker::dump_historic_ops(Formatter *f) -{ - Mutex::Locker locker(ops_in_flight_lock); - utime_t now = ceph_clock_now(cct); - history.dump_ops(now, f); -} - -void OpTracker::dump_ops_in_flight(Formatter *f) -{ - Mutex::Locker locker(ops_in_flight_lock); - f->open_object_section("ops_in_flight"); // overall dump - f->dump_int("num_ops", ops_in_flight.size()); - f->open_array_section("ops"); // list of TrackedOps - utime_t now = ceph_clock_now(cct); - for (xlist::iterator p = ops_in_flight.begin(); !p.end(); ++p) { - f->open_object_section("op"); - (*p)->dump(now, f); - f->close_section(); // this TrackedOp - } - f->close_section(); // list of TrackedOps - f->close_section(); // overall dump -} - -void OpTracker::register_inflight_op(xlist::item *i) -{ - Mutex::Locker locker(ops_in_flight_lock); - ops_in_flight.push_back(i); - ops_in_flight.back()->seq = seq++; -} - -void OpTracker::unregister_inflight_op(TrackedOp *i) -{ - Mutex::Locker locker(ops_in_flight_lock); - assert(i->xitem.get_list() == &ops_in_flight); - utime_t now = ceph_clock_now(cct); - i->xitem.remove_myself(); - i->request->clear_data(); - history.insert(now, TrackedOpRef(i)); -} - -bool OpTracker::check_ops_in_flight(std::vector &warning_vector) -{ - Mutex::Locker locker(ops_in_flight_lock); - if (!ops_in_flight.size()) - return false; - - utime_t now = ceph_clock_now(cct); - utime_t too_old = now; - too_old -= cct->_conf->osd_op_complaint_time; - - utime_t oldest_secs = now - ops_in_flight.front()->received_time; - - dout(10) << "ops_in_flight.size: " << ops_in_flight.size() - << "; oldest is " << oldest_secs - << " seconds old" << dendl; - - if (oldest_secs < cct->_conf->osd_op_complaint_time) - return false; - - xlist::iterator i = ops_in_flight.begin(); - warning_vector.reserve(cct->_conf->osd_op_log_threshold + 1); - - int slow = 0; // total slow - int warned = 0; // total logged - while (!i.end() && (*i)->received_time < too_old) { - slow++; - - // exponential backoff of warning intervals - if (((*i)->received_time + - (cct->_conf->osd_op_complaint_time * - (*i)->warn_interval_multiplier)) < now) { - // will warn - if (warning_vector.empty()) - warning_vector.push_back(""); - warned++; - if (warned > cct->_conf->osd_op_log_threshold) - break; - - utime_t age = now - (*i)->received_time; - stringstream ss; - ss << "slow request " << age << " seconds old, received at " << (*i)->received_time - << ": " << *((*i)->request) << " currently " - << ((*i)->current.size() ? (*i)->current : (*i)->state_string()); - warning_vector.push_back(ss.str()); - - // only those that have been shown will backoff - (*i)->warn_interval_multiplier *= 2; - } - ++i; - } - - // only summarize if we warn about any. if everything has backed - // off, we will stay silent. - if (warned > 0) { - stringstream ss; - ss << slow << " slow requests, " << warned << " included below; oldest blocked for > " - << oldest_secs << " secs"; - warning_vector[0] = ss.str(); - } - - return warning_vector.size(); -} - -void OpTracker::get_age_ms_histogram(pow2_hist_t *h) -{ - Mutex::Locker locker(ops_in_flight_lock); - - h->clear(); - - utime_t now = ceph_clock_now(NULL); - unsigned bin = 30; - uint32_t lb = 1 << (bin-1); // lower bound for this bin - int count = 0; - for (xlist::iterator i = ops_in_flight.begin(); !i.end(); ++i) { - utime_t age = now - (*i)->received_time; - uint32_t ms = (long)(age * 1000.0); - if (ms >= lb) { - count++; - continue; - } - if (count) - h->set(bin, count); - while (lb > ms) { - bin--; - lb >>= 1; - } - count = 1; - } - if (count) - h->set(bin, count); -} - void OpRequest::dump(utime_t now, Formatter *f) const { Message *m = request; @@ -254,38 +59,6 @@ void OpRequest::dump(utime_t now, Formatter *f) const } } -void OpTracker::mark_event(TrackedOp *op, const string &dest) -{ - utime_t now = ceph_clock_now(cct); - return _mark_event(op, dest, now); -} - -void OpTracker::_mark_event(TrackedOp *op, const string &evt, - utime_t time) -{ - Mutex::Locker locker(ops_in_flight_lock); - dout(5) << //"reqid: " << op->get_reqid() << - ", seq: " << op->seq - << ", time: " << time << ", event: " << evt - << ", request: " << *op->request << dendl; -} - -void OpTracker::RemoveOnDelete::operator()(TrackedOp *op) { - op->mark_event("done"); - tracker->unregister_inflight_op(op); - // Do not delete op, unregister_inflight_op took control -} - -void OpRequest::mark_event(const string &event) -{ - utime_t now = ceph_clock_now(tracker->cct); - { - Mutex::Locker l(lock); - events.push_back(make_pair(now, event)); - } - tracker->mark_event(this, event); -} - void OpRequest::init_from_message() { if (request->get_type() == CEPH_MSG_OSD_OP) { diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 7dc8e78afa5..80dd08cb98f 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -19,103 +19,18 @@ #include #include "common/Mutex.h" -#include "include/histogram.h" #include "include/xlist.h" #include "msg/Message.h" #include #include "common/TrackedOp.h" #include "osd/osd_types.h" -class OpTracker; -class OpHistory { - set > arrived; - set > duration; - void cleanup(utime_t now); - bool shutdown; - OpTracker *tracker; - -public: - OpHistory(OpTracker *tracker_) : shutdown(false), tracker(tracker_) {} - ~OpHistory() { - assert(arrived.empty()); - assert(duration.empty()); - } - void insert(utime_t now, TrackedOpRef op); - void dump_ops(utime_t now, Formatter *f); - void on_shutdown(); -}; - -class OpTracker { - class RemoveOnDelete { - OpTracker *tracker; - public: - RemoveOnDelete(OpTracker *tracker) : tracker(tracker) {} - void operator()(TrackedOp *op); - }; - friend class RemoveOnDelete; - friend class OpRequest; - friend class OpHistory; - uint64_t seq; - Mutex ops_in_flight_lock; - xlist ops_in_flight; - OpHistory history; - -protected: - CephContext *cct; - -public: - OpTracker(CephContext *cct_) : seq(0), ops_in_flight_lock("OpTracker mutex"), history(this), cct(cct_) {} - void dump_ops_in_flight(Formatter *f); - void dump_historic_ops(Formatter *f); - void register_inflight_op(xlist::item *i); - void unregister_inflight_op(TrackedOp *i); - - void get_age_ms_histogram(pow2_hist_t *h); - - /** - * Look for Ops which are too old, and insert warning - * strings for each Op that is too old. - * - * @param warning_strings A vector reference which is filled - * with a warning string for each old Op. - * @return True if there are any Ops to warn on, false otherwise. - */ - bool check_ops_in_flight(std::vector &warning_strings); - void mark_event(TrackedOp *op, const string &evt); - void _mark_event(TrackedOp *op, const string &evt, utime_t now); - - void on_shutdown() { - Mutex::Locker l(ops_in_flight_lock); - history.on_shutdown(); - } - ~OpTracker() { - assert(ops_in_flight.empty()); - } - - template - TRef create_request(Message *ref) - { - TRef retval(new T(ref, this), - RemoveOnDelete(this)); - - _mark_event(retval.get(), "header_read", ref->get_recv_stamp()); - _mark_event(retval.get(), "throttled", ref->get_throttle_stamp()); - _mark_event(retval.get(), "all_read", ref->get_recv_complete_stamp()); - _mark_event(retval.get(), "dispatched", ref->get_dispatch_stamp()); - - retval->init_from_message(); - - return retval; - } -}; - /** * The OpRequest takes in a Message* and takes over a single reference * to it, which it puts() when destroyed. */ struct OpRequest : public TrackedOp { friend class OpTracker; - friend class OpHistory; // rmw flags int rmw_flags; @@ -229,7 +144,6 @@ public: latest_flag_point = flag_commit_sent; } - void mark_event(const string &event); osd_reqid_t get_reqid() const { return reqid; } -- cgit v1.2.1 From a8bbb81b7b7b6420ea08bc4e99a39adc6c3c397a Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 15:49:14 -0700 Subject: OpTracker: remove the references to "osd" in config variables We may want to have daemon-specific settings in the future, but that will be a small interface change and in the mean time this keeps a clear demarcation between OSD and OpTracker infrastructure. Signed-off-by: Greg Farnum --- src/common/TrackedOp.cc | 18 +++++++++--------- src/common/config_opts.h | 10 +++++----- src/osd/OSD.cc | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index 3056db7eeb4..c9e9a061a49 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -48,14 +48,14 @@ void OpHistory::cleanup(utime_t now) { while (arrived.size() && (now - arrived.begin()->first > - (double)(tracker->cct->_conf->osd_op_history_duration))) { + (double)(tracker->cct->_conf->op_tracker_history_duration))) { duration.erase(make_pair( arrived.begin()->second->get_duration(), arrived.begin()->second)); arrived.erase(arrived.begin()); } - while (duration.size() > tracker->cct->_conf->osd_op_history_size) { + while (duration.size() > tracker->cct->_conf->op_tracker_history_size) { arrived.erase(make_pair( duration.begin()->second->get_arrived(), duration.begin()->second)); @@ -67,8 +67,8 @@ void OpHistory::dump_ops(utime_t now, Formatter *f) { cleanup(now); f->open_object_section("OpHistory"); - f->dump_int("num to keep", tracker->cct->_conf->osd_op_history_size); - f->dump_int("duration to keep", tracker->cct->_conf->osd_op_history_duration); + f->dump_int("num to keep", tracker->cct->_conf->op_tracker_history_size); + f->dump_int("duration to keep", tracker->cct->_conf->op_tracker_history_duration); { f->open_array_section("Ops"); for (set >::const_iterator i = @@ -132,7 +132,7 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) utime_t now = ceph_clock_now(cct); utime_t too_old = now; - too_old -= cct->_conf->osd_op_complaint_time; + too_old -= cct->_conf->op_tracker_complaint_time; utime_t oldest_secs = now - ops_in_flight.front()->received_time; @@ -140,11 +140,11 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) << "; oldest is " << oldest_secs << " seconds old" << dendl; - if (oldest_secs < cct->_conf->osd_op_complaint_time) + if (oldest_secs < cct->_conf->op_tracker_complaint_time) return false; xlist::iterator i = ops_in_flight.begin(); - warning_vector.reserve(cct->_conf->osd_op_log_threshold + 1); + warning_vector.reserve(cct->_conf->op_tracker_log_threshold + 1); int slow = 0; // total slow int warned = 0; // total logged @@ -153,13 +153,13 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) // exponential backoff of warning intervals if (((*i)->received_time + - (cct->_conf->osd_op_complaint_time * + (cct->_conf->op_tracker_complaint_time * (*i)->warn_interval_multiplier)) < now) { // will warn if (warning_vector.empty()) warning_vector.push_back(""); warned++; - if (warned > cct->_conf->osd_op_log_threshold) + if (warned > cct->_conf->op_tracker_log_threshold) break; utime_t age = now - (*i)->received_time; diff --git a/src/common/config_opts.h b/src/common/config_opts.h index f6283239660..521176c4672 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -471,9 +471,9 @@ OPTION(osd_pg_epoch_persisted_max_stale, OPT_U32, 200) OPTION(osd_min_pg_log_entries, OPT_U32, 3000) // number of entries to keep in the pg log when trimming it OPTION(osd_max_pg_log_entries, OPT_U32, 10000) // max entries, say when degraded, before we trim -OPTION(osd_op_complaint_time, OPT_FLOAT, 30) // how many seconds old makes an op complaint-worthy +OPTION(op_tracker_complaint_time, OPT_FLOAT, 30) // how many seconds old makes an op complaint-worthy OPTION(osd_command_max_records, OPT_INT, 256) -OPTION(osd_op_log_threshold, OPT_INT, 5) // how many op log messages to show in one go +OPTION(op_tracker_log_threshold, OPT_INT, 5) // how many op log messages to show in one go OPTION(osd_verify_sparse_read_holes, OPT_BOOL, false) // read fiemap-reported holes and verify they are zeros OPTION(osd_debug_drop_ping_probability, OPT_DOUBLE, 0) OPTION(osd_debug_drop_ping_duration, OPT_INT, 0) @@ -484,8 +484,8 @@ OPTION(osd_debug_op_order, OPT_BOOL, false) OPTION(osd_debug_verify_snaps_on_info, OPT_BOOL, false) OPTION(osd_debug_verify_stray_on_activate, OPT_BOOL, false) OPTION(osd_debug_skip_full_check_in_backfill_reservation, OPT_BOOL, false) -OPTION(osd_op_history_size, OPT_U32, 20) // Max number of completed ops to track -OPTION(osd_op_history_duration, OPT_U32, 600) // Oldest completed op to track +OPTION(op_tracker_history_size, OPT_U32, 20) // Max number of completed ops to track +OPTION(op_tracker_history_duration, OPT_U32, 600) // Oldest completed op to track OPTION(osd_target_transaction_size, OPT_INT, 30) // to adjust various transactions that batch smaller items OPTION(osd_failsafe_full_ratio, OPT_FLOAT, .97) // what % full makes an OSD "full" (failsafe) OPTION(osd_failsafe_nearfull_ratio, OPT_FLOAT, .90) // what % full makes an OSD near full (failsafe) @@ -510,7 +510,7 @@ OPTION(osd_debug_pg_log_writeout, OPT_BOOL, false) * 1..63. * * osd_recovery_op_warn_multiple scales the normal warning threshhold, - * osd_op_complaint_time, so that slow recovery ops won't cause noise + * op_tracker_complaint_time, so that slow recovery ops won't cause noise */ OPTION(osd_client_op_priority, OPT_U32, 63) OPTION(osd_recovery_op_priority, OPT_U32, 10) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d51e9dc4434..5b448a5ccb9 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2560,7 +2560,7 @@ void OSDService::check_nearfull_warning(const osd_stat_t &osd_stat) if (cur_state != new_state) { cur_state = new_state; - } else if (now - last_msg < cct->_conf->osd_op_complaint_time) { + } else if (now - last_msg < cct->_conf->op_tracker_complaint_time) { return; } last_msg = now; -- cgit v1.2.1 From 06e1bcadfe30cfd8850f6f5d30138a7998fa4130 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 16:20:29 -0700 Subject: OpTracker: move OpTracker pointer and some init code into TrackedOp Clean up some member privacy issues while we're working on them. Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 36 +++++++++++++++++++++++------------- src/osd/OpRequest.cc | 4 +--- src/osd/OpRequest.h | 1 - 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 644fc0a6182..b10485528ab 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -109,28 +109,38 @@ public: }; class TrackedOp { +public: + Message *request; /// the logical request we are tracking +private: + friend class OpHistory; + friend class OpTracker; + xlist::item xitem; protected: + OpTracker *tracker; /// the tracker we are associated with + list > events; /// list of events and their times Mutex lock; /// to protect the events list -public: - // move these to private once friended OpTracker - Message *request; - xlist::item xitem; - utime_t received_time; - // figure out how to get rid of this one? - uint8_t warn_interval_multiplier; - string current; - uint64_t seq; + utime_t received_time; /// the time the triggering Message was received + string current; /// the current state the event is in + uint64_t seq; /// a unique value set by the OpTracker - TrackedOp(Message *req) : - lock("TrackedOp::lock"), + uint8_t warn_interval_multiplier; // limits output of a given op warning + + TrackedOp(Message *req, OpTracker *_tracker) : request(req), xitem(this), - warn_interval_multiplier(1), - seq(0) {} + tracker(_tracker), + lock("TrackedOp::lock"), + seq(0), + warn_interval_multiplier(1) + { + received_time = request->get_recv_stamp(); + tracker->register_inflight_op(&xitem); + } virtual void init_from_message() {}; +public: virtual ~TrackedOp() {} utime_t get_arrived() const { diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index 81980ed2a57..345fc30f572 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -14,12 +14,10 @@ OpRequest::OpRequest(Message *req, OpTracker *tracker) : - TrackedOp(req), + TrackedOp(req, tracker), rmw_flags(0), tracker(tracker), hit_flag_points(0), latest_flag_point(0) { - received_time = request->get_recv_stamp(); - tracker->register_inflight_op(&xitem); if (req->get_priority() < tracker->cct->_conf->osd_client_op_priority) { // don't warn as quickly for low priority ops warn_interval_multiplier = tracker->cct->_conf->osd_recovery_op_warn_multiple; diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 80dd08cb98f..18bfe1a1d07 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -62,7 +62,6 @@ struct OpRequest : public TrackedOp { void dump(utime_t now, Formatter *f) const; private: - OpTracker *tracker; osd_reqid_t reqid; uint8_t hit_flag_points; uint8_t latest_flag_point; -- cgit v1.2.1 From c2934655dd9bee85806e0c418544f89eb915c88a Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 26 Mar 2013 14:21:54 -0700 Subject: osd: change how we work around an interface limitation. If this had ever actually been triggered we would have hit an assert in the OpRequest destructor that op->request is non-NULL. Signed-off-by: Greg Farnum --- src/osd/OSD.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 5b448a5ccb9..da7e138227d 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -5927,11 +5927,16 @@ void OSD::handle_pg_create(OpRequestRef op) } } - if (!require_mon_peer(op->request)) { - // we have to hack around require_mon_peer's interface limits - op->request = NULL; + /* we have to hack around require_mon_peer's interface limits, so + * grab an extra reference before going in. If the peer isn't + * a Monitor, the reference is put for us (and then cleared + * up automatically by our OpTracker infrastructure). Otherwise, + * we put the extra ref ourself. + */ + if (!require_mon_peer(op->request->get())) { return; } + op->request->put(); if (!require_same_or_newer_map(op, m->epoch)) return; -- cgit v1.2.1 From ef1d62b4122c52777b7f9e363857210a4d86b942 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 16:50:34 -0700 Subject: OpTracker: include a destructor for the TrackedOp base class. Our method of handling the OpRequest destructor is a little weird, but we're about to get rid of the request member finagling. Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 2 +- src/osd/OpRequest.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index b10485528ab..59e3c6288cc 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -141,7 +141,7 @@ protected: virtual void init_from_message() {}; public: - virtual ~TrackedOp() {} + virtual ~TrackedOp() { if (request) request->put(); } utime_t get_arrived() const { return received_time; diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 18bfe1a1d07..6d572e0f015 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -78,6 +78,7 @@ public: ~OpRequest() { assert(request); request->put(); + request = NULL; } bool been_queued_for_pg() { return hit_flag_points & flag_queued_for_pg; } -- cgit v1.2.1 From e9bcd4c6d0f0bd569edfd1e78fb522df0fe2de4a Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 17:08:43 -0700 Subject: osd: use TrackedOp::get_req() instead of direct access to the request. Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 6 ++-- src/objclass/class_api.cc | 2 +- src/osd/OSD.cc | 78 ++++++++++++++++++++++----------------------- src/osd/OpRequest.cc | 1 - src/osd/OpRequest.h | 2 -- src/osd/PG.cc | 50 ++++++++++++++--------------- src/osd/ReplicatedPG.cc | 80 +++++++++++++++++++++++------------------------ src/osd/ReplicatedPG.h | 2 +- 8 files changed, 109 insertions(+), 112 deletions(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 59e3c6288cc..08071fb9b17 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -109,13 +109,12 @@ public: }; class TrackedOp { -public: - Message *request; /// the logical request we are tracking private: friend class OpHistory; friend class OpTracker; xlist::item xitem; protected: + Message *request; /// the logical request we are tracking OpTracker *tracker; /// the tracker we are associated with list > events; /// list of events and their times @@ -127,8 +126,8 @@ protected: uint8_t warn_interval_multiplier; // limits output of a given op warning TrackedOp(Message *req, OpTracker *_tracker) : - request(req), xitem(this), + request(req), tracker(_tracker), lock("TrackedOp::lock"), seq(0), @@ -152,6 +151,7 @@ public: (events.rbegin()->first - received_time) : 0.0; } + Message *get_req() const { return request; } virtual void mark_event(const string &event); virtual const char *state_string() const = 0; diff --git a/src/objclass/class_api.cc b/src/objclass/class_api.cc index 1ac224cdfe7..bb26c752f9b 100644 --- a/src/objclass/class_api.cc +++ b/src/objclass/class_api.cc @@ -177,7 +177,7 @@ int cls_read(cls_method_context_t hctx, int ofs, int len, int cls_get_request_origin(cls_method_context_t hctx, entity_inst_t *origin) { ReplicatedPG::OpContext **pctx = static_cast(hctx); - *origin = (*pctx)->op->request->get_orig_source_inst(); + *origin = (*pctx)->op->get_req()->get_orig_source_inst(); return 0; } diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index da7e138227d..2e933b38bf0 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4598,7 +4598,7 @@ void OSD::do_waiters() void OSD::dispatch_op(OpRequestRef op) { - switch (op->request->get_type()) { + switch (op->get_req()->get_type()) { case MSG_OSD_PG_CREATE: handle_pg_create(op); @@ -5770,9 +5770,9 @@ bool OSD::require_mon_peer(Message *m) bool OSD::require_osd_peer(OpRequestRef op) { - if (!op->request->get_connection()->peer_is_osd()) { - dout(0) << "require_osd_peer received from non-osd " << op->request->get_connection()->get_peer_addr() - << " " << *op->request << dendl; + if (!op->get_req()->get_connection()->peer_is_osd()) { + dout(0) << "require_osd_peer received from non-osd " << op->get_req()->get_connection()->get_peer_addr() + << " " << *op->get_req() << dendl; return false; } return true; @@ -5784,7 +5784,7 @@ bool OSD::require_osd_peer(OpRequestRef op) */ bool OSD::require_same_or_newer_map(OpRequestRef op, epoch_t epoch) { - Message *m = op->request; + Message *m = op->get_req(); dout(15) << "require_same_or_newer_map " << epoch << " (i am " << osdmap->get_epoch() << ") " << m << dendl; assert(osd_lock.is_locked()); @@ -5907,7 +5907,7 @@ void OSD::split_pgs( */ void OSD::handle_pg_create(OpRequestRef op) { - MOSDPGCreate *m = (MOSDPGCreate*)op->request; + MOSDPGCreate *m = (MOSDPGCreate*)op->get_req(); assert(m->get_header().type == MSG_OSD_PG_CREATE); dout(10) << "handle_pg_create " << *m << dendl; @@ -5933,10 +5933,10 @@ void OSD::handle_pg_create(OpRequestRef op) * up automatically by our OpTracker infrastructure). Otherwise, * we put the extra ref ourself. */ - if (!require_mon_peer(op->request->get())) { + if (!require_mon_peer(op->get_req()->get())) { return; } - op->request->put(); + op->get_req()->put(); if (!require_same_or_newer_map(op, m->epoch)) return; @@ -6241,7 +6241,7 @@ void OSD::do_infos(map > >& info */ void OSD::handle_pg_notify(OpRequestRef op) { - MOSDPGNotify *m = (MOSDPGNotify*)op->request; + MOSDPGNotify *m = (MOSDPGNotify*)op->get_req(); assert(m->get_header().type == MSG_OSD_PG_NOTIFY); dout(7) << "handle_pg_notify from " << m->get_source() << dendl; @@ -6276,7 +6276,7 @@ void OSD::handle_pg_notify(OpRequestRef op) void OSD::handle_pg_log(OpRequestRef op) { - MOSDPGLog *m = (MOSDPGLog*) op->request; + MOSDPGLog *m = (MOSDPGLog*) op->get_req(); assert(m->get_header().type == MSG_OSD_PG_LOG); dout(7) << "handle_pg_log " << *m << " from " << m->get_source() << dendl; @@ -6304,7 +6304,7 @@ void OSD::handle_pg_log(OpRequestRef op) void OSD::handle_pg_info(OpRequestRef op) { - MOSDPGInfo *m = static_cast(op->request); + MOSDPGInfo *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_INFO); dout(7) << "handle_pg_info " << *m << " from " << m->get_source() << dendl; @@ -6337,7 +6337,7 @@ void OSD::handle_pg_info(OpRequestRef op) void OSD::handle_pg_trim(OpRequestRef op) { - MOSDPGTrim *m = (MOSDPGTrim *)op->request; + MOSDPGTrim *m = (MOSDPGTrim *)op->get_req(); assert(m->get_header().type == MSG_OSD_PG_TRIM); dout(7) << "handle_pg_trim " << *m << " from " << m->get_source() << dendl; @@ -6390,7 +6390,7 @@ void OSD::handle_pg_trim(OpRequestRef op) void OSD::handle_pg_scan(OpRequestRef op) { - MOSDPGScan *m = static_cast(op->request); + MOSDPGScan *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_SCAN); dout(10) << "handle_pg_scan " << *m << " from " << m->get_source() << dendl; @@ -6418,7 +6418,7 @@ void OSD::handle_pg_scan(OpRequestRef op) void OSD::handle_pg_backfill(OpRequestRef op) { - MOSDPGBackfill *m = static_cast(op->request); + MOSDPGBackfill *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_BACKFILL); dout(10) << "handle_pg_backfill " << *m << " from " << m->get_source() << dendl; @@ -6446,7 +6446,7 @@ void OSD::handle_pg_backfill(OpRequestRef op) void OSD::handle_pg_backfill_reserve(OpRequestRef op) { - MBackfillReserve *m = static_cast(op->request); + MBackfillReserve *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_BACKFILL_RESERVE); if (!require_osd_peer(op)) @@ -6490,7 +6490,7 @@ void OSD::handle_pg_backfill_reserve(OpRequestRef op) void OSD::handle_pg_recovery_reserve(OpRequestRef op) { - MRecoveryReserve *m = static_cast(op->request); + MRecoveryReserve *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_RECOVERY_RESERVE); if (!require_osd_peer(op)) @@ -6542,7 +6542,7 @@ void OSD::handle_pg_query(OpRequestRef op) { assert(osd_lock.is_locked()); - MOSDPGQuery *m = (MOSDPGQuery*)op->request; + MOSDPGQuery *m = (MOSDPGQuery*)op->get_req(); assert(m->get_header().type == MSG_OSD_PG_QUERY); if (!require_osd_peer(op)) @@ -6629,7 +6629,7 @@ void OSD::handle_pg_query(OpRequestRef op) void OSD::handle_pg_remove(OpRequestRef op) { - MOSDPGRemove *m = (MOSDPGRemove *)op->request; + MOSDPGRemove *m = (MOSDPGRemove *)op->get_req(); assert(m->get_header().type == MSG_OSD_PG_REMOVE); assert(osd_lock.is_locked()); @@ -6902,7 +6902,7 @@ void OSDService::reply_op_error(OpRequestRef op, int err) void OSDService::reply_op_error(OpRequestRef op, int err, eversion_t v, version_t uv) { - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); assert(m->get_header().type == CEPH_MSG_OSD_OP); int flags; flags = m->get_flags() & (CEPH_OSD_FLAG_ACK|CEPH_OSD_FLAG_ONDISK); @@ -6914,7 +6914,7 @@ void OSDService::reply_op_error(OpRequestRef op, int err, eversion_t v, void OSDService::handle_misdirected_op(PG *pg, OpRequestRef op) { - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); assert(m->get_header().type == CEPH_MSG_OSD_OP); if (m->get_map_epoch() < pg->info.history.same_primary_since) { @@ -6933,7 +6933,7 @@ void OSDService::handle_misdirected_op(PG *pg, OpRequestRef op) void OSD::handle_op(OpRequestRef op) { - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); assert(m->get_header().type == CEPH_MSG_OSD_OP); if (op_is_discardable(m)) { dout(10) << " discardable " << *m << dendl; @@ -7068,7 +7068,7 @@ void OSD::handle_op(OpRequestRef op) template void OSD::handle_replica_op(OpRequestRef op) { - T *m = static_cast(op->request); + T *m = static_cast(op->get_req()); assert(m->get_header().type == MSGTYPE); dout(10) << __func__ << *m << " epoch " << m->map_epoch << dendl; @@ -7122,24 +7122,24 @@ bool OSD::op_is_discardable(MOSDOp *op) */ void OSD::enqueue_op(PG *pg, OpRequestRef op) { - utime_t latency = ceph_clock_now(cct) - op->request->get_recv_stamp(); - dout(15) << "enqueue_op " << op << " prio " << op->request->get_priority() - << " cost " << op->request->get_cost() + utime_t latency = ceph_clock_now(cct) - op->get_req()->get_recv_stamp(); + dout(15) << "enqueue_op " << op << " prio " << op->get_req()->get_priority() + << " cost " << op->get_req()->get_cost() << " latency " << latency - << " " << *(op->request) << dendl; + << " " << *(op->get_req()) << dendl; pg->queue_op(op); } void OSD::OpWQ::_enqueue(pair item) { - unsigned priority = item.second->request->get_priority(); - unsigned cost = item.second->request->get_cost(); + unsigned priority = item.second->get_req()->get_priority(); + unsigned cost = item.second->get_req()->get_cost(); if (priority >= CEPH_MSG_PRIO_LOW) pqueue.enqueue_strict( - item.second->request->get_source_inst(), + item.second->get_req()->get_source_inst(), priority, item); else - pqueue.enqueue(item.second->request->get_source_inst(), + pqueue.enqueue(item.second->get_req()->get_source_inst(), priority, cost, item); osd->logger->set(l_osd_opq, pqueue.length()); } @@ -7154,14 +7154,14 @@ void OSD::OpWQ::_enqueue_front(pair item) pg_for_processing[&*(item.first)].pop_back(); } } - unsigned priority = item.second->request->get_priority(); - unsigned cost = item.second->request->get_cost(); + unsigned priority = item.second->get_req()->get_priority(); + unsigned cost = item.second->get_req()->get_cost(); if (priority >= CEPH_MSG_PRIO_LOW) pqueue.enqueue_strict_front( - item.second->request->get_source_inst(), + item.second->get_req()->get_source_inst(), priority, item); else - pqueue.enqueue_front(item.second->request->get_source_inst(), + pqueue.enqueue_front(item.second->get_req()->get_source_inst(), priority, cost, item); osd->logger->set(l_osd_opq, pqueue.length()); } @@ -7213,11 +7213,11 @@ void OSD::dequeue_op( PGRef pg, OpRequestRef op, ThreadPool::TPHandle &handle) { - utime_t latency = ceph_clock_now(cct) - op->request->get_recv_stamp(); - dout(10) << "dequeue_op " << op << " prio " << op->request->get_priority() - << " cost " << op->request->get_cost() + utime_t latency = ceph_clock_now(cct) - op->get_req()->get_recv_stamp(); + dout(10) << "dequeue_op " << op << " prio " << op->get_req()->get_priority() + << " cost " << op->get_req()->get_cost() << " latency " << latency - << " " << *(op->request) + << " " << *(op->get_req()) << " pg " << *pg << dendl; if (pg->deleting) return; @@ -7336,7 +7336,7 @@ void OSD::handle_conf_change(const struct md_config_t *conf, int OSD::init_op_flags(OpRequestRef op) { - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); vector::iterator iter; // client flags have no bearing on whether an op is a read, write, etc. diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index 345fc30f572..30ff999719f 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -16,7 +16,6 @@ OpRequest::OpRequest(Message *req, OpTracker *tracker) : TrackedOp(req, tracker), rmw_flags(0), - tracker(tracker), hit_flag_points(0), latest_flag_point(0) { if (req->get_priority() < tracker->cct->_conf->osd_client_op_priority) { // don't warn as quickly for low priority ops diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 6d572e0f015..9a40c1be219 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -77,8 +77,6 @@ private: public: ~OpRequest() { assert(request); - request->put(); - request = NULL; } bool been_queued_for_pg() { return hit_flag_points & flag_queued_for_pg; } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index f319d160a39..2c09ec62486 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1333,10 +1333,10 @@ void PG::do_pending_flush() bool PG::op_has_sufficient_caps(OpRequestRef op) { // only check MOSDOp - if (op->request->get_type() != CEPH_MSG_OSD_OP) + if (op->get_req()->get_type() != CEPH_MSG_OSD_OP) return true; - MOSDOp *req = static_cast(op->request); + MOSDOp *req = static_cast(op->get_req()); OSD::Session *session = (OSD::Session *)req->get_connection()->get_priv(); if (!session) { @@ -1420,7 +1420,7 @@ void PG::do_request( return; } - switch (op->request->get_type()) { + switch (op->get_req()->get_type()) { case CEPH_MSG_OSD_OP: if (is_replay() || !is_active()) { dout(20) << " replay, waiting for active on " << op << dendl; @@ -1488,7 +1488,7 @@ void PG::replay_queued_ops() c = p->first; } dout(10) << "activate replay " << p->first << " " - << *p->second->request << dendl; + << *p->second->get_req() << dendl; replay.push_back(p->second); } replay_queue.clear(); @@ -2694,7 +2694,7 @@ void PG::unreg_next_scrub() void PG::sub_op_scrub_map(OpRequestRef op) { - MOSDSubOp *m = static_cast(op->request); + MOSDSubOp *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_map" << dendl; @@ -2880,7 +2880,7 @@ void PG::_request_scrub_map(int replica, eversion_t version, void PG::sub_op_scrub_reserve(OpRequestRef op) { - MOSDSubOp *m = static_cast(op->request); + MOSDSubOp *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_reserve" << dendl; @@ -2900,7 +2900,7 @@ void PG::sub_op_scrub_reserve(OpRequestRef op) void PG::sub_op_scrub_reserve_reply(OpRequestRef op) { - MOSDSubOpReply *reply = static_cast(op->request); + MOSDSubOpReply *reply = static_cast(op->get_req()); assert(reply->get_header().type == MSG_OSD_SUBOPREPLY); dout(7) << "sub_op_scrub_reserve_reply" << dendl; @@ -2933,7 +2933,7 @@ void PG::sub_op_scrub_reserve_reply(OpRequestRef op) void PG::sub_op_scrub_unreserve(OpRequestRef op) { - assert(op->request->get_header().type == MSG_OSD_SUBOP); + assert(op->get_req()->get_header().type == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_unreserve" << dendl; op->mark_started(); @@ -2945,7 +2945,7 @@ void PG::sub_op_scrub_stop(OpRequestRef op) { op->mark_started(); - MOSDSubOp *m = static_cast(op->request); + MOSDSubOp *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_stop" << dendl; @@ -4806,7 +4806,7 @@ ostream& operator<<(ostream& out, const PG& pg) bool PG::can_discard_op(OpRequestRef op) { - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); if (OSD::op_is_discardable(m)) { dout(20) << " discard " << *m << dendl; return true; @@ -4834,7 +4834,7 @@ bool PG::can_discard_op(OpRequestRef op) template bool PG::can_discard_replica_op(OpRequestRef op) { - T *m = static_cast(op->request); + T *m = static_cast(op->get_req()); assert(m->get_header().type == MSGTYPE); // same pg? @@ -4850,7 +4850,7 @@ bool PG::can_discard_replica_op(OpRequestRef op) bool PG::can_discard_scan(OpRequestRef op) { - MOSDPGScan *m = static_cast(op->request); + MOSDPGScan *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_SCAN); if (old_peering_msg(m->map_epoch, m->query_epoch)) { @@ -4862,7 +4862,7 @@ bool PG::can_discard_scan(OpRequestRef op) bool PG::can_discard_backfill(OpRequestRef op) { - MOSDPGBackfill *m = static_cast(op->request); + MOSDPGBackfill *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_BACKFILL); if (old_peering_msg(m->map_epoch, m->query_epoch)) { @@ -4876,7 +4876,7 @@ bool PG::can_discard_backfill(OpRequestRef op) bool PG::can_discard_request(OpRequestRef op) { - switch (op->request->get_type()) { + switch (op->get_req()->get_type()) { case CEPH_MSG_OSD_OP: return can_discard_op(op); case MSG_OSD_SUBOP: @@ -4901,55 +4901,55 @@ bool PG::can_discard_request(OpRequestRef op) bool PG::split_request(OpRequestRef op, unsigned match, unsigned bits) { unsigned mask = ~((~0)<request->get_type()) { + switch (op->get_req()->get_type()) { case CEPH_MSG_OSD_OP: - return (static_cast(op->request)->get_pg().m_seed & mask) == match; + return (static_cast(op->get_req())->get_pg().m_seed & mask) == match; } return false; } bool PG::op_must_wait_for_map(OSDMapRef curmap, OpRequestRef op) { - switch (op->request->get_type()) { + switch (op->get_req()->get_type()) { case CEPH_MSG_OSD_OP: return !have_same_or_newer_map( curmap, - static_cast(op->request)->get_map_epoch()); + static_cast(op->get_req())->get_map_epoch()); case MSG_OSD_SUBOP: return !have_same_or_newer_map( curmap, - static_cast(op->request)->map_epoch); + static_cast(op->get_req())->map_epoch); case MSG_OSD_SUBOPREPLY: return !have_same_or_newer_map( curmap, - static_cast(op->request)->map_epoch); + static_cast(op->get_req())->map_epoch); case MSG_OSD_PG_SCAN: return !have_same_or_newer_map( curmap, - static_cast(op->request)->map_epoch); + static_cast(op->get_req())->map_epoch); case MSG_OSD_PG_BACKFILL: return !have_same_or_newer_map( curmap, - static_cast(op->request)->map_epoch); + static_cast(op->get_req())->map_epoch); case MSG_OSD_PG_PUSH: return !have_same_or_newer_map( curmap, - static_cast(op->request)->map_epoch); + static_cast(op->get_req())->map_epoch); case MSG_OSD_PG_PULL: return !have_same_or_newer_map( curmap, - static_cast(op->request)->map_epoch); + static_cast(op->get_req())->map_epoch); case MSG_OSD_PG_PUSH_REPLY: return !have_same_or_newer_map( curmap, - static_cast(op->request)->map_epoch); + static_cast(op->get_req())->map_epoch); } assert(0); return false; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index a92403ae370..401ad9014ff 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -427,7 +427,7 @@ bool ReplicatedPG::pg_op_must_wait(MOSDOp *op) void ReplicatedPG::do_pg_op(OpRequestRef op) { - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); assert(m->get_header().type == CEPH_MSG_OSD_OP); dout(10) << "do_pg_op " << *m << dendl; @@ -650,7 +650,7 @@ void ReplicatedPG::get_src_oloc(const object_t& oid, const object_locator_t& olo */ void ReplicatedPG::do_op(OpRequestRef op) { - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); assert(m->get_header().type == CEPH_MSG_OSD_OP); if (op->includes_pg_op()) { if (pg_op_must_wait(m)) { @@ -943,7 +943,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, ObjectContextRef obc, void ReplicatedPG::do_cache_redirect(OpRequestRef op, ObjectContextRef obc) { - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); int flags = m->get_flags() & (CEPH_OSD_FLAG_ACK|CEPH_OSD_FLAG_ONDISK); MOSDOpReply *reply = new MOSDOpReply(m, -ENOENT, get_osdmap()->get_epoch(), flags); @@ -959,7 +959,7 @@ void ReplicatedPG::execute_ctx(OpContext *ctx) { dout(10) << __func__ << " " << ctx << dendl; OpRequestRef op = ctx->op; - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); ObjectContextRef obc = ctx->obc; const hobject_t& soid = obc->obs.oi.soid; map& src_obc = ctx->src_obc; @@ -1183,16 +1183,16 @@ void ReplicatedPG::reply_ctx(OpContext *ctx, int r, eversion_t v, version_t uv) void ReplicatedPG::log_op_stats(OpContext *ctx) { OpRequestRef op = ctx->op; - MOSDOp *m = static_cast(op->request); + MOSDOp *m = static_cast(op->get_req()); utime_t now = ceph_clock_now(cct); utime_t latency = now; - latency -= ctx->op->request->get_recv_stamp(); + latency -= ctx->op->get_req()->get_recv_stamp(); utime_t rlatency; if (ctx->readable_stamp != utime_t()) { rlatency = ctx->readable_stamp; - rlatency -= ctx->op->request->get_recv_stamp(); + rlatency -= ctx->op->get_req()->get_recv_stamp(); } uint64_t inb = ctx->bytes_written; @@ -1233,9 +1233,9 @@ void ReplicatedPG::log_subop_stats(OpRequestRef op, int tag_inb, int tag_lat) { utime_t now = ceph_clock_now(cct); utime_t latency = now; - latency -= op->request->get_recv_stamp(); + latency -= op->get_req()->get_recv_stamp(); - uint64_t inb = op->request->get_data().length(); + uint64_t inb = op->get_req()->get_data().length(); osd->logger->inc(l_osd_sop); @@ -1251,10 +1251,10 @@ void ReplicatedPG::log_subop_stats(OpRequestRef op, int tag_inb, int tag_lat) void ReplicatedPG::do_sub_op(OpRequestRef op) { - MOSDSubOp *m = static_cast(op->request); + MOSDSubOp *m = static_cast(op->get_req()); assert(have_same_or_newer_map(m->map_epoch)); assert(m->get_header().type == MSG_OSD_SUBOP); - dout(15) << "do_sub_op " << *op->request << dendl; + dout(15) << "do_sub_op " << *op->get_req() << dendl; OSDOp *first = NULL; if (m->ops.size() >= 1) { @@ -1300,7 +1300,7 @@ void ReplicatedPG::do_sub_op(OpRequestRef op) void ReplicatedPG::do_sub_op_reply(OpRequestRef op) { - MOSDSubOpReply *r = static_cast(op->request); + MOSDSubOpReply *r = static_cast(op->get_req()); assert(r->get_header().type == MSG_OSD_SUBOPREPLY); if (r->ops.size() >= 1) { OSDOp& first = r->ops[0]; @@ -1323,7 +1323,7 @@ void ReplicatedPG::do_scan( OpRequestRef op, ThreadPool::TPHandle &handle) { - MOSDPGScan *m = static_cast(op->request); + MOSDPGScan *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_SCAN); dout(10) << "do_scan " << *m << dendl; @@ -1397,7 +1397,7 @@ void ReplicatedPG::do_scan( void ReplicatedPG::_do_push(OpRequestRef op) { - MOSDPGPush *m = static_cast(op->request); + MOSDPGPush *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_PUSH); int from = m->get_source().num(); @@ -1425,7 +1425,7 @@ void ReplicatedPG::_do_push(OpRequestRef op) void ReplicatedPG::_do_pull_response(OpRequestRef op) { - MOSDPGPush *m = static_cast(op->request); + MOSDPGPush *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_PUSH); int from = m->get_source().num(); @@ -1457,7 +1457,7 @@ void ReplicatedPG::_do_pull_response(OpRequestRef op) void ReplicatedPG::do_pull(OpRequestRef op) { - MOSDPGPull *m = static_cast(op->request); + MOSDPGPull *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_PULL); int from = m->get_source().num(); @@ -1473,7 +1473,7 @@ void ReplicatedPG::do_pull(OpRequestRef op) void ReplicatedPG::do_push_reply(OpRequestRef op) { - MOSDPGPushReply *m = static_cast(op->request); + MOSDPGPushReply *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_PUSH_REPLY); int from = m->get_source().num(); @@ -1494,7 +1494,7 @@ void ReplicatedPG::do_push_reply(OpRequestRef op) void ReplicatedPG::do_backfill(OpRequestRef op) { - MOSDPGBackfill *m = static_cast(op->request); + MOSDPGBackfill *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_PG_BACKFILL); dout(10) << "do_backfill " << *m << dendl; @@ -2158,7 +2158,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) ObjectContextRef src_obc; if (ceph_osd_op_type_multi(op.op)) { - MOSDOp *m = static_cast(ctx->op->request); + MOSDOp *m = static_cast(ctx->op->get_req()); object_locator_t src_oloc; get_src_oloc(soid.oid, m->get_object_locator(), src_oloc); hobject_t src_oid(osd_op.soid, src_oloc.key, soid.hash, @@ -2925,10 +2925,10 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) << " oi.version=" << oi.version.version << " ctx->at_version=" << ctx->at_version << dendl; dout(10) << "watch: oi.user_version=" << oi.user_version<< dendl; dout(10) << "watch: peer_addr=" - << ctx->op->request->get_connection()->get_peer_addr() << dendl; + << ctx->op->get_req()->get_connection()->get_peer_addr() << dendl; watch_info_t w(cookie, cct->_conf->osd_client_watch_timeout, - ctx->op->request->get_connection()->get_peer_addr()); + ctx->op->get_req()->get_connection()->get_peer_addr()); if (do_watch) { if (oi.watchers.count(make_pair(cookie, entity))) { dout(10) << " found existing watch " << w << " by " << entity << dendl; @@ -3870,7 +3870,7 @@ void ReplicatedPG::add_interval_usage(interval_set& s, object_stat_sum void ReplicatedPG::do_osd_op_effects(OpContext *ctx) { - ConnectionRef conn(ctx->op->request->get_connection()); + ConnectionRef conn(ctx->op->get_req()->get_connection()); boost::intrusive_ptr session( (OSD::Session *)conn->get_priv()); session->put(); // get_priv() takes a ref, and so does the intrusive_ptr @@ -4528,7 +4528,7 @@ void ReplicatedPG::eval_repop(RepGather *repop) { MOSDOp *m = NULL; if (repop->ctx->op) - m = static_cast(repop->ctx->op->request); + m = static_cast(repop->ctx->op->get_req()); if (m) dout(10) << "eval_repop " << *repop @@ -4604,7 +4604,7 @@ void ReplicatedPG::eval_repop(RepGather *repop) for (list::iterator i = waiting_for_ack[repop->v].begin(); i != waiting_for_ack[repop->v].end(); ++i) { - MOSDOp *m = (MOSDOp*)(*i)->request; + MOSDOp *m = (MOSDOp*)(*i)->get_req(); MOSDOpReply *reply = new MOSDOpReply(m, 0, get_osdmap()->get_epoch(), 0); reply->set_reply_versions(repop->ctx->at_version, repop->ctx->user_at_version); @@ -4700,7 +4700,7 @@ void ReplicatedPG::issue_repop(RepGather *repop, utime_t now) get_osdmap()->get_epoch(), repop->rep_tid, repop->ctx->at_version); if (ctx->op && - ((static_cast(ctx->op->request))->get_flags() & CEPH_OSD_FLAG_PARALLELEXEC)) { + ((static_cast(ctx->op->get_req()))->get_flags() & CEPH_OSD_FLAG_PARALLELEXEC)) { // replicate original op for parallel execution on replica assert(0 == "broken implementation, do not use"); } @@ -4741,7 +4741,7 @@ ReplicatedPG::RepGather *ReplicatedPG::new_repop(OpContext *ctx, ObjectContextRe tid_t rep_tid) { if (ctx->op) - dout(10) << "new_repop rep_tid " << rep_tid << " on " << *ctx->op->request << dendl; + dout(10) << "new_repop rep_tid " << rep_tid << " on " << *ctx->op->get_req() << dendl; else dout(10) << "new_repop rep_tid " << rep_tid << " (no op)" << dendl; @@ -4772,7 +4772,7 @@ void ReplicatedPG::repop_ack(RepGather *repop, int result, int ack_type, MOSDOp *m = NULL; if (repop->ctx->op) - m = static_cast(repop->ctx->op->request); + m = static_cast(repop->ctx->op->get_req()); if (m) dout(7) << "repop_ack rep_tid " << repop->rep_tid << " op " << *m @@ -5294,7 +5294,7 @@ void ReplicatedPG::put_snapset_context(SnapSetContext *ssc) void ReplicatedPG::sub_op_modify(OpRequestRef op) { - MOSDSubOp *m = static_cast(op->request); + MOSDSubOp *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_SUBOP); const hobject_t& soid = m->poid; @@ -5413,8 +5413,8 @@ void ReplicatedPG::sub_op_modify_applied(RepModify *rm) rm->applied = true; if (!pg_has_reset_since(rm->epoch_started)) { - dout(10) << "sub_op_modify_applied on " << rm << " op " << *rm->op->request << dendl; - MOSDSubOp *m = static_cast(rm->op->request); + dout(10) << "sub_op_modify_applied on " << rm << " op " << *rm->op->get_req() << dendl; + MOSDSubOp *m = static_cast(rm->op->get_req()); assert(m->get_header().type == MSG_OSD_SUBOP); if (!rm->committed) { @@ -5436,7 +5436,7 @@ void ReplicatedPG::sub_op_modify_applied(RepModify *rm) } } } else { - dout(10) << "sub_op_modify_applied on " << rm << " op " << *rm->op->request + dout(10) << "sub_op_modify_applied on " << rm << " op " << *rm->op->get_req() << " from epoch " << rm->epoch_started << " < last_peering_reset " << last_peering_reset << dendl; } @@ -5458,19 +5458,19 @@ void ReplicatedPG::sub_op_modify_commit(RepModify *rm) if (!pg_has_reset_since(rm->epoch_started)) { // send commit. - dout(10) << "sub_op_modify_commit on op " << *rm->op->request + dout(10) << "sub_op_modify_commit on op " << *rm->op->get_req() << ", sending commit to osd." << rm->ackerosd << dendl; if (get_osdmap()->is_up(rm->ackerosd)) { last_complete_ondisk = rm->last_complete; - MOSDSubOpReply *commit = new MOSDSubOpReply(static_cast(rm->op->request), 0, get_osdmap()->get_epoch(), CEPH_OSD_FLAG_ONDISK); + MOSDSubOpReply *commit = new MOSDSubOpReply(static_cast(rm->op->get_req()), 0, get_osdmap()->get_epoch(), CEPH_OSD_FLAG_ONDISK); commit->set_last_complete_ondisk(rm->last_complete); commit->set_priority(CEPH_MSG_PRIO_HIGH); // this better match ack priority! osd->send_message_osd_cluster(rm->ackerosd, commit, get_osdmap()->get_epoch()); } } else { - dout(10) << "sub_op_modify_commit " << rm << " op " << *rm->op->request + dout(10) << "sub_op_modify_commit " << rm << " op " << *rm->op->get_req() << " from epoch " << rm->epoch_started << " < last_peering_reset " << last_peering_reset << dendl; } @@ -5487,7 +5487,7 @@ void ReplicatedPG::sub_op_modify_commit(RepModify *rm) void ReplicatedPG::sub_op_modify_reply(OpRequestRef op) { - MOSDSubOpReply *r = static_cast(op->request); + MOSDSubOpReply *r = static_cast(op->get_req()); assert(r->get_header().type == MSG_OSD_SUBOPREPLY); op->mark_started(); @@ -6486,7 +6486,7 @@ void ReplicatedPG::prep_push_op_blank(const hobject_t& soid, PushOp *op) void ReplicatedPG::sub_op_push_reply(OpRequestRef op) { - MOSDSubOpReply *reply = static_cast(op->request); + MOSDSubOpReply *reply = static_cast(op->get_req()); const hobject_t& soid = reply->get_poid(); assert(reply->get_header().type == MSG_OSD_SUBOPREPLY); dout(10) << "sub_op_push_reply from " << reply->get_source() << " " << *reply << dendl; @@ -6587,7 +6587,7 @@ void ReplicatedPG::finish_degraded_object(const hobject_t& oid) */ void ReplicatedPG::sub_op_pull(OpRequestRef op) { - MOSDSubOp *m = static_cast(op->request); + MOSDSubOp *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_SUBOP); op->mark_started(); @@ -6779,7 +6779,7 @@ void ReplicatedPG::trim_pushed_data( void ReplicatedPG::sub_op_push(OpRequestRef op) { op->mark_started(); - MOSDSubOp *m = static_cast(op->request); + MOSDSubOp *m = static_cast(op->get_req()); PushOp pop; pop.soid = m->recovery_info.soid; @@ -6841,7 +6841,7 @@ void ReplicatedPG::_failed_push(int from, const hobject_t &soid) void ReplicatedPG::sub_op_remove(OpRequestRef op) { - MOSDSubOp *m = static_cast(op->request); + MOSDSubOp *m = static_cast(op->get_req()); assert(m->get_header().type == MSG_OSD_SUBOP); dout(7) << "sub_op_remove " << m->poid << dendl; @@ -7064,7 +7064,7 @@ void ReplicatedPG::apply_and_flush_repops(bool requeue) if (requeue) { if (repop->ctx->op) { - dout(10) << " requeuing " << *repop->ctx->op->request << dendl; + dout(10) << " requeuing " << *repop->ctx->op->get_req() << dendl; rq.push_back(repop->ctx->op); repop->ctx->op = OpRequestRef(); } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index e880bdecade..5b36c28a51b 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -968,7 +968,7 @@ inline ostream& operator<<(ostream& out, ReplicatedPG::RepGather& repop) //<< " wfnvram=" << repop.waitfor_nvram << " wfdisk=" << repop.waitfor_disk; if (repop.ctx->op) - out << " op=" << *(repop.ctx->op->request); + out << " op=" << *(repop.ctx->op->get_req()); out << ")"; return out; } -- cgit v1.2.1 From f7f3005555a531095f70834372d1486e391c4681 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 26 Mar 2013 15:01:17 -0700 Subject: OpTracker: provide a default implementation of TrackedOp::state_string We're moving towards dynamically-allocated states instead of the static ones this started with, so the whole bitmask-based thing doesn't make much sense any more. Assume people won't use that and provide a default. Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 08071fb9b17..5d2abf591c4 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -154,7 +154,9 @@ public: Message *get_req() const { return request; } virtual void mark_event(const string &event); - virtual const char *state_string() const = 0; + virtual const char *state_string() const { + return events.rbegin()->second.c_str(); + } virtual void dump(utime_t now, Formatter *f) const = 0; }; -- cgit v1.2.1 From a2d633bb209f0ba85d581783fec9bd10fb280e4f Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 17:11:04 -0700 Subject: OpTracker: demand that a TrackedOp gets to own its Message for life. Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 2 +- src/osd/OpRequest.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 5d2abf591c4..94eb4e3f71e 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -140,7 +140,7 @@ protected: virtual void init_from_message() {}; public: - virtual ~TrackedOp() { if (request) request->put(); } + virtual ~TrackedOp() { assert(request); request->put(); } utime_t get_arrived() const { return received_time; diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 9a40c1be219..88c4e7d4bc2 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -75,10 +75,6 @@ private: OpRequest(Message *req, OpTracker *tracker); public: - ~OpRequest() { - assert(request); - } - bool been_queued_for_pg() { return hit_flag_points & flag_queued_for_pg; } bool been_reached_pg() { return hit_flag_points & flag_reached_pg; } bool been_delayed() { return hit_flag_points & flag_delayed; } -- cgit v1.2.1 From 9e0b5eae57d8bfb3b59e1673dc631a113993f0a2 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 19 Sep 2013 17:12:57 -0700 Subject: OpTracker: get rid of TrackedOp::received_time for the Message Signed-off-by: Greg Farnum --- src/common/TrackedOp.cc | 12 ++++++------ src/common/TrackedOp.h | 6 ++---- src/osd/OpRequest.cc | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index c9e9a061a49..4ed9f20d1fc 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -134,7 +134,7 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) utime_t too_old = now; too_old -= cct->_conf->op_tracker_complaint_time; - utime_t oldest_secs = now - ops_in_flight.front()->received_time; + utime_t oldest_secs = now - ops_in_flight.front()->get_arrived(); dout(10) << "ops_in_flight.size: " << ops_in_flight.size() << "; oldest is " << oldest_secs @@ -148,11 +148,11 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) int slow = 0; // total slow int warned = 0; // total logged - while (!i.end() && (*i)->received_time < too_old) { + while (!i.end() && (*i)->get_arrived() < too_old) { slow++; // exponential backoff of warning intervals - if (((*i)->received_time + + if (((*i)->get_arrived() + (cct->_conf->op_tracker_complaint_time * (*i)->warn_interval_multiplier)) < now) { // will warn @@ -162,9 +162,9 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) if (warned > cct->_conf->op_tracker_log_threshold) break; - utime_t age = now - (*i)->received_time; + utime_t age = now - (*i)->get_arrived(); stringstream ss; - ss << "slow request " << age << " seconds old, received at " << (*i)->received_time + ss << "slow request " << age << " seconds old, received at " << (*i)->get_arrived() << ": " << *((*i)->request) << " currently " << ((*i)->current.size() ? (*i)->current : (*i)->state_string()); warning_vector.push_back(ss.str()); @@ -198,7 +198,7 @@ void OpTracker::get_age_ms_histogram(pow2_hist_t *h) uint32_t lb = 1 << (bin-1); // lower bound for this bin int count = 0; for (xlist::iterator i = ops_in_flight.begin(); !i.end(); ++i) { - utime_t age = now - (*i)->received_time; + utime_t age = now - (*i)->get_arrived(); uint32_t ms = (long)(age * 1000.0); if (ms >= lb) { count++; diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 94eb4e3f71e..9007a4d5bd2 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -119,7 +119,6 @@ protected: list > events; /// list of events and their times Mutex lock; /// to protect the events list - utime_t received_time; /// the time the triggering Message was received string current; /// the current state the event is in uint64_t seq; /// a unique value set by the OpTracker @@ -133,7 +132,6 @@ protected: seq(0), warn_interval_multiplier(1) { - received_time = request->get_recv_stamp(); tracker->register_inflight_op(&xitem); } @@ -143,12 +141,12 @@ public: virtual ~TrackedOp() { assert(request); request->put(); } utime_t get_arrived() const { - return received_time; + return request->get_recv_stamp(); } // This function maybe needs some work; assumes last event is completion time double get_duration() const { return events.size() ? - (events.rbegin()->first - received_time) : + (events.rbegin()->first - get_arrived()) : 0.0; } Message *get_req() const { return request; } diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index 30ff999719f..1c523585a8e 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -30,8 +30,8 @@ void OpRequest::dump(utime_t now, Formatter *f) const m->print(name); f->dump_string("description", name.str().c_str()); // this OpRequest f->dump_unsigned("rmw_flags", rmw_flags); - f->dump_stream("received_at") << received_time; - f->dump_float("age", now - received_time); + f->dump_stream("received_at") << get_arrived(); + f->dump_float("age", now - get_arrived()); f->dump_float("duration", get_duration()); f->dump_string("flag_point", state_string()); if (m->get_orig_source().is_client()) { -- cgit v1.2.1 From 7973d44c1ad0eb3c1af2a14834bf173a42b1a397 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 2 Oct 2013 15:10:36 -0700 Subject: OpTracker: give TrackedOp a default dump() function Signed-off-by: Greg Farnum --- src/common/TrackedOp.cc | 32 ++++++++++++++++++++++++++++++++ src/common/TrackedOp.h | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index 4ed9f20d1fc..f2413d6fc7a 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -247,3 +247,35 @@ void TrackedOp::mark_event(const string &event) } tracker->mark_event(this, event); } + +void TrackedOp::dump(utime_t now, Formatter *f) const +{ + Message *m = request; + stringstream name; + m->print(name); + f->dump_string("description", name.str().c_str()); // this TrackedOp + f->dump_stream("received_at") << get_arrived(); + f->dump_float("age", now - get_arrived()); + f->dump_float("duration", get_duration()); + f->dump_string("current_state", state_string()); + if (m->get_orig_source().is_client()) { + f->open_object_section("client_info"); + stringstream client_name; + client_name << m->get_orig_source(); + f->dump_string("client", client_name.str()); + f->dump_int("tid", m->get_tid()); + f->close_section(); // client_info + } + { + f->open_array_section("events"); + for (list >::const_iterator i = events.begin(); + i != events.end(); + ++i) { + f->open_object_section("event"); + f->dump_stream("time") << i->first; + f->dump_string("event", i->second); + f->close_section(); + } + f->close_section(); + } +} diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 9007a4d5bd2..3344301c7c8 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -155,7 +155,7 @@ public: virtual const char *state_string() const { return events.rbegin()->second.c_str(); } - virtual void dump(utime_t now, Formatter *f) const = 0; + virtual void dump(utime_t now, Formatter *f) const; }; #endif -- cgit v1.2.1 From 2723a09aba868b9357a042438bc26bc4fd6ef94f Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 2 Oct 2013 15:35:53 -0700 Subject: TrackedOp: template OpTracker on only T[::Ref] (ie, OpRequest[::Ref]) Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 14 +++++++------- src/osd/OSD.cc | 2 +- src/osd/OpRequest.h | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 3344301c7c8..c098c4b0170 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -91,19 +91,19 @@ public: assert(ops_in_flight.empty()); } - template - TRef create_request(Message *ref) + template + typename T::Ref create_request(Message *ref) { - TRef retval(new T(ref, this), - RemoveOnDelete(this)); - + typename T::Ref retval(new T(ref, this), + RemoveOnDelete(this)); + _mark_event(retval.get(), "header_read", ref->get_recv_stamp()); _mark_event(retval.get(), "throttled", ref->get_throttle_stamp()); _mark_event(retval.get(), "all_read", ref->get_recv_complete_stamp()); _mark_event(retval.get(), "dispatched", ref->get_dispatch_stamp()); - + retval->init_from_message(); - + return retval; } }; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 2e933b38bf0..8150d9b3cd9 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4724,7 +4724,7 @@ void OSD::_dispatch(Message *m) default: { - OpRequestRef op = op_tracker.create_request(m); + OpRequestRef op = op_tracker.create_request(m); op->mark_event("waiting_for_osdmap"); // no map? starting up? if (!osdmap) { diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 88c4e7d4bc2..6131aae0d2d 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -143,9 +143,10 @@ public: } void init_from_message(); -}; -typedef std::tr1::shared_ptr OpRequestRef; + typedef std::tr1::shared_ptr Ref; +}; +typedef OpRequest::Ref OpRequestRef; #endif /* OPREQUEST_H_ */ -- cgit v1.2.1 From a8761a5aa5003ab72655e393f7d418f1f95eec1d Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 2 Oct 2013 15:36:38 -0700 Subject: TrackedOp: just make CephContext member public This is the only reason we were making OpRequest a friend class, which is just a bad idea. Signed-off-by: Greg Farnum --- src/common/TrackedOp.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index c098c4b0170..88c3cb632a0 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -52,17 +52,14 @@ class OpTracker { void operator()(TrackedOp *op); }; friend class RemoveOnDelete; - friend class OpRequest; friend class OpHistory; uint64_t seq; Mutex ops_in_flight_lock; xlist ops_in_flight; OpHistory history; -protected: - CephContext *cct; - public: + CephContext *cct; OpTracker(CephContext *cct_) : seq(0), ops_in_flight_lock("OpTracker mutex"), history(this), cct(cct_) {} void dump_ops_in_flight(Formatter *f); void dump_historic_ops(Formatter *f); -- cgit v1.2.1 From 41a13450527c22be6d0d2832129412ac86145db7 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 2 Oct 2013 16:03:10 -0700 Subject: TrackedOp: rework dump interface a little Put only the bare essentials in the TrackedOp::dump() implementation, but have that call into a _dump() function that implementations can specify. Signed-off-by: Greg Farnum --- src/common/TrackedOp.cc | 20 ++------------------ src/common/TrackedOp.h | 4 +++- src/osd/OpRequest.cc | 9 +-------- src/osd/OpRequest.h | 2 +- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index f2413d6fc7a..2c19c9ec0f3 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -257,25 +257,9 @@ void TrackedOp::dump(utime_t now, Formatter *f) const f->dump_stream("received_at") << get_arrived(); f->dump_float("age", now - get_arrived()); f->dump_float("duration", get_duration()); - f->dump_string("current_state", state_string()); - if (m->get_orig_source().is_client()) { - f->open_object_section("client_info"); - stringstream client_name; - client_name << m->get_orig_source(); - f->dump_string("client", client_name.str()); - f->dump_int("tid", m->get_tid()); - f->close_section(); // client_info - } { - f->open_array_section("events"); - for (list >::const_iterator i = events.begin(); - i != events.end(); - ++i) { - f->open_object_section("event"); - f->dump_stream("time") << i->first; - f->dump_string("event", i->second); - f->close_section(); - } + f->open_array_section("type_data"); + _dump(now, f); f->close_section(); } } diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 88c3cb632a0..1734fddda0c 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -133,6 +133,8 @@ protected: } virtual void init_from_message() {}; + /// output any type-specific data you want to get when dump() is called + virtual void _dump(utime_t now, Formatter *f) const {} public: virtual ~TrackedOp() { assert(request); request->put(); } @@ -152,7 +154,7 @@ public: virtual const char *state_string() const { return events.rbegin()->second.c_str(); } - virtual void dump(utime_t now, Formatter *f) const; + void dump(utime_t now, Formatter *f) const; }; #endif diff --git a/src/osd/OpRequest.cc b/src/osd/OpRequest.cc index 1c523585a8e..2ed7a23086f 100644 --- a/src/osd/OpRequest.cc +++ b/src/osd/OpRequest.cc @@ -23,16 +23,9 @@ OpRequest::OpRequest(Message *req, OpTracker *tracker) : } } -void OpRequest::dump(utime_t now, Formatter *f) const +void OpRequest::_dump(utime_t now, Formatter *f) const { Message *m = request; - stringstream name; - m->print(name); - f->dump_string("description", name.str().c_str()); // this OpRequest - f->dump_unsigned("rmw_flags", rmw_flags); - f->dump_stream("received_at") << get_arrived(); - f->dump_float("age", now - get_arrived()); - f->dump_float("duration", get_duration()); f->dump_string("flag_point", state_string()); if (m->get_orig_source().is_client()) { f->open_object_section("client_info"); diff --git a/src/osd/OpRequest.h b/src/osd/OpRequest.h index 6131aae0d2d..87571f58787 100644 --- a/src/osd/OpRequest.h +++ b/src/osd/OpRequest.h @@ -59,7 +59,7 @@ struct OpRequest : public TrackedOp { void set_class_write() { rmw_flags |= CEPH_OSD_RMW_FLAG_CLASS_WRITE; } void set_pg_op() { rmw_flags |= CEPH_OSD_RMW_FLAG_PGOP; } - void dump(utime_t now, Formatter *f) const; + void _dump(utime_t now, Formatter *f) const; private: osd_reqid_t reqid; -- cgit v1.2.1 From ea831e05bb1392c2b8a2b1c73cd6281fce88badb Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 2 Oct 2013 16:27:19 -0700 Subject: TrackedOp: give people an _event_marked() notifier instead of a virtual mark_event() This is less prone to getting broken. Signed-off-by: Greg Farnum --- src/common/TrackedOp.cc | 1 + src/common/TrackedOp.h | 6 ++++-- src/os/Makefile.am | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index 2c19c9ec0f3..82594a6491e 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -246,6 +246,7 @@ void TrackedOp::mark_event(const string &event) events.push_back(make_pair(now, event)); } tracker->mark_event(this, event); + _event_marked(); } void TrackedOp::dump(utime_t now, Formatter *f) const diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 1734fddda0c..2fe9eeb230c 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -132,9 +132,11 @@ protected: tracker->register_inflight_op(&xitem); } - virtual void init_from_message() {}; + virtual void init_from_message() {} /// output any type-specific data you want to get when dump() is called virtual void _dump(utime_t now, Formatter *f) const {} + /// if you want something else to happen when events are marked, implement + virtual void _event_marked() {} public: virtual ~TrackedOp() { assert(request); request->put(); } @@ -150,7 +152,7 @@ public: } Message *get_req() const { return request; } - virtual void mark_event(const string &event); + void mark_event(const string &event); virtual const char *state_string() const { return events.rbegin()->second.c_str(); } diff --git a/src/os/Makefile.am b/src/os/Makefile.am index b7fef8dd209..4f12a6a3278 100644 --- a/src/os/Makefile.am +++ b/src/os/Makefile.am @@ -13,7 +13,8 @@ libos_la_SOURCES = \ os/WBThrottle.cc \ os/BtrfsFileStoreBackend.cc \ os/GenericFileStoreBackend.cc \ - os/ZFSFileStoreBackend.cc + os/ZFSFileStoreBackend.cc \ + common/TrackedOp.cc noinst_LTLIBRARIES += libos.la noinst_HEADERS += \ -- cgit v1.2.1 From d6a1799f410cad09dc27b9102911b5682ef4f346 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 2 Oct 2013 17:12:06 -0700 Subject: TrackedOp: specify queue sizes and warnings on a per-tracker basis If we have multiple trackers in a daemon, we want to be able to configure them separately. Plus, users already know how to control op sizes in the OSD, so changing the config options (as we did in a8bbb81b7b7b6420ea08bc4e99a39adc6c3c397a) is not really appropriate. Instead, provider setters which can be called at construction time (or on any other change) and use them in the OSD with the configurables we had previously. Add an observer so you can continue to change them at run-time This reverts a8bbb81b7b7b6420ea08bc4e99a39adc6c3c397a Signed-off-by: Greg Farnum --- src/common/TrackedOp.cc | 19 +++++++++---------- src/common/TrackedOp.h | 21 +++++++++++++++++++-- src/common/config_opts.h | 10 +++++----- src/osd/OSD.cc | 18 +++++++++++++++++- 4 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index 82594a6491e..d1dbc1e7135 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -48,14 +48,14 @@ void OpHistory::cleanup(utime_t now) { while (arrived.size() && (now - arrived.begin()->first > - (double)(tracker->cct->_conf->op_tracker_history_duration))) { + (double)(history_duration))) { duration.erase(make_pair( arrived.begin()->second->get_duration(), arrived.begin()->second)); arrived.erase(arrived.begin()); } - while (duration.size() > tracker->cct->_conf->op_tracker_history_size) { + while (duration.size() > history_size) { arrived.erase(make_pair( duration.begin()->second->get_arrived(), duration.begin()->second)); @@ -67,8 +67,8 @@ void OpHistory::dump_ops(utime_t now, Formatter *f) { cleanup(now); f->open_object_section("OpHistory"); - f->dump_int("num to keep", tracker->cct->_conf->op_tracker_history_size); - f->dump_int("duration to keep", tracker->cct->_conf->op_tracker_history_duration); + f->dump_int("num to keep", history_size); + f->dump_int("duration to keep", history_duration); { f->open_array_section("Ops"); for (set >::const_iterator i = @@ -132,7 +132,7 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) utime_t now = ceph_clock_now(cct); utime_t too_old = now; - too_old -= cct->_conf->op_tracker_complaint_time; + too_old -= complaint_time; utime_t oldest_secs = now - ops_in_flight.front()->get_arrived(); @@ -140,11 +140,11 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) << "; oldest is " << oldest_secs << " seconds old" << dendl; - if (oldest_secs < cct->_conf->op_tracker_complaint_time) + if (oldest_secs < complaint_time) return false; xlist::iterator i = ops_in_flight.begin(); - warning_vector.reserve(cct->_conf->op_tracker_log_threshold + 1); + warning_vector.reserve(log_threshold + 1); int slow = 0; // total slow int warned = 0; // total logged @@ -153,13 +153,12 @@ bool OpTracker::check_ops_in_flight(std::vector &warning_vector) // exponential backoff of warning intervals if (((*i)->get_arrived() + - (cct->_conf->op_tracker_complaint_time * - (*i)->warn_interval_multiplier)) < now) { + (complaint_time * (*i)->warn_interval_multiplier)) < now) { // will warn if (warning_vector.empty()) warning_vector.push_back(""); warned++; - if (warned > cct->_conf->op_tracker_log_threshold) + if (warned > log_threshold) break; utime_t age = now - (*i)->get_arrived(); diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 2fe9eeb230c..9e00c14b178 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -32,9 +32,12 @@ class OpHistory { void cleanup(utime_t now); bool shutdown; OpTracker *tracker; + uint32_t history_size; + uint32_t history_duration; public: - OpHistory(OpTracker *tracker_) : shutdown(false), tracker(tracker_) {} + OpHistory(OpTracker *tracker_) : shutdown(false), tracker(tracker_), + history_size(0), history_duration(0) {} ~OpHistory() { assert(arrived.empty()); assert(duration.empty()); @@ -42,6 +45,10 @@ public: void insert(utime_t now, TrackedOpRef op); void dump_ops(utime_t now, Formatter *f); void on_shutdown(); + void set_size_and_duration(uint32_t new_size, uint32_t new_duration) { + history_size = new_size; + history_duration = new_duration; + } }; class OpTracker { @@ -57,10 +64,20 @@ class OpTracker { Mutex ops_in_flight_lock; xlist ops_in_flight; OpHistory history; + float complaint_time; + int log_threshold; public: CephContext *cct; - OpTracker(CephContext *cct_) : seq(0), ops_in_flight_lock("OpTracker mutex"), history(this), cct(cct_) {} + OpTracker(CephContext *cct_) : seq(0), ops_in_flight_lock("OpTracker mutex"), + history(this), complaint_time(0), log_threshold(0), cct(cct_) {} + void set_complaint_and_threshold(float time, int threshold) { + complaint_time = time; + log_threshold = threshold; + } + void set_history_size_and_duration(uint32_t new_size, uint32_t new_duration) { + history.set_size_and_duration(new_size, new_duration); + } void dump_ops_in_flight(Formatter *f); void dump_historic_ops(Formatter *f); void register_inflight_op(xlist::item *i); diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 521176c4672..f6283239660 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -471,9 +471,9 @@ OPTION(osd_pg_epoch_persisted_max_stale, OPT_U32, 200) OPTION(osd_min_pg_log_entries, OPT_U32, 3000) // number of entries to keep in the pg log when trimming it OPTION(osd_max_pg_log_entries, OPT_U32, 10000) // max entries, say when degraded, before we trim -OPTION(op_tracker_complaint_time, OPT_FLOAT, 30) // how many seconds old makes an op complaint-worthy +OPTION(osd_op_complaint_time, OPT_FLOAT, 30) // how many seconds old makes an op complaint-worthy OPTION(osd_command_max_records, OPT_INT, 256) -OPTION(op_tracker_log_threshold, OPT_INT, 5) // how many op log messages to show in one go +OPTION(osd_op_log_threshold, OPT_INT, 5) // how many op log messages to show in one go OPTION(osd_verify_sparse_read_holes, OPT_BOOL, false) // read fiemap-reported holes and verify they are zeros OPTION(osd_debug_drop_ping_probability, OPT_DOUBLE, 0) OPTION(osd_debug_drop_ping_duration, OPT_INT, 0) @@ -484,8 +484,8 @@ OPTION(osd_debug_op_order, OPT_BOOL, false) OPTION(osd_debug_verify_snaps_on_info, OPT_BOOL, false) OPTION(osd_debug_verify_stray_on_activate, OPT_BOOL, false) OPTION(osd_debug_skip_full_check_in_backfill_reservation, OPT_BOOL, false) -OPTION(op_tracker_history_size, OPT_U32, 20) // Max number of completed ops to track -OPTION(op_tracker_history_duration, OPT_U32, 600) // Oldest completed op to track +OPTION(osd_op_history_size, OPT_U32, 20) // Max number of completed ops to track +OPTION(osd_op_history_duration, OPT_U32, 600) // Oldest completed op to track OPTION(osd_target_transaction_size, OPT_INT, 30) // to adjust various transactions that batch smaller items OPTION(osd_failsafe_full_ratio, OPT_FLOAT, .97) // what % full makes an OSD "full" (failsafe) OPTION(osd_failsafe_nearfull_ratio, OPT_FLOAT, .90) // what % full makes an OSD near full (failsafe) @@ -510,7 +510,7 @@ OPTION(osd_debug_pg_log_writeout, OPT_BOOL, false) * 1..63. * * osd_recovery_op_warn_multiple scales the normal warning threshhold, - * op_tracker_complaint_time, so that slow recovery ops won't cause noise + * osd_op_complaint_time, so that slow recovery ops won't cause noise */ OPTION(osd_client_op_priority, OPT_U32, 63) OPTION(osd_recovery_op_priority, OPT_U32, 10) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 8150d9b3cd9..1ba35ec2ef5 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -979,6 +979,10 @@ OSD::OSD(CephContext *cct_, int id, Messenger *internal_messenger, Messenger *ex service(this) { monc->set_messenger(client_messenger); + op_tracker.set_complaint_and_threshold(cct->_conf->osd_op_complaint_time, + cct->_conf->osd_op_log_threshold); + op_tracker.set_history_size_and_duration(cct->_conf->osd_op_history_size, + cct->_conf->osd_op_history_duration); } OSD::~OSD() @@ -2560,7 +2564,7 @@ void OSDService::check_nearfull_warning(const osd_stat_t &osd_stat) if (cur_state != new_state) { cur_state = new_state; - } else if (now - last_msg < cct->_conf->op_tracker_complaint_time) { + } else if (now - last_msg < cct->_conf->osd_op_complaint_time) { return; } last_msg = now; @@ -7318,6 +7322,8 @@ const char** OSD::get_tracked_conf_keys() const { static const char* KEYS[] = { "osd_max_backfills", + "osd_op_complaint_time", "osd_op_log_threshold", + "osd_op_history_size", "osd_op_history_duration", NULL }; return KEYS; @@ -7330,6 +7336,16 @@ void OSD::handle_conf_change(const struct md_config_t *conf, service.local_reserver.set_max(cct->_conf->osd_max_backfills); service.remote_reserver.set_max(cct->_conf->osd_max_backfills); } + if (changed.count("osd_op_complaint_time") || + changed.count("osd_op_log_threshold")) { + op_tracker.set_complaint_and_threshold(cct->_conf->osd_op_complaint_time, + cct->_conf->osd_op_log_threshold); + } + if (changed.count("osd_op_history_size") || + changed.count("osd_op_history_duration")) { + op_tracker.set_history_size_and_duration(cct->_conf->osd_op_history_size, + cct->_conf->osd_op_history_duration); + } } // -------------------------------- -- cgit v1.2.1 From 3fc6cfbb23c1e7413776e331d1cc5196b32d3709 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 4 Oct 2013 16:45:38 -0700 Subject: Makefile: add include/histogram.h to noinst_HEADERS Signed-off-by: Greg Farnum --- src/include/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 2d98e777f00..c8823ce523d 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -43,6 +43,7 @@ noinst_HEADERS += \ include/filepath.h \ include/frag.h \ include/hash.h \ + include/histogram.h \ include/intarith.h \ include/interval_set.h \ include/int_types.h \ -- cgit v1.2.1