-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
for (nr_ns = cfs_atomic_read(ldlm_namespace_nr(client));
nr_ns > 0; nr_ns--)
{
- cfs_mutex_down(ldlm_namespace_lock(client));
+ cfs_mutex_lock(ldlm_namespace_lock(client));
if (cfs_list_empty(ldlm_namespace_list(client))) {
- cfs_mutex_up(ldlm_namespace_lock(client));
+ cfs_mutex_unlock(ldlm_namespace_lock(client));
cl_env_reexit(cookie);
return 0;
}
ns = ldlm_namespace_first_locked(client);
ldlm_namespace_get(ns);
ldlm_namespace_move_locked(ns, client);
- cfs_mutex_up(ldlm_namespace_lock(client));
+ cfs_mutex_unlock(ldlm_namespace_lock(client));
total += ldlm_pool_shrink(&ns->ns_pool, 0, gfp_mask);
ldlm_namespace_put(ns);
}
/*
* Do not call shrink under ldlm_namespace_lock(client)
*/
- cfs_mutex_down(ldlm_namespace_lock(client));
+ cfs_mutex_lock(ldlm_namespace_lock(client));
if (cfs_list_empty(ldlm_namespace_list(client))) {
- cfs_mutex_up(ldlm_namespace_lock(client));
+ cfs_mutex_unlock(ldlm_namespace_lock(client));
/*
* If list is empty, we can't return any @cached > 0,
* that probably would cause needless shrinker
ns = ldlm_namespace_first_locked(client);
ldlm_namespace_get(ns);
ldlm_namespace_move_locked(ns, client);
- cfs_mutex_up(ldlm_namespace_lock(client));
+ cfs_mutex_unlock(ldlm_namespace_lock(client));
nr_locks = ldlm_pool_granted(&ns->ns_pool);
cancel = 1 + nr_locks * nr / total;
ldlm_namespace_put(ns);
}
cl_env_reexit(cookie);
- return cached;
+ /* we only decrease the SLV in server pools shrinker, return -1 to
+ * kernel to avoid needless loop. LU-1128 */
+ return (client == LDLM_NAMESPACE_SERVER) ? -1 : cached;
}
-static int ldlm_pools_srv_shrink(SHRINKER_FIRST_ARG int nr_to_scan,
- unsigned int gfp_mask)
+static int ldlm_pools_srv_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask))
{
- return ldlm_pools_shrink(LDLM_NAMESPACE_SERVER, nr_to_scan, gfp_mask);
+ return ldlm_pools_shrink(LDLM_NAMESPACE_SERVER,
+ shrink_param(sc, nr_to_scan),
+ shrink_param(sc, gfp_mask));
}
-static int ldlm_pools_cli_shrink(SHRINKER_FIRST_ARG int nr_to_scan,
- unsigned int gfp_mask)
+static int ldlm_pools_cli_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask))
{
- return ldlm_pools_shrink(LDLM_NAMESPACE_CLIENT, nr_to_scan, gfp_mask);
+ return ldlm_pools_shrink(LDLM_NAMESPACE_CLIENT,
+ shrink_param(sc, nr_to_scan),
+ shrink_param(sc, gfp_mask));
}
void ldlm_pools_recalc(ldlm_side_t client)
/*
* Check all modest namespaces first.
*/
- cfs_mutex_down(ldlm_namespace_lock(client));
+ cfs_mutex_lock(ldlm_namespace_lock(client));
cfs_list_for_each_entry(ns, ldlm_namespace_list(client),
ns_list_chain)
{
}
ldlm_pool_setup(&ns->ns_pool, l);
}
- cfs_mutex_up(ldlm_namespace_lock(client));
+ cfs_mutex_unlock(ldlm_namespace_lock(client));
}
/*
* rid of potential deadlock on client nodes when canceling
* locks synchronously.
*/
- cfs_mutex_down(ldlm_namespace_lock(client));
+ cfs_mutex_lock(ldlm_namespace_lock(client));
if (cfs_list_empty(ldlm_namespace_list(client))) {
- cfs_mutex_up(ldlm_namespace_lock(client));
+ cfs_mutex_unlock(ldlm_namespace_lock(client));
break;
}
ns = ldlm_namespace_first_locked(client);
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 (cfs_atomic_read(&ns->ns_bref) == 0) {
+ if (ns->ns_stopping) {
skip = 1;
} else {
skip = 0;
cfs_spin_unlock(&ns->ns_lock);
ldlm_namespace_move_locked(ns, client);
- cfs_mutex_up(ldlm_namespace_lock(client));
+ cfs_mutex_unlock(ldlm_namespace_lock(client));
/*
* After setup is done - recalc the pool.
ENTRY;
cfs_daemonize(t_name);
- thread->t_flags = SVC_RUNNING;
+ thread_set_flags(thread, SVC_RUNNING);
cfs_waitq_signal(&thread->t_ctl_waitq);
CDEBUG(D_DLMTRACE, "%s: pool thread starting, process %d\n",
*/
lwi = LWI_TIMEOUT(cfs_time_seconds(LDLM_POOLS_THREAD_PERIOD),
NULL, NULL);
- l_wait_event(thread->t_ctl_waitq, (thread->t_flags &
- (SVC_STOPPING|SVC_EVENT)),
+ l_wait_event(thread->t_ctl_waitq,
+ thread_is_stopping(thread) ||
+ thread_is_event(thread),
&lwi);
- if (thread->t_flags & SVC_STOPPING) {
- thread->t_flags &= ~SVC_STOPPING;
+ if (thread_test_and_clear_flags(thread, SVC_STOPPING))
break;
- } else if (thread->t_flags & SVC_EVENT) {
- thread->t_flags &= ~SVC_EVENT;
- }
+ else
+ thread_test_and_clear_flags(thread, SVC_EVENT);
}
- thread->t_flags = SVC_STOPPED;
+ thread_set_flags(thread, SVC_STOPPED);
cfs_waitq_signal(&thread->t_ctl_waitq);
CDEBUG(D_DLMTRACE, "%s: pool thread exiting, process %d\n",
RETURN(rc);
}
l_wait_event(ldlm_pools_thread->t_ctl_waitq,
- (ldlm_pools_thread->t_flags & SVC_RUNNING), &lwi);
+ thread_is_running(ldlm_pools_thread), &lwi);
RETURN(0);
}
return;
}
- ldlm_pools_thread->t_flags = SVC_STOPPING;
+ thread_set_flags(ldlm_pools_thread, SVC_STOPPING);
cfs_waitq_signal(&ldlm_pools_thread->t_ctl_waitq);
/*