Whamcloud - gitweb
Revert "LU-2459 osd: add LMA incompat flag check"
[fs/lustre-release.git] / lustre / lov / lov_lock.c
index 2424581..de55b2d 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2011, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -652,8 +652,19 @@ static int lov_lock_enqueue(const struct lu_env *env,
                                                                    sublock);
                                         break;
                                 case CLS_CACHED:
+                                       cl_lock_get(sublock);
+                                        /* take recursive mutex of sublock */
+                                        cl_lock_mutex_get(env, sublock);
+                                       /* need to release all locks in closure
+                                        * otherwise it may deadlock. LU-2683.*/
+                                        lov_sublock_unlock(env, sub, closure,
+                                                           subenv);
+                                       /* sublock and parent are held. */
                                         rc = lov_sublock_release(env, lck, i,
                                                                  1, rc);
+                                       cl_lock_mutex_put(env, sublock);
+                                       cl_lock_put(env, sublock);
+                                       break;
                                 default:
                                         lov_sublock_unlock(env, sub, closure,
                                                            subenv);
@@ -1007,6 +1018,11 @@ static int lov_lock_fits_into(const struct lu_env *env,
 
         ENTRY;
 
+       /* for top lock, it's necessary to match enq flags otherwise it will
+        * run into problem if a sublock is missing and reenqueue. */
+       if (need->cld_enq_flags != lov->lls_orig.cld_enq_flags)
+               return 0;
+
         if (need->cld_mode == CLM_GROUP)
                 /*
                  * always allow to match group lock.
@@ -1200,6 +1216,7 @@ static int lov_empty_lock_print(const struct lu_env *env, void *cookie,
        return 0;
 }
 
+/* XXX: more methods will be added later. */
 static const struct cl_lock_operations lov_empty_lock_ops = {
        .clo_fini  = lov_empty_lock_fini,
        .clo_print = lov_empty_lock_print