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 _begin_fstest auto quick punch
13 # Import common functions.
16 # real QA test starts here
18 # Modify as appropriate.
21 _require_xfs_io_command "fpunch"
23 _scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
25 # max_inline ensures data is not inlined within metadata extents
26 _scratch_mount "-o max_inline=0,nodatacow"
28 cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
29 $BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
31 extent_size=$(_scratch_btrfs_sectorsize)
33 echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
35 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \
36 $SCRATCH_MNT/testfile >> $seqres.full
38 echo "Fill all space available for data and all unallocated space." >> $seqres.full
39 dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
43 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
45 hole_offset=$(($extent_size + $unalign_by))
46 hole_len=$(($extent_size - $unalign_by))
47 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
49 hole_offset=$(($extent_size * 2 + $unalign_by))
50 hole_len=$(($extent_size * 5))
51 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
54 echo "Silence is golden"