[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170616193427.13955-10-jlayton@redhat.com>
Date: Fri, 16 Jun 2017 15:34:14 -0400
From: Jeff Layton <jlayton@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Al Viro <viro@...IV.linux.org.uk>, Jan Kara <jack@...e.cz>,
tytso@....edu, axboe@...nel.dk, mawilcox@...rosoft.com,
ross.zwisler@...ux.intel.com, corbet@....net,
Chris Mason <clm@...com>, Josef Bacik <jbacik@...com>,
David Sterba <dsterba@...e.com>,
"Darrick J . Wong" <darrick.wong@...cle.com>
Cc: Carlos Maiolino <cmaiolino@...hat.com>,
Eryu Guan <eguan@...hat.com>,
David Howells <dhowells@...hat.com>,
Christoph Hellwig <hch@...radead.org>,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-ext4@...r.kernel.org, linux-xfs@...r.kernel.org,
linux-btrfs@...r.kernel.org, linux-block@...r.kernel.org
Subject: [PATCH v7 09/22] fs: always sync metadata in __generic_file_fsync
If there were previously both metadata and data writeback errors when
fsync is called, then it will currently take two calls to fsync() to
clear them on some filesystems.
The problem is in __generic_file_fsync, which won't try to write back
the metadata if the data flush fails. Fix this by always attempting to
write out the metadata, even when a flush of the data reports an error.
Signed-off-by: Jeff Layton <jlayton@...hat.com>
---
fs/libfs.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/libfs.c b/fs/libfs.c
index 1dec90819366..c93e77ecb49c 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -974,12 +974,12 @@ int __generic_file_fsync(struct file *file, loff_t start, loff_t end,
int err;
int ret;
- err = filemap_write_and_wait_range(inode->i_mapping, start, end);
- if (err)
- return err;
+ ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
inode_lock(inode);
- ret = sync_mapping_buffers(inode->i_mapping);
+ err = sync_mapping_buffers(inode->i_mapping);
+ if (ret == 0)
+ ret = err;
if (!(inode->i_state & I_DIRTY_ALL))
goto out;
if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
@@ -988,7 +988,6 @@ int __generic_file_fsync(struct file *file, loff_t start, loff_t end,
err = sync_inode_metadata(inode, 1);
if (ret == 0)
ret = err;
-
out:
inode_unlock(inode);
err = filemap_check_errors(inode->i_mapping);
--
2.13.0
Powered by blists - more mailing lists