}
#ifdef HAVE_SPLIT_SUPPORT
-enum {
+enum cmm_split_state {
CMM_SPLIT_UNKNOWN,
CMM_SPLIT_NONE,
CMM_SPLIT_NEEDED,
CMM_SPLIT_DENIED
};
#endif
+
struct cmm_object {
struct md_object cmo_obj;
};
/* local CMM object */
struct cml_object {
- struct cmm_object cmm_obj;
+ struct cmm_object cmm_obj;
#ifdef HAVE_SPLIT_SUPPORT
/* split state of object (for dirs only)*/
- __u32 clo_split;
+ enum cmm_split_state clo_split;
#endif
};
ENTRY;
LASSERT(spec->u.sp_pfid != NULL);
+ LASSERT(S_ISDIR(la->la_mode));
mci = mdc_info_init(env);
mci->mci_opdata.fid2 = *lu_object_fid(&mo->mo_lu);
/* parent fid is needed to create dotdot on the remote node */
RETURN(rc);
}
-
+/*
+ * Return resulting fid in sfid
+ * 0: fids are not relatives
+ * fid: fid at which search stopped
+ */
static int mdc_is_subdir(const struct lu_env *env, struct md_object *mo,
const struct lu_fid *fid, struct lu_fid *sfid)
{
rc = md_is_subdir(mc->mc_desc.cl_exp, lu_object_fid(&mo->mo_lu),
fid, &mci->mci_req);
- if (rc)
- GOTO(out, rc);
-
- body = lustre_msg_buf(mci->mci_req->rq_repmsg, REPLY_REC_OFF,
- sizeof(*body));
-
- LASSERT(body->valid & (OBD_MD_FLMODE | OBD_MD_FLID) &&
- (body->mode == 0 || body->mode == 1 || body->mode == EREMOTE));
-
- rc = body->mode;
- if (rc == EREMOTE) {
- CDEBUG(D_INFO, "Remote mdo_is_subdir(), new src "
- DFID"\n", PFID(&body->fid1));
+ if (rc == 0 || rc == -EREMOTE) {
+ body = lustre_msg_buf(mci->mci_req->rq_repmsg, REPLY_REC_OFF,
+ sizeof(*body));
+ LASSERT(body->valid & OBD_MD_FLID);
+
+ CDEBUG(D_INFO, "Remote mdo_is_subdir(), new src "DFID"\n",
+ PFID(&body->fid1));
*sfid = body->fid1;
- rc = -EREMOTE;
}
EXIT;
out:
ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
- if (rc != 0)
+ if (rc != 0 && rc != -EREMOTE)
GOTO(out, rc);
body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
RETURN(0);
rc = mdd_is_parent(env, mdd, md2mdd_obj(mo), fid, sfid);
-
+ if (rc == 0) {
+ /* found root */
+ fid_zero(sfid);
+ } else if (rc == 1) {
+ /* found @fid is parent */
+ *sfid = *fid;
+ rc = 0;
+ }
RETURN(rc);
}
LASSERT(mdt_object_exists(o) > 0);
rc = mdo_is_subdir(info->mti_env, mdt_object_child(o),
&body->fid2, &repbody->fid1);
- if (rc < 0 && rc != -EREMOTE)
- RETURN(rc);
-
- /*
- * Save error code to ->mode. Later it it is used for detecting the case
- * of remote subdir.
- */
- repbody->mode = rc < 0 ? -rc : rc;
- repbody->valid = OBD_MD_FLMODE;
-
- if (rc == -EREMOTE)
+ if (rc == 0 || rc == -EREMOTE)
repbody->valid |= OBD_MD_FLID;
- RETURN(0);
+ RETURN(rc);
}
static int mdt_raw_lookup(struct mdt_thread_info *info,
ENTRY;
do {
+ LASSERT(fid_is_sane(&dst_fid));
dst = mdt_object_find(info->mti_env, info->mti_mdt, &dst_fid);
if (!IS_ERR(dst)) {
- rc = mdo_is_subdir(info->mti_env, mdt_object_child(dst),
- fid, &dst_fid);
+ rc = mdo_is_subdir(info->mti_env,
+ mdt_object_child(dst), fid,
+ &dst_fid);
mdt_object_put(info->mti_env, dst);
- if (rc < 0 && rc != -EREMOTE) {
+ if (rc != -EREMOTE && rc < 0) {
CERROR("Failed mdo_is_subdir(), rc %d\n", rc);
- } else if (rc == 1) {
- rc = -EINVAL;
+ } else {
+ /* check the found fid */
+ if (lu_fid_eq(&dst_fid, fid))
+ rc = -EINVAL;
}
} else {
rc = PTR_ERR(dst);