diff options
author | Filipe Manana <fdmanana@suse.com> | 2019-10-16 16:28:52 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-10-17 20:36:02 +0200 |
commit | ba0b084ac309283db6e329785c1dc4f45fdbd379 (patch) | |
tree | 04b984a30d1a5f79ddf3cb7920f4f4ef0c08814a /fs/btrfs/volumes.c | |
parent | c7967fc1499beb9b70bb9d33525fb0b384af8883 (diff) | |
download | linux-ba0b084ac309283db6e329785c1dc4f45fdbd379.tar.bz2 |
Btrfs: check for the full sync flag while holding the inode lock during fsync
We were checking for the full fsync flag in the inode before locking the
inode, which is racy, since at that that time it might not be set but
after we acquire the inode lock some other task set it. One case where
this can happen is on a system low on memory and some concurrent task
failed to allocate an extent map and therefore set the full sync flag on
the inode, to force the next fsync to work in full mode.
A consequence of missing the full fsync flag set is hitting the problems
fixed by commit 0c713cbab620 ("Btrfs: fix race between ranged fsync and
writeback of adjacent ranges"), BUG_ON() when dropping extents from a log
tree, hitting assertion failures at tree-log.c:copy_items() or all sorts
of weird inconsistencies after replaying a log due to file extents items
representing ranges that overlap.
So just move the check such that it's done after locking the inode and
before starting writeback again.
Fixes: 0c713cbab620 ("Btrfs: fix race between ranged fsync and writeback of adjacent ranges")
CC: stable@vger.kernel.org # 5.2+
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
0 files changed, 0 insertions, 0 deletions