Whamcloud - gitweb
Introduce ldlm_lock_addref_try() function (used by CLIO) that attempts to
authornikita <nikita>
Sat, 18 Oct 2008 17:05:50 +0000 (17:05 +0000)
committernikita <nikita>
Sat, 18 Oct 2008 17:05:50 +0000 (17:05 +0000)
addref a lock that might be being canceled concurrently.
b=16450

lustre/ChangeLog
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c

index 8d31936..38ef6a5 100644 (file)
@@ -1545,7 +1545,7 @@ Bugzilla   : 16450
 Description: Kill unused ldlm_handle2lock_ns() function.
 Details    : Kill unused ldlm_handle2lock_ns() function.
 
-Severity   : minor
+Severity   : normal
 Bugzilla   : 16450
 Description: Add lu_ref support to ldlm_lock
 Details    : lu_ref support for ldlm_lock and ldlm_resource. See lu_ref patch. 
@@ -1566,6 +1566,13 @@ Details    : lu_ref support for ldlm_lock and ldlm_resource. See lu_ref patch.
         for proper use. On the other hand, it was very instrumental in finding 
         a few leaked lock references.
 
+Severity   : normal
+Bugzilla   : 16450
+Description: Add ldlm_lock_addref_try().
+Details    : Introduce ldlm_lock_addref_try() function (used by CLIO) that
+            attempts to addref a lock that might be being canceled
+            concurrently.
+
 --------------------------------------------------------------------------------
 
 2007-08-10         Cluster File Systems, Inc. <info@clusterfs.com>
index 0e10778..be73ac0 100644 (file)
@@ -948,6 +948,7 @@ void ldlm_lock_put(struct ldlm_lock *lock);
 void ldlm_lock_destroy(struct ldlm_lock *lock);
 void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc);
 void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode);
+int  ldlm_lock_addref_try(struct lustre_handle *lockh, __u32 mode);
 void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode);
 void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode);
 void ldlm_lock_allow_match(struct ldlm_lock *lock);
index 9977c41..06efa9f 100644 (file)
@@ -601,6 +601,33 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock, __u32 mode)
         LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]);
 }
 
+/**
+ * Attempts to addref a lock, and fails if lock is already LDLM_FL_CBPENDING
+ * or destroyed.
+ *
+ * \retval 0 success, lock was addref-ed
+ *
+ * \retval -EAGAIN lock is being canceled.
+ */
+int ldlm_lock_addref_try(struct lustre_handle *lockh, __u32 mode)
+{
+        struct ldlm_lock *lock;
+        int               result;
+
+        result = -EAGAIN;
+        lock = ldlm_handle2lock(lockh);
+        if (lock != NULL) {
+                lock_res_and_lock(lock);
+                if (!(lock->l_flags & LDLM_FL_CBPENDING)) {
+                        ldlm_lock_addref_internal_nolock(lock, mode);
+                        result = 0;
+                }
+                unlock_res_and_lock(lock);
+                LDLM_LOCK_PUT(lock);
+        }
+        return result;
+}
+
 /* only called for local locks */
 void ldlm_lock_addref_internal(struct ldlm_lock *lock, __u32 mode)
 {
index e4a3205..7edf62f 100644 (file)
@@ -2371,6 +2371,7 @@ EXPORT_SYMBOL(ldlm_lock_fast_release);
 EXPORT_SYMBOL(ldlm_lock_match);
 EXPORT_SYMBOL(ldlm_lock_cancel);
 EXPORT_SYMBOL(ldlm_lock_addref);
+EXPORT_SYMBOL(ldlm_lock_addref_try);
 EXPORT_SYMBOL(ldlm_lock_decref);
 EXPORT_SYMBOL(ldlm_lock_decref_and_cancel);
 EXPORT_SYMBOL(ldlm_lock_change_resource);