Linux NFS development
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: trondmy@kernel.org
Cc: Anna Schumaker <Anna.Schumaker@netapp.com>,
	linux-nfs@vger.kernel.org, error27@gmail.com
Subject: Re: [PATCH v2 18/18] NFS: Remove unnecessary check in nfs_read_folio()
Date: Thu, 23 Feb 2023 13:22:54 +0000	[thread overview]
Message-ID: <Y/dorq8Elh4Mxg2g@casper.infradead.org> (raw)
In-Reply-To: <20230119213351.443388-19-trondmy@kernel.org>

On Thu, Jan 19, 2023 at 04:33:51PM -0500, trondmy@kernel.org wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> 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@intel.com>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
>  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
> 

  reply	other threads:[~2023-02-23 13:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19 21:33 [PATCH v2 00/18] Initial conversion of NFS basic I/O to use folios trondmy
2023-01-19 21:33 ` [PATCH v2 01/18] NFS: Fix for xfstests generic/208 trondmy
2023-01-19 21:33   ` [PATCH v2 02/18] NFS: Add basic functionality for tracking folios in struct nfs_page trondmy
2023-01-19 21:33     ` [PATCH v2 03/18] NFS: Support folios in nfs_generic_pgio() trondmy
2023-01-19 21:33       ` [PATCH v2 04/18] NFS: Fix nfs_coalesce_size() to work with folios trondmy
2023-01-19 21:33         ` [PATCH v2 05/18] NFS: Add a helper to convert a struct nfs_page into an inode trondmy
2023-01-19 21:33           ` [PATCH v2 06/18] NFS: Convert the remaining pagelist helper functions to support folios trondmy
2023-01-19 21:33             ` [PATCH v2 07/18] NFS: Add a helper nfs_wb_folio() trondmy
2023-01-19 21:33               ` [PATCH v2 08/18] NFS: Convert buffered reads to use folios trondmy
2023-01-19 21:33                 ` [PATCH v2 09/18] NFS: Convert the function nfs_wb_page() " trondmy
2023-01-19 21:33                   ` [PATCH v2 10/18] NFS: Convert buffered writes " trondmy
2023-01-19 21:33                     ` [PATCH v2 11/18] NFS: Remove unused function nfs_wb_page() trondmy
2023-01-19 21:33                       ` [PATCH v2 12/18] NFS: Convert nfs_write_begin/end to use folios trondmy
2023-01-19 21:33                         ` [PATCH v2 13/18] NFS: Fix up nfs_vm_page_mkwrite() for folios trondmy
2023-01-19 21:33                           ` [PATCH v2 14/18] NFS: Clean up O_DIRECT request allocation trondmy
2023-01-19 21:33                             ` [PATCH v2 15/18] NFS: fix up nfs_release_folio() to try to release the page trondmy
2023-01-19 21:33                               ` [PATCH v2 16/18] NFS: Enable tracing of nfs_invalidate_folio() and nfs_launder_folio() trondmy
2023-01-19 21:33                                 ` [PATCH v2 17/18] NFS: Improve tracing of nfs_wb_folio() trondmy
2023-01-19 21:33                                   ` [PATCH v2 18/18] NFS: Remove unnecessary check in nfs_read_folio() trondmy
2023-02-23 13:22                                     ` Matthew Wilcox [this message]
2023-02-23 13:43                                       ` Dan Carpenter
2023-01-24 16:07 ` [PATCH v2 00/18] Initial conversion of NFS basic I/O to use folios Olga Kornievskaia
2023-01-24 16:41   ` Trond Myklebust

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/dorq8Elh4Mxg2g@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=Anna.Schumaker@netapp.com \
    --cc=error27@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox