All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "anna@kernel.org" <anna@kernel.org>,
	"chenxiaosong2@huawei.com" <chenxiaosong2@huawei.com>,
	"smayhew@redhat.com" <smayhew@redhat.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	"liuyongqiang13@huawei.com" <liuyongqiang13@huawei.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"yi.zhang@huawei.com" <yi.zhang@huawei.com>,
	"zhangxiaoxu5@huawei.com" <zhangxiaoxu5@huawei.com>
Subject: Re: [PATCH -next 2/2] nfs: nfs_file_write() check writeback errors correctly
Date: Sat, 5 Mar 2022 17:12:46 +0000	[thread overview]
Message-ID: <461aafe64a56836b8d248556052f8d00b6d37731.camel@hammerspace.com> (raw)
In-Reply-To: <20220305124636.2002383-3-chenxiaosong2@huawei.com>

On Sat, 2022-03-05 at 20:46 +0800, ChenXiaoSong wrote:
> If nobody has seen the writeback error yet, then
> filemap_sample_wb_err()
> always return 0. Even if there is no new writeback error between
> filemap_sample_wb_err() and filemap_check_wb_err(),
> filemap_check_wb_err() will return the old error.
> 
> Fix this by using file->f_mapping->wb_err as the old error.
> 
> Fixes: ce368536dd61 ("nfs: nfs_file_write() should check for
> writeback errors")
> Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
> ---
>  fs/nfs/file.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfs/file.c b/fs/nfs/file.c
> index 83d63bce9596..8763f89c176a 100644
> --- a/fs/nfs/file.c
> +++ b/fs/nfs/file.c
> @@ -635,7 +635,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct
> iov_iter *from)
>  
>         nfs_clear_invalid_mapping(file->f_mapping);
>  
> -       since = filemap_sample_wb_err(file->f_mapping);
> +       since = file->f_mapping->wb_err;
>         nfs_start_io_write(inode);
>         result = generic_write_checks(iocb, from);
>         if (result > 0) {
> @@ -669,7 +669,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct
> iov_iter *from)
>                 goto out;
>  
>         /* Return error values */
> -       error = filemap_check_wb_err(file->f_mapping, since);
> +       error = errseq_check(&file->f_mapping->wb_err, since);
>         if (nfs_need_check_write(file, inode, error)) {
>                 int err = nfs_wb_all(inode);
>                 if (err < 0)

Hmm... Why isn't this considered a bug with filemap_sample_wb_err()? If
what you say is true, then do_dentry_open() could be picking up
existing errors from the filesystem and from the inode and propagating
them to random processes.

It basically means everyone who cares about correctness of the error
return values needs to do a fsync() immediately after open() in order
to sync up the value in file->f_wb_err.

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



  reply	other threads:[~2022-03-05 17:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-05 12:46 [PATCH -next 0/2] nfs: check writeback errors correctly ChenXiaoSong
2022-03-05 12:46 ` [PATCH -next 1/2] nfs: nfs{,4}_file_flush should consume writeback error ChenXiaoSong
2022-03-05 16:53   ` Trond Myklebust
2022-03-06  3:54     ` chenxiaosong (A)
2022-03-06 14:04       ` Trond Myklebust
2022-03-06 15:08         ` Trond Myklebust
2022-04-12 13:46           ` chenxiaosong (A)
2022-04-12 13:56             ` Trond Myklebust
2022-04-12 14:12               ` chenxiaosong (A)
2022-04-12 14:27                 ` Trond Myklebust
2022-04-20  8:50                   ` chenxiaosong (A)
2022-05-09  7:43                     ` chenxiaosong (A)
2022-03-05 12:46 ` [PATCH -next 2/2] nfs: nfs_file_write() check writeback errors correctly ChenXiaoSong
2022-03-05 17:12   ` Trond Myklebust [this message]
2022-03-06  8:50     ` chenxiaosong (A)

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=461aafe64a56836b8d248556052f8d00b6d37731.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=anna@kernel.org \
    --cc=chenxiaosong2@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=liuyongqiang13@huawei.com \
    --cc=smayhew@redhat.com \
    --cc=yi.zhang@huawei.com \
    --cc=zhangxiaoxu5@huawei.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.