diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-12-05 00:35:38 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-12-06 10:46:36 -0500 |
commit | 49a70f278658894d2899824cd4037095fb6711fe (patch) | |
tree | 8fc0e55be04a421ee9091a989c30807d891d7930 /fs/nfs/read.c | |
parent | 277459d2e2cd40594967757e8fd016c4c7016614 (diff) |
NFS: Cleanup: add common helper nfs_page_length()
Clean up a lot of ad-hoc page length calculations in fs/nfs/write.c
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r-- | fs/nfs/read.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index cca9fa259994..05cca6609977 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -30,6 +30,7 @@ | |||
30 | 30 | ||
31 | #include <asm/system.h> | 31 | #include <asm/system.h> |
32 | 32 | ||
33 | #include "internal.h" | ||
33 | #include "iostat.h" | 34 | #include "iostat.h" |
34 | 35 | ||
35 | #define NFSDBG_FACILITY NFSDBG_PAGECACHE | 36 | #define NFSDBG_FACILITY NFSDBG_PAGECACHE |
@@ -84,22 +85,6 @@ void nfs_readdata_release(void *data) | |||
84 | } | 85 | } |
85 | 86 | ||
86 | static | 87 | static |
87 | unsigned int nfs_page_length(struct inode *inode, struct page *page) | ||
88 | { | ||
89 | loff_t i_size = i_size_read(inode); | ||
90 | unsigned long idx; | ||
91 | |||
92 | if (i_size <= 0) | ||
93 | return 0; | ||
94 | idx = (i_size - 1) >> PAGE_CACHE_SHIFT; | ||
95 | if (page->index > idx) | ||
96 | return 0; | ||
97 | if (page->index != idx) | ||
98 | return PAGE_CACHE_SIZE; | ||
99 | return 1 + ((i_size - 1) & (PAGE_CACHE_SIZE - 1)); | ||
100 | } | ||
101 | |||
102 | static | ||
103 | int nfs_return_empty_page(struct page *page) | 88 | int nfs_return_empty_page(struct page *page) |
104 | { | 89 | { |
105 | memclear_highpage_flush(page, 0, PAGE_CACHE_SIZE); | 90 | memclear_highpage_flush(page, 0, PAGE_CACHE_SIZE); |
@@ -231,7 +216,7 @@ static int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, | |||
231 | struct nfs_page *new; | 216 | struct nfs_page *new; |
232 | unsigned int len; | 217 | unsigned int len; |
233 | 218 | ||
234 | len = nfs_page_length(inode, page); | 219 | len = nfs_page_length(page); |
235 | if (len == 0) | 220 | if (len == 0) |
236 | return nfs_return_empty_page(page); | 221 | return nfs_return_empty_page(page); |
237 | new = nfs_create_request(ctx, inode, page, 0, len); | 222 | new = nfs_create_request(ctx, inode, page, 0, len); |
@@ -667,7 +652,7 @@ readpage_async_filler(void *data, struct page *page) | |||
667 | unsigned int len; | 652 | unsigned int len; |
668 | 653 | ||
669 | nfs_wb_page(inode, page); | 654 | nfs_wb_page(inode, page); |
670 | len = nfs_page_length(inode, page); | 655 | len = nfs_page_length(page); |
671 | if (len == 0) | 656 | if (len == 0) |
672 | return nfs_return_empty_page(page); | 657 | return nfs_return_empty_page(page); |
673 | new = nfs_create_request(desc->ctx, inode, page, 0, len); | 658 | new = nfs_create_request(desc->ctx, inode, page, 0, len); |