aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/file.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2005-06-22 13:16:30 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2005-06-22 16:07:37 -0400
commitfe51beecc55d0b0dce289e4758e7c529a642f63e (patch)
tree9790d77fafbb52b9237ecd65c57002e87f914e12 /fs/nfs/file.c
parent7d52e86274e09fce8ac8f963e3605a84d0a305a7 (diff)
[PATCH] NFS: Ensure that fstat() always returns the correct mtime
Even if the file is open for writes. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r--fs/nfs/file.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 40436857ed42..5621ba9885f4 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -128,6 +128,21 @@ nfs_file_release(struct inode *inode, struct file *filp)
128} 128}
129 129
130/** 130/**
131 * nfs_revalidate_file - Revalidate the page cache & related metadata
132 * @inode - pointer to inode struct
133 * @file - pointer to file
134 */
135static int nfs_revalidate_file(struct inode *inode, struct file *filp)
136{
137 int retval = 0;
138
139 if ((NFS_FLAGS(inode) & NFS_INO_REVAL_PAGECACHE) || nfs_attribute_timeout(inode))
140 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
141 nfs_revalidate_mapping(inode, filp->f_mapping);
142 return 0;
143}
144
145/**
131 * nfs_revalidate_size - Revalidate the file size 146 * nfs_revalidate_size - Revalidate the file size
132 * @inode - pointer to inode struct 147 * @inode - pointer to inode struct
133 * @file - pointer to struct file 148 * @file - pointer to struct file
@@ -149,7 +164,8 @@ static int nfs_revalidate_file_size(struct inode *inode, struct file *filp)
149 goto force_reval; 164 goto force_reval;
150 if (nfsi->npages != 0) 165 if (nfsi->npages != 0)
151 return 0; 166 return 0;
152 return nfs_revalidate_inode(server, inode); 167 if (!(NFS_FLAGS(inode) & NFS_INO_REVAL_PAGECACHE) && !nfs_attribute_timeout(inode))
168 return 0;
153force_reval: 169force_reval:
154 return __nfs_revalidate_inode(server, inode); 170 return __nfs_revalidate_inode(server, inode);
155} 171}
@@ -210,7 +226,7 @@ nfs_file_read(struct kiocb *iocb, char __user * buf, size_t count, loff_t pos)
210 dentry->d_parent->d_name.name, dentry->d_name.name, 226 dentry->d_parent->d_name.name, dentry->d_name.name,
211 (unsigned long) count, (unsigned long) pos); 227 (unsigned long) count, (unsigned long) pos);
212 228
213 result = nfs_revalidate_inode(NFS_SERVER(inode), inode); 229 result = nfs_revalidate_file(inode, iocb->ki_filp);
214 if (!result) 230 if (!result)
215 result = generic_file_aio_read(iocb, buf, count, pos); 231 result = generic_file_aio_read(iocb, buf, count, pos);
216 return result; 232 return result;
@@ -228,7 +244,7 @@ nfs_file_sendfile(struct file *filp, loff_t *ppos, size_t count,
228 dentry->d_parent->d_name.name, dentry->d_name.name, 244 dentry->d_parent->d_name.name, dentry->d_name.name,
229 (unsigned long) count, (unsigned long long) *ppos); 245 (unsigned long) count, (unsigned long long) *ppos);
230 246
231 res = nfs_revalidate_inode(NFS_SERVER(inode), inode); 247 res = nfs_revalidate_file(inode, filp);
232 if (!res) 248 if (!res)
233 res = generic_file_sendfile(filp, ppos, count, actor, target); 249 res = generic_file_sendfile(filp, ppos, count, actor, target);
234 return res; 250 return res;
@@ -244,7 +260,7 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
244 dfprintk(VFS, "nfs: mmap(%s/%s)\n", 260 dfprintk(VFS, "nfs: mmap(%s/%s)\n",
245 dentry->d_parent->d_name.name, dentry->d_name.name); 261 dentry->d_parent->d_name.name, dentry->d_name.name);
246 262
247 status = nfs_revalidate_inode(NFS_SERVER(inode), inode); 263 status = nfs_revalidate_file(inode, file);
248 if (!status) 264 if (!status)
249 status = generic_file_mmap(file, vma); 265 status = generic_file_mmap(file, vma);
250 return status; 266 return status;
@@ -340,8 +356,8 @@ nfs_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t
340 result = nfs_revalidate_file_size(inode, iocb->ki_filp); 356 result = nfs_revalidate_file_size(inode, iocb->ki_filp);
341 if (result) 357 if (result)
342 goto out; 358 goto out;
343 } else 359 }
344 nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); 360 nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping);
345 361
346 result = count; 362 result = count;
347 if (!count) 363 if (!count)