generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 610
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 610
6 #
7 # Test a fallocate() zero range operation against a large file range for which
8 # there are many small extents allocated. Verify the operation does not fail
9 # and the respective range return zeroes on subsequent reads.
10 #
11 . ./common/preamble
12 _begin_fstest auto quick prealloc zero
13
14 # Import common functions.
15 . ./common/filter
16
17 # real QA test starts here
18 _supported_fs generic
19 _require_scratch
20 _require_xfs_io_command "fzero"
21 _require_xfs_io_command "fpunch"
22 _require_test_program "punch-alternating"
23
24 _scratch_mkfs >>$seqres.full 2>&1
25 _scratch_mount
26
27 # Create a file with many small extents. To speed up file creation, do
28 # buffered writes and then punch a hole on every other block.
29 $XFS_IO_PROG -f -c "pwrite -S 0xab -b 10M 0 100M" \
30         $SCRATCH_MNT/foobar >>$seqres.full
31 $here/src/punch-alternating $SCRATCH_MNT/foobar >>$seqres.full
32
33 # For btrfs, trigger a transaction commit to force metadata COW for the
34 # following fallocate zero range operation.
35 sync
36
37 $XFS_IO_PROG -c "fzero 0 100M" $SCRATCH_MNT/foobar
38
39 # Check the file content after umounting and mounting again the fs, to verify
40 # everything was persisted.
41 _scratch_cycle_mount
42
43 echo "File content after zero range operation:"
44 od -A d -t x1 $SCRATCH_MNT/foobar
45
46 status=0
47 exit