Re: [patch 10/19] Use page_cache_xxx in fs/buffer.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 28, 2007 at 07:48:08PM -0800, Christoph Lameter wrote:
> 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.

fmeh.

> 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;
>  	}

Works for me.

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group
-
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

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux