Whamcloud - gitweb
b=22942 setattr fix
authorVladimir Saveliev <Vladimir.Saveliev@sun.com>
Tue, 21 Sep 2010 22:27:12 +0000 (02:27 +0400)
committerMikhail Pershin <tappro@sun.com>
Mon, 27 Sep 2010 13:25:15 +0000 (17:25 +0400)
send attributes to osts when truncate and utimes
(not only when setting times to past)

i=vitaly

lustre/liblustre/super.c
lustre/llite/llite_lib.c
lustre/llite/vvp_io.c
lustre/tests/sanity.sh

index f7e1693..916e4c8 100644 (file)
@@ -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:
index 19c743c..a984eb1 100644 (file)
@@ -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:
index 7c8a604..7ab7760 100644 (file)
@@ -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;
index 75a1c3b..32f46ec 100755 (executable)
@@ -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
 }