};
/* import.c */
+static inline unsigned int at_est2timeout(unsigned int val)
+{
+ /* add an arbitrary minimum: 125% +5 sec */
+ return (val + (val >> 2) + 5);
+}
+
+static inline unsigned int at_timeout2est(unsigned int val)
+{
+ /* restore estimate value from timeout */
+ return ((val - 1) / 5 * 4);
+}
+
static inline void at_init(struct adaptive_timeout *at, int val, int flags) {
memset(at, 0, sizeof(*at));
at->at_current = val;
struct ptlrpc_request *req,
int new_client)
{
- int req_timeout = OBD_RECOVERY_FACTOR *
- lustre_msg_get_timeout(req->rq_reqmsg);
+ int req_timeout = lustre_msg_get_timeout(req->rq_reqmsg);
+
+ /* teach server about old server's estimates */
+ if (!new_client)
+ at_add(&req->rq_rqbd->rqbd_service->srv_at_estimate,
+ at_timeout2est(req_timeout));
check_and_start_recovery_timer(obd, handler);
+ req_timeout *= OBD_RECOVERY_FACTOR;
if (req_timeout > obd->obd_recovery_timeout && !new_client)
reset_recovery_timer(obd, req_timeout, 0);
}
idx = import_at_get_index(req->rq_import,
req->rq_request_portal);
serv_est = at_get(&at->iat_service_estimate[idx]);
- /* add an arbitrary minimum: 125% +5 sec */
- req->rq_timeout = serv_est + (serv_est >> 2) + 5;
+ req->rq_timeout = at_est2timeout(serv_est);
/* We could get even fancier here, using history to predict increased
loading... */
unsigned int oldse;
struct imp_at *at;
+ /* do estimate only if is not in recovery */
+ if (!(req->rq_send_state & (LUSTRE_IMP_FULL | LUSTRE_IMP_CONNECTING)))
+ return;
+
LASSERT(req->rq_import);
at = &req->rq_import->imp_at;
service_time = max_t(int, cfs_time_current_sec() -
req->rq_arrival_time.tv_sec, 1);
if (!(flags & PTLRPC_REPLY_EARLY) &&
- (req->rq_type != PTL_RPC_MSG_ERR)) {
- /* early replies and errors don't count toward our service
- time estimate */
+ (req->rq_type != PTL_RPC_MSG_ERR) &&
+ !(lustre_msg_get_flags(req->rq_reqmsg) &
+ (MSG_RESENT | MSG_REPLAY | MSG_LAST_REPLAY))) {
+ /* early replies, errors and recovery requests don't count
+ * toward our service time estimate */
int oldse = at_add(&svc->srv_at_estimate, service_time);
if (oldse != 0)
DEBUG_REQ(D_ADAPTTO, req,