From 2356ed42e78062abe71a1f5bd087f46f59a140d2 Mon Sep 17 00:00:00 2001
From: ericm <ericm>
Date: Wed, 19 Dec 2007 18:59:48 +0000
Subject: [PATCH] branch: b1_6 - fix AT timer might not be restarted properly.
 - fix AT checksum be ruined by further change in reply. b=14374 r=nathan,
 adilger

---
 lustre/ptlrpc/niobuf.c  |  8 ++++----
 lustre/ptlrpc/service.c | 15 ++++++---------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c
index 063dbabb75..33f9faf09c 100644
--- a/lustre/ptlrpc/niobuf.c
+++ b/lustre/ptlrpc/niobuf.c
@@ -362,7 +362,10 @@ int ptlrpc_send_reply (struct ptlrpc_request *req, int flags)
         lustre_msg_set_service_time(req->rq_repmsg, service_time);
         /* Report service time estimate for future client reqs */
         lustre_msg_set_timeout(req->rq_repmsg, at_get(&svc->srv_at_estimate));
-        
+
+        if (req->rq_export && req->rq_export->exp_obd)
+                target_pack_pool_reply(req);
+
         if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_AT_SUPPORT) {
                 /* early replies go to offset 0, regular replies go after that*/
                 if (flags & PTLRPC_REPLY_EARLY) {
@@ -383,9 +386,6 @@ int ptlrpc_send_reply (struct ptlrpc_request *req, int flags)
                       lustre_msg_get_magic(req->rq_repmsg), req->rq_replen);
         }
 
-        if (req->rq_export && req->rq_export->exp_obd)
-                target_pack_pool_reply(req);
-
         if (req->rq_export == NULL || req->rq_export->exp_connection == NULL)
                 conn = ptlrpc_get_connection(req->rq_peer, req->rq_self, NULL);
         else
diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c
index c951a5d1f3..ebc0850b3a 100644
--- a/lustre/ptlrpc/service.c
+++ b/lustre/ptlrpc/service.c
@@ -811,6 +811,9 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc)
 
         spin_unlock(&svc->srv_at_lock);
 
+        /* we have a new earliest deadline, restart the timer */
+        ptlrpc_at_set_timer(svc);
+
         CDEBUG(D_ADAPTTO, "timeout in %+ds, asking for %d secs on %d early "
                "replies\n", first, at_extra, counter);
         if (first < 0)
@@ -821,7 +824,6 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc)
 
         /* ptlrpc_server_free_request may delete an entry out of the work
            list */
-        counter = 0;
         spin_lock(&svc->srv_at_lock);
         while (!list_empty(&work_list)) {
                 rq = list_entry(work_list.next, struct ptlrpc_request,
@@ -831,20 +833,15 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc)
                    deleted, and is safe to take a ref to keep the req around */
                 atomic_inc(&rq->rq_refcount);
                 spin_unlock(&svc->srv_at_lock);
-                if (ptlrpc_at_send_early_reply(rq, at_extra) == 0) {
-                        counter++;
+
+                if (ptlrpc_at_send_early_reply(rq, at_extra) == 0)
                         ptlrpc_at_add_timed(rq);
-                }
+
                 ptlrpc_server_req_decref(rq);
                 spin_lock(&svc->srv_at_lock);
         }
         spin_unlock(&svc->srv_at_lock);
 
-        if (!counter)
-                /* Nothing added to timed list, so we have to kick the timer
-                   ourselves. */
-                ptlrpc_at_set_timer(svc);
-
         RETURN(0);      
 }
 
-- 
GitLab