From: Mike S. <sh...@us...> - 2003-07-13 00:32:19
|
Update of /cvsroot/lustre/lustre/mds In directory sc8-pr-cvs1:/tmp/cvs-serv7083/mds Modified Files: Tag: b_unify handler.c mds_open.c Log Message: merge b_intent into b_unify, now that we know it passes Index: handler.c =================================================================== RCS file: /cvsroot/lustre/lustre/mds/handler.c,v retrieving revision 1.217.6.38.2.2 retrieving revision 1.217.6.38.2.3 diff -u -w -b -B -p -r1.217.6.38.2.2 -r1.217.6.38.2.3 --- handler.c 11 Jul 2003 10:19:56 -0000 1.217.6.38.2.2 +++ handler.c 13 Jul 2003 00:32:10 -0000 1.217.6.38.2.3 @@ -860,6 +861,7 @@ static int mds_getattr_name(int offset, { struct mds_obd *mds = mds_req2mds(req); struct obd_device *obd = req->rq_export->exp_obd; + struct ldlm_reply *rep = NULL; struct obd_run_ctxt saved; struct mds_body *body; struct dentry *de = NULL, *dchild = NULL; @@ -904,9 +906,11 @@ static int mds_getattr_name(int offset, } LASSERT (offset == 0 || offset == 2); - /* if requests were at offset 2, replies go back at 1 */ - if (offset) + /* if requests were at offset 2, the getattr reply goes back at 1 */ + if (offset) { + rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep)); offset = 1; + } uc.ouc_fsuid = body->fsuid; uc.ouc_fsgid = body->fsgid; @@ -915,6 +919,7 @@ static int mds_getattr_name(int offset, uc.ouc_suppgid2 = -1; push_ctxt(&saved, &mds->mds_ctxt, &uc); /* Step 1: Lookup/lock parent */ + intent_set_disposition(rep, DISP_LOOKUP_EXECD); de = mds_fid2locked_dentry(obd, &body->fid1, NULL, LCK_PR, &parent_lockh); if (IS_ERR(de)) @@ -936,8 +941,10 @@ static int mds_getattr_name(int offset, cleanup_phase = 2; /* child dentry */ if (dchild->d_inode == NULL) { + intent_set_disposition(rep, DISP_LOOKUP_NEG); GOTO(cleanup, rc = -ENOENT); - } + } else + intent_set_disposition(rep, DISP_LOOKUP_POS); /* Step 3: Lock child */ child_res_id.name[0] = dchild->d_inode->i_ino; @@ -1724,6 +1731,20 @@ static void fixup_handle_for_resent_req( remote_hdl.cookie); } +int intent_disposition(struct ldlm_reply *rep, int flag) +{ + if (!rep) + return 0; + return (rep->lock_policy_res1 & flag); +} + +void intent_set_disposition(struct ldlm_reply *rep, int flag) +{ + if (!rep) + return; + rep->lock_policy_res1 |= flag; +} + static int ldlm_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp, void *req_cookie, ldlm_mode_t mode, int flags, void *data) @@ -1765,7 +1786,7 @@ static int ldlm_intent_policy(struct ldl RETURN(req->rq_status); rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep)); - rep->lock_policy_res1 = IT_INTENT_EXEC; + intent_set_disposition(rep, DISP_IT_EXECD); fixup_handle_for_resent_req(req, lock, &lockh); @@ -1773,12 +1794,12 @@ static int ldlm_intent_policy(struct ldl switch ((long)it->opc) { case IT_OPEN: case IT_CREAT|IT_OPEN: +#warning swab here to assert that an mds_open reint packet is following rep->lock_policy_res2 = mds_reint(req, offset, &lockh); - /* We return a dentry to the client if IT_OPEN_POS is - * set, or if we make it to the OPEN portion of the - * programme (which implies that we created) */ - if (!(rep->lock_policy_res1 & IT_OPEN_POS || - rep->lock_policy_res1 & IT_OPEN_OPEN)) + /* We abort the lock if the lookup was negative and + * we did not make it to the OPEN portion */ + if (intent_disposition(rep, DISP_LOOKUP_NEG) && + !intent_disposition(rep, DISP_OPEN_OPEN)) RETURN(ELDLM_LOCK_ABORTED); break; case IT_GETATTR: @@ -1788,8 +1809,11 @@ static int ldlm_intent_policy(struct ldl &lockh); /* FIXME: we need to sit down and decide on who should * set req->rq_status, who should return negative and - * positive return values, and what they all mean. */ - if (rep->lock_policy_res2) + * positive return values, and what they all mean. + * - replay: returns 0 & req->status is old status + * - otherwise: returns req->status */ + if (!intent_disposition(rep, DISP_LOOKUP_POS) || + rep->lock_policy_res2) RETURN(ELDLM_LOCK_ABORTED); if (req->rq_status != 0) { rep->lock_policy_res2 = req->rq_status; Index: mds_open.c =================================================================== RCS file: /cvsroot/lustre/lustre/mds/mds_open.c,v retrieving revision 1.3.6.17.2.1 retrieving revision 1.3.6.17.2.2 diff -u -w -b -B -p -r1.3.6.17.2.1 -r1.3.6.17.2.2 --- mds_open.c 11 Jul 2003 10:19:56 -0000 1.3.6.17.2.1 +++ mds_open.c 13 Jul 2003 00:32:10 -0000 1.3.6.17.2.2 @@ -102,7 +102,7 @@ void reconstruct_open(struct mds_update_ struct dentry *parent, *child; struct ldlm_reply *rep; struct mds_body *body; - int disp, rc; + int rc; struct list_head *t; int put_child = 1; ENTRY; @@ -114,14 +114,13 @@ void reconstruct_open(struct mds_update_ /* copy rc, transno and disp; steal locks */ req->rq_transno = mcd->mcd_last_transno; req->rq_status = mcd->mcd_last_result; - disp = rep->lock_policy_res1 = mcd->mcd_last_data; + intent_set_disposition(rep, mcd->mcd_last_data); if (oldreq) mds_steal_ack_locks(req->rq_export, req); - /* We never care about these. */ - disp &= ~(IT_OPEN_LOOKUP | IT_OPEN_POS | IT_OPEN_NEG); - if (!disp) { + /* Only replay if create or open actually happened. */ + if (!intent_disposition(rep, DISP_OPEN_CREATE | DISP_OPEN_OPEN) ) { EXIT; return; /* error looking up parent or child */ } @@ -136,11 +135,11 @@ void reconstruct_open(struct mds_update_ GOTO(out_dput, 0); /* child not present to open */ } - /* At this point, we know we have a child, which means that we'll send - * it back _unless_ it was open failed, _and_ we didn't create the file. - * I love you guys. No, really. + /* At this point, we know we have a child. We'll send + * it back _unless_ it not created and open failed. */ - if (((disp & (IT_OPEN_OPEN | IT_OPEN_CREATE)) == IT_OPEN_OPEN) && + if (intent_disposition(rep, DISP_OPEN_OPEN) && + !intent_disposition(rep, DISP_OPEN_CREATE) && req->rq_status) { GOTO(out_dput, 0); } @@ -178,7 +177,7 @@ void reconstruct_open(struct mds_update_ /* If we didn't get as far as trying to open, then some locking thing * probably went wrong, and we'll just bail here. */ - if ((disp & IT_OPEN_OPEN) == 0) + if (!intent_disposition(rep, DISP_OPEN_OPEN)) GOTO(out_dput, 0); /* If we failed, then we must have failed opening, so don't look for @@ -390,7 +389,6 @@ int mds_open(struct mds_update_record *r LASSERT(offset == 2); /* If we got here, we must be called via intent */ med = &req->rq_export->exp_mds_data; - rep->lock_policy_res1 |= IT_OPEN_LOOKUP; if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK)) { CERROR("test case OBD_FAIL_MDS_OPEN_PACK\n"); req->rq_status = -ENOMEM; @@ -452,6 +450,7 @@ int mds_open(struct mds_update_record *r acc_mode |= MAY_WRITE; /* Step 1: Find and lock the parent */ + intent_set_disposition(rep, DISP_LOOKUP_EXECD); parent_mode = (rec->ur_flags & O_CREAT) ? LCK_PW : LCK_PR; parent = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, parent_mode, &parent_lockh); @@ -472,9 +471,9 @@ int mds_open(struct mds_update_record *r cleanup_phase = 2; /* child dentry */ if (dchild->d_inode) - rep->lock_policy_res1 |= IT_OPEN_POS; + intent_set_disposition(rep, DISP_LOOKUP_POS); else - rep->lock_policy_res1 |= IT_OPEN_NEG; + intent_set_disposition(rep, DISP_LOOKUP_NEG); /* Step 3: If the child was negative, and we're supposed to, * create it. */ @@ -486,7 +485,7 @@ int mds_open(struct mds_update_record *r GOTO(cleanup, rc = -ENOENT); } - rep->lock_policy_res1 |= IT_OPEN_CREATE; + intent_set_disposition(rep, DISP_OPEN_CREATE); handle = fsfilt_start(obd, parent->d_inode, FSFILT_OP_CREATE, NULL); if (IS_ERR(handle)) { @@ -614,7 +613,7 @@ int mds_open(struct mds_update_record *r GOTO(cleanup, rc = -ENOTDIR); /* Step 5: mds_open it */ - rep->lock_policy_res1 |= IT_OPEN_OPEN; + intent_set_disposition(rep, DISP_OPEN_OPEN); openit: /* dentry_open does a dput(de) and mntput(mds->mds_vfsmnt) on error */ mfd = mds_dentry_open(dchild, mds->mds_vfsmnt, @@ -643,7 +642,8 @@ int mds_open(struct mds_update_record *r * ldlm_intent_policy: if we found the dentry, or we tried to * open it (meaning that we created, if it wasn't found), then * we return the lock to the caller and client. */ - if (!(rep->lock_policy_res1 & (IT_OPEN_OPEN | IT_OPEN_POS))) + if (intent_disposition(rep, DISP_LOOKUP_NEG) && + !intent_disposition(rep, DISP_OPEN_OPEN)) ldlm_lock_decref(child_lockh, child_mode); case 2: if (rc || S_ISLNK(dchild->d_inode->i_mode)) |