btrfs: test fsync after rename and link with cow and nocow writes
Test for fsync data loss after renaming a file or adding a hard link,
with a previous fsync of another file, as well as that mtime and ctime
are correct after a power failure. Test both with COW and NOCOW writes.
This currently fails differently on different kernels:
- For kernels older than 4.19 (<= 4.18) and kernels starting from 5.10,
the NOCOW tests are expected to fail very often on the mtime and ctime
checks.
The data loss check has slim chances of failing on a virtualized
environment, because the race that leads to the data loss is due to
the fsync() returning after writeback of the data finishes and
returning without issuing barriers (sending REQ_PREFLUSH to the
device), as explained in the test's comments.
For kernels between 4.19 (inclusive) and 5.9 (inclusive), it is not
expected to fail.
- For the btrfs integration branch (misc-next), and what is currently in
Linus' master branch (5.13 merge window changes), in addition to the
failures mentioned before, the test should fail very often on the data
loss and mtime/ctime checks for COW writes.
The issues are fixed by a patch for the kernel that has the following
subject:
"btrfs: fix race leading to unpersisted data and metadata on fsync"
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>