From b4e0446ad189788529e4d69d4dfa9c822f2e3bae Mon Sep 17 00:00:00 2001 From: Vladimir Saveliev Date: Wed, 22 Sep 2010 02:27:12 +0400 Subject: [PATCH] b=22942 setattr fix send attributes to osts when truncate and utimes (not only when setting times to past) i=vitaly --- lustre/liblustre/super.c | 16 +++++++++------- lustre/llite/llite_lib.c | 16 +++++++++------- lustre/llite/vvp_io.c | 9 +++++---- lustre/tests/sanity.sh | 6 +++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index f7e1693..916e4c8 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -767,13 +767,15 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) if (ia_valid & ATTR_SIZE) attr->ia_valid |= ATTR_SIZE; - if ((ia_valid & ATTR_SIZE) | - ((ia_valid | ATTR_ATIME | ATTR_ATIME_SET) && - LTIME_S(attr->ia_atime) < LTIME_S(attr->ia_ctime)) || - ((ia_valid | ATTR_MTIME | ATTR_MTIME_SET) && - LTIME_S(attr->ia_mtime) < LTIME_S(attr->ia_ctime))) - /* perform truncate and setting mtime/atime to past under PW - * 0:EOF extent lock (new_size:EOF for truncate) */ + if ((ia_valid & ATTR_SIZE) || + (ia_valid | ATTR_ATIME | ATTR_ATIME_SET) || + (ia_valid | ATTR_MTIME | ATTR_MTIME_SET)) + /* on truncate and utimes send attributes to osts, setting + * mtime/atime to past will be performed under PW 0:EOF extent + * lock (new_size:EOF for truncate) + * it may seem excessive to send mtime/atime updates to osts + * when not setting times to past, but it is necessary due to + * possible time de-synchronization */ rc = cl_setattr_ost(inode, attr, NULL); EXIT; out: diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 19c743c..a984eb1 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1277,13 +1277,15 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) if (ia_valid & ATTR_SIZE) attr->ia_valid |= ATTR_SIZE; - if ((ia_valid & ATTR_SIZE) | - ((ia_valid | ATTR_ATIME | ATTR_ATIME_SET) && - LTIME_S(attr->ia_atime) < LTIME_S(attr->ia_ctime)) || - ((ia_valid | ATTR_MTIME | ATTR_MTIME_SET) && - LTIME_S(attr->ia_mtime) < LTIME_S(attr->ia_ctime))) - /* perform truncate and setting mtime/atime to past under PW - * 0:EOF extent lock (new_size:EOF for truncate) */ + if ((ia_valid & ATTR_SIZE) || + (ia_valid | ATTR_ATIME | ATTR_ATIME_SET) || + (ia_valid | ATTR_MTIME | ATTR_MTIME_SET)) + /* on truncate and utimes send attributes to osts, setting + * mtime/atime to past will be performed under PW 0:EOF extent + * lock (new_size:EOF for truncate) + * it may seem excessive to send mtime/atime updates to osts + * when not setting times to past, but it is necessary due to + * possible time de-synchronization */ rc = ll_setattr_ost(inode, attr); EXIT; out: diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 7c8a604..7ab7760 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -306,10 +306,11 @@ static int vvp_io_setattr_lock(const struct lu_env *env, if (new_size == 0) enqflags = CEF_DISCARD_DATA; } else { - LASSERT((io->u.ci_setattr.sa_attr.lvb_mtime < - io->u.ci_setattr.sa_attr.lvb_ctime) || - (io->u.ci_setattr.sa_attr.lvb_atime < - io->u.ci_setattr.sa_attr.lvb_ctime)); + if ((io->u.ci_setattr.sa_attr.lvb_mtime >= + io->u.ci_setattr.sa_attr.lvb_ctime) || + (io->u.ci_setattr.sa_attr.lvb_atime >= + io->u.ci_setattr.sa_attr.lvb_ctime)) + return 0; new_size = 0; } cio->u.setattr.cui_local_lock = SETATTR_EXTENT_LOCK; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 75a1c3b..32f46ec 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2106,11 +2106,11 @@ test_39() { $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then echo "mtime" - ls -l $DIR/$tfile $DIR/${tfile}2 + ls -l --full-time $DIR/$tfile $DIR/${tfile}2 echo "atime" - ls -lu $DIR/$tfile $DIR/${tfile}2 + ls -lu --full-time $DIR/$tfile $DIR/${tfile}2 echo "ctime" - ls -lc $DIR/$tfile $DIR/${tfile}2 + ls -lc --full-time $DIR/$tfile $DIR/${tfile}2 error "O_TRUNC didn't change timestamps" fi } -- 1.8.3.1