generic/501: make the test work on machines with a non 4K page size
Currently generic/501 fails on machines with a page size different from 4K
(like ppc64le), because the clone operation fails with -EINVAL due to the
fact we pass it an offset that is 4K aligned but not aligned to the page
size of the machine.
The test doesn't actually need offsets and lengths to be 4K aligned, so
just update the test to use offsets and lenghts that work for page size.
Also add a comment mentioning that a file size of at least 16Mb was a
necessary condition to trigger the btrfs bug.
The test is a regression test for a btrfs issue fixed by kernel commit
bd3599a0e142cd ("Btrfs: fix file data corruption after cloning a range
and fsync"), which landed in kernel 4.18.
Since I couldn't compile a 4.17 kernel on debian testing, I tried this
with a 4.18 kernel with that commit reverted, and it fails as expected
on a x86_64 box:
$ ./check generic/501
FSTYP -- btrfs
PLATFORM -- Linux/x86_64 debian9 4.18.0-btrfs-next-64 #1 SMP (...)
MKFS_OPTIONS -- /dev/sdc
MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1
generic/501 1s ... - output mismatch (see .../xfstests/results//generic/501.out.bad)
--- tests/generic/501.out 2020-07-22 14:50:12.
585674202 +0100
+++ /home/fdmanana/git/hub/xfstests/results//generic/501.out.bad ...
@@ -2,4 +2,4 @@
File bar digest before power failure:
69319d0343ab8f5ea564167da445addc SCRATCH_MNT/bar
File bar digest after power failure:
-
69319d0343ab8f5ea564167da445addc SCRATCH_MNT/bar
+
21de7d7325fe4dae1f3311d5a76f819f SCRATCH_MNT/bar
...
(Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/generic/501.out ...
Ran: generic/501
Failures: generic/501
Failed 1 of 1 tests
Without the commit reverted it passes as expected.
Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>