]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Cache bypass: make readpage deal with reads at end of file
authorMarc Dionne <marc.c.dionne@gmail.com>
Sun, 7 Nov 2010 18:14:55 +0000 (13:14 -0500)
committerDerrick Brashear <shadow@dementia.org>
Mon, 8 Nov 2010 19:40:31 +0000 (11:40 -0800)
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.

Change-Id: If86ed785c4e9d50edb1a960142f726fa869c50fc
Reviewed-on: http://gerrit.openafs.org/3281
Reviewed-by: Matt Benjamin <matt@linuxbox.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/afs/LINUX/osi_vnodeops.c

index 74895296701e7b88d87a71d5378071f65d8334a2..780c8efd3c0056827ff6bc636f4e371f6b24f5cc 100644 (file)
@@ -1820,6 +1820,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 */