From 4244bbbf9a2d2f82c337993953b977702ffcc18b Mon Sep 17 00:00:00 2001 From: zhanghc Date: Tue, 3 Mar 2009 16:38:50 +0000 Subject: [PATCH] b=17757 clear DISP_OPEN_LOCK flag in "reconstruct_open" if the corresponding lock was canceled i=Green i=Johann --- lustre/include/lustre_dlm.h | 5 ----- lustre/include/lustre_mds.h | 37 +++++++++++++++++++++++++++++++++---- lustre/mdc/mdc_locks.c | 18 ------------------ lustre/mds/handler.c | 34 ++++++++++------------------------ lustre/mds/mds_open.c | 38 +++++++++++++++++++------------------- 5 files changed, 62 insertions(+), 70 deletions(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index a20ee95..cb635f9 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -874,11 +874,6 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, int lock_flags, int cancel_flags, void *opaque); int ldlm_cli_cancel_list(struct list_head *head, int count, struct ptlrpc_request *req, int off); -/* mds/handler.c */ -/* This has to be here because recursive inclusion sucks. */ -int intent_disposition(struct ldlm_reply *rep, int flag); -void intent_set_disposition(struct ldlm_reply *rep, int flag); - /* ioctls for trying requests */ #define IOC_LDLM_TYPE 'f' diff --git a/lustre/include/lustre_mds.h b/lustre/include/lustre_mds.h index d7afc22..2d014a1 100644 --- a/lustre/include/lustre_mds.h +++ b/lustre/include/lustre_mds.h @@ -143,14 +143,43 @@ struct mds_file_data { int mds_reint_rec(struct mds_update_record *r, int offset, struct ptlrpc_request *req, struct lustre_handle *); -/* mds/mds_lov.c */ +/* mds/handler.c */ +static int inline ldlm_reply_disposition(struct ldlm_reply *rep, int flag) +{ + return (rep ? rep->lock_policy_res1 & flag : 0); +} + +static void inline ldlm_reply_set_disposition(struct ldlm_reply *rep, int flag) +{ + if (rep) + rep->lock_policy_res1 |= flag; +} + +static void inline ldlm_reply_clear_disposition(struct ldlm_reply *rep, + int flag) +{ + if (rep) + rep->lock_policy_res1 &= ~flag; +} /* mdc/mdc_locks.c */ struct md_enqueue_info; -int it_disposition(struct lookup_intent *it, int flag); -void it_set_disposition(struct lookup_intent *it, int flag); -void it_clear_disposition(struct lookup_intent *it, int flag); +static int inline it_disposition(struct lookup_intent *it, int flag) +{ + return it->d.lustre.it_disposition & flag; +} + +static void inline it_set_disposition(struct lookup_intent *it, int flag) +{ + it->d.lustre.it_disposition |= flag; +} + +static inline void it_clear_disposition(struct lookup_intent *it, int flag) +{ + it->d.lustre.it_disposition &= ~flag; +} + int it_open_error(int phase, struct lookup_intent *it); void mdc_set_lock_data(__u64 *lockh, void *data); int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid, diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index 02c350b..2058b68 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -53,24 +53,6 @@ #include #include "mdc_internal.h" -int it_disposition(struct lookup_intent *it, int flag) -{ - return it->d.lustre.it_disposition & flag; -} -EXPORT_SYMBOL(it_disposition); - -void it_set_disposition(struct lookup_intent *it, int flag) -{ - it->d.lustre.it_disposition |= flag; -} -EXPORT_SYMBOL(it_set_disposition); - -void it_clear_disposition(struct lookup_intent *it, int flag) -{ - it->d.lustre.it_disposition &= ~flag; -} -EXPORT_SYMBOL(it_clear_disposition); - int it_open_error(int phase, struct lookup_intent *it) { if (it_disposition(it, DISP_OPEN_OPEN)) { diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index e26e4aa..a6db60d 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -947,7 +947,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc); cleanup_phase = 1; /* kernel context */ - intent_set_disposition(rep, DISP_LOOKUP_EXECD); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD); /* FIXME: handle raw lookup */ #if 0 @@ -1030,12 +1030,12 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, cleanup_phase = 2; /* dchild, dparent, locks */ if (dchild->d_inode == NULL) { - intent_set_disposition(rep, DISP_LOOKUP_NEG); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_NEG); /* in the intent case, the policy clears this error: the disposition is enough */ GOTO(cleanup, rc = -ENOENT); } else { - intent_set_disposition(rep, DISP_LOOKUP_POS); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_POS); } if (req->rq_repmsg == NULL) { @@ -2381,20 +2381,6 @@ static void fixup_handle_for_resent_req(struct ptlrpc_request *req, int offset, 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; -} - #define IS_CLIENT_DISCONNECT_ERROR(error) \ (error == -ENOTCONN || error == -ENODEV) @@ -2455,7 +2441,7 @@ static int mds_intent_policy(struct ldlm_namespace *ns, RETURN(req->rq_status = rc); rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF, sizeof(*rep)); - intent_set_disposition(rep, DISP_IT_EXECD); + ldlm_reply_set_disposition(rep, DISP_IT_EXECD); /* execute policy */ switch ((long)it->opc) { @@ -2471,16 +2457,16 @@ static int mds_intent_policy(struct ldlm_namespace *ns, #if 0 /* 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_EXECD)) + if (!ldlm_reply_disposition(rep, DISP_LOOKUP_EXECD)) RETURN(ELDLM_LOCK_ABORTED); - if (intent_disposition(rep, DISP_LOOKUP_NEG) && - !intent_disposition(rep, DISP_OPEN_OPEN)) + if (ldlm_reply_disposition(rep, DISP_LOOKUP_NEG) && + !ldlm_reply_disposition(rep, DISP_OPEN_OPEN)) #endif /* If there was an error of some sort or if we are not * returning any locks */ if (rep->lock_policy_res2 || - !intent_disposition(rep, DISP_OPEN_LOCK)) { + !ldlm_reply_disposition(rep, DISP_OPEN_LOCK)) { /* If it is the disconnect error (ENODEV & ENOCONN) * ptlrpc layer should know this imediately, it should * be replied by rq_stats, otherwise, return it by @@ -2518,9 +2504,9 @@ static int mds_intent_policy(struct ldlm_namespace *ns, policy_res{1,2} with disposition and status. - replay: returns 0 & req->status is old status - otherwise: returns req->status */ - if (intent_disposition(rep, DISP_LOOKUP_NEG)) + if (ldlm_reply_disposition(rep, DISP_LOOKUP_NEG)) rep->lock_policy_res2 = 0; - if (!intent_disposition(rep, DISP_LOOKUP_POS) || + if (!ldlm_reply_disposition(rep, DISP_LOOKUP_POS) || rep->lock_policy_res2) RETURN(ELDLM_LOCK_ABORTED); if (req->rq_status != 0) { diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index d5b0cc5..c945b4d 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -533,10 +533,10 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, /* copy rc, transno and disp; steal locks */ mds_req_from_lcd(req, lcd); - intent_set_disposition(rep, le32_to_cpu(lcd->lcd_last_data)); + ldlm_reply_set_disposition(rep, le32_to_cpu(lcd->lcd_last_data)); /* Only replay if create or open actually happened. */ - if (!intent_disposition(rep, DISP_OPEN_CREATE | DISP_OPEN_OPEN) ) { + if (!ldlm_reply_disposition(rep, DISP_OPEN_CREATE | DISP_OPEN_OPEN) ) { EXIT; return; /* error looking up parent or child */ } @@ -574,8 +574,8 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, /* At this point, we know we have a child. We'll send * it back _unless_ it not created and open failed. */ - if (intent_disposition(rep, DISP_OPEN_OPEN) && - !intent_disposition(rep, DISP_OPEN_CREATE) && + if (ldlm_reply_disposition(rep, DISP_OPEN_OPEN) && + !ldlm_reply_disposition(rep, DISP_OPEN_CREATE) && req->rq_status) { GOTO(out_dput, 0); } @@ -622,7 +622,7 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, /* 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 (!intent_disposition(rep, DISP_OPEN_OPEN)) + if (!ldlm_reply_disposition(rep, DISP_OPEN_OPEN)) GOTO(out_dput, 0); /* If we failed, then we must have failed opening, so don't look for @@ -681,14 +681,14 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, mds_mfd_put(mfd); - if (!intent_disposition(rep, DISP_OPEN_LOCK)) + if (!ldlm_reply_disposition(rep, DISP_OPEN_LOCK)) GOTO(out_dput, 0); /* child_lockh has been set in fixup_handle_for_resent_req called * in mds_intent_policy for resent request */ if (child_lockh == NULL || !lustre_handle_is_used(child_lockh)) { /* the lock is already canceled! clear DISP_OPEN_LOCK */ - intent_disposition(rep, ~DISP_OPEN_LOCK); + ldlm_reply_clear_disposition(rep, DISP_OPEN_LOCK); } out_dput: @@ -851,7 +851,7 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild, if ((rc = mds_lov_prepare_objids(obd,lmm)) != 0) RETURN(rc); - intent_set_disposition(rep, DISP_OPEN_OPEN); + ldlm_reply_set_disposition(rep, DISP_OPEN_OPEN); mfd = mds_dentry_open(dchild, mds->mds_vfsmnt, flags, req); if (IS_ERR(mfd)) RETURN(PTR_ERR(mfd)); @@ -903,8 +903,8 @@ static int mds_open_by_fid(struct ptlrpc_request *req, struct ll_fid *fid, } mds_pack_inode2body(body, dchild->d_inode); - intent_set_disposition(rep, DISP_LOOKUP_EXECD); - intent_set_disposition(rep, DISP_LOOKUP_POS); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_POS); rc = mds_finish_open(req, dchild, body, flags, &handle, rec, rep, NULL); rc = mds_finish_transno(mds, NULL, handle, @@ -1118,8 +1118,8 @@ int mds_open(struct mds_update_record *rec, int offset, } else { /* Just cannot find parent - make it look like * usual negative lookup to avoid extra MDS RPC */ - intent_set_disposition(rep, DISP_LOOKUP_EXECD); - intent_set_disposition(rep, DISP_LOOKUP_NEG); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_NEG); } GOTO(cleanup, rc); } @@ -1137,11 +1137,11 @@ int mds_open(struct mds_update_record *rec, int offset, cleanup_phase = 2; /* child dentry */ - intent_set_disposition(rep, DISP_LOOKUP_EXECD); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD); if (dchild->d_inode) - intent_set_disposition(rep, DISP_LOOKUP_POS); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_POS); else - intent_set_disposition(rep, DISP_LOOKUP_NEG); + ldlm_reply_set_disposition(rep, DISP_LOOKUP_NEG); /*Step 3: If the child was negative, and we're supposed to, create it.*/ if (dchild->d_inode == NULL) { @@ -1180,7 +1180,7 @@ int mds_open(struct mds_update_record *rec, int offset, current->fsuid, gid, 1, &rec_pending, NULL, NULL, 0); - intent_set_disposition(rep, DISP_OPEN_CREATE); + ldlm_reply_set_disposition(rep, DISP_OPEN_CREATE); handle = fsfilt_start(obd, dparent->d_inode, FSFILT_OP_CREATE, NULL); if (IS_ERR(handle)) { @@ -1251,7 +1251,7 @@ int mds_open(struct mds_update_record *rec, int offset, /* for nfs and join - we need two locks for same fid, but * with different mode */ if (need_open_lock && !use_parent) { - intent_set_disposition(rep, DISP_OPEN_LOCK); + ldlm_reply_set_disposition(rep, DISP_OPEN_LOCK); need_open_lock = 0; } } @@ -1304,7 +1304,7 @@ found_child: GOTO(cleanup, rc = -EACCES); } if (ll_permission(dchild->d_inode, acc_mode, NULL)) { - intent_set_disposition(rep, DISP_OPEN_OPEN); + ldlm_reply_set_disposition(rep, DISP_OPEN_OPEN); GOTO(cleanup, rc = -EACCES); } } else if (rec->ur_flags & MDS_OPEN_DIRECTORY) { @@ -1334,7 +1334,7 @@ found_child: GOTO(cleanup, rc); /* Let mds_intent_policy know that we have a lock to return */ - intent_set_disposition(rep, DISP_OPEN_LOCK); + ldlm_reply_set_disposition(rep, DISP_OPEN_LOCK); } if (!S_ISREG(dchild->d_inode->i_mode) && -- 1.8.3.1