ma->ma_valid = 0;
mutex_lock(&o->mot_lov_mutex);
if (!(o->mot_flags & MOF_LOV_CREATED)) {
- if (p != NULL && !fid_is_md_operative(mdt_object_fid(p)))
- GOTO(unlock, rc = -EPERM);
-
rc = mdo_create_data(info->mti_env,
p ? mdt_object_child(p) : NULL,
mdt_object_child(o), spec, ma);
if (rc == 0 && ma->ma_valid & MA_LOV)
o->mot_flags |= MOF_LOV_CREATED;
}
-unlock:
+
mutex_unlock(&o->mot_lov_mutex);
RETURN(rc);
}
/* normal open holds read mode of open sem */
down_read(&obj->mot_open_sem);
- if (open_flags & FMODE_WRITE)
- lm = LCK_CW;
- else if (open_flags & MDS_FMODE_EXEC)
- lm = LCK_PR;
- else
- lm = LCK_CR;
-
if (open_flags & MDS_OPEN_LOCK) {
+ if (open_flags & FMODE_WRITE)
+ lm = LCK_CW;
+ else if (open_flags & MDS_FMODE_EXEC)
+ lm = LCK_PR;
+ else
+ lm = LCK_CR;
+
*ibits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_OPEN;
- } else if (open_flags & (FMODE_WRITE | MDS_FMODE_EXEC) ||
- atomic_read(&obj->mot_lease_count) > 0) {
- /* We need to flush conflicting locks or revoke a lease.
- * In either case there is no need to acquire a layout
- * lock since it won't be returned to the client. */
- try_layout = false;
+ } else if (atomic_read(&obj->mot_lease_count) > 0) {
+ if (open_flags & FMODE_WRITE)
+ lm = LCK_CW;
+ else
+ lm = LCK_CR;
+
+ /* revoke lease */
*ibits = MDS_INODELOCK_OPEN;
+ try_layout = false;
+
lhc = &info->mti_lh[MDT_LH_LOCAL];
}
-
- CDEBUG(D_INODE, "normal open FID = "DFID", open_count = %d, "
- "lm = %d\n",
- PFID(mdt_object_fid(obj)),
- atomic_read(&obj->mot_open_count), lm);
+ CDEBUG(D_INODE, "normal open:"DFID" lease count: %d, lm: %d\n",
+ PFID(mdt_object_fid(obj)),
+ atomic_read(&obj->mot_open_count), lm);
}
mdt_lock_reg_init(lhc, lm);
up_read(&obj->mot_open_sem);
/* Cross-ref case, the lock should be returned to the client */
- if (ibits == 0 || rc == -EREMOTE)
+ if (ibits == 0 || rc == -MDT_EREMOTE_OPEN)
RETURN_EXIT;
if (!(open_flags & MDS_OPEN_LOCK) && !(ibits & MDS_INODELOCK_LAYOUT)) {
ma->ma_need |= MA_PFID;
}
- o = mdt_object_find(env, mdt, rr->rr_fid2);
- if (IS_ERR(o))
- RETURN(rc = PTR_ERR(o));
+ o = mdt_object_find(env, mdt, rr->rr_fid2);
+ if (IS_ERR(o))
+ GOTO(out_parent_put, rc = PTR_ERR(o));
if (mdt_object_remote(o)) {
CDEBUG(D_INFO, "%s: "DFID" is on remote MDT.\n",
if (flags & MDS_OPEN_RELEASE && !mdt_hsm_release_allow(ma))
GOTO(out, rc = -EPERM);
- rc = mdt_object_open_lock(info, o, lhc, &ibits);
- if (rc)
- GOTO(out_unlock, rc);
+ rc = mdt_check_resent_lock(info, o, lhc);
+ if (rc < 0) {
+ GOTO(out, rc);
+ } else if (rc > 0) {
+ rc = mdt_object_open_lock(info, o, lhc, &ibits);
+ if (rc)
+ GOTO(out_unlock, rc);
+ }
if (ma->ma_valid & MA_PFID) {
parent = mdt_object_find(env, mdt, &ma->ma_pfid);
mdt_object_open_unlock(info, o, lhc, ibits, rc);
out:
mdt_object_put(env, o);
+out_parent_put:
if (parent != NULL)
mdt_object_put(env, parent);
return rc;
if (rc != 0)
GOTO(out, rc);
- /* Do not create lov object if the fid is opened
- * under OBF */
- if (S_ISREG(ma->ma_attr.la_mode) &&
- !(ma->ma_valid & MA_LOV) && (flags & FMODE_WRITE) &&
- fid_is_obf(parent_fid))
- GOTO(out, rc = -EPERM);
-
rc = mdt_finish_open(info, NULL, o, flags, 0, rep);
} else {
/*
GOTO(out, result = -EFAULT);
}
CDEBUG(D_INFO, "No object(1), continue as regular open.\n");
- } else if ((!lu_name_is_valid(&rr->rr_name) &&
- (create_flags & MDS_OPEN_LOCK)) ||
- (create_flags & MDS_OPEN_BY_FID)) {
+ } else if (create_flags & (MDS_OPEN_BY_FID | MDS_OPEN_LOCK)) {
+ /*
+ * MDS_OPEN_LOCK is checked for backward compatibility with 2.1
+ * client.
+ */
result = mdt_open_by_fid_lock(info, ldlm_rep, lhc);
- /* If result is 0 then open by FID has found the file
- * and there is nothing left for us to do here. More
- * generally if it is anything other than -ENOENT or
- * -EREMOTE then we return that now. If -ENOENT and
- * MDS_OPEN_CREAT is set then we must create the file
- * below. If -EREMOTE then we need to return a LOOKUP
- * lock to the client, which we do below. Hence this
- * odd looking condition. See LU-2523. */
- if (!(result == -ENOENT && (create_flags & MDS_OPEN_CREAT)) &&
- result != -EREMOTE)
- GOTO(out, result);
-
- CDEBUG(D_INFO, "No object(2), continue as regular open.\n");
+ if (result < 0)
+ CDEBUG(D_INFO, "no object for "DFID": %d\n",
+ PFID(rr->rr_fid2), result);
+ GOTO(out, result);
}
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK))
*/
LASSERT(lhc != NULL);
- if (lustre_handle_is_used(&lhc->mlh_reg_lh)) {
- struct ldlm_lock *lock;
-
- LASSERT(msg_flags & MSG_RESENT);
-
- lock = ldlm_handle2lock(&lhc->mlh_reg_lh);
- if (!lock) {
- CERROR("Invalid lock handle "LPX64"\n",
- lhc->mlh_reg_lh.cookie);
- LBUG();
- }
- LASSERT(fid_res_name_eq(mdt_object_fid(child),
- &lock->l_resource->lr_name));
- LDLM_LOCK_PUT(lock);
- rc = 0;
- } else {
+ rc = mdt_check_resent_lock(info, child, lhc);
+ if (rc < 0) {
+ GOTO(out_child, result = rc);
+ } else if (rc > 0) {
mdt_lock_handle_init(lhc);
mdt_lock_reg_init(lhc, LCK_PR);
if (rc != 0)
result = rc;
else
- result = -EREMOTE;
+ result = -MDT_EREMOTE_OPEN;
GOTO(out_child, result);
} else if (mdt_object_exists(child)) {
/* We have to get attr & LOV EA & HSM for this
}
}
- if (lustre_handle_is_used(&lhc->mlh_reg_lh)) {
+ rc = mdt_check_resent_lock(info, child, lhc);
+ if (rc < 0) {
+ GOTO(out_child, result = rc);
+ } else if (rc == 0) {
/* the open lock might already be gotten in
- * mdt_intent_fixup_resent */
+ * ldlm_handle_enqueue() */
LASSERT(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT);
if (create_flags & MDS_OPEN_LOCK)
mdt_set_disposition(info, ldlm_rep, DISP_OPEN_LOCK);