2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle. All Rights Reserved.
7 # Test if the unaligned (by size and offset) punch hole is successful when FS
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
29 # remove previous $seqres.full before test
32 # real QA test starts here
34 # Modify as appropriate.
38 _require_xfs_io_command "fpunch"
40 _scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
42 # max_inline ensures data is not inlined within metadata extents
43 _scratch_mount "-o max_inline=0,nodatacow"
45 cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
46 $BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
48 extent_size=$(_scratch_btrfs_sectorsize)
50 echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
52 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \
53 $SCRATCH_MNT/testfile >> $seqres.full
55 echo "Fill all space available for data and all unallocated space." >> $seqres.full
56 dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
60 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
62 hole_offset=$(($extent_size + $unalign_by))
63 hole_len=$(($extent_size - $unalign_by))
64 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
66 hole_offset=$(($extent_size * 2 + $unalign_by))
67 hole_len=$(($extent_size * 5))
68 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
71 echo "Silence is golden"