From c10f264656ccc03549de4f6aa11bf08e33148668 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Sun, 7 Nov 2010 13:14:55 -0500 Subject: [PATCH] Cache bypass: make readpage deal with reads at end of file When a file's size is an exact multiple of the page size, the vfs will issue a readpage for an extra page at the end, for which there is no data. Deal with it here instead of letting it trickle down to the background daemon, which will issue an unnecessary read to the server, and maybe get confused because there is no data. Reviewed-on: http://gerrit.openafs.org/3281 Reviewed-by: Matt Benjamin Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit 8ec31f26770ef1e85fb3a6005467f0e2d3ce1715) Change-Id: Ib47a8cc62611c6e7c904898990b38ae48d8478e3 Reviewed-on: http://gerrit.openafs.org/3642 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/LINUX/osi_vnodeops.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 8df04ec76..b799bc115 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1809,6 +1809,17 @@ afs_linux_bypass_readpage(struct file *fp, struct page *pp) struct nocache_read_request *ancr; int code; + /* + * Special case: if page is at or past end of file, just zero it and set + * it as up to date. + */ + if (page_offset(pp) >= i_size_read(fp->f_mapping->host)) { + zero_user_segment(pp, 0, PAGE_CACHE_SIZE); + SetPageUptodate(pp); + unlock_page(pp); + return 0; + } + ClearPageError(pp); /* receiver frees */ -- 2.39.5