From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Lameter Subject: Re: [patch 10/19] Use page_cache_xxx in fs/buffer.c Date: Wed, 28 Nov 2007 19:48:08 -0800 (PST) Message-ID: References: <20071129011052.866354847@sgi.com> <20071129011146.563342672@sgi.com> <20071129033459.GT119954183@sgi.com> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Mel Gorman , William Lee Irwin III , Jens Axboe , Badari Pulavarty , Maxim Levitsky , Fengguang Wu , swin wang , totty.lu@gmail.com, hugh@veritas.com, joern@lazybastard.org To: David Chinner Return-path: Received: from relay1.sgi.com ([192.48.171.29]:37832 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755295AbXK2DsM (ORCPT ); Wed, 28 Nov 2007 22:48:12 -0500 In-Reply-To: <20071129033459.GT119954183@sgi.com> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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 --- 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; }