Whamcloud - gitweb
LU-2193 ofd: look up FID to destroy before locking
[fs/lustre-release.git] / lustre / ldlm / ldlm_lockd.c
index c62a1a2..8dcde3e 100644 (file)
@@ -1012,17 +1012,31 @@ int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data)
        struct ptlrpc_request           *req;
        struct ldlm_cb_async_args       *ca;
        int                              rc;
+       struct req_format               *req_fmt;
         ENTRY;
 
         LASSERT(lock != NULL);
 
+       if (arg->gl_desc != NULL)
+               /* There is a glimpse descriptor to pack */
+               req_fmt = &RQF_LDLM_GL_DESC_CALLBACK;
+       else
+               req_fmt = &RQF_LDLM_GL_CALLBACK;
+
         req = ptlrpc_request_alloc_pack(lock->l_export->exp_imp_reverse,
-                                        &RQF_LDLM_GL_CALLBACK,
-                                        LUSTRE_DLM_VERSION, LDLM_GL_CALLBACK);
+                                       req_fmt, LUSTRE_DLM_VERSION,
+                                       LDLM_GL_CALLBACK);
 
         if (req == NULL)
                 RETURN(-ENOMEM);
 
+       if (arg->gl_desc != NULL) {
+               /* copy the GL descriptor */
+               union ldlm_gl_desc      *desc;
+               desc = req_capsule_client_get(&req->rq_pill, &RMF_DLM_GL_DESC);
+               *desc = *arg->gl_desc;
+       }
+
         body = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ);
         body->lock_handle[0] = lock->l_remote_handle;
         ldlm_lock2desc(lock, &body->lock_desc);
@@ -1067,6 +1081,22 @@ int ldlm_glimpse_locks(struct ldlm_resource *res, cfs_list_t *gl_work_list)
        RETURN(rc);
 }
 
+/* return ldlm lock associated with a lock callback request */
+struct ldlm_lock *ldlm_request_lock(struct ptlrpc_request *req)
+{
+       struct ldlm_cb_async_args       *ca;
+       struct ldlm_lock                *lock;
+       ENTRY;
+
+       ca = ptlrpc_req_async_args(req);
+       lock = ca->ca_lock;
+       if (lock == NULL)
+               RETURN(ERR_PTR(-EFAULT));
+
+       RETURN(lock);
+}
+EXPORT_SYMBOL(ldlm_request_lock);
+
 static void ldlm_svc_get_eopc(const struct ldlm_request *dlm_req,
                        struct lprocfs_stats *srv_stats)
 {
@@ -1476,6 +1506,9 @@ int ldlm_request_cancel(struct ptlrpc_request *req,
         if (first >= count)
                 RETURN(0);
 
+       if (count == 1 && dlm_req->lock_handle[0].cookie == 0)
+               RETURN(0);
+
         /* There is no lock on the server at the replay time,
          * skip lock cancelling to make replay tests to pass. */
         if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)
@@ -1953,19 +1986,19 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
         LASSERT(req->rq_export != NULL);
         LASSERT(req->rq_export->exp_obd != NULL);
 
-        switch (lustre_msg_get_opc(req->rq_reqmsg)) {
-        case LDLM_BL_CALLBACK:
-                if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_BL_CALLBACK))
-                        RETURN(0);
-                break;
-        case LDLM_CP_CALLBACK:
-                if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CP_CALLBACK))
-                        RETURN(0);
-                break;
-        case LDLM_GL_CALLBACK:
-                if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_GL_CALLBACK))
-                        RETURN(0);
-                break;
+       switch (lustre_msg_get_opc(req->rq_reqmsg)) {
+       case LDLM_BL_CALLBACK:
+               if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_BL_CALLBACK_NET))
+                       RETURN(0);
+               break;
+       case LDLM_CP_CALLBACK:
+               if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CP_CALLBACK_NET))
+                       RETURN(0);
+               break;
+       case LDLM_GL_CALLBACK:
+               if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_GL_CALLBACK_NET))
+                       RETURN(0);
+               break;
         case LDLM_SET_INFO:
                 rc = ldlm_handle_setinfo(req);
                 ldlm_callback_reply(req, rc);
@@ -1980,19 +2013,6 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
                         RETURN(0);
                 ldlm_callback_reply(req, rc);
                 RETURN(0);
-        case OBD_QC_CALLBACK:
-                req_capsule_set(&req->rq_pill, &RQF_QC_CALLBACK);
-                if (OBD_FAIL_CHECK(OBD_FAIL_OBD_QC_CALLBACK_NET))
-                        RETURN(0);
-                rc = target_handle_qc_callback(req);
-                ldlm_callback_reply(req, rc);
-                RETURN(0);
-        case QUOTA_DQACQ:
-        case QUOTA_DQREL:
-                /* reply in handler */
-                req_capsule_set(&req->rq_pill, &RQF_MDS_QUOTA_DQACQ);
-                rc = target_handle_dqacq_callback(req);
-                RETURN(0);
         case LLOG_ORIGIN_HANDLE_CREATE:
                 req_capsule_set(&req->rq_pill, &RQF_LLOG_ORIGIN_HANDLE_CREATE);
                 if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET))
@@ -2174,8 +2194,8 @@ static int ldlm_cancel_handler(struct ptlrpc_request *req)
         case LDLM_CANCEL:
                 req_capsule_set(&req->rq_pill, &RQF_LDLM_CANCEL);
                 CDEBUG(D_INODE, "cancel\n");
-                if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL))
-                        RETURN(0);
+               if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_NET))
+                       RETURN(0);
                 rc = ldlm_handle_cancel(req);
                 if (rc)
                         break;