#endif
#define DEBUG_SUBSYSTEM S_MDS
+#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/version.h>
}
/* replay case */
- if (rec->ur_fid2->id) {
+ if(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
+ LASSERT (rec->ur_fid2->id);
body->valid |= OBD_MD_FLBLKSZ | OBD_MD_FLEASIZE;
lmm_size = rec->ur_eadatalen;
lmm = rec->ur_eadata;
RETURN(0);
}
+
+ if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_ALLOC_OBDO))
+ GOTO(out_ids, rc = -ENOMEM);
+
oa = obdo_alloc();
if (oa == NULL)
GOTO(out_ids, rc = -ENOMEM);
if (child_lockh == NULL)
child_lockh = &lockh;
- rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, NULL,
- child_res_id, LDLM_PLAIN, NULL, 0,
- LCK_EX, &lock_flags, ldlm_completion_ast,
- mds_blocking_ast, NULL, child_lockh);
+ rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, child_res_id,
+ LDLM_PLAIN, NULL, LCK_EX, &lock_flags,
+ mds_blocking_ast, ldlm_completion_ast, NULL, NULL,
+ NULL, 0, NULL, child_lockh);
if (rc != ELDLM_OK)
CERROR("ldlm_cli_enqueue: %d\n", rc);
else if (child_lockh == &lockh)
/* Step 0: If we are passed a fid, then we assume the client already
* opened this file and is only replaying the RPC, so we open the
* inode by fid (at some large expense in security). */
- if (rec->ur_fid2->id) {
+ if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
+ DEBUG_REQ(D_HA, req, "open replay, disp: "LPX64"\n",
+ rep->lock_policy_res1);
+
+ LASSERT(rec->ur_fid2->id);
+
rc = mds_open_by_fid(req, rec->ur_fid2, body, rec->ur_flags,
rec, rep);
- if (rc != -ENOENT)
+ if (rc != -ENOENT)
RETURN(rc);
/* We didn't find the correct inode on disk either, so we
* need to re-create it via a regular replay. */
LASSERT(rec->ur_flags & MDS_OPEN_CREAT);
+ } else {
+ LASSERT(!rec->ur_fid2->id);
}
+
LASSERT(offset == 2); /* If we got here, we must be called via intent */
med = &req->rq_export->exp_mds_data;
if ((rec->ur_flags & MDS_OPEN_DIRECTORY) &&
!S_ISDIR(dchild->d_inode->i_mode))
GOTO(cleanup, rc = -ENOTDIR);
+
+ if (S_ISDIR(dchild->d_inode->i_mode)) {
+ if (rec->ur_flags & MDS_OPEN_CREAT || rec->ur_flags & FMODE_WRITE) {
+ /*we are tryying to create or write a exist dir*/
+ GOTO(cleanup, rc = -EISDIR);
+ }
+ if (ll_permission(dchild->d_inode, acc_mode, NULL)) {
+ GOTO(cleanup, rc = -EACCES);
+ }
+ }
/* Step 5: mds_open it */
rc = mds_finish_open(req, dchild, body, rec->ur_flags, &handle, rec,