From fa55c6a4b41cd4fd240debe719b205056b04a0bf Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Sun, 1 Feb 2015 21:52:00 -0500 Subject: staging/lustre/ptlrpc: avoid list scan in ptlrpcd_check ptlrpcd_check() always scan all requests on ptlrpc_request_set and try to finish completed requests, this is low efficiency. Even worse, l_wait_event() always checks condition for twice before sleeping and one more time after waking up, which means it will call ptlrpcd_check() for three times in each loop. This patch will move completed requests at the head of list in ptlrpc_check_set(), with this change ptlrpcd_check doesn't need to scan all requests anymore. Signed-off-by: Liang Zhen Reviewed-on: http://review.whamcloud.com/11513 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5548 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Johann Lombardi Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c') diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index cbcc541cac43..4621b71fe0b6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -306,21 +306,16 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) if (atomic_read(&set->set_remaining)) rc |= ptlrpc_check_set(env, set); - if (!list_empty(&set->set_requests)) { - /* - * XXX: our set never completes, so we prune the completed - * reqs after each iteration. boy could this be smarter. - */ - list_for_each_safe(pos, tmp, &set->set_requests) { - req = list_entry(pos, struct ptlrpc_request, - rq_set_chain); - if (req->rq_phase != RQ_PHASE_COMPLETE) - continue; + /* NB: ptlrpc_check_set has already moved completed request at the + * head of seq::set_requests */ + list_for_each_safe(pos, tmp, &set->set_requests) { + req = list_entry(pos, struct ptlrpc_request, rq_set_chain); + if (req->rq_phase != RQ_PHASE_COMPLETE) + break; - list_del_init(&req->rq_set_chain); - req->rq_set = NULL; - ptlrpc_req_finished(req); - } + list_del_init(&req->rq_set_chain); + req->rq_set = NULL; + ptlrpc_req_finished(req); } if (rc == 0) { -- cgit v1.2.3-59-g8ed1b