+ /* cancel ELC locks of source */
+ rc = lmv_early_cancel(exp, child_tgt, op_data, tgt->ltd_index, LCK_EX,
+ MDS_INODELOCK_ELC, MF_MDC_CANCEL_FID3);
+ if (rc)
+ RETURN(rc);
+
+ rc = md_rename(tgt->ltd_exp, op_data, name, namelen, NULL, 0, request);
+
+ RETURN(rc);
+}
+
+static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
+ const char *old, size_t oldlen,
+ const char *new, size_t newlen,
+ struct ptlrpc_request **request)
+{
+ struct obd_device *obd = exp->exp_obd;
+ struct lmv_obd *lmv = &obd->u.lmv;
+ struct lmv_tgt_desc *sp_tgt;
+ struct lmv_tgt_desc *tp_tgt = NULL;
+ struct lmv_tgt_desc *src_tgt = NULL;
+ struct lmv_tgt_desc *tgt;
+ struct mdt_body *body;
+ int rc;
+
+ ENTRY;
+
+ LASSERT(oldlen != 0);
+
+ if (op_data->op_cli_flags & CLI_MIGRATE) {
+ rc = lmv_migrate(exp, op_data, old, oldlen, request);
+ RETURN(rc);
+ }
+
+ op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
+ op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
+ op_data->op_cap = cfs_curproc_cap_pack();
+
+ op_data->op_name = new;
+ op_data->op_namelen = newlen;
+
+ tp_tgt = lmv_locate_tgt2(lmv, op_data);
+ if (IS_ERR(tp_tgt))
+ RETURN(PTR_ERR(tp_tgt));
+
+ /* Since the target child might be destroyed, and it might become
+ * orphan, and we can only check orphan on the local MDT right now, so
+ * we send rename request to the MDT where target child is located. If
+ * target child does not exist, then it will send the request to the
+ * target parent */