From: Oleg Drokin Date: Mon, 5 Nov 2012 05:21:06 +0000 (-0500) Subject: LU-2275 mdt: Avoid setting positive dispositions too early X-Git-Tag: 2.3.59~37 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f5ecf580adc319fd9abe41bd79389b50015d5c13;ds=inline LU-2275 mdt: Avoid setting positive dispositions too early mdt_finish_open and mdt_open_by_fid_lock set DISP_LOOKUP_POS and DISP_OPEN_OPEN a bit too eagerly only to have later code add negative disposition and a lookup error, confusing a client with such self-contradicting replies in the end. This patch only sets positive dispositions when we are sure not to get them overruled. Change-Id: I3389f1d59b21f4a9e4c16ca75b398785ea6e130c Signed-off-by: Oleg Drokin Reviewed-by: wangdi Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index e225c5b..a614bf3 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -912,8 +912,6 @@ int mdt_finish_open(struct mdt_thread_info *info, RETURN(0); } - mdt_set_disposition(info, rep, DISP_OPEN_OPEN); - /* * We need to return the existing object's fid back, so it is done here, * after preparing the reply. @@ -957,11 +955,15 @@ int mdt_finish_open(struct mdt_thread_info *info, else repbody->valid |= OBD_MD_FLEASIZE; } + mdt_set_disposition(info, rep, DISP_OPEN_OPEN); RETURN(0); } } rc = mdt_mfd_open(info, p, o, flags, created); + if (!rc) + mdt_set_disposition(info, rep, DISP_OPEN_OPEN); + RETURN(rc); } @@ -1156,8 +1158,7 @@ int mdt_open_by_fid_lock(struct mdt_thread_info *info, struct ldlm_reply *rep, GOTO(out, rc); } mdt_set_disposition(info, rep, (DISP_IT_EXECD | - DISP_LOOKUP_EXECD | - DISP_LOOKUP_POS)); + DISP_LOOKUP_EXECD)); if (flags & FMODE_WRITE) lm = LCK_CW; @@ -1189,13 +1190,17 @@ int mdt_open_by_fid_lock(struct mdt_thread_info *info, struct ldlm_reply *rep, } } - if (flags & MDS_OPEN_LOCK) - mdt_set_disposition(info, rep, DISP_OPEN_LOCK); rc = mdt_finish_open(info, parent, o, flags, 0, rep); if (!(flags & MDS_OPEN_LOCK) || rc) mdt_object_unlock(info, o, lhc, 1); + if (!rc) { + mdt_set_disposition(info, rep, DISP_LOOKUP_POS); + if (flags & MDS_OPEN_LOCK) + mdt_set_disposition(info, rep, DISP_OPEN_LOCK); + } + GOTO(out, rc); out: mdt_object_put(env, o); @@ -1537,10 +1542,12 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) created, ldlm_rep); if (rc) { result = rc; - if (lustre_handle_is_used(&lhc->mlh_reg_lh)) + if (lustre_handle_is_used(&lhc->mlh_reg_lh)) { /* openlock was acquired and mdt_finish_open failed - drop the openlock */ mdt_object_unlock(info, child, lhc, 1); + mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_LOCK); + } if (created) { ma->ma_need = 0; ma->ma_valid = 0; @@ -1552,6 +1559,7 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) &info->mti_attr); if (rc != 0) CERROR("Error in cleanup of open\n"); + mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_CREATE); } } EXIT;