* Return real version or ENOENT_VERSION if object doesn't exist
*/
static void mdt_obj_version_get(struct mdt_thread_info *info,
* Return real version or ENOENT_VERSION if object doesn't exist
*/
static void mdt_obj_version_get(struct mdt_thread_info *info,
* Should be called only during replay.
*/
static int mdt_version_check(struct ptlrpc_request *req,
* Should be called only during replay.
*/
static int mdt_version_check(struct ptlrpc_request *req,
- __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);
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,
* Save pre-versions in reply.
*/
static void mdt_version_save(struct ptlrpc_request *req, __u64 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;
+ 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;
- /* 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,
* Versions are saved in reply only during normal operations not replays.
*/
void mdt_version_get_save(struct mdt_thread_info *info,
- /* 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,
}
/**
* Get version from disk and check it, no save in reply.
*/
int mdt_version_get_check(struct mdt_thread_info *info,
- 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,
}
/**
* Get version from disk and check if recovery or just save.
*/
int mdt_version_get_check_save(struct mdt_thread_info *info,
- 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)
{
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;
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));
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
struct obd_export *exp = mdt_info_req(info)->rq_export;
/* Only new clients can create remote dir( >= 2.4) and
/* 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
/* 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
if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID))
lockpart |= MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM;
if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID))
lockpart |= MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM;
/* If the file was modified, add the dirty flag */
ma->ma_need = MA_HSM;
rc = mdt_attr_get_complex(info, mo, ma);
/* If the file was modified, add the dirty flag */
ma->ma_need = MA_HSM;
rc = mdt_attr_get_complex(info, mo, ma);
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);
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);
DEBUG_REQ(D_INODE, req, "setattr "DFID" %x", PFID(rr->rr_fid1),
(unsigned int)ma->ma_attr.la_valid);
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.
GOTO(out_put, rc = -ETXTBSY);
/* LU-10286: compatibility check for FLR.
if (!exp_connect_flr(info->mti_exp) ||
!exp_connect_overstriping(info->mti_exp)) {
rc = mdt_big_xattr_get(info, mo, XATTR_NAME_LOV);
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);
if (ma->ma_attr_flags & MDS_DATA_MODIFIED)
rc = mdt_add_dirty_flag(info, mo, ma);
case S_IFSOCK:
/* Special file should stay on the same node as parent. */
mdt_counter_incr(req, LPROC_MDT_MKNOD);
case S_IFSOCK:
/* Special file should stay on the same node as parent. */
mdt_counter_incr(req, LPROC_MDT_MKNOD);
DEBUG_REQ(D_INODE, req, "unlink "DFID"/"DNAME"", PFID(rr->rr_fid1),
PNAME(&rr->rr_name));
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.
* 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;
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;
* 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
* 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
mdt_object_lock(info, mc, child_lh, MDS_INODELOCK_LOOKUP);
repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
LASSERT(repbody != NULL);
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
}
/* We used to acquire MDS_INODELOCK_FULL here but we can't do
* this now because a running HSM restore on the child (unlink
lock_ibits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE;
if (mdt_object_remote(mp)) {
/* Enqueue lookup lock from parent MDT */
lock_ibits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE;
if (mdt_object_remote(mp)) {
/* Enqueue lookup lock from parent MDT */
put_parent:
mdt_object_put(info->mti_env, mp);
CFS_RACE_WAKEUP(OBD_FAIL_OBD_ZERO_NLINK_RACE);
put_parent:
mdt_object_put(info->mti_env, mp);
CFS_RACE_WAKEUP(OBD_FAIL_OBD_ZERO_NLINK_RACE);
DEBUG_REQ(D_INODE, req, "link "DFID" to "DFID"/"DNAME,
PFID(rr->rr_fid1), PFID(rr->rr_fid2), PNAME(&rr->rr_name));
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
ldlm_request_cancel(req, info->mti_dlm_req, 0, LATF_SKIP);
/* Invalid case so return error immediately instead of
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
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
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,
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,
- 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;
CDEBUG(D_INODE, "migrate "DFID"/"DNAME" to "DFID"\n", PFID(rr->rr_fid1),
PNAME(&rr->rr_name), PFID(rr->rr_fid2));
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,
up_write(&sobj->mot_open_sem);
unlock_links:
/* if we've got too many locks to save into RPC,
if (!rc && do_sync)
mdt_device_sync(env, mdt);
mdt_unlock_list(info, &link_locks, do_sync ? 1 : rc);
if (!rc && do_sync)
mdt_device_sync(env, mdt);
mdt_unlock_list(info, &link_locks, do_sync ? 1 : rc);
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));
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
/* 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
GOTO(out_put_old, rc = -EXDEV);
/* Check if @mtgtdir is subdir of @mold, before locking child
GOTO(out_put_old, rc = -EXDEV);
/* Check if @mtgtdir is subdir of @mold, before locking child
if (mtgtdir != msrcdir) {
rc = mdo_is_subdir(info->mti_env, mdt_object_child(mtgtdir),
old_fid);
if (mtgtdir != msrcdir) {
rc = mdo_is_subdir(info->mti_env, mdt_object_child(mtgtdir),
old_fid);
fid_zero(new_fid);
rc = mdt_lookup_version_check(info, mtgtdir, &rr->rr_tgt_name, new_fid,
3);
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
/* 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
if (S_ISDIR(lu_object_attr(&mnew->mot_obj)) &&
!S_ISDIR(lu_object_attr(&mold->mot_obj)))
GOTO(out_put_new, rc = -EISDIR);
if (S_ISDIR(lu_object_attr(&mnew->mot_obj)) &&
!S_ISDIR(lu_object_attr(&mold->mot_obj)))
GOTO(out_put_new, rc = -EISDIR);
GOTO(out_unlock_old, rc);
/* Check if @msrcdir is subdir of @mnew, before locking child
GOTO(out_unlock_old, rc);
/* Check if @msrcdir is subdir of @mnew, before locking child
if (mtgtdir != msrcdir) {
rc = mdo_is_subdir(info->mti_env,
mdt_object_child(msrcdir), new_fid);
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
/* 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
lh_newp = &info->mti_lh[MDT_LH_NEW];
mdt_lock_reg_init(lh_newp, LCK_EX);
lh_newp = &info->mti_lh[MDT_LH_NEW];
mdt_lock_reg_init(lh_newp, LCK_EX);
DEBUG_REQ(D_INODE, req, DFID", FLR file resync", PFID(rr->rr_fid1));
if (info->mti_dlm_req)
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
/* 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
if (!down_write_trylock(&mo->mot_open_sem))
GOTO(out_put_lease, rc = -EBUSY);
if (!down_write_trylock(&mo->mot_open_sem))
GOTO(out_put_lease, rc = -EBUSY);