file.c (edc4ff7c08e9885c40e60c4fb39fa42cc91a0602) | file.c (44b11874ff583b6e766a05856b04f3c492c32b84) |
---|---|
1/* 2 * linux/fs/nfs/file.c 3 * 4 * Copyright (C) 1992 Rick Sladkey 5 * 6 * Changes Copyright (C) 1994 by Florian La Roche 7 * - Do not copy data too often around in the kernel. 8 * - In nfs_file_read the return value of kmalloc wasn't checked. --- 113 unchanged lines hidden (view full) --- 122 /* Ensure that dirty pages are flushed out with the right creds */ 123 if (filp->f_mode & FMODE_WRITE) 124 filemap_fdatawrite(filp->f_mapping); 125 nfs_inc_stats(inode, NFSIOS_VFSRELEASE); 126 return NFS_PROTO(inode)->file_release(inode, filp); 127} 128 129/** | 1/* 2 * linux/fs/nfs/file.c 3 * 4 * Copyright (C) 1992 Rick Sladkey 5 * 6 * Changes Copyright (C) 1994 by Florian La Roche 7 * - Do not copy data too often around in the kernel. 8 * - In nfs_file_read the return value of kmalloc wasn't checked. --- 113 unchanged lines hidden (view full) --- 122 /* Ensure that dirty pages are flushed out with the right creds */ 123 if (filp->f_mode & FMODE_WRITE) 124 filemap_fdatawrite(filp->f_mapping); 125 nfs_inc_stats(inode, NFSIOS_VFSRELEASE); 126 return NFS_PROTO(inode)->file_release(inode, filp); 127} 128 129/** |
130 * nfs_revalidate_file - Revalidate the page cache & related metadata 131 * @inode - pointer to inode struct 132 * @file - pointer to file 133 */ 134static int nfs_revalidate_file(struct inode *inode, struct file *filp) 135{ 136 struct nfs_inode *nfsi = NFS_I(inode); 137 int retval = 0; 138 139 if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR)) 140 || nfs_attribute_timeout(inode)) 141 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode); 142 nfs_revalidate_mapping(inode, filp->f_mapping); 143 return 0; 144} 145 146/** | |
147 * nfs_revalidate_size - Revalidate the file size 148 * @inode - pointer to inode struct 149 * @file - pointer to struct file 150 * 151 * Revalidates the file length. This is basically a wrapper around 152 * nfs_revalidate_inode() that takes into account the fact that we may 153 * have cached writes (in which case we don't care about the server's 154 * idea of what the file length is), or O_DIRECT (in which case we --- 68 unchanged lines hidden (view full) --- 223 if (iocb->ki_filp->f_flags & O_DIRECT) 224 return nfs_file_direct_read(iocb, buf, count, pos); 225#endif 226 227 dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n", 228 dentry->d_parent->d_name.name, dentry->d_name.name, 229 (unsigned long) count, (unsigned long) pos); 230 | 130 * nfs_revalidate_size - Revalidate the file size 131 * @inode - pointer to inode struct 132 * @file - pointer to struct file 133 * 134 * Revalidates the file length. This is basically a wrapper around 135 * nfs_revalidate_inode() that takes into account the fact that we may 136 * have cached writes (in which case we don't care about the server's 137 * idea of what the file length is), or O_DIRECT (in which case we --- 68 unchanged lines hidden (view full) --- 206 if (iocb->ki_filp->f_flags & O_DIRECT) 207 return nfs_file_direct_read(iocb, buf, count, pos); 208#endif 209 210 dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n", 211 dentry->d_parent->d_name.name, dentry->d_name.name, 212 (unsigned long) count, (unsigned long) pos); 213 |
231 result = nfs_revalidate_file(inode, iocb->ki_filp); | 214 result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); |
232 nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count); 233 if (!result) 234 result = generic_file_aio_read(iocb, buf, count, pos); 235 return result; 236} 237 238static ssize_t 239nfs_file_sendfile(struct file *filp, loff_t *ppos, size_t count, 240 read_actor_t actor, void *target) 241{ 242 struct dentry *dentry = filp->f_dentry; 243 struct inode *inode = dentry->d_inode; 244 ssize_t res; 245 246 dfprintk(VFS, "nfs: sendfile(%s/%s, %lu@%Lu)\n", 247 dentry->d_parent->d_name.name, dentry->d_name.name, 248 (unsigned long) count, (unsigned long long) *ppos); 249 | 215 nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count); 216 if (!result) 217 result = generic_file_aio_read(iocb, buf, count, pos); 218 return result; 219} 220 221static ssize_t 222nfs_file_sendfile(struct file *filp, loff_t *ppos, size_t count, 223 read_actor_t actor, void *target) 224{ 225 struct dentry *dentry = filp->f_dentry; 226 struct inode *inode = dentry->d_inode; 227 ssize_t res; 228 229 dfprintk(VFS, "nfs: sendfile(%s/%s, %lu@%Lu)\n", 230 dentry->d_parent->d_name.name, dentry->d_name.name, 231 (unsigned long) count, (unsigned long long) *ppos); 232 |
250 res = nfs_revalidate_file(inode, filp); | 233 res = nfs_revalidate_mapping(inode, filp->f_mapping); |
251 if (!res) 252 res = generic_file_sendfile(filp, ppos, count, actor, target); 253 return res; 254} 255 256static int 257nfs_file_mmap(struct file * file, struct vm_area_struct * vma) 258{ 259 struct dentry *dentry = file->f_dentry; 260 struct inode *inode = dentry->d_inode; 261 int status; 262 263 dfprintk(VFS, "nfs: mmap(%s/%s)\n", 264 dentry->d_parent->d_name.name, dentry->d_name.name); 265 | 234 if (!res) 235 res = generic_file_sendfile(filp, ppos, count, actor, target); 236 return res; 237} 238 239static int 240nfs_file_mmap(struct file * file, struct vm_area_struct * vma) 241{ 242 struct dentry *dentry = file->f_dentry; 243 struct inode *inode = dentry->d_inode; 244 int status; 245 246 dfprintk(VFS, "nfs: mmap(%s/%s)\n", 247 dentry->d_parent->d_name.name, dentry->d_name.name); 248 |
266 status = nfs_revalidate_file(inode, file); | 249 status = nfs_revalidate_mapping(inode, file->f_mapping); |
267 if (!status) 268 status = generic_file_mmap(file, vma); 269 return status; 270} 271 272/* 273 * Flush any dirty pages for this process, and check for write errors. 274 * The return status from this call provides a reliable indication of --- 93 unchanged lines hidden (view full) --- 368 /* 369 * O_APPEND implies that we must revalidate the file length. 370 */ 371 if (iocb->ki_filp->f_flags & O_APPEND) { 372 result = nfs_revalidate_file_size(inode, iocb->ki_filp); 373 if (result) 374 goto out; 375 } | 250 if (!status) 251 status = generic_file_mmap(file, vma); 252 return status; 253} 254 255/* 256 * Flush any dirty pages for this process, and check for write errors. 257 * The return status from this call provides a reliable indication of --- 93 unchanged lines hidden (view full) --- 351 /* 352 * O_APPEND implies that we must revalidate the file length. 353 */ 354 if (iocb->ki_filp->f_flags & O_APPEND) { 355 result = nfs_revalidate_file_size(inode, iocb->ki_filp); 356 if (result) 357 goto out; 358 } |
376 nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); | |
377 378 result = count; 379 if (!count) 380 goto out; 381 382 nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); 383 result = generic_file_aio_write(iocb, buf, count, pos); 384out: --- 176 unchanged lines hidden --- | 359 360 result = count; 361 if (!count) 362 goto out; 363 364 nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); 365 result = generic_file_aio_write(iocb, buf, count, pos); 366out: --- 176 unchanged lines hidden --- |