Files
apfstests/tests/generic/092
T
Darrick J. Wong a860a167d8 common: kill _supported_os
fstests only supports Linux, so get rid of this unnecessary predicate.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-09-21 01:16:50 +08:00

56 lines
1.4 KiB
Bash
Executable File

#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2015 Facebook. All Rights Reserved.
#
# FS QA Test No. 092
#
# fallocate/truncate tests with FALLOC_FL_KEEP_SIZE option.
# Verify if the disk space is released after truncating a file to i_size after
# writing to a portion of a preallocated range.
#
# This also verifies that truncat'ing up past i_size doesn't remove the
# preallocated space.
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=0 # success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/punch
# real QA test starts here
# Modify as appropriate.
_supported_fs generic
_require_test
_require_xfs_io_command "falloc"
_require_xfs_io_command "fiemap"
# First test to make sure that truncating at i_size trims the preallocated bit
# past i_size
$XFS_IO_PROG -f -c "falloc -k 0 10M" -c "pwrite 0 5M" -c "truncate 5M"\
$TEST_DIR/testfile.$seq | _filter_xfs_io
sync
$XFS_IO_PROG -c "fiemap -v" $TEST_DIR/testfile.$seq | _filter_fiemap
# Now verify that if we truncate up past i_size we don't trim the preallocated
# bit
$XFS_IO_PROG -c "falloc -k 5M 5M" -c "truncate 7M" $TEST_DIR/testfile.$seq
$XFS_IO_PROG -c "fiemap -v" $TEST_DIR/testfile.$seq | _filter_fiemap
# success, all done
exit