/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011 Whamcloud, Inc.
+ *
*/
/*
* This file is part of Lustre, http://www.lustre.org/
*/
ldlm_cli_pool_pop_slv(pl);
- cfs_spin_lock(&ns->ns_unused_lock);
+ cfs_spin_lock(&ns->ns_lock);
unused = ns->ns_nr_unused;
- cfs_spin_unlock(&ns->ns_unused_lock);
+ cfs_spin_unlock(&ns->ns_lock);
if (nr) {
- canceled = ldlm_cancel_lru(ns, nr, LDLM_SYNC,
+ canceled = ldlm_cancel_lru(ns, nr, LDLM_ASYNC,
LDLM_CANCEL_SHRINK);
}
#ifdef __KERNEL__
if (!var_name)
RETURN(-ENOMEM);
- parent_ns_proc = lprocfs_srch(ldlm_ns_proc_dir, ns->ns_name);
+ parent_ns_proc = lprocfs_srch(ldlm_ns_proc_dir,
+ ldlm_ns_name(ns));
if (parent_ns_proc == NULL) {
CERROR("%s: proc entry is not initialized\n",
- ns->ns_name);
+ ldlm_ns_name(ns));
GOTO(out_free_name, rc = -EINVAL);
}
pl->pl_proc_dir = lprocfs_register("pool", parent_ns_proc,
pl->pl_grant_plan = LDLM_POOL_GP(LDLM_POOL_HOST_L);
snprintf(pl->pl_name, sizeof(pl->pl_name), "ldlm-pool-%s-%d",
- ns->ns_name, idx);
+ ldlm_ns_name(ns), idx);
if (client == LDLM_NAMESPACE_SERVER) {
pl->pl_ops = &ldlm_srv_pool_ops;
ldlm_namespace_move_locked(ns, client);
cfs_mutex_up(ldlm_namespace_lock(client));
total += ldlm_pool_shrink(&ns->ns_pool, 0, gfp_mask);
- ldlm_namespace_put(ns, 1);
+ ldlm_namespace_put(ns);
}
if (nr == 0 || total == 0) {
cancel = 1 + nr_locks * nr / total;
ldlm_pool_shrink(&ns->ns_pool, cancel, gfp_mask);
cached += ldlm_pool_granted(&ns->ns_pool);
- ldlm_namespace_put(ns, 1);
+ ldlm_namespace_put(ns);
}
cl_env_reexit(cookie);
return cached;
}
-static int ldlm_pools_srv_shrink(int nr, unsigned int gfp_mask)
+static int ldlm_pools_srv_shrink(SHRINKER_FIRST_ARG int nr_to_scan,
+ unsigned int gfp_mask)
{
- return ldlm_pools_shrink(LDLM_NAMESPACE_SERVER, nr, gfp_mask);
+ return ldlm_pools_shrink(LDLM_NAMESPACE_SERVER, nr_to_scan, gfp_mask);
}
-static int ldlm_pools_cli_shrink(int nr, unsigned int gfp_mask)
+static int ldlm_pools_cli_shrink(SHRINKER_FIRST_ARG int nr_to_scan,
+ unsigned int gfp_mask)
{
- return ldlm_pools_shrink(LDLM_NAMESPACE_CLIENT, nr, gfp_mask);
+ return ldlm_pools_shrink(LDLM_NAMESPACE_CLIENT, nr_to_scan, gfp_mask);
}
void ldlm_pools_recalc(ldlm_side_t client)
}
ns = ldlm_namespace_first_locked(client);
- cfs_spin_lock(&ns->ns_hash_lock);
+ cfs_spin_lock(&ns->ns_lock);
/*
* skip ns which is being freed, and we don't want to increase
- * its refcount again, not even temporarily. bz21519.
+ * its refcount again, not even temporarily. bz21519 & LU-499.
*/
- if (ns->ns_refcount == 0) {
+ if (ns->ns_stopping) {
skip = 1;
} else {
skip = 0;
- ldlm_namespace_get_locked(ns);
+ ldlm_namespace_get(ns);
}
- cfs_spin_unlock(&ns->ns_hash_lock);
+ cfs_spin_unlock(&ns->ns_lock);
ldlm_namespace_move_locked(ns, client);
cfs_mutex_up(ldlm_namespace_lock(client));
*/
if (!skip) {
ldlm_pool_recalc(&ns->ns_pool);
- ldlm_namespace_put(ns, 1);
+ ldlm_namespace_put(ns);
}
}
}
* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
* just drop the VM and FILES in cfs_daemonize() right away.
*/
- rc = cfs_kernel_thread(ldlm_pools_thread_main, ldlm_pools_thread,
- CLONE_VM | CLONE_FILES);
+ rc = cfs_create_thread(ldlm_pools_thread_main, ldlm_pools_thread,
+ CFS_DAEMON_FLAGS);
if (rc < 0) {
CERROR("Can't start pool thread, error %d\n",
rc);