From ef1758a0d3cb9ac3abbe0e60ac689cf3b2aa3a6e Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Thu, 6 Nov 2014 10:00:32 -0800 Subject: [PATCH] LU-5781 osc: osc_lock_weight endless loop fix With huge number of pages to scan by osc_lock_weight() it is likely CLP_GANG_RESCHED is returned from osc_page_gang_lookup() and the scan will be repeated again from the start. To be sure that the scan is progressing across those restarts, next scan should be started from the last scanned page index plus one. Xyratex-bug-id: MRP-2145 Change-Id: I60775f2d8f688029d97ad4fe64f9b2698ed278c8 Signed-off-by: Alexander Zarochentsev Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/12859 Tested-by: Jenkins Reviewed-by: Johann Lombardi Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/osc/osc_lock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index c119d14..c2ff0ac 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -911,12 +911,11 @@ static int weigh_cb(const struct lu_env *env, struct cl_io *io, #if defined(__KERNEL__) struct page *vmpage = cl_page_vmpage(env, page); - if (PageLocked(vmpage) || PageDirty(vmpage) || PageWriteback(vmpage)) { - (*(unsigned long *)cbdata)++; + if (PageLocked(vmpage) || PageDirty(vmpage) || PageWriteback(vmpage)) return CLP_GANG_ABORT; - } #endif + *(pgoff_t *)cbdata = page->cp_index + 1; return CLP_GANG_OKAY; } @@ -926,7 +925,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env, struct cl_io *io = &osc_env_info(env)->oti_io; struct cl_lock_descr *descr = &ols->ols_cl.cls_lock->cll_descr; struct cl_object *obj = ols->ols_cl.cls_obj; - unsigned long npages = 0; + pgoff_t page_index; int result; ENTRY; @@ -936,10 +935,11 @@ static unsigned long osc_lock_weight(const struct lu_env *env, if (result != 0) RETURN(result); + page_index = descr->cld_start; do { result = cl_page_gang_lookup(env, obj, io, - descr->cld_start, descr->cld_end, - weigh_cb, (void *)&npages); + page_index, descr->cld_end, + weigh_cb, (void *)&page_index); if (result == CLP_GANG_ABORT) break; if (result == CLP_GANG_RESCHED) @@ -947,7 +947,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env, } while (result != CLP_GANG_OKAY); cl_io_fini(env, io); - return npages; + return result == CLP_GANG_ABORT ? 1 : 0; } /** -- 1.8.3.1