From 762e8111d2dc7d4edffb002241e8cda1f7cf4129 Mon Sep 17 00:00:00 2001
From: bobijam <bobijam>
Date: Tue, 22 Jul 2008 02:41:46 +0000
Subject: [PATCH] Branch b1_6 b=11063 i=johann, adilger

update mtime on file close.
---
 lustre/mds/mds_open.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c
index e7d4023325..a0063de3da 100644
--- a/lustre/mds/mds_open.c
+++ b/lustre/mds/mds_open.c
@@ -1407,17 +1407,28 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset,
 
         }
 #endif
-        if (request_body != NULL && request_body->valid & OBD_MD_FLATIME) {
-                /* Only start a transaction to write out only the atime if
-                 * it is more out-of-date than the specified limit.  If we
-                 * are already going to write out the atime then do it anyway.
-                 * */
-                LTIME_S(iattr.ia_atime) = request_body->atime;
-                if ((LTIME_S(iattr.ia_atime) >
-                     LTIME_S(inode->i_atime) + mds->mds_atime_diff) ||
-                    (iattr.ia_valid != 0 &&
-                     LTIME_S(iattr.ia_atime) > LTIME_S(inode->i_atime)))
-                        iattr.ia_valid |= ATTR_ATIME;
+        if (request_body != NULL) {
+               if (request_body->valid & OBD_MD_FLMTIME) {
+                      LTIME_S(iattr.ia_mtime) = request_body->mtime;
+                      if (LTIME_S(iattr.ia_mtime) > LTIME_S(inode->i_mtime) &&
+                          ((request_body->valid & OBD_MD_FLCTIME) == 0 ||
+                           request_body->ctime > LTIME_S(inode->i_ctime)))
+                              iattr.ia_valid |= ATTR_MTIME;
+               }
+
+               if (request_body->valid & OBD_MD_FLATIME) {
+                       /* Only start a transaction to write out only the atime
+                        * if it is more out-of-date than the specified limit.
+                        * If we are already going to write out the inode then
+                        * update the atime anyway.
+                        */
+                       LTIME_S(iattr.ia_atime) = request_body->atime;
+                       if ((LTIME_S(iattr.ia_atime) >
+                            LTIME_S(inode->i_atime) + mds->mds_atime_diff) ||
+                           (iattr.ia_valid != 0 &&
+                            LTIME_S(iattr.ia_atime) > LTIME_S(inode->i_atime)))
+                               iattr.ia_valid |= ATTR_ATIME;
+               }
         }
 
         if (iattr.ia_valid != 0) {
-- 
GitLab