[PATCH] reiserfs_write_full_page() should not get_block past eof

reiserfs_write_full_page does zero bytes in the file past eof, but it may
call get_block on those buffers as well. On machines where the page size
is larger than the blocksize, this can result in mmaped files incorrectly
growing up to a block boundary during writepage.

The fix is to avoid calling get_block for any blocks that are entirely past
eof

Signed-off-by: Chris Mason <mason@suse.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Chris Mason and committed by Linus Torvalds b4c76fa7 b5f3953c

+12 -2
+12 -2
fs/reiserfs/inode.c
··· 2340 2340 unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT; 2341 2341 int error = 0; 2342 2342 unsigned long block; 2343 + sector_t last_block; 2343 2344 struct buffer_head *head, *bh; 2344 2345 int partial = 0; 2345 2346 int nr = 0; ··· 2388 2387 } 2389 2388 bh = head; 2390 2389 block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits); 2390 + last_block = (i_size_read(inode) - 1) >> inode->i_blkbits; 2391 2391 /* first map all the buffers, logging any direct items we find */ 2392 2392 do { 2393 - if ((checked || buffer_dirty(bh)) && (!buffer_mapped(bh) || 2394 - (buffer_mapped(bh) 2393 + if (block > last_block) { 2394 + /* 2395 + * This can happen when the block size is less than 2396 + * the page size. The corresponding bytes in the page 2397 + * were zero filled above 2398 + */ 2399 + clear_buffer_dirty(bh); 2400 + set_buffer_uptodate(bh); 2401 + } else if ((checked || buffer_dirty(bh)) && 2402 + (!buffer_mapped(bh) || (buffer_mapped(bh) 2395 2403 && bh->b_blocknr == 2396 2404 0))) { 2397 2405 /* not mapped yet, or it points to a direct item, search