Whamcloud - gitweb
LU-2827 ldlm: wrong handling of ldlm resends
[fs/lustre-release.git] / lustre / ldlm / ldlm_inodebits.c
index e10a654..4f505d5 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -187,11 +187,16 @@ int ldlm_process_inodebits_lock(struct ldlm_lock *lock, __u64 *flags,
         int rc;
         ENTRY;
 
-        LASSERT(cfs_list_empty(&res->lr_converting));
-        check_res_locked(res);
+       LASSERT(lock->l_granted_mode != lock->l_req_mode);
+       LASSERT(cfs_list_empty(&res->lr_converting));
+       check_res_locked(res);
+
+       /* (*flags & LDLM_FL_BLOCK_NOWAIT) is for layout lock right now. */
+        if (!first_enq || (*flags & LDLM_FL_BLOCK_NOWAIT)) {
+               *err = ELDLM_LOCK_ABORTED;
+               if (*flags & LDLM_FL_BLOCK_NOWAIT)
+                       *err = ELDLM_LOCK_WOULDBLOCK;
 
-        if (!first_enq) {
-                LASSERT(work_list != NULL);
                 rc = ldlm_inodebits_compat_queue(&res->lr_granted, lock, NULL);
                 if (!rc)
                         RETURN(LDLM_ITER_STOP);
@@ -201,6 +206,8 @@ int ldlm_process_inodebits_lock(struct ldlm_lock *lock, __u64 *flags,
 
                 ldlm_resource_unlink_lock(lock);
                 ldlm_grant_lock(lock, work_list);
+
+               *err = ELDLM_OK;
                 RETURN(LDLM_ITER_CONTINUE);
         }