2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:45 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2009-05-28 17:04:15 +02:00
|
|
|
# FSQA Test No. 166
|
|
|
|
|
#
|
|
|
|
|
# ->page-mkwrite test - unwritten extents and mmap
|
2009-05-12 13:24:15 -05:00
|
|
|
#
|
2007-04-23 16:00:46 +00:00
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2007-04-23 16:00:46 +00:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
2013-12-03 10:29:26 +11:00
|
|
|
trap "exit \$status" 0 1 2 3 15
|
2013-03-15 12:28:02 +00:00
|
|
|
rm -f $seqres.full
|
2007-04-23 16:00:46 +00:00
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
2007-04-23 16:00:46 +00:00
|
|
|
|
2008-03-25 05:19:50 +00:00
|
|
|
# assumes 1st, 3rd and 5th blocks are single written blocks,
|
|
|
|
|
# the others are unwritten.
|
2007-04-23 16:00:46 +00:00
|
|
|
_filter_blocks()
|
|
|
|
|
{
|
2008-03-25 05:19:50 +00:00
|
|
|
$AWK_PROG '
|
2008-05-15 16:38:14 +00:00
|
|
|
/^ +[0-9]/ {
|
2008-03-25 05:19:50 +00:00
|
|
|
if (!written_size) {
|
|
|
|
|
written_size = $6
|
|
|
|
|
unwritten1 = ((1048576/512) / 2) - written_size
|
|
|
|
|
unwritten2 = ((1048576/512) / 2) - 2 * written_size
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-08 04:10:08 +00:00
|
|
|
# is the extent unwritten?
|
2008-04-28 06:26:58 +00:00
|
|
|
unwritten_ext = 0;
|
|
|
|
|
if ($7 >= 10000)
|
|
|
|
|
unwritten_ext = 1;
|
|
|
|
|
|
|
|
|
|
size = "RIGHT"
|
|
|
|
|
flags = "GOOD"
|
|
|
|
|
if (unwritten_ext) {
|
2008-03-25 05:19:50 +00:00
|
|
|
if (unwritten1) {
|
|
|
|
|
if ($6 != unwritten1)
|
|
|
|
|
size = "WRONG"
|
|
|
|
|
unwritten1 = 0;
|
|
|
|
|
} else if ($6 != unwritten2) {
|
|
|
|
|
size = "WRONG"
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ($6 != written_size)
|
|
|
|
|
size = "WRONG"
|
|
|
|
|
}
|
|
|
|
|
print $1, "[AA..BB]", "XX..YY", "AG", "(AA..BB)", size, flags
|
|
|
|
|
}'
|
2007-04-23 16:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_fs xfs
|
|
|
|
|
|
|
|
|
|
_require_scratch
|
2018-11-10 12:51:43 +01:00
|
|
|
_require_xfs_io_command "falloc"
|
|
|
|
|
|
2007-04-23 16:00:46 +00:00
|
|
|
_scratch_mkfs_xfs >/dev/null 2>&1
|
|
|
|
|
_scratch_mount
|
|
|
|
|
|
|
|
|
|
TEST_FILE=$SCRATCH_MNT/test_file
|
|
|
|
|
TEST_PROG=$here/src/unwritten_mmap
|
2008-03-25 05:19:50 +00:00
|
|
|
FILE_SIZE=1048576
|
2007-04-23 16:00:46 +00:00
|
|
|
|
|
|
|
|
rm -f $TEST_FILE
|
|
|
|
|
$TEST_PROG $FILE_SIZE $TEST_FILE
|
|
|
|
|
|
2013-03-15 12:28:02 +00:00
|
|
|
xfs_bmap -vp $TEST_FILE >> $seqres.full
|
2007-04-23 16:00:46 +00:00
|
|
|
xfs_bmap -vp $TEST_FILE | _filter_blocks
|
|
|
|
|
|
|
|
|
|
status=0
|
|
|
|
|
exit
|