- struct ldlm_resource *res;
- int rc;
- ENTRY;
- if (ns_is_client(ldlm_lock_to_ns(lock))) {
- CERROR("Trying to cancel local lock\n");
- LBUG();
- }
- LDLM_DEBUG(lock, "client-side local convert");
-
- res = ldlm_lock_convert(lock, new_mode, flags);
- if (res) {
- ldlm_reprocess_all(res);
- rc = 0;
- } else {
- rc = LUSTRE_EDEADLK;
- }
- LDLM_DEBUG(lock, "client-side local convert handler END");
- LDLM_LOCK_PUT(lock);
- RETURN(rc);
-}
+ struct ldlm_request *body;
+ struct ptlrpc_request *req;
+ struct obd_export *exp = lock->l_conn_export;
+
+ ENTRY;
+
+ LASSERT(exp != NULL);
+
+ /*
+ * this is better to check earlier and it is done so already,
+ * but this check is kept too as final one to issue an error
+ * if any new code will miss such check.
+ */
+ if (!exp_connect_lock_convert(exp)) {
+ LDLM_ERROR(lock, "server doesn't support lock convert\n");
+ RETURN(-EPROTO);
+ }
+
+ if (lock->l_resource->lr_type != LDLM_IBITS) {
+ LDLM_ERROR(lock, "convert works with IBITS locks only.");
+ RETURN(-EINVAL);
+ }
+
+ LDLM_DEBUG(lock, "client-side convert");
+
+ req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
+ &RQF_LDLM_CONVERT, LUSTRE_DLM_VERSION,
+ LDLM_CONVERT);
+ if (req == NULL)
+ RETURN(-ENOMEM);
+
+ body = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ);
+ body->lock_handle[0] = lock->l_remote_handle;
+
+ body->lock_desc.l_req_mode = lock->l_req_mode;
+ body->lock_desc.l_granted_mode = lock->l_granted_mode;
+
+ body->lock_desc.l_policy_data.l_inodebits.bits = new_bits;
+ body->lock_desc.l_policy_data.l_inodebits.cancel_bits = 0;