aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-01-03 03:55:34 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-01-06 14:58:50 -0500
commit70b9ecbdb9c5fdc731f8780bffd45d9519020c4a (patch)
tree4678182bd417945cd424a652396510bc53eff8b7
parent24174119c73983d5217da8f56a12c79a9b57e056 (diff)
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: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/nfs/write.c23
-rw-r--r--include/linux/nfs_fs.h1
3 files changed, 15 insertions, 11 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index acde2c5725bf..2c7f8aac1dec 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -952,6 +952,8 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
952 int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME; 952 int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
953 int err; 953 int err;
954 954
955 /* Flush out writes to the server in order to update c/mtime */
956 nfs_sync_inode(inode, 0, 0, FLUSH_WAIT|FLUSH_NOCOMMIT);
955 if (__IS_FLG(inode, MS_NOATIME)) 957 if (__IS_FLG(inode, MS_NOATIME))
956 need_atime = 0; 958 need_atime = 0;
957 else if (__IS_FLG(inode, MS_NODIRATIME) && S_ISDIR(inode->i_mode)) 959 else if (__IS_FLG(inode, MS_NODIRATIME) && S_ISDIR(inode->i_mode))
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 1ce0c200df16..9449b6835509 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1377,22 +1377,23 @@ int nfs_commit_inode(struct inode *inode, int how)
1377int nfs_sync_inode(struct inode *inode, unsigned long idx_start, 1377int nfs_sync_inode(struct inode *inode, unsigned long idx_start,
1378 unsigned int npages, int how) 1378 unsigned int npages, int how)
1379{ 1379{
1380 int error, 1380 int nocommit = how & FLUSH_NOCOMMIT;
1381 wait; 1381 int wait = how & FLUSH_WAIT;
1382 int error;
1382 1383
1383 wait = how & FLUSH_WAIT; 1384 how &= ~(FLUSH_WAIT|FLUSH_NOCOMMIT);
1384 how &= ~FLUSH_WAIT;
1385 1385
1386 do { 1386 do {
1387 error = 0; 1387 if (wait) {
1388 if (wait)
1389 error = nfs_wait_on_requests(inode, idx_start, npages); 1388 error = nfs_wait_on_requests(inode, idx_start, npages);
1390 if (error == 0) 1389 if (error != 0)
1391 error = nfs_flush_inode(inode, idx_start, npages, how); 1390 continue;
1392#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 1391 }
1393 if (error == 0) 1392 error = nfs_flush_inode(inode, idx_start, npages, how);
1393 if (error != 0)
1394 continue;
1395 if (!nocommit)
1394 error = nfs_commit_inode(inode, how); 1396 error = nfs_commit_inode(inode, how);
1395#endif
1396 } while (error > 0); 1397 } while (error > 0);
1397 return error; 1398 return error;
1398} 1399}
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index d38010ba6477..408d82d3d97c 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -62,6 +62,7 @@
62#define FLUSH_STABLE 4 /* commit to stable storage */ 62#define FLUSH_STABLE 4 /* commit to stable storage */
63#define FLUSH_LOWPRI 8 /* low priority background flush */ 63#define FLUSH_LOWPRI 8 /* low priority background flush */
64#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */ 64#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */
65#define FLUSH_NOCOMMIT 32 /* Don't send the NFSv3/v4 COMMIT */
65 66
66#ifdef __KERNEL__ 67#ifdef __KERNEL__
67 68