aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2007-04-20 04:18:30 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2007-05-01 04:11:46 -0400
commitbf126aee6d54fe1e509846abf3b27aba84c6d7ce (patch)
tree5d21f057b2d5ee00cab9ac25f5d0e160bf57d533 /fs
parent476c006be009d4121e401a9e9f49a3362a7a272f (diff)
[GFS2] Patch to fix mmap of stuffed files
If a stuffed file is mmaped and a page fault is generated at some offset above the initial page, we need to create a zero page to hang the buffer heads off before we can unstuff the file. This is a fix for bz #236087 Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/ops_address.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 90c287932d58..30c15622174f 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -197,7 +197,19 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
197 void *kaddr; 197 void *kaddr;
198 int error; 198 int error;
199 199
200 BUG_ON(page->index); 200 /*
201 * Due to the order of unstuffing files and ->nopage(), we can be
202 * asked for a zero page in the case of a stuffed file being extended,
203 * so we need to supply one here. It doesn't happen often.
204 */
205 if (unlikely(page->index)) {
206 kaddr = kmap_atomic(page, KM_USER0);
207 memset(kaddr, 0, PAGE_CACHE_SIZE);
208 kunmap_atomic(kaddr, KM_USER0);
209 flush_dcache_page(page);
210 SetPageUptodate(page);
211 return 0;
212 }
201 213
202 error = gfs2_meta_inode_buffer(ip, &dibh); 214 error = gfs2_meta_inode_buffer(ip, &dibh);
203 if (error) 215 if (error)
@@ -208,9 +220,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
208 ip->i_di.di_size); 220 ip->i_di.di_size);
209 memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size); 221 memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size);
210 kunmap_atomic(kaddr, KM_USER0); 222 kunmap_atomic(kaddr, KM_USER0);
211 223 flush_dcache_page(page);
212 brelse(dibh); 224 brelse(dibh);
213
214 SetPageUptodate(page); 225 SetPageUptodate(page);
215 226
216 return 0; 227 return 0;