aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lustre/ldlm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/lustre/lustre/ldlm')
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_extent.c4
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lock.c18
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c14
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_pool.c8
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_request.c12
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_resource.c20
6 files changed, 33 insertions, 43 deletions
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index fac9d19d50b6..11b11b5f3216 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -64,7 +64,6 @@
__u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
{
struct ldlm_resource *res = lock->l_resource;
- struct list_head *tmp;
struct ldlm_lock *lck;
__u64 kms = 0;
@@ -74,8 +73,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
*/
ldlm_set_kms_ignore(lock);
- list_for_each(tmp, &res->lr_granted) {
- lck = list_entry(tmp, struct ldlm_lock, l_res_link);
+ list_for_each_entry(lck, &res->lr_granted, l_res_link) {
if (ldlm_is_kms_ignore(lck))
continue;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 7cb61e2e7d3b..7cbc6a06afec 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -886,17 +886,15 @@ static void search_granted_lock(struct list_head *queue,
struct ldlm_lock *req,
struct sl_insert_point *prev)
{
- struct list_head *tmp;
struct ldlm_lock *lock, *mode_end, *policy_end;
- list_for_each(tmp, queue) {
- lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+ list_for_each_entry(lock, queue, l_res_link) {
mode_end = list_prev_entry(lock, l_sl_mode);
if (lock->l_req_mode != req->l_req_mode) {
/* jump to last lock of mode group */
- tmp = &mode_end->l_res_link;
+ lock = mode_end;
continue;
}
@@ -933,9 +931,7 @@ static void search_granted_lock(struct list_head *queue,
break;
/* go to next policy group within mode group */
- tmp = policy_end->l_res_link.next;
- lock = list_entry(tmp, struct ldlm_lock,
- l_res_link);
+ lock = list_next_entry(policy_end, l_res_link);
} /* loop over policy groups within the mode group */
/* insert point is last lock of the mode group,
@@ -1687,7 +1683,7 @@ ldlm_work_bl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
if (list_empty(arg->list))
return -ENOENT;
- lock = list_entry(arg->list->next, struct ldlm_lock, l_bl_ast);
+ lock = list_first_entry(arg->list, struct ldlm_lock, l_bl_ast);
/* nobody should touch l_bl_ast */
lock_res_and_lock(lock);
@@ -1723,7 +1719,7 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
if (list_empty(arg->list))
return -ENOENT;
- lock = list_entry(arg->list->next, struct ldlm_lock, l_cp_ast);
+ lock = list_first_entry(arg->list, struct ldlm_lock, l_cp_ast);
/* It's possible to receive a completion AST before we've set
* the l_completion_ast pointer: either because the AST arrived
@@ -1769,7 +1765,7 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
if (list_empty(arg->list))
return -ENOENT;
- lock = list_entry(arg->list->next, struct ldlm_lock, l_rk_ast);
+ lock = list_first_entry(arg->list, struct ldlm_lock, l_rk_ast);
list_del_init(&lock->l_rk_ast);
/* the desc just pretend to exclusive */
@@ -1796,7 +1792,7 @@ static int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
if (list_empty(arg->list))
return -ENOENT;
- gl_work = list_entry(arg->list->next, struct ldlm_glimpse_work,
+ gl_work = list_first_entry(arg->list, struct ldlm_glimpse_work,
gl_list);
list_del_init(&gl_work->gl_list);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 2d5a2c932ddc..5f6e7c933b81 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -696,13 +696,13 @@ static int ldlm_bl_get_work(struct ldlm_bl_pool *blp,
/* process a request from the blp_list at least every blp_num_threads */
if (!list_empty(&blp->blp_list) &&
(list_empty(&blp->blp_prio_list) || num_bl == 0))
- blwi = list_entry(blp->blp_list.next,
- struct ldlm_bl_work_item, blwi_entry);
+ blwi = list_first_entry(&blp->blp_list,
+ struct ldlm_bl_work_item, blwi_entry);
else
if (!list_empty(&blp->blp_prio_list))
- blwi = list_entry(blp->blp_prio_list.next,
- struct ldlm_bl_work_item,
- blwi_entry);
+ blwi = list_first_entry(&blp->blp_prio_list,
+ struct ldlm_bl_work_item,
+ blwi_entry);
if (blwi) {
if (++num_bl >= num_th)
@@ -1093,8 +1093,10 @@ static int ldlm_cleanup(void)
kset_unregister(ldlm_ns_kset);
if (ldlm_svc_kset)
kset_unregister(ldlm_svc_kset);
- if (ldlm_kobj)
+ if (ldlm_kobj) {
+ sysfs_remove_group(ldlm_kobj, &ldlm_attr_group);
kobject_put(ldlm_kobj);
+ }
ldlm_debugfs_cleanup();
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index da65d00a7811..8563bd32befa 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -1086,8 +1086,12 @@ int ldlm_pools_init(void)
int rc;
rc = ldlm_pools_thread_start();
- if (rc == 0)
- register_shrinker(&ldlm_pools_cli_shrinker);
+ if (rc)
+ return rc;
+
+ rc = register_shrinker(&ldlm_pools_cli_shrinker);
+ if (rc)
+ ldlm_pools_thread_stop();
return rc;
}
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 02ea14c9b089..6aa37463db46 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1656,7 +1656,7 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count,
*/
while (count > 0) {
LASSERT(!list_empty(cancels));
- lock = list_entry(cancels->next, struct ldlm_lock, l_bl_ast);
+ lock = list_first_entry(cancels, struct ldlm_lock, l_bl_ast);
LASSERT(lock->l_conn_export);
if (exp_connect_cancelset(lock->l_conn_export)) {
@@ -1780,7 +1780,7 @@ EXPORT_SYMBOL(ldlm_cli_cancel_unused);
static int ldlm_resource_foreach(struct ldlm_resource *res,
ldlm_iterator_t iter, void *closure)
{
- struct list_head *tmp, *next;
+ struct ldlm_lock *tmp;
struct ldlm_lock *lock;
int rc = LDLM_ITER_CONTINUE;
@@ -1788,18 +1788,14 @@ static int ldlm_resource_foreach(struct ldlm_resource *res,
return LDLM_ITER_CONTINUE;
lock_res(res);
- list_for_each_safe(tmp, next, &res->lr_granted) {
- lock = list_entry(tmp, struct ldlm_lock, l_res_link);
-
+ list_for_each_entry_safe(lock, tmp, &res->lr_granted, l_res_link) {
if (iter(lock, closure) == LDLM_ITER_STOP) {
rc = LDLM_ITER_STOP;
goto out;
}
}
- list_for_each_safe(tmp, next, &res->lr_waiting) {
- lock = list_entry(tmp, struct ldlm_lock, l_res_link);
-
+ list_for_each_entry_safe(lock, tmp, &res->lr_waiting, l_res_link) {
if (iter(lock, closure) == LDLM_ITER_STOP) {
rc = LDLM_ITER_STOP;
goto out;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 2689ffdf10e3..9958533cc227 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -752,24 +752,22 @@ extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
__u64 flags)
{
- struct list_head *tmp;
int rc = 0;
bool local_only = !!(flags & LDLM_FL_LOCAL_ONLY);
do {
- struct ldlm_lock *lock = NULL;
+ struct ldlm_lock *lock = NULL, *tmp;
struct lustre_handle lockh;
/* First, we look for non-cleaned-yet lock
* all cleaned locks are marked by CLEANED flag.
*/
lock_res(res);
- list_for_each(tmp, q) {
- lock = list_entry(tmp, struct ldlm_lock, l_res_link);
- if (ldlm_is_cleaned(lock)) {
- lock = NULL;
+ list_for_each_entry(tmp, q, l_res_link) {
+ if (ldlm_is_cleaned(tmp))
continue;
- }
+
+ lock = tmp;
LDLM_LOCK_GET(lock);
ldlm_set_cleaned(lock);
break;
@@ -1283,19 +1281,15 @@ void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc)
*/
void ldlm_dump_all_namespaces(enum ldlm_side client, int level)
{
- struct list_head *tmp;
+ struct ldlm_namespace *ns;
if (!((libcfs_debug | D_ERROR) & level))
return;
mutex_lock(ldlm_namespace_lock(client));
- list_for_each(tmp, ldlm_namespace_list(client)) {
- struct ldlm_namespace *ns;
-
- ns = list_entry(tmp, struct ldlm_namespace, ns_list_chain);
+ list_for_each_entry(ns, ldlm_namespace_list(client), ns_list_chain)
ldlm_namespace_dump(level, ns);
- }
mutex_unlock(ldlm_namespace_lock(client));
}