Commit 70b9ecbd authored by Trond Myklebust's avatar Trond Myklebust

NFS: Make stat() return updated mtimes after a write()

 The SuS states that a call to write() will cause mtime to be updated on
 the file. In order to satisfy that requirement, we need to flush out
 any cached writes in nfs_getattr().
 Speed things up slightly by not committing the writes.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 24174119
...@@ -952,6 +952,8 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) ...@@ -952,6 +952,8 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME; int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
int err; int err;
/* Flush out writes to the server in order to update c/mtime */
nfs_sync_inode(inode, 0, 0, FLUSH_WAIT|FLUSH_NOCOMMIT);
if (__IS_FLG(inode, MS_NOATIME)) if (__IS_FLG(inode, MS_NOATIME))
need_atime = 0; need_atime = 0;
else if (__IS_FLG(inode, MS_NODIRATIME) && S_ISDIR(inode->i_mode)) else if (__IS_FLG(inode, MS_NODIRATIME) && S_ISDIR(inode->i_mode))
......
...@@ -1377,22 +1377,23 @@ int nfs_commit_inode(struct inode *inode, int how) ...@@ -1377,22 +1377,23 @@ int nfs_commit_inode(struct inode *inode, int how)
int nfs_sync_inode(struct inode *inode, unsigned long idx_start, int nfs_sync_inode(struct inode *inode, unsigned long idx_start,
unsigned int npages, int how) unsigned int npages, int how)
{ {
int error, int nocommit = how & FLUSH_NOCOMMIT;
wait; int wait = how & FLUSH_WAIT;
int error;
wait = how & FLUSH_WAIT; how &= ~(FLUSH_WAIT|FLUSH_NOCOMMIT);
how &= ~FLUSH_WAIT;
do { do {
error = 0; if (wait) {
if (wait)
error = nfs_wait_on_requests(inode, idx_start, npages); error = nfs_wait_on_requests(inode, idx_start, npages);
if (error == 0) if (error != 0)
error = nfs_flush_inode(inode, idx_start, npages, how); continue;
#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) }
if (error == 0) error = nfs_flush_inode(inode, idx_start, npages, how);
if (error != 0)
continue;
if (!nocommit)
error = nfs_commit_inode(inode, how); error = nfs_commit_inode(inode, how);
#endif
} while (error > 0); } while (error > 0);
return error; return error;
} }
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#define FLUSH_STABLE 4 /* commit to stable storage */ #define FLUSH_STABLE 4 /* commit to stable storage */
#define FLUSH_LOWPRI 8 /* low priority background flush */ #define FLUSH_LOWPRI 8 /* low priority background flush */
#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */ #define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */
#define FLUSH_NOCOMMIT 32 /* Don't send the NFSv3/v4 COMMIT */
#ifdef __KERNEL__ #ifdef __KERNEL__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment