}
pl->pl_proc_dir = lprocfs_register("pool", parent_ns_proc,
NULL, NULL);
- if (IS_ERR(pl->pl_proc_dir)) {
- CERROR("LProcFS failed in ldlm-pool-init\n");
- rc = PTR_ERR(pl->pl_proc_dir);
- GOTO(out_free_name, rc);
- }
+ if (IS_ERR(pl->pl_proc_dir)) {
+ rc = PTR_ERR(pl->pl_proc_dir);
+ pl->pl_proc_dir = NULL;
+ CERROR("%s: cannot create 'pool' proc entry: rc = %d\n",
+ ldlm_ns_name(ns), rc);
+ GOTO(out_free_name, rc);
+ }
var_name[MAX_STRING_SIZE] = '\0';
memset(pool_vars, 0, sizeof(pool_vars));
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);
}
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;
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)
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);
}
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;
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);
}
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)
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");
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)