Whamcloud - gitweb
LU-3936 ldlm: ldlm_cancel_stale_locks()) ASSERTION( count > 0 ) failed
[fs/lustre-release.git] / lustre / ldlm / ldlm_pool.c
index 8782652..734b330 100644 (file)
@@ -1059,7 +1059,7 @@ __u32 ldlm_pool_get_lvf(struct ldlm_pool *pl)
 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);
 }
@@ -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)
 {
-        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;
@@ -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--)
         {
-                int cancel, nr_locks;
+               __u64 cancel;
+               unsigned int nr_locks;
 
                 /*
                  * 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);
-                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);
         }
@@ -1340,15 +1343,15 @@ EXPORT_SYMBOL(ldlm_pools_recalc);
 
 static int ldlm_pools_thread_main(void *arg)
 {
-        struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
+       struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
        int s_time, c_time;
-        ENTRY;
+       ENTRY;
 
-        thread_set_flags(thread, SVC_RUNNING);
-        cfs_waitq_signal(&thread->t_ctl_waitq);
+       thread_set_flags(thread, SVC_RUNNING);
+       wake_up(&thread->t_ctl_waitq);
 
-        CDEBUG(D_DLMTRACE, "%s: pool thread starting, process %d\n",
-              "ldlm_poold", cfs_curproc_pid());
+       CDEBUG(D_DLMTRACE, "%s: pool thread starting, process %d\n",
+              "ldlm_poold", current_pid());
 
         while (1) {
                 struct l_wait_info lwi;
@@ -1376,11 +1379,11 @@ static int ldlm_pools_thread_main(void *arg)
                         thread_test_and_clear_flags(thread, SVC_EVENT);
         }
 
-        thread_set_flags(thread, SVC_STOPPED);
-        cfs_waitq_signal(&thread->t_ctl_waitq);
+       thread_set_flags(thread, SVC_STOPPED);
+       wake_up(&thread->t_ctl_waitq);
 
-        CDEBUG(D_DLMTRACE, "%s: pool thread exiting, process %d\n",
-               "ldlm_poold", cfs_curproc_pid());
+       CDEBUG(D_DLMTRACE, "%s: pool thread exiting, process %d\n",
+               "ldlm_poold", current_pid());
 
        complete_and_exit(&ldlm_pools_comp, 0);
 }
@@ -1388,7 +1391,7 @@ static int ldlm_pools_thread_main(void *arg)
 static int ldlm_pools_thread_start(void)
 {
        struct l_wait_info lwi = { 0 };
-       cfs_task_t *task;
+       struct task_struct *task;
        ENTRY;
 
        if (ldlm_pools_thread != NULL)
@@ -1399,7 +1402,7 @@ static int ldlm_pools_thread_start(void)
                RETURN(-ENOMEM);
 
        init_completion(&ldlm_pools_comp);
-       cfs_waitq_init(&ldlm_pools_thread->t_ctl_waitq);
+       init_waitqueue_head(&ldlm_pools_thread->t_ctl_waitq);
 
        task = kthread_run(ldlm_pools_thread_main, ldlm_pools_thread,
                           "ldlm_poold");
@@ -1416,25 +1419,25 @@ static int ldlm_pools_thread_start(void)
 
 static void ldlm_pools_thread_stop(void)
 {
-        ENTRY;
+       ENTRY;
 
-        if (ldlm_pools_thread == NULL) {
-                EXIT;
-                return;
-        }
+       if (ldlm_pools_thread == NULL) {
+               EXIT;
+               return;
+       }
 
-        thread_set_flags(ldlm_pools_thread, SVC_STOPPING);
-        cfs_waitq_signal(&ldlm_pools_thread->t_ctl_waitq);
+       thread_set_flags(ldlm_pools_thread, SVC_STOPPING);
+       wake_up(&ldlm_pools_thread->t_ctl_waitq);
 
-        /*
-         * Make sure that pools thread is finished before freeing @thread.
-         * This fixes possible race and oops due to accessing freed memory
-         * in pools thread.
-         */
+       /*
+        * Make sure that pools thread is finished before freeing @thread.
+        * This fixes possible race and oops due to accessing freed memory
+        * in pools thread.
+        */
        wait_for_completion(&ldlm_pools_comp);
-        OBD_FREE_PTR(ldlm_pools_thread);
-        ldlm_pools_thread = NULL;
-        EXIT;
+       OBD_FREE_PTR(ldlm_pools_thread);
+       ldlm_pools_thread = NULL;
+       EXIT;
 }
 
 int ldlm_pools_init(void)