lkml.org 
[lkml]   [2023]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 08/11] cifs: Remove call to filemap_check_wb_err()
From
Date
On Mon, 2023-01-09 at 09:42 -0500, Jeff Layton wrote:
> On Mon, 2023-01-09 at 05:18 +0000, Matthew Wilcox (Oracle) wrote:
> > filemap_write_and_wait() now calls filemap_check_wb_err(), so we cannot
> > glean any additional information by calling it ourselves. It may also
> > be misleading as it will pick up on any errors since the beginning of
> > time which may well be since before this program opened the file.
> >
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > ---
> > fs/cifs/file.c | 8 +++-----
> > 1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> > index 22dfc1f8b4f1..7e7ee26cf77d 100644
> > --- a/fs/cifs/file.c
> > +++ b/fs/cifs/file.c
> > @@ -3042,14 +3042,12 @@ int cifs_flush(struct file *file, fl_owner_t id)
> > int rc = 0;
> >
> > if (file->f_mode & FMODE_WRITE)
> > - rc = filemap_write_and_wait(inode->i_mapping);
> > + rc = filemap_write_and_wait(file->f_mapping);
>
> If we're calling ->flush, then the file is being closed. Should this
> just be?
> rc = file_write_and_wait(file);
>
> It's not like we need to worry about corrupting ->f_wb_err at that
> point.
>

OTOH, I suppose it is possible for there to be racing fsync syscall with
a filp_close, and in that case advancing the f_wb_err might be a bad
idea, particularly since a lot of places ignore the return from
filp_close. It's probably best to _not_ advance the f_wb_err on ->flush
calls.

That said...wonder if we ought to consider making filp_close and ->flush
void return functions. There's no POSIX requirement to flush all of the
data on close(), so an application really shouldn't rely on seeing
writeback errors returned there since it's not reliable.

If you care about writeback errors, you have to call fsync -- full stop.

> >
> > cifs_dbg(FYI, "Flush inode %p file %p rc %d\n", inode, file rc);
> > - if (rc) {
> > - /* get more nuanced writeback errors */
> > - rc = filemap_check_wb_err(file->f_mapping, 0);
> > + if (rc)
> > trace_cifs_flush_err(inode->i_ino, rc);
> > - }
> > +
> > return rc;
> > }
> >
>

--
Jeff Layton <jlayton@redhat.com>

\
 
 \ /
  Last update: 2023-03-26 23:33    [W:0.348 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site