Whamcloud - gitweb
LU-221 don't use a/c/m time for newly allocated object in OST
authorhongchao.zhang <hongchao.zhang@whamcloud.com>
Sat, 16 Jul 2011 22:16:55 +0000 (06:16 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 Jul 2011 06:19:12 +0000 (02:19 -0400)
in OST, the a/c/m time is unusable for newly allocated object for
it has not gotten valid time info from clients. by setting the a/c/m
time as LONG_MIN at creation will make the clients ignore the time.

Change-Id: I0d6094e4257626ffd1128b3540837deaf230e056
Signed-off-by: Hongchao Zhang <hongchao.zhang@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1084
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdfilter/filter.c

index fb13c62..ad44312 100644 (file)
@@ -3809,6 +3809,7 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa,
         struct dentry *dchild = NULL, *dparent = NULL;
         struct filter_obd *filter;
         struct obd_statfs *osfs;
         struct dentry *dchild = NULL, *dparent = NULL;
         struct filter_obd *filter;
         struct obd_statfs *osfs;
+        struct iattr iattr;
         int err = 0, rc = 0, recreate_obj = 0, i;
         cfs_time_t enough_time = cfs_time_shift(DISK_TIMEOUT/2);
         __u64 os_ffree;
         int err = 0, rc = 0, recreate_obj = 0, i;
         cfs_time_t enough_time = cfs_time_shift(DISK_TIMEOUT/2);
         __u64 os_ffree;
@@ -3953,6 +3954,19 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa,
                                        dchild->d_inode->i_ino);
 
 set_last_id:
                                        dchild->d_inode->i_ino);
 
 set_last_id:
+                /* Set a/c/m time to a insane large negative value at creation
+                 * time so that any timestamp arriving from the client will
+                 * always be newer and update the inode.
+                 * See LU-221 for details */
+                iattr.ia_valid = ATTR_ATIME | ATTR_MTIME | ATTR_CTIME;
+                LTIME_S(iattr.ia_atime) = INT_MIN + 24 * 3600;
+                LTIME_S(iattr.ia_mtime) = INT_MIN + 24 * 3600;
+                LTIME_S(iattr.ia_ctime) = INT_MIN + 24 * 3600;
+                err = fsfilt_setattr(obd, dchild, handle, &iattr, 0);
+                if (err)
+                        CERROR("unable to initialize a/c/m time of newly"
+                               "created inode\n");
+
                 if (!recreate_obj) {
                         filter_set_last_id(filter, next_id, group);
                         err = filter_update_last_objid(obd, group, 0);
                 if (!recreate_obj) {
                         filter_set_last_id(filter, next_id, group);
                         err = filter_update_last_objid(obd, group, 0);