From 4a59e8f0b834bf9b05f790d252c6e6a27ea02259 Mon Sep 17 00:00:00 2001 From: yury Date: Sun, 23 Nov 2008 12:37:46 +0000 Subject: [PATCH] b=17738 r=zam,shadow - kill old locks from ldlm pools in convert time before adding them back with new mode. --- lustre/ldlm/ldlm_lock.c | 14 ++++++++++++++ lustre/ldlm/ldlm_pool.c | 2 ++ 2 files changed, 16 insertions(+) diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 1ec702a..97d680c 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -1677,6 +1677,7 @@ void ldlm_cancel_locks_for_export(struct obd_export *exp) */ void ldlm_lock_downgrade(struct ldlm_lock *lock, int new_mode) { + struct ldlm_namespace *ns; ENTRY; LASSERT(lock->l_granted_mode & (LCK_PW | LCK_EX)); @@ -1684,6 +1685,13 @@ void ldlm_lock_downgrade(struct ldlm_lock *lock, int new_mode) lock_res_and_lock(lock); ldlm_resource_unlink_lock(lock); + /* + * Remove the lock from pool as it will be added again in + * ldlm_grant_lock() called below. + */ + ns = lock->l_resource->lr_namespace; + ldlm_pool_del(&ns->ns_pool, lock); + lock->l_req_mode = new_mode; ldlm_grant_lock(lock, NULL); unlock_res_and_lock(lock); @@ -1745,6 +1753,12 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, node = NULL; } } + + /* + * Remove old lock from the pool before adding the lock with new + * mode below in ->policy() + */ + ldlm_pool_del(&ns->ns_pool, lock); /* If this is a local resource, put it on the appropriate list. */ if (ns_is_client(res->lr_namespace)) { diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c index 4d0b57e..09b9590 100644 --- a/lustre/ldlm/ldlm_pool.c +++ b/lustre/ldlm/ldlm_pool.c @@ -906,6 +906,7 @@ void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock) return; ENTRY; + LDLM_DEBUG(lock, "add lock to pool"); atomic_inc(&pl->pl_granted); atomic_inc(&pl->pl_grant_rate); atomic_inc(&pl->pl_grant_speed); @@ -935,6 +936,7 @@ void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock) return; ENTRY; + LDLM_DEBUG(lock, "del lock from pool"); LASSERT(atomic_read(&pl->pl_granted) > 0); atomic_dec(&pl->pl_granted); atomic_inc(&pl->pl_cancel_rate); -- 1.8.3.1