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.
37 _require_xfs_io_command "fpunch"
39 _scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
41 # max_inline ensures data is not inlined within metadata extents
42 _scratch_mount "-o max_inline=0,nodatacow"
44 cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
45 $BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
47 extent_size=$(_scratch_btrfs_sectorsize)
49 echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
51 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \
52 $SCRATCH_MNT/testfile >> $seqres.full
54 echo "Fill all space available for data and all unallocated space." >> $seqres.full
55 dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
59 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
61 hole_offset=$(($extent_size + $unalign_by))
62 hole_len=$(($extent_size - $unalign_by))
63 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
65 hole_offset=$(($extent_size * 2 + $unalign_by))
66 hole_len=$(($extent_size * 5))
67 $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
70 echo "Silence is golden"