Re: [PATCH v2 18/18] NFS: Remove unnecessary check in nfs_read_folio()

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

 



On Thu, Jan 19, 2023 at 04:33:51PM -0500, trondmy@xxxxxxxxxx wrote:
> From: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
> 
> All the callers are expected to supply a valid struct file argument, so
> there is no need for the NULL check.

Ummm.  Not sure that's true.  Look at this path:

mapping_read_folio_gfp(mapping, index, gfp)
do_read_cache_folio(mapping, index, NULL, NULL, gfp)
filemap_read_folio(NULL, mapping->a_ops->read_folio, folio)

It could well be that nobody does this to an NFS file!  The places where
I see this called tend to be filesystems doing it to block devices,
or filesystems doing it to their own files (eg reading a journal file
or quota file)

But I'm suspicious of static match tools claiming it can't ever happen,
and I'd like more details please.  I can't find the original report.
Also, it would have been nice to be cc'd on the folio conversion patches.

> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Reported-by: Dan Carpenter <error27@xxxxxxxxx>
> Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
> ---
>  fs/nfs/read.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/fs/nfs/read.c b/fs/nfs/read.c
> index bf4154f9b48c..c380cff4108e 100644
> --- a/fs/nfs/read.c
> +++ b/fs/nfs/read.c
> @@ -355,13 +355,7 @@ int nfs_read_folio(struct file *file, struct folio *folio)
>  	if (NFS_STALE(inode))
>  		goto out_unlock;
>  
> -	if (file == NULL) {
> -		ret = -EBADF;
> -		desc.ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
> -		if (desc.ctx == NULL)
> -			goto out_unlock;
> -	} else
> -		desc.ctx = get_nfs_open_context(nfs_file_open_context(file));
> +	desc.ctx = get_nfs_open_context(nfs_file_open_context(file));
>  
>  	xchg(&desc.ctx->error, 0);
>  	nfs_pageio_init_read(&desc.pgio, inode, false,
> -- 
> 2.39.0
> 



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux