Whamcloud - gitweb
b=17738
authoryury <yury>
Sun, 23 Nov 2008 12:37:46 +0000 (12:37 +0000)
committeryury <yury>
Sun, 23 Nov 2008 12:37:46 +0000 (12:37 +0000)
r=zam,shadow

- kill old locks from ldlm pools in convert time before adding them back with new mode.

lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_pool.c

index 1ec702a..97d680c 100644 (file)
@@ -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)
 {
  */
 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));
         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);
 
         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);
         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;
                 }
         }
                         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)) {
 
         /* If this is a local resource, put it on the appropriate list. */
         if (ns_is_client(res->lr_namespace)) {
index 4d0b57e..09b9590 100644 (file)
@@ -906,6 +906,7 @@ void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock)
                 return;
         ENTRY;
 
                 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);
         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;
 
                 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);
         LASSERT(atomic_read(&pl->pl_granted) > 0);
         atomic_dec(&pl->pl_granted);
         atomic_inc(&pl->pl_cancel_rate);