void OSD::check_ops_in_flight()
{
- stringstream ss;
- if (op_tracker.check_ops_in_flight(ss))
- clog.warn(ss);
+ vector<string> warnings;
+ if (op_tracker.check_ops_in_flight(warnings)) {
+ for (vector<string>::iterator i = warnings.begin();
+ i != warnings.end();
+ ++i) {
+ clog.warn() << *i;
+ }
+ }
return;
}
i->remove_myself();
}
-bool OpTracker::check_ops_in_flight(ostream &out)
+bool OpTracker::check_ops_in_flight(std::vector<string> &warning_vector)
{
Mutex::Locker locker(ops_in_flight_lock);
if (!ops_in_flight.size())
utime_t now = ceph_clock_now(g_ceph_context);
utime_t too_old = now;
too_old -= g_conf->osd_op_complaint_time;
-
+
dout(10) << "ops_in_flight.size: " << ops_in_flight.size()
- << "; oldest is " << now - ops_in_flight.front()->received_time
- << " seconds old" << dendl;
+ << "; oldest is " << now - ops_in_flight.front()->received_time
+ << " seconds old" << dendl;
xlist<OpRequest*>::iterator i = ops_in_flight.begin();
+ warning_vector.reserve(ops_in_flight.size());
+ int warning_num = 0;
while (!i.end() && (*i)->received_time < too_old) {
// exponential backoff of warning intervals
if ( ( (*i)->received_time +
- (g_conf->osd_op_complaint_time *
- (*i)->warn_interval_multiplier) )< now) {
- out << "old request " << *((*i)->request) << " received at "
- << (*i)->received_time << " currently " << (*i)->state_string();
+ (g_conf->osd_op_complaint_time *
+ (*i)->warn_interval_multiplier) )< now) {
+ stringstream ss;
+ ss << "old request " << *((*i)->request) << " received at "
+ << (*i)->received_time << " currently " << (*i)->state_string();
(*i)->warn_interval_multiplier *= 2;
+ warning_vector[warning_num++] = ss.str();
}
++i;
}
- return !i.end();
+ return warning_num;
}
void OpTracker::mark_event(OpRequest *op, const string &dest)
#define OPREQUEST_H_
#include <sstream>
#include <stdint.h>
+#include <vector>
+
#include <include/utime.h>
#include "common/Mutex.h"
#include "include/xlist.h"
void dump_ops_in_flight(std::ostream& ss);
void register_inflight_op(xlist<OpRequest*>::item *i);
void unregister_inflight_op(xlist<OpRequest*>::item *i);
- bool check_ops_in_flight(std::ostream &out);
+ /**
+ * Look for Ops which are too old, and insert warning
+ * strings for each Op that is too old.
+ *
+ * @param warning_strings A vector<string> 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<string> &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);