aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/internal.h
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-05 00:35:38 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-06 10:46:36 -0500
commit49a70f278658894d2899824cd4037095fb6711fe (patch)
tree8fc0e55be04a421ee9091a989c30807d891d7930 /fs/nfs/internal.h
parent277459d2e2cd40594967757e8fd016c4c7016614 (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/internal.h')
-rw-r--r--fs/nfs/internal.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index d205466233f6..a28f6ce2e131 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -217,3 +217,21 @@ void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
217 if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0) 217 if (sb->s_maxbytes > MAX_LFS_FILESIZE || sb->s_maxbytes <= 0)
218 sb->s_maxbytes = MAX_LFS_FILESIZE; 218 sb->s_maxbytes = MAX_LFS_FILESIZE;
219} 219}
220
221/*
222 * Determine the number of bytes of data the page contains
223 */
224static inline
225unsigned int nfs_page_length(struct page *page)
226{
227 loff_t i_size = i_size_read(page->mapping->host);
228
229 if (i_size > 0) {
230 pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
231 if (page->index < end_index)
232 return PAGE_CACHE_SIZE;
233 if (page->index == end_index)
234 return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1;
235 }
236 return 0;
237}