Whamcloud - gitweb
LU-5260 llite: removing ll_cl_context when error occurs
[fs/lustre-release.git] / lustre / ofd / ofd_dlm.c
index 22effa0..6337548 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -88,7 +88,7 @@ static enum interval_iter ofd_intent_cb(struct interval_node *n, void *args)
 }
 
 int ofd_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp,
-                     void *req_cookie, ldlm_mode_t mode, int flags,
+                     void *req_cookie, ldlm_mode_t mode, __u64 flags,
                      void *data)
 {
        struct ptlrpc_request           *req = req_cookie;
@@ -98,8 +98,7 @@ int ofd_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp,
        struct ost_lvb                  *res_lvb, *reply_lvb;
        struct ldlm_reply               *rep;
        ldlm_error_t                     err;
-       int                              idx, rc;
-       int                              tmpflags = 0, only_liblustre = 1;
+       int                              idx, rc, only_liblustre = 1;
        struct ldlm_interval_tree       *tree;
        struct ofd_intent_args           arg;
        __u32                            repsize[3] = {
@@ -111,6 +110,7 @@ int ofd_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp,
        CFS_LIST_HEAD(gl_list);
        ENTRY;
 
+       lock->l_lvb_type = LVB_T_OST;
        policy = ldlm_get_processing_policy(res);
        LASSERT(policy != NULL);
        LASSERT(req != NULL);
@@ -141,8 +141,17 @@ int ofd_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp,
 
        LASSERT(ns == ldlm_res_to_ns(res));
        lock_res(res);
-       rc = policy(lock, &tmpflags, 0, &err, NULL);
-       check_res_locked(res);
+
+       /* Check if this is a resend case (MSG_RESENT is set on RPC) and a
+        * lock was found by ldlm_handle_enqueue(); if so no need to grant
+        * it again. */
+       if (flags & LDLM_FL_RESENT) {
+               rc = LDLM_ITER_CONTINUE;
+       } else {
+               __u64 tmpflags = 0;
+               rc = policy(lock, &tmpflags, 0, &err, NULL);
+               check_res_locked(res);
+       }
 
        /* The lock met with no resistance; we're finished. */
        if (rc == LDLM_ITER_CONTINUE) {
@@ -223,7 +232,7 @@ int ofd_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp,
         */
        if (l->l_glimpse_ast == NULL) {
                /* We are racing with unlink(); just return -ENOENT */
-               rep->lock_policy_res1 = -ENOENT;
+               rep->lock_policy_res1 = ptlrpc_status_hton(-ENOENT);
                goto out;
        }
 
@@ -234,6 +243,9 @@ int ofd_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp,
        /* The glimpse callback is sent to one single extent lock. As a result,
         * the gl_work list is just composed of one element */
        cfs_list_add_tail(&gl_work.gl_list, &gl_list);
+       /* There is actually no need for a glimpse descriptor when glimpsing
+        * extent locks */
+       gl_work.gl_desc = NULL;
        /* the ldlm_glimpse_work structure is allocated on the stack */
        gl_work.gl_flags = LDLM_GL_WORK_NOFREE;