From d9c49e2021ef2da4e65af943a9770fad1fa5e6cf Mon Sep 17 00:00:00 2001 From: yury Date: Sat, 8 Nov 2008 10:43:33 +0000 Subject: [PATCH] b=17310 r=johann,shadow - make sure that no new inflight rpcs may come after ptlrpcd_deactivate_import() for both synchronous and asynchronous sending. To do so we make sure that imp_inflight++ is done only when permission is granted by ptlrpc_import_delay_req() which makes decision should req be sent, deferred or killed as import is not in the state to send it in observable future. For async sending, rpc is only counted inflight when its added to sending or delaying list instead of just adding it to set for processing. This fixes assert in ptlrpc_invalidate_import() and as number of other issues; - synchronize imp_inflight and the presence on sending or delaying list for ptlrpc_queue_wait() case. So that, now it is guaranteed that if imp_inflight != 0 we may always find hanging rpc either in sending or in delaying list; - make sure that in ptlrcp_queue_wait() we remove rpc from sending or delaying list and dec inflight only after ptlrpc_unregister_reply() is done. This way we make sure that accounting is correct. Rpc can't be returned to the pool or counted finished until lnet lets us go with finished reply unlink; - check for inflight and rq_list in pinger; - comments, cleanups; --- lustre/ptlrpc/pinger.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c index c46907b..bfde1af 100644 --- a/lustre/ptlrpc/pinger.c +++ b/lustre/ptlrpc/pinger.c @@ -485,6 +485,7 @@ static int pinger_check_rpcs(void *arg) struct ptlrpc_request *req; struct ptlrpc_request_set *set; struct list_head *iter; + struct obd_import *imp; struct pinger_data *pd = &pinger_args; int rc; @@ -592,17 +593,23 @@ do_check_set: if (req->rq_phase == RQ_PHASE_COMPLETE) continue; - ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE); - atomic_dec(&req->rq_import->imp_inflight); - set->set_remaining--; - /* If it was disconnected, don't sweat it. */ - if (list_empty(&req->rq_import->imp_pinger_chain)) { - ptlrpc_unregister_reply(req, 0); - continue; - } + CDEBUG(D_RPCTRACE, "Pinger initiate expire request(%p)\n", + req); - CDEBUG(D_RPCTRACE, "pinger initiate expire_one_request\n"); + /* This will also unregister reply. */ ptlrpc_expire_one_request(req, 0); + + /* We're done with this req, let's finally move it to complete + * phase and take care of inflights. */ + ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE); + imp = req->rq_import; + spin_lock(&imp->imp_lock); + if (!list_empty(&req->rq_list)) { + list_del_init(&req->rq_list); + atomic_dec(&imp->imp_inflight); + } + spin_unlock(&imp->imp_lock); + set->set_remaining--; } mutex_up(&pinger_sem); -- 1.8.3.1