Whamcloud - gitweb
LU-5781 osc: osc_lock_weight endless loop fix 59/12859/2
authorJinshan Xiong <jinshan.xiong@intel.com>
Thu, 6 Nov 2014 18:00:32 +0000 (10:00 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 4 Dec 2014 20:27:12 +0000 (20:27 +0000)
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 <alexander.zarochentsev@seagate.com>
Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-on: http://review.whamcloud.com/12859
Tested-by: Jenkins
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osc/osc_lock.c

index c119d14..c2ff0ac 100644 (file)
@@ -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;
 }
 
 /**