public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: do_generic_file_read() never gets a NULL 'filp' argument
@ 2008-09-22  6:16 Krishna Kumar
  2008-09-22  8:33 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Krishna Kumar @ 2008-09-22  6:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: krkumar2, Krishna Kumar

From: Krishna Kumar <krkumar2@in.ibm.com>

The 'filp' argument to do_generic_file_read() is never NULL.

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 mm/filemap.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -ruNp 2.6.27-rc7-org/mm/filemap.c 2.6.27-rc7-new/mm/filemap.c
--- 2.6.27-rc7-org/mm/filemap.c	2008-09-17 12:53:25.000000000 +0530
+++ 2.6.27-rc7-new/mm/filemap.c	2008-09-17 12:53:59.000000000 +0530
@@ -1186,8 +1186,7 @@ out:
 	ra->prev_pos |= prev_offset;
 
 	*ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset;
-	if (filp)
-		file_accessed(filp);
+	file_accessed(filp);
 }
 
 int file_read_actor(read_descriptor_t *desc, struct page *page,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: do_generic_file_read() never gets a NULL 'filp' argument
  2008-09-22  6:16 [PATCH] mm: do_generic_file_read() never gets a NULL 'filp' argument Krishna Kumar
@ 2008-09-22  8:33 ` Andrew Morton
  2008-09-22  8:39   ` Christoph Hellwig
  2008-09-22  8:40   ` KOSAKI Motohiro
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2008-09-22  8:33 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: linux-kernel

On Mon, 22 Sep 2008 11:46:10 +0530 Krishna Kumar <krkumar2@in.ibm.com> wrote:

> From: Krishna Kumar <krkumar2@in.ibm.com>
> 
> The 'filp' argument to do_generic_file_read() is never NULL.
> 

How did you verify this?

NFS used to like passing NULL file*'s into VFS functions.  I don't
recall whether it affected do_generic_file_read().

>  mm/filemap.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff -ruNp 2.6.27-rc7-org/mm/filemap.c 2.6.27-rc7-new/mm/filemap.c
> --- 2.6.27-rc7-org/mm/filemap.c	2008-09-17 12:53:25.000000000 +0530
> +++ 2.6.27-rc7-new/mm/filemap.c	2008-09-17 12:53:59.000000000 +0530
> @@ -1186,8 +1186,7 @@ out:
>  	ra->prev_pos |= prev_offset;
>  
>  	*ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset;
> -	if (filp)
> -		file_accessed(filp);
> +	file_accessed(filp);
>  }
>  
>  int file_read_actor(read_descriptor_t *desc, struct page *page,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: do_generic_file_read() never gets a NULL 'filp' argument
  2008-09-22  8:33 ` Andrew Morton
@ 2008-09-22  8:39   ` Christoph Hellwig
  2008-09-22 17:36     ` Andrew Morton
  2008-09-22  8:40   ` KOSAKI Motohiro
  1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2008-09-22  8:39 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Krishna Kumar, linux-kernel

On Mon, Sep 22, 2008 at 01:33:38AM -0700, Andrew Morton wrote:
> On Mon, 22 Sep 2008 11:46:10 +0530 Krishna Kumar <krkumar2@in.ibm.com> wrote:
> 
> > From: Krishna Kumar <krkumar2@in.ibm.com>
> > 
> > The 'filp' argument to do_generic_file_read() is never NULL.
> > 
> 
> How did you verify this?
> 
> NFS used to like passing NULL file*'s into VFS functions.  I don't
> recall whether it affected do_generic_file_read().

The only thing nfsd passed a NULL file pointer in is ->fsync on
directories.  If anyone did pass a NULL file pointer into
do_generic_file_read it would oops in it's very first line of code.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: do_generic_file_read() never gets a NULL 'filp' argument
  2008-09-22  8:33 ` Andrew Morton
  2008-09-22  8:39   ` Christoph Hellwig
@ 2008-09-22  8:40   ` KOSAKI Motohiro
  1 sibling, 0 replies; 6+ messages in thread
From: KOSAKI Motohiro @ 2008-09-22  8:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: kosaki.motohiro, Krishna Kumar, linux-kernel

> On Mon, 22 Sep 2008 11:46:10 +0530 Krishna Kumar <krkumar2@in.ibm.com> wrote:
> 
> > From: Krishna Kumar <krkumar2@in.ibm.com>
> > 
> > The 'filp' argument to do_generic_file_read() is never NULL.
> > 
> 
> How did you verify this?
> 
> NFS used to like passing NULL file*'s into VFS functions.  I don't
> recall whether it affected do_generic_file_read().

Andrew, current do_generic_file_read have filp dereference at the beginning of function.
So, I believe nobody pass to NULL.


static void do_generic_file_read(struct file *filp, loff_t *ppos,
                read_descriptor_t *desc, read_actor_t actor)
{
        struct address_space *mapping = filp->f_mapping;  /* here */
        struct inode *inode = mapping->host;
        struct file_ra_state *ra = &filp->f_ra;          /* ditto */
        pgoff_t index;
        pgoff_t last_index;
        pgoff_t prev_index;



> 
> >  mm/filemap.c |    3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff -ruNp 2.6.27-rc7-org/mm/filemap.c 2.6.27-rc7-new/mm/filemap.c
> > --- 2.6.27-rc7-org/mm/filemap.c	2008-09-17 12:53:25.000000000 +0530
> > +++ 2.6.27-rc7-new/mm/filemap.c	2008-09-17 12:53:59.000000000 +0530
> > @@ -1186,8 +1186,7 @@ out:
> >  	ra->prev_pos |= prev_offset;
> >  
> >  	*ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset;
> > -	if (filp)
> > -		file_accessed(filp);
> > +	file_accessed(filp);
> >  }
> >  
> >  int file_read_actor(read_descriptor_t *desc, struct page *page,
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: do_generic_file_read() never gets a NULL 'filp' argument
  2008-09-22  8:39   ` Christoph Hellwig
@ 2008-09-22 17:36     ` Andrew Morton
  2008-09-23 11:00       ` KOSAKI Motohiro
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2008-09-22 17:36 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Krishna Kumar, linux-kernel

On Mon, 22 Sep 2008 04:39:46 -0400 Christoph Hellwig <hch@infradead.org> wrote:

> On Mon, Sep 22, 2008 at 01:33:38AM -0700, Andrew Morton wrote:
> > On Mon, 22 Sep 2008 11:46:10 +0530 Krishna Kumar <krkumar2@in.ibm.com> wrote:
> > 
> > > From: Krishna Kumar <krkumar2@in.ibm.com>
> > > 
> > > The 'filp' argument to do_generic_file_read() is never NULL.
> > > 
> > 
> > How did you verify this?
> > 
> > NFS used to like passing NULL file*'s into VFS functions.  I don't
> > recall whether it affected do_generic_file_read().
> 
> The only thing nfsd passed a NULL file pointer in is ->fsync on
> directories.

NFS, not NFSD.  It was page_cache_read(), iirc.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: do_generic_file_read() never gets a NULL 'filp' argument
  2008-09-22 17:36     ` Andrew Morton
@ 2008-09-23 11:00       ` KOSAKI Motohiro
  0 siblings, 0 replies; 6+ messages in thread
From: KOSAKI Motohiro @ 2008-09-23 11:00 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kosaki.motohiro, Christoph Hellwig, Krishna Kumar, linux-kernel

Hi Andrew,

> > > > The 'filp' argument to do_generic_file_read() is never NULL.
> > > 
> > > How did you verify this?
> > > 
> > > NFS used to like passing NULL file*'s into VFS functions.  I don't
> > > recall whether it affected do_generic_file_read().
> > 
> > The only thing nfsd passed a NULL file pointer in is ->fsync on
> > directories.
> 
> NFS, not NFSD.  It was page_cache_read(), iirc.

Is it important?
Cristoph wrote following decision reason at last mail.
I believe he was right.

> If anyone did pass a NULL file pointer into
> do_generic_file_read it would oops in it's very first line of code.


IOW, do_generic_file_read() has following calling hieralcy.

generic_file_aio_read()
  +- do_generic_file_read()

and fs/nfs/file.c has

	const struct file_operations nfs_file_operations = {
	        .llseek         = nfs_file_llseek,
	        .read           = do_sync_read,
	        .write          = do_sync_write,
	        .aio_read       = nfs_file_read,
	        .aio_write      = nfs_file_write,

So, nfs doesn't use generic_file_aio_read.
it directly indicate nfs doesn't use do_generic_file_read().

in the other hand, page_cache_read() has following calling hieralcy.

filemap_fault()
  +- page_cache_read()
      +- a_ops->readpage()

So, page_cache_read is mmap() related helper function and
do_generic_file_read is read() related helper function.
they are independent IMHO.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-09-23 11:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-22  6:16 [PATCH] mm: do_generic_file_read() never gets a NULL 'filp' argument Krishna Kumar
2008-09-22  8:33 ` Andrew Morton
2008-09-22  8:39   ` Christoph Hellwig
2008-09-22 17:36     ` Andrew Morton
2008-09-23 11:00       ` KOSAKI Motohiro
2008-09-22  8:40   ` KOSAKI Motohiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox