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>
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);
}
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;
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--)
{
+ __u64 cancel;
+ unsigned int nr_locks;
/*
* Do not call shrink under ldlm_namespace_lock(client)
/*
* Do not call shrink under ldlm_namespace_lock(client)
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);
}