* needed here but update is.
*/
child_bits &= ~MDS_INODELOCK_LOOKUP;
- //child_bits |= MDS_INODELOCK_UPDATE;
+ child_bits |= MDS_INODELOCK_UPDATE;
rc = mdt_object_lock(info, child, lhc, child_bits);
}
if (rc == 0) {
} else {
mdt_lock_handle_init(lhc);
lhc->mlh_mode = LCK_CR;
- if (lu_object_exists(&child->mot_obj.mo_lu) < 0) {
- /* we should take LOOKUP lock for cross-ref object */
- child_bits &= ~MDS_INODELOCK_UPDATE;
- child_bits |= MDS_INODELOCK_LOOKUP;
- }
- mdt_object_lock(info, child, lhc, child_bits);
+ rc = mdt_object_cr_lock(info, child, lhc, child_bits);
+ if (rc != 0)
+ GOTO(out_child, rc);
}
/* finally, we can get attr for child. */
}
- mdt_object_put(info->mti_ctxt, child);
EXIT;
+out_child:
+ mdt_object_put(info->mti_ctxt, child);
out_parent:
mdt_object_unlock(info, parent, lhp, 1);
out:
LASSERT(!lustre_handle_is_used(&lh->mlh_lh));
LASSERT(lh->mlh_mode != LCK_MINMODE);
-#if 0
if (lu_object_exists(&o->mot_obj.mo_lu) < 0) {
LASSERT(!(ibits & MDS_INODELOCK_UPDATE));
LASSERT(ibits & MDS_INODELOCK_LOOKUP);
}
-#endif
policy->l_inodebits.bits = ibits;
rc = fid_lock(ns, mdt_object_fid(o), &lh->mlh_lh, lh->mlh_mode,
RETURN(rc);
}
+/* lock with cross-ref fixes */
+int mdt_object_cr_lock(struct mdt_thread_info *info, struct mdt_object *o,
+ struct mdt_lock_handle *lh, __u64 ibits)
+{
+ if (lu_object_exists(&o->mot_obj.mo_lu) < 0) {
+ /* cross-ref object fix */
+ ibits &= ~MDS_INODELOCK_UPDATE;
+ ibits |= MDS_INODELOCK_LOOKUP;
+ }
+ return mdt_object_lock(info, o, lh, ibits);
+}
+
/*
* Just call ldlm_lock_decref() if decref, else we only call ptlrpc_save_lock()
* to save this lock in req. when transaction committed, req will be released,
GOTO(out_unlock_parent, rc);
/* we will lock the child regardless it is local or remote. No harm. */
- mc = mdt_object_find_lock(info, child_fid, child_lh, MDS_INODELOCK_FULL);
+ mc = mdt_object_find(info->mti_ctxt, info->mti_mdt, child_fid);
if (IS_ERR(mc))
GOTO(out_unlock_parent, rc = PTR_ERR(mc));
+ rc = mdt_object_cr_lock(info, mc, lhc, MDS_INODELOCK_FULL);
+ if (rc != 0)
+ GOTO(out_put_child, rc);
mdt_fail_write(info->mti_ctxt, info->mti_mdt->mdt_bottom,
OBD_FAIL_MDS_REINT_UNLINK_WRITE);
GOTO(out_unlock_child, rc);
out_unlock_child:
- mdt_object_unlock_put(info, mc, child_lh, rc);
+ mdt_object_unlock(info, mc, lhc, rc);
+out_put_child:
+ mdt_object_put(info->mti_ctxt, mc);
out_unlock_parent:
mdt_object_unlock_put(info, mp, parent_lh, rc);
out: