LASSERT(S_ISDIR(lu_object_attr(&mo->mo_lu)));
memset(ma, 0, sizeof(*ma));
+
/* Step1: Checking whether the dir needs to be split. */
rc = cmm_expect_splitting(env, mo, ma, &split);
if (rc)
RETURN(rc);
+
if (split != CMM_EXPECT_SPLIT)
RETURN(0);
- LASSERTF(mo->mo_pdo_mode == MDL_EX, "Split is only valid if "
- "dir is protected by MDL_EX lock. Lock mode 0x%x\n",
- (int)mo->mo_pdo_mode);
-
/*
* Disable trans for splitting, since there will be so many trans in
* this one ops, confilct with current recovery design.
GOTO(cleanup, rc);
}
- /* step2: Prepare the md memory */
+ /* Step2: Prepare the md memory */
ma->ma_lmv_size = CMM_MD_SIZE(cmm->cmm_tgt_count + 1);
OBD_ALLOC(ma->ma_lmv, ma->ma_lmv_size);
if (ma->ma_lmv == NULL)
/* Finally, split succeed, tell client to recreate the object */
CWARN("Dir "DFID" has been split\n", PFID(lu_object_fid(&mo->mo_lu)));
rc = -ERESTART;
+ EXIT;
cleanup:
OBD_FREE(ma->ma_lmv, ma->ma_lmv_size);
- RETURN(rc);
+ return rc;
}
int cmm_mdsnum_check(const struct lu_env *env, struct md_object *mp,
struct lu_object mo_lu;
struct md_object_operations *mo_ops;
struct md_dir_operations *mo_dir_ops;
-
- /*
- * XXX: This is for debug only, to check on all layers lock mode on the
- * object. This is useful say for split. Split should be protected by EX
- * lock and this should be checked in cmm split code.
- */
- mdl_mode_t mo_reg_mode;
- mdl_mode_t mo_pdo_mode;
};
static inline int lu_device_is_md(const struct lu_device *d)
*mds = 0;
rc = -ENOSYS;
}
-exit:
+
if (rc) {
CERROR("Can't choose MDS, err = %d\n", rc);
} else {
RETURN(m);
}
-/* XXX: This is for debug only. */
-static inline void mdt_object_set_mode(struct mdt_object *o,
- struct mdt_lock_handle *lh)
-{
- struct md_object *n = mdt_object_child(o);
- mdl_mode_t reg_mode, pdo_mode;
-
- pdo_mode = mdt_dlm_mode2mdl_mode(lh->mlh_pdo_mode);
- reg_mode = mdt_dlm_mode2mdl_mode(lh->mlh_reg_mode);
-
- if (lh->mlh_pdo_lh.cookie != 0)
- o->mot_obj.mo_pdo_mode = pdo_mode;
- else
- o->mot_obj.mo_pdo_mode = MDL_MINMODE;
-
- if (lh->mlh_reg_lh.cookie != 0)
- o->mot_obj.mo_reg_mode = reg_mode;
- else
- o->mot_obj.mo_reg_mode = MDL_MINMODE;
-
- n->mo_pdo_mode = o->mot_obj.mo_pdo_mode;
- n->mo_reg_mode = o->mot_obj.mo_reg_mode;
-}
-
int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o,
struct mdt_lock_handle *lh, __u64 ibits, int locality)
{
mdt_fid_unlock(&lh->mlh_pdo_lh, lh->mlh_pdo_mode);
lh->mlh_pdo_lh.cookie = 0ull;
}
-
- if (rc == 0)
- mdt_object_set_mode(o, lh);
RETURN(rc);
}
lh->mlh_reg_lh.cookie = 0;
}
- mdt_object_set_mode(o, lh);
-
EXIT;
}