Whamcloud - gitweb
LU-8347 ldlm: granting conflicting locks
[fs/lustre-release.git] / lustre / ldlm / ldlm_lock.c
index 10f8e8f..03ba8c2 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -383,16 +379,6 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
         ldlm_lock_remove_from_lru(lock);
         class_handle_unhash(&lock->l_handle);
 
-#if 0
-        /* Wake anyone waiting for this lock */
-        /* FIXME: I should probably add yet another flag, instead of using
-         * l_export to only call this on clients */
-        if (lock->l_export)
-                class_export_put(lock->l_export);
-        lock->l_export = NULL;
-        if (lock->l_export && lock->l_completion_ast)
-                lock->l_completion_ast(lock, 0);
-#endif
         EXIT;
         return 1;
 }
@@ -603,6 +589,13 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle,
        if (lock == NULL)
                RETURN(NULL);
 
+       if (lock->l_export != NULL && lock->l_export->exp_failed) {
+               CDEBUG(D_INFO, "lock export failed: lock %p, exp %p\n",
+                      lock, lock->l_export);
+               LDLM_LOCK_PUT(lock);
+               RETURN(NULL);
+       }
+
        /* It's unlikely but possible that someone marked the lock as
         * destroyed after we did handle2object on it */
        if ((flags == 0) && !ldlm_is_destroyed(lock)) {
@@ -719,7 +712,7 @@ void ldlm_lock_addref(const struct lustre_handle *lockh, enum ldlm_mode mode)
        struct ldlm_lock *lock;
 
        lock = ldlm_handle2lock(lockh);
-       LASSERTF(lock != NULL, "Non-existing lock: "LPX64"\n", lockh->cookie);
+       LASSERTF(lock != NULL, "Non-existing lock: %#llx\n", lockh->cookie);
        ldlm_lock_addref_internal(lock, mode);
        LDLM_LOCK_PUT(lock);
 }
@@ -903,7 +896,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, enum ldlm_mode mode)
 void ldlm_lock_decref(const struct lustre_handle *lockh, enum ldlm_mode mode)
 {
         struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0);
-        LASSERTF(lock != NULL, "Non-existing lock: "LPX64"\n", lockh->cookie);
+       LASSERTF(lock != NULL, "Non-existing lock: %#llx\n", lockh->cookie);
         ldlm_lock_decref_internal(lock, mode);
         LDLM_LOCK_PUT(lock);
 }
@@ -1470,7 +1463,7 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags,
         }
  out2:
         if (rc) {
-                LDLM_DEBUG(lock, "matched ("LPU64" "LPU64")",
+               LDLM_DEBUG(lock, "matched (%llu %llu)",
                            (type == LDLM_PLAIN || type == LDLM_IBITS) ?
                                 res_id->name[2] : policy->l_extent.start,
                            (type == LDLM_PLAIN || type == LDLM_IBITS) ?
@@ -1490,7 +1483,7 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags,
 
         } else if (!(flags & LDLM_FL_TEST_LOCK)) {/*less verbose for test-only*/
                 LDLM_DEBUG_NOLOCK("not matched ns %p type %u mode %u res "
-                                  LPU64"/"LPU64" ("LPU64" "LPU64")", ns,
+                                 "%llu/%llu (%llu %llu)", ns,
                                   type, mode, res_id->name[0], res_id->name[1],
                                   (type == LDLM_PLAIN || type == LDLM_IBITS) ?
                                         res_id->name[2] :policy->l_extent.start,
@@ -2151,6 +2144,7 @@ void ldlm_reprocess_all(struct ldlm_resource *res)
 {
        struct list_head rpc_list;
 #ifdef HAVE_SERVER_SUPPORT
+       struct obd_device *obd;
         int rc;
         ENTRY;
 
@@ -2161,6 +2155,13 @@ void ldlm_reprocess_all(struct ldlm_resource *res)
                 return;
         }
 
+       /* Disable reprocess during lock replay stage but allow during
+        * request replay stage.
+        */
+       obd = ldlm_res_to_ns(res)->ns_obd;
+       if (obd->obd_recovering &&
+           atomic_read(&obd->obd_req_replay_clients) == 0)
+               RETURN_EXIT;
 restart:
         lock_res(res);
         rc = ldlm_reprocess_queue(res, &res->lr_converting, &rpc_list);
@@ -2630,9 +2631,9 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 
         if (resource == NULL) {
                 libcfs_debug_vmsg2(msgdata, fmt, args,
-                       " ns: \?\? lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s "
-                       "res: \?\? rrc=\?\? type: \?\?\? flags: "LPX64" nid: %s "
-                       "remote: "LPX64" expref: %d pid: %u timeout: %lu "
+                      " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s "
+                      "res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s "
+                      "remote: %#llx expref: %d pid: %u timeout: %lu "
                       "lvb_type: %d\n",
                        lock,
                       lock->l_handle.h_cookie, atomic_read(&lock->l_refc),
@@ -2649,10 +2650,10 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
        switch (resource->lr_type) {
        case LDLM_EXTENT:
                libcfs_debug_vmsg2(msgdata, fmt, args,
-                       " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s "
-                       "res: "DLDLMRES" rrc: %d type: %s ["LPU64"->"LPU64"] "
-                       "(req "LPU64"->"LPU64") flags: "LPX64" nid: %s remote: "
-                       LPX64" expref: %d pid: %u timeout: %lu lvb_type: %d\n",
+                       " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s "
+                       "res: "DLDLMRES" rrc: %d type: %s [%llu->%llu] "
+                       "(req %llu->%llu) flags: %#llx nid: %s remote: "
+                       "%#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
                        ldlm_lock_to_ns_name(lock), lock,
                        lock->l_handle.h_cookie, atomic_read(&lock->l_refc),
                        lock->l_readers, lock->l_writers,
@@ -2672,10 +2673,10 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 
        case LDLM_FLOCK:
                libcfs_debug_vmsg2(msgdata, fmt, args,
-                       " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s "
+                       " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s "
                        "res: "DLDLMRES" rrc: %d type: %s pid: %d "
-                       "["LPU64"->"LPU64"] flags: "LPX64" nid: %s "
-                       "remote: "LPX64" expref: %d pid: %u timeout: %lu\n",
+                       "[%llu->%llu] flags: %#llx nid: %s "
+                       "remote: %#llx expref: %d pid: %u timeout: %lu\n",
                        ldlm_lock_to_ns_name(lock), lock,
                        lock->l_handle.h_cookie, atomic_read(&lock->l_refc),
                        lock->l_readers, lock->l_writers,
@@ -2694,9 +2695,9 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 
        case LDLM_IBITS:
                libcfs_debug_vmsg2(msgdata, fmt, args,
-                       " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s "
-                       "res: "DLDLMRES" bits "LPX64" rrc: %d type: %s "
-                       "flags: "LPX64" nid: %s remote: "LPX64" expref: %d "
+                       " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s "
+                       "res: "DLDLMRES" bits %#llx rrc: %d type: %s "
+                       "flags: %#llx nid: %s remote: %#llx expref: %d "
                        "pid: %u timeout: %lu lvb_type: %d\n",
                        ldlm_lock_to_ns_name(lock),
                        lock, lock->l_handle.h_cookie,
@@ -2716,9 +2717,9 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 
        default:
                libcfs_debug_vmsg2(msgdata, fmt, args,
-                       " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s "
-                       "res: "DLDLMRES" rrc: %d type: %s flags: "LPX64" "
-                       "nid: %s remote: "LPX64" expref: %d pid: %u "
+                       " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s "
+                       "res: "DLDLMRES" rrc: %d type: %s flags: %#llx "
+                       "nid: %s remote: %#llx expref: %d pid: %u "
                        "timeout: %lu lvb_type: %d\n",
                        ldlm_lock_to_ns_name(lock),
                        lock, lock->l_handle.h_cookie,