From e3d1eaf0ca6bfddede5aba1d1fc3f1e25cdb259e Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Fri, 2 Oct 2009 23:15:26 +0100 Subject: [PATCH] Use page_offset() on Linux Since time began, Linux has provided page_offset() to turn a page index into an offset into the corresponding file. Make us use this everywhere we calculate a page offset, rather than doing our own maths. Reviewed-on: http://gerrit.openafs.org/581 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afs/LINUX/osi_vnodeops.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 44be0300f..75a510303 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1738,7 +1738,7 @@ afs_linux_bypass_readpages(struct file *fp, struct address_space *mapping, } if(page_ix == 0) { - offset = ((lof_t) pp->index) << PAGE_CACHE_SHIFT; + offset = page_offset(pp); auio->uio_offset = offset; base_index = pp->index; } @@ -1806,19 +1806,12 @@ afs_linux_bypass_readpage(struct file *fp, struct page *pp) ClearPageError(pp); - /* If the page is past the end of the file, skip it */ - isize = (i_size_read(fp->f_mapping->host) - 1) >> PAGE_CACHE_SHIFT; - if(pp->index > isize) { - if (PageLocked(pp)) - UnlockPage(pp); - return 0; - } /* receiver frees */ auio = osi_Alloc(sizeof(uio_t)); iovecp = osi_Alloc(sizeof(struct iovec)); /* address can be NULL, because we overwrite it with 'pp', below */ - setup_uio(auio, iovecp, NULL, (pp->index << PAGE_CACHE_SHIFT), + setup_uio(auio, iovecp, NULL, page_offset(pp), PAGE_SIZE, UIO_READ, AFS_UIOSYS); /* save the page for background map */ @@ -2012,7 +2005,7 @@ afs_linux_writepage_sync(struct inode *ip, struct page *pp, int f_flags = 0; buffer = kmap(pp) + offset; - base = (((loff_t) pp->index) << PAGE_CACHE_SHIFT) + offset; + base = page_offset(pp) + offset; credp = crref(); afs_maybe_lock_kernel(); -- 2.39.5