From 53ed199c6dfe3958339a565098a607ddbd768c97 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Wed, 27 Jun 2012 21:29:05 +0800 Subject: [PATCH] LU-988 clio: use OSC object's m/a/ctime when build write RPC When building OST write RPC, inode's m/a/ctime are out-dated until lov_merge_lvb() is called, so we need OSC object's m/a/ctime to set the OST object. Signed-off-by: Bobi Jam Change-Id: Ie4466ad646fd87c36577ea2aad5fa19ad97c5be7 Reviewed-on: http://review.whamcloud.com/3200 Reviewed-by: Jinshan Xiong Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/obd_support.h | 1 + lustre/lclient/lcommon_cl.c | 40 +++++++++++++++++++--------------------- lustre/osc/osc_io.c | 42 +++++++++++++++++++++++++++++------------- lustre/tests/sanity.sh | 11 ++++++++--- 4 files changed, 57 insertions(+), 37 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 5cf7fbc..c32b09f 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -340,6 +340,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_OSC_CP_CANCEL_RACE 0x40f #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410 #define OBD_FAIL_OSC_NO_GRANT 0x411 +#define OBD_FAIL_OSC_DELAY_SETTIME 0x412 #define OBD_FAIL_PTLRPC 0x500 #define OBD_FAIL_PTLRPC_ACK 0x501 diff --git a/lustre/lclient/lcommon_cl.c b/lustre/lclient/lcommon_cl.c index 3071da5..19cb4aa 100644 --- a/lustre/lclient/lcommon_cl.c +++ b/lustre/lclient/lcommon_cl.c @@ -976,28 +976,26 @@ void ccc_req_attr_set(const struct lu_env *env, struct obdo *oa; obd_flag valid_flags; - oa = attr->cra_oa; - inode = ccc_object_inode(obj); - valid_flags = OBD_MD_FLTYPE|OBD_MD_FLATIME; - - if (flags != (obd_valid)~0ULL) - valid_flags |= OBD_MD_FLMTIME|OBD_MD_FLCTIME|OBD_MD_FLATIME; - else { - LASSERT(attr->cra_capa == NULL); - attr->cra_capa = cl_capa_lookup(inode, - slice->crs_req->crq_type); - } + oa = attr->cra_oa; + inode = ccc_object_inode(obj); + valid_flags = OBD_MD_FLTYPE; + + if ((flags & OBD_MD_FLOSSCAPA) != 0) { + LASSERT(attr->cra_capa == NULL); + attr->cra_capa = cl_capa_lookup(inode, + slice->crs_req->crq_type); + } - if (slice->crs_req->crq_type == CRT_WRITE) { - if (flags & OBD_MD_FLEPOCH) { - oa->o_valid |= OBD_MD_FLEPOCH; - oa->o_ioepoch = cl_i2info(inode)->lli_ioepoch; - valid_flags |= OBD_MD_FLMTIME|OBD_MD_FLCTIME| - OBD_MD_FLUID|OBD_MD_FLGID; - } - } - obdo_from_inode(oa, inode, valid_flags & flags); - obdo_set_parent_fid(oa, &cl_i2info(inode)->lli_fid); + if (slice->crs_req->crq_type == CRT_WRITE) { + if (flags & OBD_MD_FLEPOCH) { + oa->o_valid |= OBD_MD_FLEPOCH; + oa->o_ioepoch = cl_i2info(inode)->lli_ioepoch; + valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME | + OBD_MD_FLUID | OBD_MD_FLGID; + } + } + obdo_from_inode(oa, inode, valid_flags & flags); + obdo_set_parent_fid(oa, &cl_i2info(inode)->lli_fid); #ifdef __KERNEL__ memcpy(attr->cra_jobid, cl_i2info(inode)->lli_jobid, JOBSTATS_JOBID_SIZE); diff --git a/lustre/osc/osc_io.c b/lustre/osc/osc_io.c index cc14b5a..b66019b 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -551,6 +551,7 @@ static int osc_io_write_start(const struct lu_env *env, ENTRY; if (oio->oi_lockless == 0) { + OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); cl_object_attr_lock(obj); result = cl_object_attr_get(env, obj, attr); if (result == 0) { @@ -738,20 +739,35 @@ static void osc_req_completion(const struct lu_env *env, * fields. */ static void osc_req_attr_set(const struct lu_env *env, - const struct cl_req_slice *slice, - const struct cl_object *obj, - struct cl_req_attr *attr, obd_valid flags) + const struct cl_req_slice *slice, + const struct cl_object *obj, + struct cl_req_attr *attr, obd_valid flags) { - struct lov_oinfo *oinfo; - struct cl_req *clerq; - struct cl_page *apage; /* _some_ page in @clerq */ - struct cl_lock *lock; /* _some_ lock protecting @apage */ - struct osc_lock *olck; - struct osc_page *opg; - struct obdo *oa; - - oa = attr->cra_oa; - oinfo = cl2osc(obj)->oo_oinfo; + struct lov_oinfo *oinfo; + struct cl_req *clerq; + struct cl_page *apage; /* _some_ page in @clerq */ + struct cl_lock *lock; /* _some_ lock protecting @apage */ + struct osc_lock *olck; + struct osc_page *opg; + struct obdo *oa; + struct ost_lvb *lvb; + + oinfo = cl2osc(obj)->oo_oinfo; + lvb = &oinfo->loi_lvb; + oa = attr->cra_oa; + + if ((flags & OBD_MD_FLMTIME) != 0) { + oa->o_mtime = lvb->lvb_mtime; + oa->o_valid |= OBD_MD_FLMTIME; + } + if ((flags & OBD_MD_FLATIME) != 0) { + oa->o_atime = lvb->lvb_atime; + oa->o_valid |= OBD_MD_FLATIME; + } + if ((flags & OBD_MD_FLCTIME) != 0) { + oa->o_ctime = lvb->lvb_ctime; + oa->o_valid |= OBD_MD_FLCTIME; + } if (flags & OBD_MD_FLID) { oa->o_id = oinfo->loi_id; oa->o_valid |= OBD_MD_FLID; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 5c21ca0..36e2aa0 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2426,7 +2426,10 @@ test_39j() { touch $DIR1/$tfile sleep 1 - multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed" + #define OBD_FAIL_OSC_DELAY_SETTIME 0x412 + lctl set_param fail_loc=0x80000412 + multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || + error "multiop failed" local multipid=$! local mtime1=`stat -c %Y $DIR1/$tfile` @@ -2437,12 +2440,14 @@ test_39j() { for (( i=0; i < 2; i++ )) ; do local mtime2=`stat -c %Y $DIR1/$tfile-1` - [ "$mtime1" = "$mtime2" ] || \ - error "mtime is lost on close: $mtime2, should be $mtime1" + [ "$mtime1" = "$mtime2" ] || + error "mtime is lost on close: $mtime2, " \ + "should be $mtime1" cancel_lru_locks osc if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi done + lctl set_param fail_loc=0 stop_full_debug_logging } run_test 39j "write, rename, close, stat =======================" -- 1.8.3.1