Whamcloud - gitweb
LU-8175 ldlm: conflicting PW & PR extent locks on a client
[fs/lustre-release.git] / lustre / ldlm / ldlm_extent.c
index 721e458..b51265f 100644 (file)
@@ -1035,6 +1035,26 @@ void ldlm_extent_add_lock(struct ldlm_resource *res,
         /* even though we use interval tree to manage the extent lock, we also
          * add the locks into grant list, for debug purpose, .. */
         ldlm_resource_add_lock(res, &res->lr_granted, lock);
+
+       if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_GRANT_CHECK)) {
+               struct ldlm_lock *lck;
+
+               list_for_each_entry_reverse(lck, &res->lr_granted,
+                                           l_res_link) {
+                       if (lck == lock)
+                               continue;
+                       if (lockmode_compat(lck->l_granted_mode,
+                                           lock->l_granted_mode))
+                               continue;
+                       if (ldlm_extent_overlap(&lck->l_req_extent,
+                                               &lock->l_req_extent)) {
+                               CDEBUG(D_ERROR, "granting conflicting lock %p "
+                                               "%p\n", lck, lock);
+                               ldlm_resource_dump(D_ERROR, res);
+                               LBUG();
+                       }
+               }
+       }
 }
 
 /** Remove cancelled lock from resource interval tree. */