On Thu, 29 Nov 2007, David Chinner wrote: > > - while (index > (curidx = (curpos = *bytes)>>PAGE_CACHE_SHIFT)) { > > - zerofrom = curpos & ~PAGE_CACHE_MASK; > > + while (index > (curidx = page_cache_index(mapping, (curpos = *bytes)))) { > > + zerofrom = page_cache_offset(mapping, curpos); > > That doesn't get any prettier. Perhaps: > > while (index > (curidx = page_cache_index(mapping, *bytes))) { > curpos = *bytes; > zerofrom = page_cache_offset(mapping, curpos); Results in a gcc warning about the possible use of an unitialized variable. How about this? fs/buffer.c enhancements and fixes Signed-off-by: Christoph Lameter <clameter@xxxxxxx> --- fs/buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Index: mm/fs/buffer.c =================================================================== --- mm.orig/fs/buffer.c 2007-11-28 19:39:23.606383803 -0800 +++ mm/fs/buffer.c 2007-11-28 19:46:10.238382715 -0800 @@ -914,11 +914,10 @@ struct buffer_head *alloc_page_buffers(s { struct buffer_head *bh, *head; long offset; - unsigned int page_size = page_cache_size(page->mapping); try_again: head = NULL; - offset = page_size; + offset = page_cache_size(page->mapping); while ((offset -= size) >= 0) { bh = alloc_buffer_head(GFP_NOFS); if (!bh) @@ -2221,7 +2220,8 @@ int cont_expand_zero(struct file *file, index = page_cache_index(mapping, pos); offset = page_cache_offset(mapping, pos); - while (index > (curidx = page_cache_index(mapping, (curpos = *bytes)))) { + while (curpos = *bytes, curidx = page_cache_index(mapping, curpos), + index > curidx) { zerofrom = page_cache_offset(mapping, curpos); if (zerofrom & (blocksize-1)) { *bytes |= (blocksize-1); @@ -2368,7 +2368,7 @@ block_page_mkwrite(struct vm_area_struct mapping = page->mapping; size = i_size_read(inode); if ((mapping != inode->i_mapping) || - (page_offset(page) > size)) { + (page_cache_pos(mapping, page->index, 0) > size)) { /* page got truncated out from underneath us */ goto out_unlock; } - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html