Skip to content
Snippets Groups Projects
Commit b7e795c8 authored by Vladimir Saveliev's avatar Vladimir Saveliev
Browse files

Branch HEAD

b=14975
i=green
i=huanghua

Openlock cache forward port
parent 89a5b725
No related branches found
No related tags found
No related merge requests found
...@@ -1159,6 +1159,10 @@ Description: Procfs and llog threads access destoryed import sometimes. ...@@ -1159,6 +1159,10 @@ Description: Procfs and llog threads access destoryed import sometimes.
Details : Sync the import destoryed process with procfs and llog threads by Details : Sync the import destoryed process with procfs and llog threads by
the import refcount and semaphore. the import refcount and semaphore.
Severity : enhancement
Bugzilla : 14975
Description: openlock cache of b1_6 port to HEAD
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
2007-08-10 Cluster File Systems, Inc. <info@clusterfs.com> 2007-08-10 Cluster File Systems, Inc. <info@clusterfs.com>
......
...@@ -857,8 +857,9 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) ...@@ -857,8 +857,9 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
__u32 create_flags = info->mti_spec.sp_cr_flags; __u32 create_flags = info->mti_spec.sp_cr_flags;
struct mdt_reint_record *rr = &info->mti_rr; struct mdt_reint_record *rr = &info->mti_rr;
struct lu_name *lname; struct lu_name *lname;
int result; int result, rc;
int created = 0; int created = 0;
__u32 msg_flags;
ENTRY; ENTRY;
OBD_FAIL_TIMEOUT_ORSET(OBD_FAIL_MDS_PAUSE_OPEN, OBD_FAIL_ONCE, OBD_FAIL_TIMEOUT_ORSET(OBD_FAIL_MDS_PAUSE_OPEN, OBD_FAIL_ONCE,
...@@ -880,14 +881,15 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) ...@@ -880,14 +881,15 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
CERROR("JOIN file will be supported soon\n"); CERROR("JOIN file will be supported soon\n");
GOTO(out, result = err_serious(-EOPNOTSUPP)); GOTO(out, result = err_serious(-EOPNOTSUPP));
} }
msg_flags = lustre_msg_get_flags(req->rq_reqmsg);
CDEBUG(D_INODE, "I am going to open "DFID"/(%s->"DFID") " CDEBUG(D_INODE, "I am going to open "DFID"/(%s->"DFID") "
"cr_flag=0%o mode=0%06o msg_flag=0x%x\n", "cr_flag=0%o mode=0%06o msg_flag=0x%x\n",
PFID(rr->rr_fid1), rr->rr_name, PFID(rr->rr_fid1), rr->rr_name,
PFID(rr->rr_fid2), create_flags, PFID(rr->rr_fid2), create_flags,
ma->ma_attr.la_mode, lustre_msg_get_flags(req->rq_reqmsg)); ma->ma_attr.la_mode, msg_flags);
if ((lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) || if (msg_flags & MSG_REPLAY ||
(req->rq_export->exp_libclient && create_flags&MDS_OPEN_HAS_EA)) { (req->rq_export->exp_libclient && create_flags&MDS_OPEN_HAS_EA)) {
/* This is a replay request or from liblustre with ea. */ /* This is a replay request or from liblustre with ea. */
result = mdt_open_by_fid(info, ldlm_rep); result = mdt_open_by_fid(info, ldlm_rep);
...@@ -1010,8 +1012,6 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) ...@@ -1010,8 +1012,6 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
* The object is on remote node, return its FID for remote open. * The object is on remote node, return its FID for remote open.
*/ */
if (result == -EREMOTE) { if (result == -EREMOTE) {
int rc;
/* /*
* Check if this lock already was sent to client and * Check if this lock already was sent to client and
* this is resent case. For resent case do not take lock * this is resent case. For resent case do not take lock
...@@ -1022,8 +1022,7 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) ...@@ -1022,8 +1022,7 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
if (lustre_handle_is_used(&lhc->mlh_reg_lh)) { if (lustre_handle_is_used(&lhc->mlh_reg_lh)) {
struct ldlm_lock *lock; struct ldlm_lock *lock;
LASSERT(lustre_msg_get_flags(req->rq_reqmsg) & LASSERT(msg_flags & MSG_RESENT);
MSG_RESENT);
lock = ldlm_handle2lock(&lhc->mlh_reg_lh); lock = ldlm_handle2lock(&lhc->mlh_reg_lh);
if (!lock) { if (!lock) {
...@@ -1051,23 +1050,55 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) ...@@ -1051,23 +1050,55 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
} }
} }
LASSERT(!lustre_handle_is_used(&lhc->mlh_reg_lh));
/* get openlock if this is not replay and if a client requested it */
if (!(msg_flags & MSG_REPLAY) && create_flags & MDS_OPEN_LOCK) {
ldlm_mode_t lm;
LASSERT(!created);
if (create_flags & FMODE_WRITE)
lm = LCK_CW;
else if (create_flags & MDS_FMODE_EXEC)
lm = LCK_PR;
else
lm = LCK_CR;
mdt_lock_handle_init(lhc);
mdt_lock_reg_init(lhc, lm);
rc = mdt_object_lock(info, child, lhc,
MDS_INODELOCK_LOOKUP | MDS_INODELOCK_OPEN,
MDT_CROSS_LOCK);
if (rc) {
result = rc;
GOTO(out_child, result);
} else {
result = -EREMOTE;
mdt_set_disposition(info, ldlm_rep, DISP_OPEN_LOCK);
}
}
/* Try to open it now. */ /* Try to open it now. */
result = mdt_finish_open(info, parent, child, create_flags, rc = mdt_finish_open(info, parent, child, create_flags,
created, ldlm_rep); created, ldlm_rep);
if (rc) {
if (result != 0 && created) { result = rc;
int rc2; if (lustre_handle_is_used(&lhc->mlh_reg_lh))
ma->ma_need = 0; /* openlock was acquired and mdt_finish_open failed -
ma->ma_valid = 0; drop the openlock */
ma->ma_cookie_size = 0; mdt_object_unlock(info, child, lhc, 1);
info->mti_no_need_trans = 1; if (created) {
rc2 = mdo_unlink(info->mti_env, ma->ma_need = 0;
mdt_object_child(parent), ma->ma_valid = 0;
mdt_object_child(child), ma->ma_cookie_size = 0;
lname, info->mti_no_need_trans = 1;
&info->mti_attr); rc = mdo_unlink(info->mti_env,
if (rc2 != 0) mdt_object_child(parent),
CERROR("Error in cleanup of open\n"); mdt_object_child(child),
lname,
&info->mti_attr);
if (rc != 0)
CERROR("Error in cleanup of open\n");
}
} }
EXIT; EXIT;
out_child: out_child:
...@@ -1075,7 +1106,7 @@ out_child: ...@@ -1075,7 +1106,7 @@ out_child:
out_parent: out_parent:
mdt_object_unlock_put(info, parent, lh, result); mdt_object_unlock_put(info, parent, lh, result);
out: out:
if (result) if (result && result != -EREMOTE)
lustre_msg_set_transno(req->rq_repmsg, 0); lustre_msg_set_transno(req->rq_repmsg, 0);
return result; return result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment