return -EINVAL;
}
+ CDEBUG(D_INFO, "name %.*s hash_type %d idx %d\n", namelen, name,
+ hashtype, idx);
+
LASSERT(idx < max_mdt_index);
return idx;
}
struct lmv_user_md *lum;
lum = op_data->op_data;
- *mds = lum->lum_stripe_offset;
+ if (lum->lum_stripe_offset != (__u32)-1) {
+ *mds = lum->lum_stripe_offset;
+ } else {
+ /*
+ * -1 means default, which will be in the same MDT with
+ * the stripe
+ */
+ *mds = op_data->op_mds;
+ lum->lum_stripe_offset = op_data->op_mds;
+ }
} else {
/*
* Allocate new fid on target according to operation type and
* For striped-directory, it will locate MDT by name. And also
* it will reset op_fid1 with the FID of the chosen stripe.
**/
+struct lmv_tgt_desc *
+lmv_locate_target_for_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm,
+ const char *name, int namelen, struct lu_fid *fid,
+ u32 *mds)
+{
+ const struct lmv_oinfo *oinfo;
+ struct lmv_tgt_desc *tgt;
+
+ oinfo = lsm_name_to_stripe_info(lsm, name, namelen);
+ *fid = oinfo->lmo_fid;
+ *mds = oinfo->lmo_mds;
+ tgt = lmv_get_target(lmv, *mds);
+
+ CDEBUG(D_INFO, "locate on mds %u "DFID"\n", *mds, PFID(fid));
+ return tgt;
+}
+
struct lmv_tgt_desc
*lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
struct lu_fid *fid)
{
struct lmv_stripe_md *lsm = op_data->op_mea1;
- const struct lmv_oinfo *oinfo;
struct lmv_tgt_desc *tgt;
if (!lsm || lsm->lsm_md_stripe_count <= 1 ||
return tgt;
}
- oinfo = lsm_name_to_stripe_info(lsm, op_data->op_name,
- op_data->op_namelen);
- *fid = oinfo->lmo_fid;
- op_data->op_mds = oinfo->lmo_mds;
- tgt = lmv_get_target(lmv, op_data->op_mds);
-
- CDEBUG(D_INFO, "locate on mds %u\n", op_data->op_mds);
-
- return tgt;
+ return lmv_locate_target_for_name(lmv, lsm, op_data->op_name,
+ op_data->op_namelen, fid,
+ &op_data->op_mds);
}
static int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
LCK_EX, MDS_INODELOCK_FULL,
MF_MDC_CANCEL_FID4);
+ CDEBUG(D_INODE, DFID":m%d to "DFID"\n", PFID(&op_data->op_fid1),
+ op_data->op_mds, PFID(&op_data->op_fid2));
+
if (rc == 0)
rc = md_rename(src_tgt->ltd_exp, op_data, old, oldlen,
new, newlen, request);
return rc;
retry:
/* Send unlink requests to the MDT where the child is located */
- if (likely(!fid_is_zero(&op_data->op_fid2)))
- tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
- else
+ if (likely(!fid_is_zero(&op_data->op_fid2))) {
+ tgt = lmv_find_target(lmv, &op_data->op_fid2);
+ if (IS_ERR(tgt))
+ return PTR_ERR(tgt);
+
+ /* For striped dir, we need to locate the parent as well */
+ if (op_data->op_mea1 &&
+ op_data->op_mea1->lsm_md_stripe_count > 1) {
+ LASSERT(op_data->op_name && op_data->op_namelen);
+ lmv_locate_target_for_name(lmv, op_data->op_mea1,
+ op_data->op_name,
+ op_data->op_namelen,
+ &op_data->op_fid1,
+ &op_data->op_mds);
+ }
+ } else {
tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
- if (IS_ERR(tgt))
- return PTR_ERR(tgt);
+ if (IS_ERR(tgt))
+ return PTR_ERR(tgt);
+ }
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
struct lmv_obd *lmv = &obd->u.lmv;
struct lmv_tgt_desc *tgt = lmv->tgts[0];
- if (md->lmv)
+ if (md->lmv) {
lmv_free_memmd(md->lmv);
+ md->lmv = NULL;
+ }
if (!tgt || !tgt->ltd_exp)
return -EINVAL;
return md_free_lustre_md(tgt->ltd_exp, md);