Whamcloud - gitweb
LU-3936 ldlm: ldlm_cancel_stale_locks()) ASSERTION( count > 0 ) failed 26/7626/2
authorAndriy Skulysh <Andriy_Skulysh@xyratex.com>
Thu, 12 Sep 2013 07:10:59 +0000 (10:10 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 25 Oct 2013 02:08:51 +0000 (02:08 +0000)
number of granted locks can be really huge.
Use 64bit math to calculate amount of locks to cancel

Change-Id: Iac0b52dd578baf9955b50597d0832ac8715895f1
Xyratex-bug-id: MRP-1296
Signed-off-by: Andriy Skulysh <Andriy_Skulysh@xyratex.com>
Reviewed-by: Alexey Lyashkov <Alexey_Lyashkov@xyratex.com>
Reviewed-by: Alexander Boyko <Alexander_Boyko@xyratex.com>
Reviewed-by: Vitaly Fertman <Vitaly_Fertman@xyratex.com>
Reviewed-on: http://review.whamcloud.com/7626
Tested-by: Hudson
Reviewed-by: Alexander Boyko <alexander_boyko@xyratex.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ldlm/ldlm_pool.c

index 3259ff8..734b330 100644 (file)
@@ -1059,7 +1059,7 @@ __u32 ldlm_pool_get_lvf(struct ldlm_pool *pl)
 EXPORT_SYMBOL(ldlm_pool_get_lvf);
 
 #ifdef __KERNEL__
 EXPORT_SYMBOL(ldlm_pool_get_lvf);
 
 #ifdef __KERNEL__
-static int ldlm_pool_granted(struct ldlm_pool *pl)
+static unsigned int ldlm_pool_granted(struct ldlm_pool *pl)
 {
         return cfs_atomic_read(&pl->pl_granted);
 }
 {
         return cfs_atomic_read(&pl->pl_granted);
 }
@@ -1077,7 +1077,8 @@ static struct completion ldlm_pools_comp;
 static int ldlm_pools_shrink(ldlm_side_t client, int nr,
                              unsigned int gfp_mask)
 {
 static int ldlm_pools_shrink(ldlm_side_t client, int nr,
                              unsigned int gfp_mask)
 {
-        int total = 0, cached = 0, nr_ns;
+       unsigned int total = 0, cached = 0;
+       int nr_ns;
         struct ldlm_namespace *ns;
        struct ldlm_namespace *ns_old = NULL; /* loop detection */
         void *cookie;
         struct ldlm_namespace *ns;
        struct ldlm_namespace *ns_old = NULL; /* loop detection */
         void *cookie;
@@ -1137,7 +1138,8 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr,
        for (nr_ns = ldlm_namespace_nr_read(client) - nr_ns;
             nr_ns > 0; nr_ns--)
         {
        for (nr_ns = ldlm_namespace_nr_read(client) - nr_ns;
             nr_ns > 0; nr_ns--)
         {
-                int cancel, nr_locks;
+               __u64 cancel;
+               unsigned int nr_locks;
 
                 /*
                  * Do not call shrink under ldlm_namespace_lock(client)
 
                 /*
                  * Do not call shrink under ldlm_namespace_lock(client)
@@ -1159,8 +1161,9 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr,
                mutex_unlock(ldlm_namespace_lock(client));
 
                 nr_locks = ldlm_pool_granted(&ns->ns_pool);
                mutex_unlock(ldlm_namespace_lock(client));
 
                 nr_locks = ldlm_pool_granted(&ns->ns_pool);
-                cancel = 1 + nr_locks * nr / total;
-                ldlm_pool_shrink(&ns->ns_pool, cancel, gfp_mask);
+               cancel = (__u64)nr_locks * nr;
+               do_div(cancel, total);
+               ldlm_pool_shrink(&ns->ns_pool, 1 + cancel, gfp_mask);
                 cached += ldlm_pool_granted(&ns->ns_pool);
                 ldlm_namespace_put(ns);
         }
                 cached += ldlm_pool_granted(&ns->ns_pool);
                 ldlm_namespace_put(ns);
         }