#include <lustre_lmv.h>
static inline void mdt_reint_init_ma(struct mdt_thread_info *info,
- struct md_attr *ma)
+ struct md_attr *ma)
{
ma->ma_need = MA_INODE;
- ma->ma_valid = 0;
+ ma->ma_valid = 0;
}
/**
* Return real version or ENOENT_VERSION if object doesn't exist
*/
static void mdt_obj_version_get(struct mdt_thread_info *info,
- struct mdt_object *o, __u64 *version)
+ struct mdt_object *o, __u64 *version)
{
LASSERT(o);
* Should be called only during replay.
*/
static int mdt_version_check(struct ptlrpc_request *req,
- __u64 version, int idx)
+ __u64 version, int idx)
{
- __u64 *pre_ver = lustre_msg_get_versions(req->rq_reqmsg);
- ENTRY;
-
- if (!exp_connect_vbr(req->rq_export))
- RETURN(0);
-
- LASSERT(req_is_replay(req));
- /** VBR: version is checked always because costs nothing */
- LASSERT(idx < PTLRPC_NUM_VERSIONS);
- /** Sanity check for malformed buffers */
- if (pre_ver == NULL) {
- CERROR("No versions in request buffer\n");
+ __u64 *pre_ver = lustre_msg_get_versions(req->rq_reqmsg);
+
+ ENTRY;
+ if (!exp_connect_vbr(req->rq_export))
+ RETURN(0);
+
+ LASSERT(req_is_replay(req));
+ /** VBR: version is checked always because costs nothing */
+ LASSERT(idx < PTLRPC_NUM_VERSIONS);
+ /** Sanity check for malformed buffers */
+ if (pre_ver == NULL) {
+ CERROR("No versions in request buffer\n");
spin_lock(&req->rq_export->exp_lock);
req->rq_export->exp_vbr_failed = 1;
spin_unlock(&req->rq_export->exp_lock);
* Save pre-versions in reply.
*/
static void mdt_version_save(struct ptlrpc_request *req, __u64 version,
- int idx)
+ int idx)
{
- __u64 *reply_ver;
+ __u64 *reply_ver;
- if (!exp_connect_vbr(req->rq_export))
- return;
+ if (!exp_connect_vbr(req->rq_export))
+ return;
- LASSERT(!req_is_replay(req));
- LASSERT(req->rq_repmsg != NULL);
- reply_ver = lustre_msg_get_versions(req->rq_repmsg);
- if (reply_ver)
- reply_ver[idx] = version;
+ LASSERT(!req_is_replay(req));
+ LASSERT(req->rq_repmsg != NULL);
+ reply_ver = lustre_msg_get_versions(req->rq_repmsg);
+ if (reply_ver)
+ reply_ver[idx] = version;
}
/**
*/
static void mdt_enoent_version_save(struct mdt_thread_info *info, int idx)
{
- /* save version of file name for replay, it must be ENOENT here */
- if (!req_is_replay(mdt_info_req(info))) {
- info->mti_ver[idx] = ENOENT_VERSION;
- mdt_version_save(mdt_info_req(info), info->mti_ver[idx], idx);
- }
+ /* save version of file name for replay, it must be ENOENT here */
+ if (!req_is_replay(mdt_info_req(info))) {
+ info->mti_ver[idx] = ENOENT_VERSION;
+ mdt_version_save(mdt_info_req(info), info->mti_ver[idx], idx);
+ }
}
/**
* Versions are saved in reply only during normal operations not replays.
*/
void mdt_version_get_save(struct mdt_thread_info *info,
- struct mdt_object *mto, int idx)
+ struct mdt_object *mto, int idx)
{
- /* don't save versions during replay */
- if (!req_is_replay(mdt_info_req(info))) {
- mdt_obj_version_get(info, mto, &info->mti_ver[idx]);
- mdt_version_save(mdt_info_req(info), info->mti_ver[idx], idx);
- }
+ /* don't save versions during replay */
+ if (!req_is_replay(mdt_info_req(info))) {
+ mdt_obj_version_get(info, mto, &info->mti_ver[idx]);
+ mdt_version_save(mdt_info_req(info), info->mti_ver[idx], idx);
+ }
}
/**
* Get version from disk and check it, no save in reply.
*/
int mdt_version_get_check(struct mdt_thread_info *info,
- struct mdt_object *mto, int idx)
+ struct mdt_object *mto, int idx)
{
- /* only check versions during replay */
- if (!req_is_replay(mdt_info_req(info)))
- return 0;
+ /* only check versions during replay */
+ if (!req_is_replay(mdt_info_req(info)))
+ return 0;
- mdt_obj_version_get(info, mto, &info->mti_ver[idx]);
- return mdt_version_check(mdt_info_req(info), info->mti_ver[idx], idx);
+ mdt_obj_version_get(info, mto, &info->mti_ver[idx]);
+ return mdt_version_check(mdt_info_req(info), info->mti_ver[idx], idx);
}
/**
* Get version from disk and check if recovery or just save.
*/
int mdt_version_get_check_save(struct mdt_thread_info *info,
- struct mdt_object *mto, int idx)
+ struct mdt_object *mto, int idx)
{
- int rc = 0;
-
- mdt_obj_version_get(info, mto, &info->mti_ver[idx]);
- if (req_is_replay(mdt_info_req(info)))
- rc = mdt_version_check(mdt_info_req(info), info->mti_ver[idx],
- idx);
- else
- mdt_version_save(mdt_info_req(info), info->mti_ver[idx], idx);
- return rc;
+ int rc = 0;
+
+ mdt_obj_version_get(info, mto, &info->mti_ver[idx]);
+ if (req_is_replay(mdt_info_req(info)))
+ rc = mdt_version_check(mdt_info_req(info), info->mti_ver[idx],
+ idx);
+ else
+ mdt_version_save(mdt_info_req(info), info->mti_ver[idx], idx);
+ return rc;
}
/**
const struct lu_name *lname,
struct lu_fid *fid, int idx)
{
- int rc, vbrc;
-
- rc = mdo_lookup(info->mti_env, mdt_object_child(p), lname, fid,
- &info->mti_spec);
- /* Check version only during replay */
- if (!req_is_replay(mdt_info_req(info)))
- return rc;
-
- info->mti_ver[idx] = ENOENT_VERSION;
- if (rc == 0) {
- struct mdt_object *child;
- child = mdt_object_find(info->mti_env, info->mti_mdt, fid);
- if (likely(!IS_ERR(child))) {
- mdt_obj_version_get(info, child, &info->mti_ver[idx]);
- mdt_object_put(info->mti_env, child);
- }
- }
- vbrc = mdt_version_check(mdt_info_req(info), info->mti_ver[idx], idx);
- return vbrc ? vbrc : rc;
+ int rc, vbrc;
+
+ rc = mdo_lookup(info->mti_env, mdt_object_child(p), lname, fid,
+ &info->mti_spec);
+ /* Check version only during replay */
+ if (!req_is_replay(mdt_info_req(info)))
+ return rc;
+
+ info->mti_ver[idx] = ENOENT_VERSION;
+ if (rc == 0) {
+ struct mdt_object *child;
+
+ child = mdt_object_find(info->mti_env, info->mti_mdt, fid);
+ if (likely(!IS_ERR(child))) {
+ mdt_obj_version_get(info, child, &info->mti_ver[idx]);
+ mdt_object_put(info->mti_env, child);
+ }
+ }
+ vbrc = mdt_version_check(mdt_info_req(info), info->mti_ver[idx], idx);
+ return vbrc ? vbrc : rc;
}
int rc;
ENTRY;
-
if (!mdt->mdt_enable_dir_restripe)
RETURN(-EPERM);
struct md_op_spec *spec = &info->mti_spec;
bool restripe = false;
int rc;
- ENTRY;
+ ENTRY;
DEBUG_REQ(D_INODE, mdt_info_req(info),
"Create ("DNAME"->"DFID") in "DFID,
PNAME(&rr->rr_name), PFID(rr->rr_fid2), PFID(rr->rr_fid1));
struct obd_export *exp = mdt_info_req(info)->rq_export;
/* Only new clients can create remote dir( >= 2.4) and
- * striped dir(>= 2.6), old client will return -ENOTSUPP */
+ * striped dir(>= 2.6), old client will return -ENOTSUPP
+ */
if (!mdt_is_dne_client(exp))
RETURN(-ENOTSUPP);
struct ldlm_enqueue_info *einfo = &info->mti_einfo[0];
bool cos_incompat;
int rc;
- ENTRY;
+ ENTRY;
rc = mdt_object_striped(info, mo);
if (rc < 0)
RETURN(rc);
/* Even though the new MDT will grant PERM lock to the old
* client, but the old client will almost ignore that during
* So it needs to revoke both LOOKUP and PERM lock here, so
- * both new and old client can cancel the dcache */
+ * both new and old client can cancel the dcache
+ */
if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID))
lockpart |= MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM;
struct lu_ucred *uc = mdt_ucred(info);
cfs_cap_t cap_saved;
int rc;
- ENTRY;
+ ENTRY;
/* If the file was modified, add the dirty flag */
ma->ma_need = MA_HSM;
rc = mdt_attr_get_complex(info, mo, ma);
ma->ma_hsm.mh_flags |= HS_DIRTY;
/* Bump cap so that closes from non-owner writers can
- * set the HSM state to dirty. */
+ * set the HSM state to dirty.
+ */
cap_saved = uc->uc_cap;
uc->uc_cap |= MD_CAP_TO_MASK(CFS_CAP_FOWNER);
rc = mdt_hsm_attr_set(info, mo, &ma->ma_hsm);
struct ptlrpc_request *req = mdt_info_req(info);
struct mdt_object *mo;
struct mdt_body *repbody;
+ ktime_t kstart = ktime_get();
int rc, rc2;
- ENTRY;
+ ENTRY;
DEBUG_REQ(D_INODE, req, "setattr "DFID" %x", PFID(rr->rr_fid1),
(unsigned int)ma->ma_attr.la_valid);
GOTO(out_put, rc = -ETXTBSY);
/* LU-10286: compatibility check for FLR.
- * Please check the comment in mdt_finish_open() for details */
+ * Please check the comment in mdt_finish_open() for details
+ */
if (!exp_connect_flr(info->mti_exp) ||
!exp_connect_overstriping(info->mti_exp)) {
rc = mdt_big_xattr_get(info, mo, XATTR_NAME_LOV);
if (ma->ma_attr_flags & MDS_DATA_MODIFIED)
rc = mdt_add_dirty_flag(info, mo, ma);
- ma->ma_need = MA_INODE;
- ma->ma_valid = 0;
+ ma->ma_need = MA_INODE;
+ ma->ma_valid = 0;
rc = mdt_attr_get_complex(info, mo, ma);
if (rc != 0)
GOTO(out_put, rc);
mdt_object_put(info->mti_env, mo);
out:
if (rc == 0)
- mdt_counter_incr(req, LPROC_MDT_SETATTR);
+ mdt_counter_incr(req, LPROC_MDT_SETATTR,
+ ktime_us_delta(ktime_get(), kstart));
- mdt_client_compatibility(info);
- rc2 = mdt_fix_reply(info);
- if (rc == 0)
- rc = rc2;
- return rc;
+ mdt_client_compatibility(info);
+ rc2 = mdt_fix_reply(info);
+ if (rc == 0)
+ rc = rc2;
+ return rc;
}
static int mdt_reint_create(struct mdt_thread_info *info,
- struct mdt_lock_handle *lhc)
+ struct mdt_lock_handle *lhc)
{
- struct ptlrpc_request *req = mdt_info_req(info);
- int rc;
- ENTRY;
+ struct ptlrpc_request *req = mdt_info_req(info);
+ ktime_t kstart = ktime_get();
+ int rc;
- if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE))
- RETURN(err_serious(-ESTALE));
+ ENTRY;
+ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE))
+ RETURN(err_serious(-ESTALE));
if (info->mti_dlm_req)
ldlm_request_cancel(mdt_info_req(info),
switch (info->mti_attr.ma_attr.la_mode & S_IFMT) {
case S_IFDIR:
- mdt_counter_incr(req, LPROC_MDT_MKDIR);
- break;
- case S_IFREG:
- case S_IFLNK:
- case S_IFCHR:
- case S_IFBLK:
- case S_IFIFO:
+ case S_IFREG:
+ case S_IFLNK:
+ case S_IFCHR:
+ case S_IFBLK:
+ case S_IFIFO:
case S_IFSOCK:
- /* Special file should stay on the same node as parent. */
- mdt_counter_incr(req, LPROC_MDT_MKNOD);
break;
default:
CERROR("%s: Unsupported mode %o\n",
}
rc = mdt_create(info);
+ if (rc == 0) {
+ if ((info->mti_attr.ma_attr.la_mode & S_IFMT) == S_IFDIR)
+ mdt_counter_incr(req, LPROC_MDT_MKDIR,
+ ktime_us_delta(ktime_get(), kstart));
+ else
+ /* Special file should stay on the same node as parent*/
+ mdt_counter_incr(req, LPROC_MDT_MKNOD,
+ ktime_us_delta(ktime_get(), kstart));
+ }
+
RETURN(rc);
}
__u64 lock_ibits;
bool cos_incompat = false;
int no_name = 0;
+ ktime_t kstart = ktime_get();
int rc;
ENTRY;
-
DEBUG_REQ(D_INODE, req, "unlink "DFID"/"DNAME"", PFID(rr->rr_fid1),
PNAME(&rr->rr_name));
* find the name entry on MDT0 anymore.
* In this case, MDT1 only needs to destory the local
* directory.
- * */
+ */
if (mdt_object_remote(mp) && rc == -ENOENT &&
!fid_is_zero(rr->rr_fid2) &&
lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT) {
no_name = 1;
*child_fid = *rr->rr_fid2;
- } else {
+ } else {
GOTO(unlock_parent, rc);
- }
+ }
}
if (!fid_is_md_operative(child_fid))
* this MDT. Since the unlink will happen on another MDT,
* it will release the LOOKUP lock right away. Then What
* would happen if another client try to grab the LOOKUP
- * lock at the same time with unlink XXX */
+ * lock at the same time with unlink XXX
+ */
mdt_object_lock(info, mc, child_lh, MDS_INODELOCK_LOOKUP);
repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
LASSERT(repbody != NULL);
}
/* We used to acquire MDS_INODELOCK_FULL here but we can't do
* this now because a running HSM restore on the child (unlink
- * victim) will hold the layout lock. See LU-4002. */
+ * victim) will hold the layout lock. See LU-4002.
+ */
lock_ibits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE;
if (mdt_object_remote(mp)) {
/* Enqueue lookup lock from parent MDT */
if (ma->ma_valid & MA_INODE) {
switch (ma->ma_attr.la_mode & S_IFMT) {
case S_IFDIR:
- mdt_counter_incr(req, LPROC_MDT_RMDIR);
+ mdt_counter_incr(req, LPROC_MDT_RMDIR,
+ ktime_us_delta(ktime_get(), kstart));
break;
case S_IFREG:
case S_IFLNK:
case S_IFBLK:
case S_IFIFO:
case S_IFSOCK:
- mdt_counter_incr(req, LPROC_MDT_UNLINK);
+ mdt_counter_incr(req, LPROC_MDT_UNLINK,
+ ktime_us_delta(ktime_get(), kstart));
break;
default:
LASSERTF(0, "bad file type %o unlinking\n",
put_parent:
mdt_object_put(info->mti_env, mp);
CFS_RACE_WAKEUP(OBD_FAIL_OBD_ZERO_NLINK_RACE);
- return rc;
+ return rc;
}
/*
struct mdt_object *mp;
struct mdt_lock_handle *lhs;
struct mdt_lock_handle *lhp;
+ ktime_t kstart = ktime_get();
bool cos_incompat;
int rc;
- ENTRY;
+ ENTRY;
DEBUG_REQ(D_INODE, req, "link "DFID" to "DFID"/"DNAME,
PFID(rr->rr_fid1), PFID(rr->rr_fid2), PNAME(&rr->rr_name));
ldlm_request_cancel(req, info->mti_dlm_req, 0, LATF_SKIP);
/* Invalid case so return error immediately instead of
- * processing it */
+ * processing it
+ */
if (lu_fid_eq(rr->rr_fid1, rr->rr_fid2))
RETURN(-EPERM);
mdt_object_child(ms), &rr->rr_name, ma);
if (rc == 0)
- mdt_counter_incr(req, LPROC_MDT_LINK);
+ mdt_counter_incr(req, LPROC_MDT_LINK,
+ ktime_us_delta(ktime_get(), kstart));
EXIT;
unlock_source:
struct lustre_handle *lh)
{
int rc;
- ENTRY;
+ ENTRY;
if (mdt_seq_site(info->mti_mdt)->ss_node_id != 0) {
struct lu_fid *fid = &info->mti_tmp_fid1;
struct mdt_object *obj;
/* XXX, right now, it has to use object API to
* enqueue lock cross MDT, so it will enqueue
- * rename lock(with LUSTRE_BFL_FID) by root object */
+ * rename lock(with LUSTRE_BFL_FID) by root object
+ */
lu_root_fid(fid);
obj = mdt_object_find(info->mti_env, info->mti_mdt, fid);
if (IS_ERR(obj))
__u64 flags = 0;
fid_build_reg_res_name(&LUSTRE_BFL_FID, res_id);
- memset(policy, 0, sizeof *policy);
+ memset(policy, 0, sizeof(*policy));
policy->l_inodebits.bits = MDS_INODELOCK_UPDATE;
flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
rc = ldlm_cli_enqueue_local(info->mti_env, ns, res_id,
int rc;
ENTRY;
-
dir = mdt_object_find(info->mti_env, info->mti_mdt, fid);
if (IS_ERR(dir))
RETURN(dir);
* different list.
*/
struct mdt_sub_lock {
- struct mdt_object *msl_obj;
- struct mdt_lock_handle msl_lh;
- struct list_head msl_linkage;
+ struct mdt_object *msl_obj;
+ struct mdt_lock_handle msl_lh;
+ struct list_head msl_linkage;
};
static void mdt_unlock_list(struct mdt_thread_info *info,
int rc;
ENTRY;
-
if (S_ISDIR(lu_object_attr(&obj->mot_obj)))
RETURN(0);
int rc;
ENTRY;
-
LASSERT(mdt_object_remote(obj));
LASSERT(ma->ma_valid & MA_LMV);
LASSERT(lmv);
bool open_sem_locked = false;
bool do_sync = false;
int rc;
- ENTRY;
+ ENTRY;
CDEBUG(D_INODE, "migrate "DFID"/"DNAME" to "DFID"\n", PFID(rr->rr_fid1),
PNAME(&rr->rr_name), PFID(rr->rr_fid2));
up_write(&sobj->mot_open_sem);
unlock_links:
/* if we've got too many locks to save into RPC,
- * then just commit before the locks are released */
+ * then just commit before the locks are released
+ */
if (!rc && do_sync)
mdt_device_sync(env, mdt);
mdt_unlock_list(info, &link_locks, do_sync ? 1 : rc);
}
/*
+ * lock rename source object.
+ *
+ * Both source and source parent may be remote, and source may be a remote
+ * object on source parent, to avoid overriding lock handle, store remote
+ * LOOKUP lock separately in @lhr.
+ *
+ * \retval 0 on success
+ * \retval -ev negative errno upon error
+ */
+static int mdt_rename_source_lock(struct mdt_thread_info *info,
+ struct mdt_object *parent,
+ struct mdt_object *child,
+ struct mdt_lock_handle *lhc,
+ struct mdt_lock_handle *lhr,
+ __u64 ibits,
+ bool cos_incompat)
+{
+ int rc;
+
+ rc = mdt_is_remote_object(info, parent, child);
+ if (rc < 0)
+ return rc;
+
+ if (rc) {
+ /* enqueue remote LOOKUP lock from the parent MDT */
+ __u64 rmt_ibits = MDS_INODELOCK_LOOKUP;
+
+ if (mdt_object_remote(parent)) {
+ rc = mdt_remote_object_lock(info, parent,
+ mdt_object_fid(child),
+ &lhr->mlh_rreg_lh,
+ lhr->mlh_rreg_mode,
+ rmt_ibits, false);
+ if (rc != ELDLM_OK)
+ return rc;
+ } else {
+ LASSERT(mdt_object_remote(child));
+ rc = mdt_object_local_lock(info, child, lhr,
+ &rmt_ibits, 0, true);
+ if (rc < 0)
+ return rc;
+ }
+
+ ibits &= ~MDS_INODELOCK_LOOKUP;
+ }
+
+ if (mdt_object_remote(child)) {
+ rc = mdt_remote_object_lock(info, child, mdt_object_fid(child),
+ &lhc->mlh_rreg_lh,
+ lhc->mlh_rreg_mode,
+ ibits, false);
+ if (rc == ELDLM_OK)
+ rc = 0;
+ } else {
+ rc = mdt_reint_object_lock(info, child, lhc, ibits,
+ cos_incompat);
+ }
+
+ if (!rc)
+ mdt_object_unlock(info, child, lhr, rc);
+
+ return rc;
+}
+
+/*
* VBR: rename versions in reply: 0 - srcdir parent; 1 - tgtdir parent;
* 2 - srcdir child; 3 - tgtdir child.
* Update on disk version of srcdir child.
struct mdt_lock_handle *lh_srcdirp;
struct mdt_lock_handle *lh_tgtdirp;
struct mdt_lock_handle *lh_oldp = NULL;
+ struct mdt_lock_handle *lh_rmt = NULL;
struct mdt_lock_handle *lh_newp = NULL;
struct lu_fid *old_fid = &info->mti_tmp_fid1;
struct lu_fid *new_fid = &info->mti_tmp_fid2;
__u64 lock_ibits;
bool reverse = false, discard = false;
bool cos_incompat;
+ ktime_t kstart = ktime_get();
int rc;
- ENTRY;
+ ENTRY;
DEBUG_REQ(D_INODE, req, "rename "DFID"/"DNAME" to "DFID"/"DNAME,
PFID(rr->rr_fid1), PNAME(&rr->rr_name),
PFID(rr->rr_fid2), PNAME(&rr->rr_tgt_name));
/* source needs to be looked up after locking source parent, otherwise
* this rename may race with unlink source, and cause rename hang, see
* sanityn.sh 55b, so check parents first, if later we found source is
- * remote, relock parents. */
+ * remote, relock parents.
+ */
cos_incompat = (mdt_object_remote(msrcdir) ||
mdt_object_remote(mtgtdir));
GOTO(out_put_old, rc = -EXDEV);
/* Check if @mtgtdir is subdir of @mold, before locking child
- * to avoid reverse locking. */
+ * to avoid reverse locking.
+ */
if (mtgtdir != msrcdir) {
rc = mdo_is_subdir(info->mti_env, mdt_object_child(mtgtdir),
old_fid);
/* find mnew object:
* mnew target object may not exist now
- * lookup with version checking */
+ * lookup with version checking
+ */
fid_zero(new_fid);
rc = mdt_lookup_version_check(info, mtgtdir, &rr->rr_tgt_name, new_fid,
3);
/* Before locking the target dir, check we do not replace
* a dir with a non-dir, otherwise it may deadlock with
* link op which tries to create a link in this dir
- * back to this non-dir. */
+ * back to this non-dir.
+ */
if (S_ISDIR(lu_object_attr(&mnew->mot_obj)) &&
!S_ISDIR(lu_object_attr(&mold->mot_obj)))
GOTO(out_put_new, rc = -EISDIR);
lh_oldp = &info->mti_lh[MDT_LH_OLD];
+ lh_rmt = &info->mti_lh[MDT_LH_RMT];
mdt_lock_reg_init(lh_oldp, LCK_EX);
+ mdt_lock_reg_init(lh_rmt, LCK_EX);
lock_ibits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_XATTR;
- if (mdt_object_remote(msrcdir)) {
- /* Enqueue lookup lock from the parent MDT */
- rc = mdt_remote_object_lock(info, msrcdir,
- mdt_object_fid(mold),
- &lh_oldp->mlh_rreg_lh,
- lh_oldp->mlh_rreg_mode,
- MDS_INODELOCK_LOOKUP,
- false);
- if (rc != ELDLM_OK)
- GOTO(out_put_new, rc);
-
- lock_ibits &= ~MDS_INODELOCK_LOOKUP;
- }
-
- rc = mdt_reint_object_lock(info, mold, lh_oldp, lock_ibits,
- cos_incompat);
- if (rc != 0)
- GOTO(out_unlock_old, rc);
+ rc = mdt_rename_source_lock(info, msrcdir, mold, lh_oldp,
+ lh_rmt, lock_ibits, cos_incompat);
+ if (rc < 0)
+ GOTO(out_put_new, rc);
/* Check if @msrcdir is subdir of @mnew, before locking child
- * to avoid reverse locking. */
+ * to avoid reverse locking.
+ */
if (mtgtdir != msrcdir) {
rc = mdo_is_subdir(info->mti_env,
mdt_object_child(msrcdir), new_fid);
/* We used to acquire MDS_INODELOCK_FULL here but we
* can't do this now because a running HSM restore on
* the rename onto victim will hold the layout
- * lock. See LU-4002. */
+ * lock. See LU-4002.
+ */
lh_newp = &info->mti_lh[MDT_LH_NEW];
mdt_lock_reg_init(lh_newp, LCK_EX);
- rc = mdt_reint_object_lock(info, mnew, lh_newp,
- MDS_INODELOCK_LOOKUP |
- MDS_INODELOCK_UPDATE,
+ lock_ibits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE;
+ if (mdt_object_remote(mtgtdir)) {
+ rc = mdt_remote_object_lock(info, mtgtdir,
+ mdt_object_fid(mnew),
+ &lh_newp->mlh_rreg_lh,
+ lh_newp->mlh_rreg_mode,
+ MDS_INODELOCK_LOOKUP,
+ false);
+ if (rc != ELDLM_OK)
+ GOTO(out_unlock_old, rc);
+
+ lock_ibits &= ~MDS_INODELOCK_LOOKUP;
+ }
+ rc = mdt_reint_object_lock(info, mnew, lh_newp, lock_ibits,
cos_incompat);
if (rc != 0)
- GOTO(out_unlock_old, rc);
+ GOTO(out_unlock_new, rc);
/* get and save version after locking */
mdt_version_get_save(info, mnew, 3);
- } else if (rc != -EREMOTE && rc != -ENOENT) {
+ } else if (rc != -ENOENT) {
GOTO(out_put_old, rc);
} else {
lh_oldp = &info->mti_lh[MDT_LH_OLD];
+ lh_rmt = &info->mti_lh[MDT_LH_RMT];
mdt_lock_reg_init(lh_oldp, LCK_EX);
+ mdt_lock_reg_init(lh_rmt, LCK_EX);
lock_ibits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_XATTR;
- if (mdt_object_remote(msrcdir)) {
- /* Enqueue lookup lock from the parent MDT */
- rc = mdt_remote_object_lock(info, msrcdir,
- mdt_object_fid(mold),
- &lh_oldp->mlh_rreg_lh,
- lh_oldp->mlh_rreg_mode,
- MDS_INODELOCK_LOOKUP,
- false);
- if (rc != ELDLM_OK)
- GOTO(out_put_old, rc);
-
- lock_ibits &= ~MDS_INODELOCK_LOOKUP;
- }
-
- rc = mdt_reint_object_lock(info, mold, lh_oldp, lock_ibits,
- cos_incompat);
+ rc = mdt_rename_source_lock(info, msrcdir, mold, lh_oldp,
+ lh_rmt, lock_ibits, cos_incompat);
if (rc != 0)
- GOTO(out_unlock_old, rc);
+ GOTO(out_put_old, rc);
mdt_enoent_version_save(info, 3);
}
/* handle last link of tgt object */
if (rc == 0) {
- mdt_counter_incr(req, LPROC_MDT_RENAME);
+ mdt_counter_incr(req, LPROC_MDT_RENAME,
+ ktime_us_delta(ktime_get(), kstart));
if (mnew) {
mdt_handle_last_unlink(info, mnew, ma);
discard = mdt_dom_check_for_discard(info, mnew);
}
mdt_rename_counter_tally(info, info->mti_mdt, req,
- msrcdir, mtgtdir);
+ msrcdir, mtgtdir,
+ ktime_us_delta(ktime_get(), kstart));
}
EXIT;
+out_unlock_new:
if (mnew != NULL)
mdt_object_unlock(info, mnew, lh_newp, rc);
out_unlock_old:
+ mdt_object_unlock(info, NULL, lh_rmt, rc);
mdt_object_unlock(info, mold, lh_oldp, rc);
out_put_new:
if (mnew && !discard)
int rc, rc2;
ENTRY;
-
DEBUG_REQ(D_INODE, req, DFID", FLR file resync", PFID(rr->rr_fid1));
if (info->mti_dlm_req)
/* It's really necessary to grab open_sem and check if the lease lock
* has been lost. There would exist a concurrent writer coming in and
* generating some dirty data in memory cache, the writeback would fail
- * after the layout version is increased by MDS_REINT_RESYNC RPC. */
+ * after the layout version is increased by MDS_REINT_RESYNC RPC.
+ */
if (!down_write_trylock(&mo->mot_open_sem))
GOTO(out_put_lease, rc = -EBUSY);
{
const struct mdt_reinter *mr;
int rc;
- ENTRY;
+ ENTRY;
if (!(info->mti_rr.rr_opcode < ARRAY_SIZE(mdt_reinters)))
RETURN(-EPROTO);