From 6329d66ef032d4c9393946c8bf1d012ffc5a9ee8 Mon Sep 17 00:00:00 2001 From: pschwan Date: Thu, 19 Sep 2002 18:28:18 +0000 Subject: [PATCH] - Added preventative locking in two areas, where we're walking shared lists - Fixed a subtle race condition in ldlm_local_lock_enqueue: we checked to see if a completion AST had been received and then acted, with no lock. This fixes the assertion that I was seeing yesterday. --- lustre/ldlm/ldlm_extent.c | 2 ++ lustre/ldlm/ldlm_lock.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lustre/ldlm/ldlm_extent.c b/lustre/ldlm/ldlm_extent.c index 4f7f9eb..a89aed06 100644 --- a/lustre/ldlm/ldlm_extent.c +++ b/lustre/ldlm/ldlm_extent.c @@ -79,9 +79,11 @@ int ldlm_extent_policy(struct ldlm_lock *lock, void *req_cookie, if (!res) LBUG(); + l_lock(&res->lr_namespace->ns_lock); policy_internal(&res->lr_granted, req_ex, &new_ex, mode); policy_internal(&res->lr_converting, req_ex, &new_ex, mode); policy_internal(&res->lr_waiting, req_ex, &new_ex, mode); + l_unlock(&res->lr_namespace->ns_lock); memcpy(&lock->l_extent, &new_ex, sizeof(new_ex)); diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 02cf2a2..de02509 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -649,6 +649,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_lock * lock, lock->l_cookie = cookie; lock->l_cookie_len = cookie_len; + l_lock(&res->lr_namespace->ns_lock); if (local && lock->l_req_mode == lock->l_granted_mode) { /* The server returned a blocked lock, but it was granted before * we got a chance to actually enqueue it. We don't need to do @@ -695,6 +696,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_lock * lock, ldlm_grant_lock(lock); EXIT; out: + l_unlock(&res->lr_namespace->ns_lock); /* Don't set 'completion_ast' until here so that if the lock is granted * immediately we don't do an unnecessary completion call. */ lock->l_completion_ast = completion; @@ -830,7 +832,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, } else { /* FIXME: We should try the conversion right away and possibly * return success without the need for an extra AST */ - list_add_tail(&lock->l_res_link, &res->lr_converting); + ldlm_resource_add_lock(res, res->lr_converting.prev, lock); *flags |= LDLM_FL_BLOCK_CONV; } -- 1.8.3.1