* unused 'size' assignment in filemap_nopage
@ 2005-03-22 21:52 Jeff Moyer
2005-03-23 6:53 ` Jan Engelhardt
2005-03-23 11:08 ` Herbert Xu
0 siblings, 2 replies; 4+ messages in thread
From: Jeff Moyer @ 2005-03-22 21:52 UTC (permalink / raw)
To: linux-kernel
filemap_nopage has the following code:
retry_all:
size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
if (pgoff >= size)
goto outside_data_content;
/* If we don't want any read-ahead, don't bother */
if (VM_RandomReadHint(area))
goto no_cached_page;
/*
* The "size" of the file, as far as mmap is concerned, isn't bigger
* than the mapping
*/
if (size > endoff)
size = endoff;
After this, size is not referenced. So, either this potential reassignment
of size is superfluous, or we are missing some other code later on in the
function. If it is the former, I've attached a patch which will remove the
code.
Thanks,
Jeff
--- linux-2.6.12-rc1/mm/filemap.c.orig 2005-03-22 16:28:01.429426880 -0500
+++ linux-2.6.12-rc1/mm/filemap.c 2005-03-22 16:29:22.564092536 -0500
@@ -1191,13 +1191,6 @@ retry_all:
goto no_cached_page;
/*
- * The "size" of the file, as far as mmap is concerned, isn't bigger
- * than the mapping
- */
- if (size > endoff)
- size = endoff;
-
- /*
* The readahead code wants to be told about each and every page
* so it can build and shrink its windows appropriately
*
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: unused 'size' assignment in filemap_nopage
2005-03-22 21:52 unused 'size' assignment in filemap_nopage Jeff Moyer
@ 2005-03-23 6:53 ` Jan Engelhardt
2005-03-23 11:08 ` Herbert Xu
1 sibling, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2005-03-23 6:53 UTC (permalink / raw)
To: Jeff Moyer; +Cc: linux-kernel
> size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
> if (pgoff >= size)
> goto outside_data_content;
> ...
> if (size > endoff)
> size = endoff;
>
>After this, size is not referenced. So, either this potential reassignment
>of size is superfluous, or we are missing some other code later on in the
>function. If it is the former, I've attached a patch which will remove the
>code.
Only if you can make sure the SIZE will never be bigger than ENDOFF.
What you see here is basically:
size = min(endoff, (i_size_read...))
With a pgoff>=size somewhere ;)
Jan Engelhardt
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: unused 'size' assignment in filemap_nopage
2005-03-22 21:52 unused 'size' assignment in filemap_nopage Jeff Moyer
2005-03-23 6:53 ` Jan Engelhardt
@ 2005-03-23 11:08 ` Herbert Xu
2005-03-23 13:44 ` Jeff Moyer
1 sibling, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2005-03-23 11:08 UTC (permalink / raw)
To: jmoyer; +Cc: linux-kernel
Jeff Moyer <jmoyer@redhat.com> wrote:
>
> After this, size is not referenced. So, either this potential reassignment
> of size is superfluous, or we are missing some other code later on in the
> function. If it is the former, I've attached a patch which will remove the
> code.
Yes it's obsolete. You can remove endoff as well.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: unused 'size' assignment in filemap_nopage
2005-03-23 11:08 ` Herbert Xu
@ 2005-03-23 13:44 ` Jeff Moyer
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Moyer @ 2005-03-23 13:44 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-kernel
==> Regarding Re: unused 'size' assignment in filemap_nopage; Herbert Xu <herbert@gondor.apana.org.au> adds:
herbert> Jeff Moyer <jmoyer@redhat.com> wrote:
>> After this, size is not referenced. So, either this potential
>> reassignment of size is superfluous, or we are missing some other code
>> later on in the function. If it is the former, I've attached a patch
>> which will remove the code.
herbert> Yes it's obsolete. You can remove endoff as well.
Okay, here's the patch.
Thanks,
Jeff
--- linux-2.6.11/mm/filemap.c.orig 2005-03-23 08:32:38.182822976 -0500
+++ linux-2.6.11/mm/filemap.c 2005-03-23 08:33:34.966190592 -0500
@@ -1175,11 +1175,10 @@ struct page * filemap_nopage(struct vm_a
struct file_ra_state *ra = &file->f_ra;
struct inode *inode = mapping->host;
struct page *page;
- unsigned long size, pgoff, endoff;
+ unsigned long size, pgoff;
int did_readaround = 0, majmin = VM_FAULT_MINOR;
pgoff = ((address - area->vm_start) >> PAGE_CACHE_SHIFT) + area->vm_pgoff;
- endoff = ((area->vm_end - area->vm_start) >> PAGE_CACHE_SHIFT) + area->vm_pgoff;
retry_all:
size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
@@ -1191,13 +1190,6 @@ retry_all:
goto no_cached_page;
/*
- * The "size" of the file, as far as mmap is concerned, isn't bigger
- * than the mapping
- */
- if (size > endoff)
- size = endoff;
-
- /*
* The readahead code wants to be told about each and every page
* so it can build and shrink its windows appropriately
*
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-03-23 13:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-22 21:52 unused 'size' assignment in filemap_nopage Jeff Moyer
2005-03-23 6:53 ` Jan Engelhardt
2005-03-23 11:08 ` Herbert Xu
2005-03-23 13:44 ` Jeff Moyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®