From 7b70c1598a9b484cfe7f50c584caaca5ab64f0ba Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Tue, 6 Jan 2015 18:17:56 -0800 Subject: [PATCH] LU-5951 clio: update timestamps after buiding rpc The mtime/atime/ctime in the write RPC has to be updated after the RPC is built (where xid is generated), otherwise, it could race with the setattr and updating wrong timestamps on OST side. Seems this regression was introduced when landing clio code. Use ofd_write_lock() to protect fmd lookup/udpate in ofd_punch_object(), otherwise, it could race with ofd_attr_set() and ofd_commitrw(). This patch is back-ported from the following one: Lustre-commit: 665ad328b368f1cbd8646690999b609d7b0feaf9 Lustre-change: http://review.whamcloud.com/12865 Signed-off-by: Niu Yawei Change-Id: Icb4c364752e72b4dece1496c0888797487ca239d Reviewed-on: http://review.whamcloud.com/13261 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/ofd/ofd_objects.c | 2 +- lustre/osc/osc_request.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index 22c6580..2bfee20 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -447,12 +447,12 @@ int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo, /* we support truncate, not punch yet */ LASSERT(end == OBD_OBJECT_EOF); + ofd_write_lock(env, fo); fmd = ofd_fmd_get(info->fti_exp, &fo->ofo_header.loh_fid); if (fmd && fmd->fmd_mactime_xid < info->fti_xid) fmd->fmd_mactime_xid = info->fti_xid; ofd_fmd_put(info->fti_exp, fmd); - ofd_write_lock(env, fo); if (!ofd_object_exists(fo)) GOTO(unlock, rc = -ENOENT); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index cc42688..1598057 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2078,6 +2078,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, int page_count = 0; int i; int rc; + struct ost_body *body; CFS_LIST_HEAD(rpc_list); ENTRY; @@ -2171,6 +2172,8 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, * later setattr before earlier BRW (as determined by the request xid), * the OST will not use BRW timestamps. Sadly, there is no obvious * way to do this in a single call. bug 10150 */ + body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); + crattr->cra_oa = &body->oa; cl_req_attr_set(env, clerq, crattr, OBD_MD_FLMTIME|OBD_MD_FLCTIME|OBD_MD_FLATIME); -- 1.8.3.1