if (rc != 0)
mdt_set_disposition(info, rep, DISP_LOOKUP_EXECD);
- /* Cross-ref case, the lock should be returned to the client */
- if (rc == -EREMOTE) {
- LASSERT(lustre_handle_is_used(&lhc->mlh_reg_lh));
- rep->lock_policy_res2 = 0;
- rc = mdt_intent_lock_replace(info, lockp, NULL, lhc, flags);
- RETURN(rc);
- }
- rep->lock_policy_res2 = clear_serious(rc);
+ /* the open lock or the lock for cross-ref object should be
+ * returned to the client */
+ if (rc == -EREMOTE || mdt_get_disposition(rep, DISP_OPEN_LOCK)) {
+ LASSERT(lustre_handle_is_used(&lhc->mlh_reg_lh));
+ rep->lock_policy_res2 = 0;
+ rc = mdt_intent_lock_replace(info, lockp, NULL, lhc, flags);
+ RETURN(rc);
+ }
+
+ rep->lock_policy_res2 = clear_serious(rc);
if (rep->lock_policy_res2 == -ENOENT &&
mdt_get_disposition(rep, DISP_LOOKUP_NEG))
* that looks like it was actually almost succesful and a failure at the
* same time */
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_NEGATIVE_POSITIVE)) {
- mdt_set_disposition(info, rep, DISP_OPEN_LOCK | \
- DISP_OPEN_OPEN | DISP_LOOKUP_NEG | \
- DISP_LOOKUP_POS);
+ mdt_set_disposition(info, rep, DISP_OPEN_OPEN |
+ DISP_LOOKUP_NEG |
+ DISP_LOOKUP_POS);
+
+ if (flags & MDS_OPEN_LOCK)
+ mdt_set_disposition(info, rep, DISP_OPEN_LOCK);
+
RETURN(-ENOENT);
}
* if open or layout lock is granted. */
rc = 1;
}
- if (rc != 0)
+
+ if (rc != 0) {
+ struct ldlm_reply *ldlm_rep;
+
+ ldlm_rep = req_capsule_server_get(info->mti_pill, &RMF_DLM_REP);
+ mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_LOCK);
mdt_object_unlock(info, obj, lhc, 1);
+ }
}
int mdt_open_by_fid_lock(struct mdt_thread_info *info, struct ldlm_reply *rep,
/* get openlock if this is not replay and if a client requested it */
if (!req_is_replay(req)) {
rc = mdt_object_open_lock(info, child, lhc, &ibits);
- if (rc != 0) {
+ if (rc != 0)
GOTO(out_child, result = rc);
- } else if (create_flags & MDS_OPEN_LOCK) {
- result = -EREMOTE;
+ else if (create_flags & MDS_OPEN_LOCK)
mdt_set_disposition(info, ldlm_rep, DISP_OPEN_LOCK);
- }
}
/* Try to open it now. */
lname,
&info->mti_attr, 0);
if (rc != 0)
- CERROR("Error in cleanup of open\n");
+ CERROR("%s: "DFID" cleanup of open: rc = %d\n",
+ mdt_obd_name(info->mti_mdt),
+ PFID(mdt_object_fid(child)), rc);
mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_CREATE);
}
}
out_parent:
mdt_object_unlock_put(info, parent, lh, result || !created);
out:
- if (result && result != -EREMOTE)
- lustre_msg_set_transno(req->rq_repmsg, 0);
- return result;
+ if (result)
+ lustre_msg_set_transno(req->rq_repmsg, 0);
+ return result;
}
#define MFD_CLOSED(mode) (((mode) & ~(MDS_FMODE_EPOCH | MDS_FMODE_SOM | \