Whamcloud - gitweb
LU-3200 mdc: layout lock rpc must not take rpc_lock
[fs/lustre-release.git] / lustre / mdc / mdc_locks.c
index c17feed..f2d666f 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -117,7 +117,8 @@ EXPORT_SYMBOL(it_open_error);
 int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data,
                       __u64 *bits)
 {
-        struct ldlm_lock *lock;
+       struct ldlm_lock *lock;
+       struct inode *new_inode = data;
         ENTRY;
 
         if(bits)
@@ -131,18 +132,18 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data,
         LASSERT(lock != NULL);
         lock_res_and_lock(lock);
 #ifdef __KERNEL__
-        if (lock->l_ast_data && lock->l_ast_data != data) {
-                struct inode *new_inode = data;
-                struct inode *old_inode = lock->l_ast_data;
-                LASSERTF(old_inode->i_state & I_FREEING,
-                         "Found existing inode %p/%lu/%u state %lu in lock: "
-                         "setting data to %p/%lu/%u\n", old_inode,
-                         old_inode->i_ino, old_inode->i_generation,
-                         old_inode->i_state,
-                         new_inode, new_inode->i_ino, new_inode->i_generation);
-        }
+       if (lock->l_resource->lr_lvb_inode &&
+           lock->l_resource->lr_lvb_inode != data) {
+               struct inode *old_inode = lock->l_resource->lr_lvb_inode;
+               LASSERTF(old_inode->i_state & I_FREEING,
+                        "Found existing inode %p/%lu/%u state %lu in lock: "
+                        "setting data to %p/%lu/%u\n", old_inode,
+                        old_inode->i_ino, old_inode->i_generation,
+                        old_inode->i_state,
+                        new_inode, new_inode->i_ino, new_inode->i_generation);
+       }
 #endif
-        lock->l_ast_data = data;
+       lock->l_resource->lr_lvb_inode = new_inode;
         if (bits)
                 *bits = lock->l_policy_data.l_inodebits.bits;
 
@@ -186,19 +187,28 @@ int mdc_cancel_unused(struct obd_export *exp,
         RETURN(rc);
 }
 
-int mdc_change_cbdata(struct obd_export *exp,
-                      const struct lu_fid *fid,
-                      ldlm_iterator_t it, void *data)
+int mdc_null_inode(struct obd_export *exp,
+                  const struct lu_fid *fid)
 {
-        struct ldlm_res_id res_id;
-        ENTRY;
+       struct ldlm_res_id res_id;
+       struct ldlm_resource *res;
+       struct ldlm_namespace *ns = class_exp2obd(exp)->obd_namespace;
+       ENTRY;
 
-        fid_build_reg_res_name(fid, &res_id);
-        ldlm_resource_iterate(class_exp2obd(exp)->obd_namespace,
-                              &res_id, it, data);
+       LASSERTF(ns != NULL, "no namespace passed\n");
 
-        EXIT;
-        return 0;
+       fid_build_reg_res_name(fid, &res_id);
+
+       res = ldlm_resource_get(ns, NULL, &res_id, 0, 0);
+       if(res == NULL)
+               RETURN(0);
+
+       lock_res(res);
+       res->lr_lvb_inode = NULL;
+       unlock_res(res);
+
+       ldlm_resource_putref(res);
+       RETURN(0);
 }
 
 /* find any ldlm lock of the inode in mdc
@@ -836,6 +846,9 @@ resend:
         lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP);
         LASSERT(lockrep != NULL);
 
+       lockrep->lock_policy_res2 =
+               ptlrpc_status_ntoh(lockrep->lock_policy_res2);
+
         /* Retry the create infinitely when we get -EINPROGRESS from
          * server. This is required by the new quota design. */
         if (it && it->it_op & IT_CREAT &&
@@ -877,7 +890,7 @@ static int mdc_finish_intent_lock(struct obd_export *exp,
         struct mdt_body *mdt_body;
         struct ldlm_lock *lock;
         int rc;
-
+       ENTRY;
 
         LASSERT(request != NULL);
         LASSERT(request != LP_POISON);
@@ -1135,6 +1148,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env,
         struct lookup_intent     *it;
         struct lustre_handle     *lockh;
         struct obd_device        *obddev;
+       struct ldlm_reply        *lockrep;
        __u64                     flags = LDLM_FL_HAS_INTENT;
         ENTRY;
 
@@ -1155,6 +1169,12 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env,
                 GOTO(out, rc);
         }
 
+       lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP);
+       LASSERT(lockrep != NULL);
+
+       lockrep->lock_policy_res2 =
+               ptlrpc_status_ntoh(lockrep->lock_policy_res2);
+
         rc = mdc_finish_enqueue(exp, req, einfo, it, lockh, rc);
         if (rc)
                 GOTO(out, rc);