aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2009-04-03 11:42:44 -0400
committerDavid Howells <dhowells@redhat.com>2009-04-03 11:42:44 -0400
commit9a9fc1c03315f1606596e55b4096d39e2079a041 (patch)
tree0eb9a2d9844a821e515baeb59e6d5e38384d5915 /fs/nfs/read.c
parentf42b293d6d5259043a8944b556eeab427c695d57 (diff)
NFS: Read pages from FS-Cache into an NFS inode
Read pages from an FS-Cache data storage object representing an inode into an NFS inode. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com> Acked-by: Al Viro <viro@zeniv.linux.org.uk> Tested-by: Daire Byrne <Daire.Byrne@framestore.com>
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 98b74009c9d7..e18ba792872f 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -24,6 +24,7 @@
24 24
25#include "internal.h" 25#include "internal.h"
26#include "iostat.h" 26#include "iostat.h"
27#include "fscache.h"
27 28
28#define NFSDBG_FACILITY NFSDBG_PAGECACHE 29#define NFSDBG_FACILITY NFSDBG_PAGECACHE
29 30
@@ -510,8 +511,15 @@ int nfs_readpage(struct file *file, struct page *page)
510 } else 511 } else
511 ctx = get_nfs_open_context(nfs_file_open_context(file)); 512 ctx = get_nfs_open_context(nfs_file_open_context(file));
512 513
514 if (!IS_SYNC(inode)) {
515 error = nfs_readpage_from_fscache(ctx, inode, page);
516 if (error == 0)
517 goto out;
518 }
519
513 error = nfs_readpage_async(ctx, inode, page); 520 error = nfs_readpage_async(ctx, inode, page);
514 521
522out:
515 put_nfs_open_context(ctx); 523 put_nfs_open_context(ctx);
516 return error; 524 return error;
517out_unlock: 525out_unlock:
@@ -584,6 +592,15 @@ int nfs_readpages(struct file *filp, struct address_space *mapping,
584 return -EBADF; 592 return -EBADF;
585 } else 593 } else
586 desc.ctx = get_nfs_open_context(nfs_file_open_context(filp)); 594 desc.ctx = get_nfs_open_context(nfs_file_open_context(filp));
595
596 /* attempt to read as many of the pages as possible from the cache
597 * - this returns -ENOBUFS immediately if the cookie is negative
598 */
599 ret = nfs_readpages_from_fscache(desc.ctx, inode, mapping,
600 pages, &nr_pages);
601 if (ret == 0)
602 goto read_complete; /* all pages were read */
603
587 if (rsize < PAGE_CACHE_SIZE) 604 if (rsize < PAGE_CACHE_SIZE)
588 nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0); 605 nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0);
589 else 606 else
@@ -594,6 +611,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping,
594 nfs_pageio_complete(&pgio); 611 nfs_pageio_complete(&pgio);
595 npages = (pgio.pg_bytes_written + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 612 npages = (pgio.pg_bytes_written + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
596 nfs_add_stats(inode, NFSIOS_READPAGES, npages); 613 nfs_add_stats(inode, NFSIOS_READPAGES, npages);
614read_complete:
597 put_nfs_open_context(desc.ctx); 615 put_nfs_open_context(desc.ctx);
598out: 616out:
599 return ret; 617 return ret;