From 97a10cf9797bbed02fb131f6a205b6a0ceeb0525 Mon Sep 17 00:00:00 2001 From: Alexey Zhuravlev Date: Wed, 18 Sep 2019 15:23:44 +0300 Subject: [PATCH] LU-10496 ofd: serialize fmd check and set Serialize FMD check and set in OFD to prevent update with old data. Update also sanity tests 39j,k to cancel LRU locks on both mdc and osc namespaces because for DOM files both MDT and OST stripes are being used Test-Parameters: testlist=sanity-dom Signed-off-by: Alexey Zhuravlev Change-Id: I02e28e1e3e8e533d9c7450d798fceb9261b27ea0 Reviewed-on: https://review.whamcloud.com/36228 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/ofd/ofd_io.c | 14 ++++++-------- lustre/ofd/ofd_objects.c | 9 +++++---- lustre/tests/sanity.sh | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index d4bdd68..a5d49e1 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -1097,6 +1097,7 @@ ofd_commitrw_write(const struct lu_env *env, struct obd_export *exp, int niocount, struct niobuf_local *lnb, unsigned long granted, int old_rc) { + struct ofd_thread_info *info = ofd_info(env); struct filter_export_data *fed = &exp->exp_filter_data; struct ofd_object *fo; struct dt_object *o; @@ -1205,7 +1206,9 @@ retry: GOTO(out_unlock, rc); } - if (la->la_valid) { + /* Don't update timestamps if this write is older than a + * setattr which modifies the timestamps. b=10150 */ + if (la->la_valid && tgt_fmd_check(exp, fid, info->fti_xid)) { rc = dt_attr_set(env, o, la, th); if (rc) GOTO(out_unlock, rc); @@ -1297,13 +1300,8 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, if (cmd == OBD_BRW_WRITE) { struct lu_nodemap *nodemap; - /* Don't update timestamps if this write is older than a - * setattr which modifies the timestamps. b=10150 */ - valid = OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLPROJID; - if (tgt_fmd_check(exp, fid, info->fti_xid)) - valid |= OBD_MD_FLATIME | OBD_MD_FLMTIME | - OBD_MD_FLCTIME; - + valid = OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLPROJID | + OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME; la_from_obdo(&info->fti_attr, oa, valid); rc = ofd_commitrw_write(env, exp, ofd, fid, &info->fti_attr, diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index e98e72b..4c76972 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -664,10 +664,6 @@ int ofd_attr_set(const struct lu_env *env, struct ofd_object *fo, if (!ofd_object_exists(fo)) GOTO(out, rc = -ENOENT); - if (la->la_valid & (LA_ATIME | LA_MTIME | LA_CTIME)) - tgt_fmd_update(info->fti_exp, &fo->ofo_header.loh_fid, - info->fti_xid); - /* VBR: version recovery check */ rc = ofd_version_get_check(info, fo); if (rc) @@ -700,6 +696,11 @@ int ofd_attr_set(const struct lu_env *env, struct ofd_object *fo, if (!ofd_object_exists(fo)) GOTO(unlock, rc = -ENOENT); + /* serialize vs ofd_commitrw_write() */ + if (la->la_valid & (LA_ATIME | LA_MTIME | LA_CTIME)) + tgt_fmd_update(info->fti_exp, &fo->ofo_header.loh_fid, + info->fti_xid); + rc = dt_attr_set(env, ofd_object_child(fo), la, th); if (rc) GOTO(unlock, rc); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index c409edb..b8ca080 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -4266,7 +4266,7 @@ test_39j() { error "mtime is lost on close: $mtime2, " \ "should be $mtime1" - cancel_lru_locks $OSC + cancel_lru_locks if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi done lctl set_param fail_loc=0 @@ -4295,7 +4295,7 @@ test_39k() { [ "$mtime2" = $TEST_39_MTIME ] || \ error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME" - cancel_lru_locks osc + cancel_lru_locks if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi done } -- 1.8.3.1