From: Simon Wilkinson Date: Mon, 25 Apr 2011 18:18:39 +0000 (-0400) Subject: Linux: Don't read pages beyond the cache eof X-Git-Tag: upstream/1.6.0.pre5^2~7 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=2571b6285d5da8ef62ab38c3a938258ddd7bac4e;p=packages%2Fo%2Fopenafs.git Linux: Don't read pages beyond the cache eof If we attempt to read past the end of the current cache file (for example, when we're extending the file with ftruncate), don't force the backend filesystem to populate that page with non-existent data. This will hopefully fix a bus error when using tmpfs as a backing cache. FIXES 128452 Reviewed-on: http://gerrit.openafs.org/4562 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit 79d5b5cce65b10134004c4cb2b7b34ac509cba6a) Change-Id: Id9956be824a4c4d8db7deb65403f4d9740758e42 Reviewed-on: http://gerrit.openafs.org/4600 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index d8d23b57e..45e0a356a 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1415,15 +1415,26 @@ afs_linux_read_cache(struct file *cachefp, struct page *page, int chunk, struct pagevec *lrupv, struct afs_pagecopy_task *task) { loff_t offset = page_offset(page); + struct inode *cacheinode = cachefp->f_dentry->d_inode; struct page *newpage, *cachepage; struct address_space *cachemapping; - int pageindex; + int pageindex, endindex; int code = 0; - cachemapping = cachefp->f_dentry->d_inode->i_mapping; + cachemapping = cacheinode->i_mapping; newpage = NULL; cachepage = NULL; + /* If we're trying to read a page that's past the end of the disk + * cache file, then just return a zeroed page */ + if (offset >= i_size_read(cacheinode)) { + zero_user_segment(page, 0, PAGE_CACHE_SIZE); + SetPageUptodate(page); + if (task) + unlock_page(page); + return 0; + } + /* From our offset, we now need to work out which page in the disk * file it corresponds to. This will be fun ... */ pageindex = (offset - AFS_CHUNKTOBASE(chunk)) >> PAGE_CACHE_SHIFT;