| #! /bin/bash |
| # SPDX-License-Identifier: GPL-2.0 |
| # Copyright (c) 2018 Oracle. All Rights Reserved. |
| # |
| # FS QA Test 204 |
| # |
| # Test if the unaligned (by size and offset) punch hole is successful when FS |
| # is at ENOSPC. |
| # |
| . ./common/preamble |
| _begin_fstest auto quick punch |
| |
| . ./common/filter |
| |
| _require_scratch |
| _require_xfs_io_command "fpunch" |
| |
| _scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full |
| |
| # max_inline ensures data is not inlined within metadata extents |
| _scratch_mount "-o max_inline=0,nodatacow" |
| |
| cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full |
| $BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full |
| |
| extent_size=$(_scratch_btrfs_sectorsize) |
| unalign_by=512 |
| echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full |
| |
| $XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \ |
| $SCRATCH_MNT/testfile >> $seqres.full |
| |
| echo "Fill all space available for data and all unallocated space." >> $seqres.full |
| dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1 |
| |
| hole_offset=0 |
| hole_len=$unalign_by |
| $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile |
| |
| hole_offset=$(($extent_size + $unalign_by)) |
| hole_len=$(($extent_size - $unalign_by)) |
| $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile |
| |
| hole_offset=$(($extent_size * 2 + $unalign_by)) |
| hole_len=$(($extent_size * 5)) |
| $XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile |
| |
| # success, all done |
| echo "Silence is golden" |
| status=0 |
| exit |