Commit 662e035c authored by wang di's avatar wang di Committed by Greg Kroah-Hartman

staging: lustre: lmv: allow cross-MDT rename and link

Remove checks for cross-MDT operation, so cross-MDT
rename and link will be allowed.

Remove obsolete locality parameters in MDT lock API after all of
cross-MDT operations are allowed.

This is the client side changed only so the upstream
client can support this.
Signed-off-by: default avatarwang di <di.wang@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3537
Reviewed-on: http://review.whamcloud.com/12282Reviewed-by: default avatarJames Simmons <uja.ornl@yahoo.com>
Reviewed-by: default avatarLai Siyao <lai.siyao@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 11c647ca
...@@ -1903,7 +1903,10 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, ...@@ -1903,7 +1903,10 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
{ {
struct obd_device *obd = exp->exp_obd; struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv; struct lmv_obd *lmv = &obd->u.lmv;
struct obd_export *target_exp;
struct lmv_tgt_desc *src_tgt; struct lmv_tgt_desc *src_tgt;
struct lmv_tgt_desc *tgt_tgt;
struct mdt_body *body;
int rc; int rc;
LASSERT(oldlen != 0); LASSERT(oldlen != 0);
...@@ -1943,6 +1946,10 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, ...@@ -1943,6 +1946,10 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
if (rc) if (rc)
return rc; return rc;
src_tgt = lmv_find_target(lmv, &op_data->op_fid3); src_tgt = lmv_find_target(lmv, &op_data->op_fid3);
if (IS_ERR(src_tgt))
return PTR_ERR(src_tgt);
target_exp = src_tgt->ltd_exp;
} else { } else {
if (op_data->op_mea1) { if (op_data->op_mea1) {
struct lmv_stripe_md *lsm = op_data->op_mea1; struct lmv_stripe_md *lsm = op_data->op_mea1;
...@@ -1951,29 +1958,27 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, ...@@ -1951,29 +1958,27 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
oldlen, oldlen,
&op_data->op_fid1, &op_data->op_fid1,
&op_data->op_mds); &op_data->op_mds);
if (IS_ERR(src_tgt))
return PTR_ERR(src_tgt);
} else { } else {
src_tgt = lmv_find_target(lmv, &op_data->op_fid1); src_tgt = lmv_find_target(lmv, &op_data->op_fid1);
}
if (IS_ERR(src_tgt)) if (IS_ERR(src_tgt))
return PTR_ERR(src_tgt); return PTR_ERR(src_tgt);
op_data->op_mds = src_tgt->ltd_idx;
}
if (op_data->op_mea2) { if (op_data->op_mea2) {
struct lmv_stripe_md *lsm = op_data->op_mea2; struct lmv_stripe_md *lsm = op_data->op_mea2;
const struct lmv_oinfo *oinfo;
oinfo = lsm_name_to_stripe_info(lsm, new, newlen); tgt_tgt = lmv_locate_target_for_name(lmv, lsm, new,
if (IS_ERR(oinfo)) newlen,
return PTR_ERR(oinfo); &op_data->op_fid2,
&op_data->op_mds);
op_data->op_fid2 = oinfo->lmo_fid; } else {
tgt_tgt = lmv_find_target(lmv, &op_data->op_fid2);
} }
if (IS_ERR(tgt_tgt))
return PTR_ERR(tgt_tgt);
target_exp = tgt_tgt->ltd_exp;
} }
if (IS_ERR(src_tgt))
return PTR_ERR(src_tgt);
/* /*
* LOOKUP lock on src child (fid3) should also be cancelled for * LOOKUP lock on src child (fid3) should also be cancelled for
...@@ -2014,20 +2019,52 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, ...@@ -2014,20 +2019,52 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
return rc; return rc;
} }
retry_rename:
/* /*
* Cancel all the locks on tgt child (fid4). * Cancel all the locks on tgt child (fid4).
*/ */
if (fid_is_sane(&op_data->op_fid4)) if (fid_is_sane(&op_data->op_fid4)) {
struct lmv_tgt_desc *tgt;
rc = lmv_early_cancel(exp, NULL, op_data, src_tgt->ltd_idx, rc = lmv_early_cancel(exp, NULL, op_data, src_tgt->ltd_idx,
LCK_EX, MDS_INODELOCK_FULL, LCK_EX, MDS_INODELOCK_FULL,
MF_MDC_CANCEL_FID4); MF_MDC_CANCEL_FID4);
if (rc)
return rc;
CDEBUG(D_INODE, DFID":m%d to "DFID"\n", PFID(&op_data->op_fid1), tgt = lmv_find_target(lmv, &op_data->op_fid4);
op_data->op_mds, PFID(&op_data->op_fid2)); if (IS_ERR(tgt))
return PTR_ERR(tgt);
rc = md_rename(src_tgt->ltd_exp, op_data, old, oldlen, /*
new, newlen, request); * 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
*/
target_exp = tgt->ltd_exp;
}
rc = md_rename(target_exp, op_data, old, oldlen, new, newlen, request);
if (rc && rc != -EREMOTE)
return rc; return rc;
body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY);
if (!body)
return -EPROTO;
/* Not cross-ref case, just get out of here. */
if (likely(!(body->mbo_valid & OBD_MD_MDS)))
return rc;
CDEBUG(D_INODE, "%s: try rename to another MDT for " DFID "\n",
exp->exp_obd->obd_name, PFID(&body->mbo_fid1));
op_data->op_fid4 = body->mbo_fid1;
ptlrpc_req_finished(*request);
*request = NULL;
goto retry_rename;
} }
static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment