- /* directory is already splitted, so we have to forward
- * request to the right MDS */
- mds = raw_name2idx(obj->objcount, (char *)name, len);
- CDEBUG(D_OTHER, "forward to MDS #%u\n", mds);
+ int mea_idx;
+
+ /*
+ * Directory is already split, so we have to forward request to
+ * the right MDS.
+ */
+ mea_idx = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
+ (char *)op_data->op_name,
+ op_data->op_namelen);
+
+ rpid = obj->lo_inodes[mea_idx].li_fid;
+
+ sop_data->op_mds = obj->lo_inodes[mea_idx].li_mds;
+ tgt_exp = lmv_get_export(lmv, sop_data->op_mds);
+ sop_data->op_bias &= ~MDS_CHECK_SPLIT;
+ lmv_obj_put(obj);
+ CDEBUG(D_OTHER, "Choose slave dir ("DFID")\n", PFID(&rpid));
+ } else {
+ struct lmv_tgt_desc *tgt;
+
+ sop_data->op_bias |= MDS_CHECK_SPLIT;
+ tgt = lmv_find_target(lmv, &rpid);
+ sop_data->op_mds = tgt->ltd_idx;
+ tgt_exp = tgt->ltd_exp;
+ }
+ if (IS_ERR(tgt_exp))
+ GOTO(out_free_sop_data, rc = PTR_ERR(tgt_exp));
+
+ sop_data->op_fid1 = rpid;
+
+ if (it->it_op & IT_CREAT) {
+ /*
+ * For open with IT_CREATE and for IT_CREATE cases allocate new
+ * fid and setup FLD for it.
+ */
+ rc = lmv_fid_alloc(exp, &sop_data->op_fid2, sop_data);
+ if (rc)
+ GOTO(out_free_sop_data, rc);