diff options
author | Filipe Manana <fdmanana@suse.com> | 2016-01-21 10:17:54 +0000 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-01-25 16:50:26 -0800 |
commit | de0ee0edb21fbab4c7afa3e94573ecfebfb0244e (patch) | |
tree | 52b0a9db694a7810bed41f04fa5be2b843352484 /fs/nfs/iostat.h | |
parent | 6b5aa88c861cf0e4156e490009e2018d4fc81109 (diff) | |
download | linux-stable-de0ee0edb21fbab4c7afa3e94573ecfebfb0244e.tar.gz linux-stable-de0ee0edb21fbab4c7afa3e94573ecfebfb0244e.tar.bz2 linux-stable-de0ee0edb21fbab4c7afa3e94573ecfebfb0244e.zip |
Btrfs: fix race between fsync and lockless direct IO writes
An fsync, using the fast path, can race with a concurrent lockless direct
IO write and end up logging a file extent item that points to an extent
that wasn't written to yet. This is because the fast fsync path collects
ordered extents into a local list and then collects all the new extent
maps to log file extent items based on them, while the direct IO write
path creates the new extent map before it creates the corresponding
ordered extent (and submitting the respective bio(s)).
So fix this by making the direct IO write path create ordered extents
before the extent maps and make the fast fsync path collect any new
ordered extents after it collects the extent maps.
Note that making the fsync handler call inode_dio_wait() (after acquiring
the inode's i_mutex) would not work and lead to a deadlock when doing
AIO, as through AIO we end up in a path where the fsync handler is called
(through dio_aio_complete_work() -> dio_complete() -> vfs_fsync_range())
before the inode's dio counter is decremented (inode_dio_wait() waits
for this counter to have a value of zero).
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/nfs/iostat.h')
0 files changed, 0 insertions, 0 deletions