mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "miklos@szeredi.hu" <miklos@szeredi.hu>,
	"jlayton@kernel.org" <jlayton@kernel.org>
Cc: "chenxiaosong2@huawei.com" <chenxiaosong2@huawei.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"liuyongqiang13@huawei.com" <liuyongqiang13@huawei.com>,
	"zhangxiaoxu5@huawei.com" <zhangxiaoxu5@huawei.com>,
	"yi.zhang@huawei.com" <yi.zhang@huawei.com>
Subject: Re: [PATCH -next,v2] fuse: return the more nuanced writeback error on close()
Date: Tue, 31 May 2022 15:31:41 +0000	[thread overview]
Message-ID: <9dd14ee55bd023d59dc4d3621cb4042b502872ba.camel@hammerspace.com> (raw)
In-Reply-To: <CAJfpegt-+6oSCxx1-LHet4qm4s7p0jSoP9Vg8PJka3=1dqBXng@mail.gmail.com>

On Mon, 2022-05-30 at 14:13 +0200, Miklos Szeredi wrote:
> On Mon, 23 May 2022 at 03:35, ChenXiaoSong <chenxiaosong2@huawei.com>
> wrote:
> > 
> > As filemap_check_errors() only report -EIO or -ENOSPC, we return
> > more nuanced
> > writeback error -(file->f_mapping->wb_err & MAX_ERRNO).
> > 
> >   filemap_write_and_wait
> >     filemap_write_and_wait_range
> >       filemap_check_errors
> >         -ENOSPC or -EIO
> >   filemap_check_wb_err
> >     errseq_check
> >       return -(file->f_mapping->wb_err & MAX_ERRNO)
> > 
> > Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
> > ---
> >  fs/fuse/file.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> > index f18d14d5fea1..9917bc2795e6 100644
> > --- a/fs/fuse/file.c
> > +++ b/fs/fuse/file.c
> > @@ -488,10 +488,10 @@ static int fuse_flush(struct file *file,
> > fl_owner_t id)
> >         inode_unlock(inode);
> > 
> >         err = filemap_check_errors(file->f_mapping);
> > +       /* return more nuanced writeback errors */
> >         if (err)
> > -               return err;
> > +               return filemap_check_wb_err(file->f_mapping, 0);
> 
> I'm wondering if this should be file_check_and_advance_wb_err()
> instead.
> 
> Is there a difference between ->flush() and ->fsync()?
> 
> Jeff, can you please help?
> 

Hi Miklos,

We just went through this discussion for the case of NFS.

The point is that ->flush() is only called on close(). While you can
report errors in close(), the 'man 2 fsync' manpage documents that
post-Linux 4.13, the writeback errors are required to be returned on -
>fsync(). You should therefore not be calling
file_check_and_advance_wb_err() in anything that is being called as
part of close() since that will clear the error from the errseq_t and
prevent it from being reported in a future fsync() call from a dup()ed
file descriptor, etc.

NFS also wants to make a special case out of write() when we know that
the error is one of EDQUOT, EFBIG or ENOSPC, in which case we will also
use  file_check_and_advance_wb_err() to return the error immediately,
and clear it from the errseq_t.

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



      parent reply	other threads:[~2022-05-31 15:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23  1:48 ChenXiaoSong
2022-05-30 12:13 ` Miklos Szeredi
2022-05-30 14:02   ` Jeff Layton
2022-05-30 14:38     ` Miklos Szeredi
2022-05-30 22:33     ` NeilBrown
2022-05-31 15:31   ` Trond Myklebust [this message]

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=9dd14ee55bd023d59dc4d3621cb4042b502872ba.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=chenxiaosong2@huawei.com \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyongqiang13@huawei.com \
    --cc=miklos@szeredi.hu \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®