Whamcloud - gitweb
- on cnbuild ping time is set to some strange value, the patch is intended
[fs/lustre-release.git] / lustre / ldlm / l_lock.c
index 680d4f0..11cd02d 100644 (file)
@@ -20,6 +20,8 @@
  *
  */
 
+#define DEBUG_SUBSYSTEM S_LDLM
+#ifdef __KERNEL__
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#else 
+#include <liblustre.h>
+#endif
 
-#define DEBUG_SUBSYSTEM S_LDLM
-
-#include <linux/obd_class.h>
+#include <linux/lustre_dlm.h>
 #include <linux/lustre_lib.h>
 
 /* invariants:
@@ -65,6 +68,10 @@ void l_lock(struct lustre_lock *lock)
                 owner = 1;
         spin_unlock(&lock->l_spin);
 
+        /* This is safe to increment outside the spinlock because we
+         * can only have 1 CPU running on the current task
+         * (i.e. l_owner == current), regardless of the number of CPUs.
+         */
         if (owner) {
                 ++lock->l_depth;
         } else {
@@ -78,9 +85,9 @@ void l_lock(struct lustre_lock *lock)
 
 void l_unlock(struct lustre_lock *lock)
 {
-        LASSERT(lock->l_owner == current);
-        LASSERT(lock->l_depth >= 0);
-
+        LASSERTF(lock->l_owner == current, "lock %p, current %p\n",
+                 lock->l_owner, current);
+        LASSERTF(lock->l_depth >= 0, "depth %d\n", lock->l_depth);
         spin_lock(&lock->l_spin);
         if (--lock->l_depth < 0) {
                 lock->l_owner = NULL;
@@ -106,3 +113,27 @@ int l_has_lock(struct lustre_lock *lock)
                 CDEBUG(D_INFO, "lock_depth: %d\n", depth);
         return owner;
 }
+
+#ifdef __KERNEL__
+#include <linux/lustre_version.h>
+void l_check_no_ns_lock(struct ldlm_namespace *ns)
+{
+        static unsigned long next_msg;
+
+        if (l_has_lock(&ns->ns_lock) && time_after(jiffies, next_msg)) {
+                CERROR("namespace %s lock held illegally; tell phil\n",
+                       ns->ns_name);
+                portals_debug_dumpstack(NULL);
+                next_msg = jiffies + 60 * HZ;
+        }
+}
+
+#else
+void l_check_no_ns_lock(struct ldlm_namespace *ns)
+{
+        if (l_has_lock(&ns->ns_lock)) {
+                CERROR("namespace %s lock held illegally; tell phil\n",
+                       ns->ns_name);
+        }
+}
+#endif /* __KERNEL__ */