From 213445468f0928cff918c31f6a53fac24258de0b Mon Sep 17 00:00:00 2001 From: anserper Date: Fri, 17 Jul 2009 16:04:06 +0000 Subject: [PATCH] b=18801 i=Johann Lombardi i=Girish Shilamkar mtime fix for dio --- lustre/autoconf/lustre-core.m4 | 18 ++++++++++++++++++ lustre/include/linux/lustre_compat25.h | 6 ++++++ lustre/llite/rw.c | 2 ++ lustre/tests/sanityN.sh | 17 +++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f15857e..d4f3c2c 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -976,6 +976,23 @@ LB_LINUX_TRY_COMPILE([ EXTRA_KCFLAGS="$tmp_flags" ]) +# LC_FILE_UPDATE_TIME +# 2.6.9 has inode_update_time instead of file_update_time +AC_DEFUN([LC_FILE_UPDATE_TIME], +[AC_MSG_CHECKING([if file_update_time is exported]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + file_update_time(NULL); +],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FILE_UPDATE_TIME, 1, + [use file_update_time]) +],[ + AC_MSG_RESULT(no) +]) +]) + # LC_FILE_WRITEV # 2.6.19 replaced writev with aio_write AC_DEFUN([LC_FILE_WRITEV], @@ -1887,6 +1904,7 @@ AC_DEFUN([LC_PROG_LINUX], # 2.6.19 LC_INODE_BLKSIZE LC_VFS_READDIR_U64_INO + LC_FILE_UPDATE_TIME LC_FILE_WRITEV LC_FILE_READV diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 62eeb47..34ea09e 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -615,5 +615,11 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) #define bio_hw_segments(q, bio) 0 #endif +#ifdef HAVE_FILE_UPDATE_TIME +#define ll_update_time(file) file_update_time(file) +#else +#define ll_update_time(file) inode_update_time(file->f_mapping->host, 1) +#endif + #endif /* __KERNEL__ */ #endif /* _COMPAT25_H */ diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 1487e57..d97ade6 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -2379,6 +2379,8 @@ ssize_t ll_file_lockless_io(struct file *file, const struct iovec *iov, } if (file->f_flags & O_DIRECT) { + if (rw == WRITE) + ll_update_time(file); /* do not copy data for O_DIRECT */ rc = ll_direct_IO(rw, file, iov, *ppos, nr_segs, 0); if (rc > 0) diff --git a/lustre/tests/sanityN.sh b/lustre/tests/sanityN.sh index db77e5d..fcc3ccd 100644 --- a/lustre/tests/sanityN.sh +++ b/lustre/tests/sanityN.sh @@ -841,6 +841,23 @@ test_37() { # bug 18695 } run_test 37 "check i_size is not updated for directory on close (bug 18695) ==============" +test_39() { + local originaltime + local updatedtime + local delay=3 + + touch $DIR1/$tfile + originaltime=$(stat -c %Y $DIR1/$tfile) + log "original modification time is $originaltime" + sleep $delay + multiop $DIR1/$tfile oO_DIRECT:O_WRONLY:w$((10*1048576))c || error "multiop has failed" + updatedtime=$(stat -c %Y $DIR2/$tfile) + log "updated modification time is $updatedtime" + [ $((updatedtime - originaltime)) -ge $delay ] || error "invalid modification time" + rm -rf $DIR/$tfile +} +run_test 39 "direct I/O writes should update mtime =========" + log "cleanup: ======================================================" check_and_cleanup_lustre -- 1.8.3.1