blob: 892417707feabc225574fbb2af8c9b05608a1b38 [file] [log] [blame]
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2017 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. 473
#
# Test for the new ranged query functionality in xfs_io's fiemap command.
# This tests various combinations of hole + data layout being printed.
# Also the test used 16k holes to be compatible with 16k block filesystems
#
. ./common/preamble
_begin_fstest broken
# Import common functions.
. ./common/punch
# real QA test starts here
# Modify as appropriate.
_require_test
_require_xfs_io_command "truncate"
# ranged is a special argument which checks if fiemap supports
# [offset [len]] args
_require_xfs_io_command "fiemap" "ranged"
file=$TEST_DIR/fiemap.$seq
rm -f $file
# Create a file with 64k hole followed by 64k data, and this pattern
# repeats till it reaches 4M file size, so each extent has 64k data.
# But truncate file to its final size first, otherwise XFS would merge
# some extents due to speculative preallocation.
$XFS_IO_PROG -f -c "truncate 4m" $file
for i in {0..31}; do
$XFS_IO_PROG -c "pwrite $(($i*128+64))k 64k" $file >/dev/null;
done
# Query 1 data extent between 64k..64k range
echo "Basic data extent"
$XFS_IO_PROG -c "fiemap -v 64k 64k" $file | _filter_fiemap
# Query data and hole extent
echo "Data + Hole"
$XFS_IO_PROG -c "fiemap -v 64k 80k" $file | _filter_fiemap
echo "Hole + Data"
$XFS_IO_PROG -c "fiemap -v 0 65k" $file | _filter_fiemap
echo "Hole + Data + Hole"
$XFS_IO_PROG -c "fiemap -v 0k 130k" $file | _filter_fiemap
echo "Data + Hole + Data"
$XFS_IO_PROG -c "fiemap -v 64k 192k" $file | _filter_fiemap
echo "Beginning with a hole"
$XFS_IO_PROG -c "fiemap -v 0 3k" $file | _filter_fiemap
# Query for 0..160k that's 40 extents, more than the EXTENT_BATCH
echo "Query more than 32 extents"
$XFS_IO_PROG -c "fiemap -v 0 3m" $file | _filter_fiemap
echo "Larger query than file size"
$XFS_IO_PROG -c "fiemap -v 0 5m" $file | _filter_fiemap
# mapping past eof shouldn't print anything"
$XFS_IO_PROG -c "fiemap -v 5m" $file | _filter_fiemap
echo "Skip first hole"
# check everything without the first hole
$XFS_IO_PROG -c "fiemap -v 64k" $file | _filter_fiemap
# success, all done
status=0
exit