Skip to content

Commit

Permalink
ext4: use ext4_write_inode() when fsyncing w/o a journal
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Theodore Ts'o committed Dec 31, 2018
1 parent e868078 commit ad211f3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fs/ext4/fsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,23 @@ 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))
goto issue_flush;
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.
Expand Down

0 comments on commit ad211f3

Please sign in to comment.