Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "smayhew@redhat.com" <smayhew@redhat.com>,
	"anna.schumaker@netapp.com" <anna.schumaker@netapp.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 1/2] nfs: ensure correct writeback errors are returned on close()
Date: Fri, 31 Jul 2020 19:16:39 +0000
Message-ID: <cbd94bd68cbdefd06591ae7ba4d57fdd8b619ebf.camel@hammerspace.com> (raw)
In-Reply-To: <20200731174614.1299346-2-smayhew@redhat.com>

On Fri, 2020-07-31 at 13:46 -0400, Scott Mayhew wrote:
> nfs_wb_all() calls filemap_write_and_wait(), which uses
> filemap_check_errors() to determine the error to return.
> filemap_check_errors() only looks at the mapping->flags and will
> therefore only return either -ENOSPC or -EIO.  To ensure that the
> correct error is returned on close(), nfs{,4}_file_flush() should
> call
> file_check_and_advance_wb_err() which looks at the errseq value in
> mapping->wb_err.
> 
> Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism
> with
> generic one")
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> ---
>  fs/nfs/file.c     | 3 ++-
>  fs/nfs/nfs4file.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfs/file.c b/fs/nfs/file.c
> index f96367a2463e..eeef6580052f 100644
> --- a/fs/nfs/file.c
> +++ b/fs/nfs/file.c
> @@ -148,7 +148,8 @@ nfs_file_flush(struct file *file, fl_owner_t id)
>  		return 0;
>  
>  	/* Flush writes to the server and return any errors */
> -	return nfs_wb_all(inode);
> +	nfs_wb_all(inode);
> +	return file_check_and_advance_wb_err(file);
>  }
>  
>  ssize_t
> diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
> index 8e5d6223ddd3..77bf9c12734c 100644
> --- a/fs/nfs/nfs4file.c
> +++ b/fs/nfs/nfs4file.c
> @@ -125,7 +125,8 @@ nfs4_file_flush(struct file *file, fl_owner_t id)
>  		return filemap_fdatawrite(file->f_mapping);
>  
>  	/* Flush writes to the server and return any errors */
> -	return nfs_wb_all(inode);
> +	nfs_wb_all(inode);
> +	return file_check_and_advance_wb_err(file);
>  }
>  
>  #ifdef CONFIG_NFS_V4_2

I don't think this one is correct. The contract with POSIX is that we
always deliver the error on fsync(). If we call
file_check_and_advance_wb_err() here in nfs_file_flush(), then that
means we eat the error before it can get delivered to fsync().

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 17:46 [PATCH 0/2] nfs: two writeback error reporting fixes Scott Mayhew
2020-07-31 17:46 ` [PATCH 1/2] nfs: ensure correct writeback errors are returned on close() Scott Mayhew
2020-07-31 19:16   ` Trond Myklebust [this message]
2020-07-31 19:43     ` Scott Mayhew
2020-07-31 19:49       ` Trond Myklebust
2020-07-31 17:46 ` [PATCH 2/2] nfs: nfs_file_write() should check for writeback errors Scott Mayhew

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=cbd94bd68cbdefd06591ae7ba4d57fdd8b619ebf.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=anna.schumaker@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=smayhew@redhat.com \
    /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

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git