+ if (unlikely(dlm_req->lock_desc.l_req_mode <= LCK_MINMODE ||
+ dlm_req->lock_desc.l_req_mode >= LCK_MAXMODE ||
+ dlm_req->lock_desc.l_req_mode &
+ (dlm_req->lock_desc.l_req_mode-1))) {
+ DEBUG_REQ(D_ERROR, req, "invalid lock request mode %d",
+ dlm_req->lock_desc.l_req_mode);
+ GOTO(out, rc = -EFAULT);
+ }
+
+ if (req->rq_export->exp_connect_flags & OBD_CONNECT_IBITS) {
+ if (unlikely(dlm_req->lock_desc.l_resource.lr_type ==
+ LDLM_PLAIN)) {
+ DEBUG_REQ(D_ERROR, req,
+ "PLAIN lock request from IBITS client?");
+ GOTO(out, rc = -EPROTO);
+ }
+ } else if (unlikely(dlm_req->lock_desc.l_resource.lr_type ==
+ LDLM_IBITS)) {
+ DEBUG_REQ(D_ERROR, req,
+ "IBITS lock request from unaware client?");
+ GOTO(out, rc = -EPROTO);
+ }
+
+#if 0
+ /* FIXME this makes it impossible to use LDLM_PLAIN locks -- check
+ against server's _CONNECT_SUPPORTED flags? (I don't want to use
+ ibits for mgc/mgs) */
+
+ /* INODEBITS_INTEROP: Perform conversion from plain lock to
+ * inodebits lock if client does not support them. */
+ if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_IBITS) &&
+ (dlm_req->lock_desc.l_resource.lr_type == LDLM_PLAIN)) {
+ dlm_req->lock_desc.l_resource.lr_type = LDLM_IBITS;
+ dlm_req->lock_desc.l_policy_data.l_inodebits.bits =
+ MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE;
+ if (dlm_req->lock_desc.l_req_mode == LCK_PR)
+ dlm_req->lock_desc.l_req_mode = LCK_CR;
+ }
+#endif
+
+ if (unlikely(flags & LDLM_FL_REPLAY)) {
+ /* Find an existing lock in the per-export lock hash */
+ lock = lustre_hash_lookup(req->rq_export->exp_lock_hash,
+ (void *)&dlm_req->lock_handle[0]);
+ if (lock != NULL) {
+ DEBUG_REQ(D_DLMTRACE, req, "found existing lock cookie "
+ LPX64, lock->l_handle.h_cookie);
+ GOTO(existing_lock, rc = 0);
+ }
+ }