diff options
author | Theodore Ts'o <tytso@mit.edu> | 2018-12-31 00:10:48 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-16 22:07:13 +0100 |
commit | 82f71b8bc05c6866b7dfae96ebca5ee102f76afa (patch) | |
tree | a394e3669581460cc0a84be3042de3c7d96d3ca5 /fs/ext4 | |
parent | b17971aeaf144ec627b0516ecc990c0a3fd278fe (diff) | |
download | linux-stable-82f71b8bc05c6866b7dfae96ebca5ee102f76afa.tar.gz linux-stable-82f71b8bc05c6866b7dfae96ebca5ee102f76afa.tar.bz2 linux-stable-82f71b8bc05c6866b7dfae96ebca5ee102f76afa.zip |
ext4: use ext4_write_inode() when fsyncing w/o a journal
commit ad211f3e94b314a910d4af03178a0b52a7d1ee0a upstream.
In no-journal mode, we previously used __generic_file_fsync() in
no-journal mode. This triggers a lockdep warning, and in addition,
it's not safe to depend on the inode writeback mechanism in the case
ext4. We can solve both problems by calling ext4_write_inode()
directly.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/fsync.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index 26a7fe5c4fd3..87a7ff00ef62 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c @@ -116,8 +116,16 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) goto out; } + ret = file_write_and_wait_range(file, start, end); + if (ret) + return ret; + if (!journal) { - ret = __generic_file_fsync(file, start, end, datasync); + struct writeback_control wbc = { + .sync_mode = WB_SYNC_ALL + }; + + ret = ext4_write_inode(inode, &wbc); if (!ret) ret = ext4_sync_parent(inode); if (test_opt(inode->i_sb, BARRIER)) @@ -125,9 +133,6 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) goto out; } - ret = file_write_and_wait_range(file, start, end); - if (ret) - return ret; /* * data=writeback,ordered: * The caller's filemap_fdatawrite()/wait will sync the data. |