From: fanyong Date: Tue, 10 Feb 2009 05:08:45 +0000 (+0000) Subject: Branch HEAD X-Git-Tag: v1_9_160~22 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b64d843a984a5a715de4dd1df7edf6f7f9e52bcb;p=fs%2Flustre-release.git Branch HEAD b=18295 i=huanghua i=pravin Osd should not update object's xtime when calls ldiskfs stuff. --- diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 363b81a..6b53bc9 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -1692,12 +1692,11 @@ static int __osd_xattr_set(const struct lu_env *env, struct dt_object *dt, *t = inode->i_ctime; rc = inode->i_op->setxattr(dentry, name, buf->lb_buf, buf->lb_len, fs_flags); - if (likely(rc == 0)) { - spin_lock(&obj->oo_guard); - inode->i_ctime = *t; - spin_unlock(&obj->oo_guard); - mark_inode_dirty(inode); - } + /* ctime should not be updated with server-side time. */ + spin_lock(&obj->oo_guard); + inode->i_ctime = *t; + spin_unlock(&obj->oo_guard); + mark_inode_dirty(inode); return rc; } @@ -1962,13 +1961,11 @@ static int osd_xattr_del(const struct lu_env *env, dentry->d_inode = inode; *t = inode->i_ctime; rc = inode->i_op->removexattr(dentry, name); - if (likely(rc == 0)) { - /* ctime should not be updated with server-side time. */ - spin_lock(&obj->oo_guard); - inode->i_ctime = *t; - spin_unlock(&obj->oo_guard); - mark_inode_dirty(inode); - } + /* ctime should not be updated with server-side time. */ + spin_lock(&obj->oo_guard); + inode->i_ctime = *t; + spin_unlock(&obj->oo_guard); + mark_inode_dirty(inode); return rc; } @@ -2429,10 +2426,20 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt, (char *)key, strlen((char *)key)); bh = ldiskfs_find_entry(dentry, &de); if (bh) { + struct osd_thread_info *oti = osd_oti_get(env); + struct timespec *ctime = &oti->oti_time; + struct timespec *mtime = &oti->oti_time2; + + *ctime = dir->i_ctime; + *mtime = dir->i_mtime; rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh); - if (!rc) - mark_inode_dirty(dir); + /* xtime should not be updated with server-side time. */ + spin_lock(&obj->oo_guard); + dir->i_ctime = *ctime; + dir->i_mtime = *mtime; + spin_unlock(&obj->oo_guard); + mark_inode_dirty(dir); brelse(bh); } else rc = -ENOENT; @@ -2773,7 +2780,7 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt, const char *name = (const char *)key; struct osd_object *child; #ifdef HAVE_QUOTA_SUPPORT - cfs_cap_t save = current->cap_effective; + cfs_cap_t save = current->cap_effective; #endif int rc; @@ -2791,6 +2798,13 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt, RETURN(rc); child = osd_object_find(env, dt, fid); if (!IS_ERR(child)) { + struct inode *inode = obj->oo_inode; + struct osd_thread_info *oti = osd_oti_get(env); + struct timespec *ctime = &oti->oti_time; + struct timespec *mtime = &oti->oti_time2; + + *ctime = inode->i_ctime; + *mtime = inode->i_mtime; #ifdef HAVE_QUOTA_SUPPORT if (ignore_quota) current->cap_effective |= CFS_CAP_SYS_RESOURCE_MASK; @@ -2803,6 +2817,12 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt, current->cap_effective = save; #endif osd_object_put(env, child); + /* xtime should not be updated with server-side time. */ + spin_lock(&obj->oo_guard); + inode->i_ctime = *ctime; + inode->i_mtime = *mtime; + spin_unlock(&obj->oo_guard); + mark_inode_dirty(inode); } else { rc = PTR_ERR(child); } diff --git a/lustre/osd/osd_internal.h b/lustre/osd/osd_internal.h index 8fd25f2..8007fbd 100644 --- a/lustre/osd/osd_internal.h +++ b/lustre/osd/osd_internal.h @@ -173,10 +173,8 @@ struct osd_thread_info { * XXX temporary: for ->i_op calls. */ struct txn_param oti_txn; - /* - * XXX temporary: fake dentry used by xattr calls. - */ struct timespec oti_time; + struct timespec oti_time2; /* * XXX temporary: fake struct file for osd_object_sync */ diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 568620d..b7f4eaf 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2649,11 +2649,11 @@ test_56o() { setup_56 $NUMFILES $NUMDIRS TDIR=$DIR/${tdir}g - utime $TDIR/file1 > /dev/null || error - utime $TDIR/file2 > /dev/null || error - utime $TDIR/dir1 > /dev/null || error - utime $TDIR/dir2 > /dev/null || error - utime $TDIR/dir1/file1 > /dev/null || error + utime $TDIR/file1 > /dev/null || error "utime (1)" + utime $TDIR/file2 > /dev/null || error "utime (2)" + utime $TDIR/dir1 > /dev/null || error "utime (3)" + utime $TDIR/dir2 > /dev/null || error "utime (4)" + utime $TDIR/dir1/file1 > /dev/null || error "utime (5)" EXPECTED=5 NUMS=`$LFIND -mtime +1 $TDIR | wc -l` diff --git a/lustre/tests/utime.c b/lustre/tests/utime.c index 8bc5259..79236706 100644 --- a/lustre/tests/utime.c +++ b/lustre/tests/utime.c @@ -66,9 +66,6 @@ int main(int argc, char *argv[]) int rc; int c; - utb.actime = 200000; - utb.modtime = 100000; - while ((c = getopt(argc, argv, "s:")) != -1) { switch(c) { case 's': @@ -104,9 +101,9 @@ int main(int argc, char *argv[]) } if (st.st_mtime < before_mknod || st.st_mtime > after_mknod) { - fprintf(stderr, - "%s: bad mknod times %lu <= %lu <= %lu false\n", - prog, before_mknod, st.st_mtime, after_mknod); + fprintf(stderr, "%s: bad mknod(%s) times %lu <= %lu <= " + "%lu false\n", prog, filename, before_mknod, + st.st_mtime, after_mknod); return 4; } @@ -126,9 +123,10 @@ int main(int argc, char *argv[]) if (st2.st_mtime < before_mknod || st2.st_mtime > after_mknod) { - fprintf(stderr, "%s: bad mknod times %lu <= %lu" - " <= %lu false\n", prog, before_mknod, - st2.st_mtime, after_mknod); + fprintf(stderr, "%s: bad mknod(%s) times %lu " + " <= %lu <= %lu false\n", prog, + filename, before_mknod, st2.st_mtime, + after_mknod); return 6; } @@ -139,7 +137,8 @@ int main(int argc, char *argv[]) } } - /* See above */ + utb.actime = 200000; + utb.modtime = 100000; rc = utime(filename, &utb); if (rc) { fprintf(stderr, "%s: utime(%s) failed: rc %d: %s\n", @@ -155,14 +154,14 @@ int main(int argc, char *argv[]) } if (st.st_mtime != utb.modtime ) { - fprintf(stderr, "%s: bad utime mtime %lu should be %lu\n", - prog, st.st_mtime, utb.modtime); + fprintf(stderr, "%s: bad utime mtime(%s) %lu should be %lu\n", + prog, filename, st.st_mtime, utb.modtime); return 9; } if (st.st_atime != utb.actime ) { - fprintf(stderr, "%s: bad utime atime %lu should be %lu\n", - prog, st.st_atime, utb.actime); + fprintf(stderr, "%s: bad utime atime(%s) %lu should be %lu\n", + prog, filename, st.st_atime, utb.actime); return 10; } @@ -181,14 +180,16 @@ int main(int argc, char *argv[]) } if (st2.st_mtime != st.st_mtime) { - fprintf(stderr, "%s: not synced mtime between clients: %lu " - "should be %lu\n", prog, st2.st_mtime, st.st_mtime); + fprintf(stderr, "%s: not synced mtime(%s) between clients: " + "%lu should be %lu\n", prog, secname, + st2.st_mtime, st.st_mtime); return 13; } if (st2.st_ctime != st.st_ctime) { - fprintf(stderr, "%s: not synced ctime between clients: %lu " - " should be %lu\n", prog, st2.st_ctime, st.st_ctime); + fprintf(stderr, "%s: not synced ctime(%s) between clients: " + "%lu should be %lu\n", prog, secname, + st2.st_ctime, st.st_ctime); return 14; }