Whamcloud - gitweb
LU-988 clio: use OSC object's m/a/ctime when build write RPC
authorBobi Jam <bobijam@whamcloud.com>
Wed, 27 Jun 2012 13:29:05 +0000 (21:29 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 Jul 2012 06:55:20 +0000 (02:55 -0400)
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 <bobijam@whamcloud.com>
Change-Id: Ie4466ad646fd87c36577ea2aad5fa19ad97c5be7
Reviewed-on: http://review.whamcloud.com/3200
Reviewed-by: Jinshan Xiong <jinshan.xiong@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd_support.h
lustre/lclient/lcommon_cl.c
lustre/osc/osc_io.c
lustre/tests/sanity.sh

index 5cf7fbc..c32b09f 100644 (file)
@@ -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_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
 
 #define OBD_FAIL_PTLRPC                  0x500
 #define OBD_FAIL_PTLRPC_ACK              0x501
index 3071da5..19cb4aa 100644 (file)
@@ -976,28 +976,26 @@ void ccc_req_attr_set(const struct lu_env *env,
         struct obdo  *oa;
         obd_flag      valid_flags;
 
         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);
 #ifdef __KERNEL__
        memcpy(attr->cra_jobid, cl_i2info(inode)->lli_jobid,
               JOBSTATS_JOBID_SIZE);
index cc14b5a..b66019b 100644 (file)
@@ -551,6 +551,7 @@ static int osc_io_write_start(const struct lu_env *env,
         ENTRY;
 
         if (oio->oi_lockless == 0) {
         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) {
                 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,
  * 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;
         if (flags & OBD_MD_FLID) {
                 oa->o_id = oinfo->loi_id;
                 oa->o_valid |= OBD_MD_FLID;
index 5c21ca0..36e2aa0 100644 (file)
@@ -2426,7 +2426,10 @@ test_39j() {
        touch $DIR1/$tfile
        sleep 1
 
        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`
 
        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`
 
        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
 
                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 ======================="
        stop_full_debug_logging
 }
 run_test 39j "write, rename, close, stat ======================="