From: Sebastien Buisson Date: Tue, 4 Jul 2017 15:21:44 +0000 (+0900) Subject: LU-9727 lustre: record CLOSE if OPEN was recorded X-Git-Tag: 2.10.58~22 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F29%2F27929%2F21;p=fs%2Flustre-release.git LU-9727 lustre: record CLOSE if OPEN was recorded Record CL_CLOSE events in changelogs only if file was opened in write mode, or if CL_OPEN was recorded. Changelogs mask may change between open and close operations, but this is not a big deal if we have a CL_CLOSE entry with no matching CL_OPEN. Plus Changelogs mask may not change often. Signed-off-by: Sebastien Buisson Change-Id: I5984a4b07b84d84c3860b9b21abc3b19b7fd9b1a Reviewed-on: https://review.whamcloud.com/27929 Reviewed-by: Andreas Dilger Reviewed-by: Matthew S Reviewed-by: Li Xi Tested-by: Jenkins Tested-by: Maloo --- diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index fc31d01..2bc73a4 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -2520,8 +2520,15 @@ cont: out: mdd_write_unlock(env, mdd_obj); + /* Record CL_CLOSE in changelog only if file was opened in write mode, + * or if CL_OPEN was recorded. + * Changelogs mask may change between open and close operations, but + * this is not a big deal if we have a CL_CLOSE entry with no matching + * CL_OPEN. Plus Changelogs mask may not change often. + */ if (!rc && !blocked && - (mode & (FMODE_WRITE | MDS_OPEN_APPEND | MDS_OPEN_TRUNC)) && + ((mode & (FMODE_WRITE | MDS_OPEN_APPEND | MDS_OPEN_TRUNC)) || + (mdd->mdd_cl.mc_mask & (1 << CL_OPEN))) && !(ma->ma_valid & MA_FLAGS && ma->ma_attr_flags & MDS_RECOV_OPEN)) { if (handle == NULL) { handle = mdd_trans_create(env, mdo2mdd(obj));