2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:42 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2009 Red Hat, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2009-06-24 12:58:11 -05:00
|
|
|
# FS QA Test No. 214
|
|
|
|
|
#
|
|
|
|
|
# Basic unwritten extent sanity checks
|
|
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2009-06-24 12:58:11 -05:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2010-06-25 08:25:56 +10:00
|
|
|
rm -f $TEST_DIR/ouch*
|
2009-06-24 12:58:11 -05:00
|
|
|
cd /
|
|
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=$TEST_DIR/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
2009-06-24 12:58:11 -05:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
# generic, but xfs_io's fallocate must work
|
|
|
|
|
_supported_fs generic
|
|
|
|
|
# only Linux supports fallocate
|
|
|
|
|
_supported_os Linux
|
2014-08-13 11:08:41 +10:00
|
|
|
_require_test
|
2009-06-24 12:58:11 -05:00
|
|
|
|
|
|
|
|
[ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
|
|
|
|
|
|
2013-03-15 12:28:02 +00:00
|
|
|
rm -f $seqres.full
|
2010-06-25 08:25:56 +10:00
|
|
|
rm -f $TEST_DIR/ouch*
|
2009-06-24 12:58:11 -05:00
|
|
|
|
2014-04-28 10:55:12 +10:00
|
|
|
_require_xfs_io_command "falloc"
|
2016-02-19 10:44:45 +11:00
|
|
|
_require_odirect
|
2009-06-24 12:58:11 -05:00
|
|
|
|
|
|
|
|
# Ok, off we go.
|
|
|
|
|
|
2010-01-12 23:16:53 +00:00
|
|
|
# We don't remove files after they are written to check
|
|
|
|
|
# for subsequent fs corruption at the end
|
|
|
|
|
rm -f $TEST_DIR/test214-*
|
|
|
|
|
|
2009-06-24 12:58:11 -05:00
|
|
|
# Super-trivial; preallocate a region and read it; get 0s.
|
|
|
|
|
echo "=== falloc & read ==="
|
2013-05-14 08:33:44 -05:00
|
|
|
$XFS_IO_PROG -f \
|
2009-06-24 12:58:11 -05:00
|
|
|
-c 'falloc 0 4096' \
|
|
|
|
|
-c 'pread -v 0 4096' \
|
2010-01-12 23:16:53 +00:00
|
|
|
$TEST_DIR/test214-1 | _filter_xfs_io_unique
|
2009-06-24 12:58:11 -05:00
|
|
|
|
|
|
|
|
# Preallocate a chunk, write 1 byte, read it all back.
|
|
|
|
|
# Should get no stale data. Early ext4 bug.
|
|
|
|
|
|
|
|
|
|
echo "=== falloc, write beginning, read ==="
|
2013-05-14 08:33:44 -05:00
|
|
|
$XFS_IO_PROG -f \
|
2009-06-24 12:58:11 -05:00
|
|
|
-c 'falloc 0 512' \
|
|
|
|
|
-c 'pwrite 0 1' \
|
|
|
|
|
-c 'pread -v 0 512' \
|
2010-01-12 23:16:53 +00:00
|
|
|
$TEST_DIR/test214-2 | _filter_xfs_io_unique
|
2009-06-24 12:58:11 -05:00
|
|
|
|
|
|
|
|
# Same but write in the middle of the region
|
|
|
|
|
echo "=== falloc, write middle, read ==="
|
2013-05-14 08:33:44 -05:00
|
|
|
$XFS_IO_PROG -f \
|
2009-06-24 12:58:11 -05:00
|
|
|
-c 'falloc 0 512' \
|
|
|
|
|
-c 'pwrite 256 1' \
|
|
|
|
|
-c 'pread -v 0 512' \
|
2010-01-12 23:16:53 +00:00
|
|
|
$TEST_DIR/test214-3 | _filter_xfs_io_unique
|
2009-06-24 12:58:11 -05:00
|
|
|
|
|
|
|
|
# Same but write the end of the region
|
|
|
|
|
echo "=== falloc, write end, read ==="
|
2013-05-14 08:33:44 -05:00
|
|
|
$XFS_IO_PROG -f \
|
2009-06-24 12:58:11 -05:00
|
|
|
-c 'falloc 0 512' \
|
|
|
|
|
-c 'pwrite 511 1' \
|
|
|
|
|
-c 'pread -v 0 512' \
|
2010-01-12 23:16:53 +00:00
|
|
|
$TEST_DIR/test214-4 | _filter_xfs_io_unique
|
2009-06-24 12:58:11 -05:00
|
|
|
|
|
|
|
|
# Reported by IBM on ext4.
|
|
|
|
|
#
|
|
|
|
|
# Fixed by commit a41f20716975910d9beb90b7efc61107901492b8
|
|
|
|
|
#
|
|
|
|
|
# The file was previously preallocated, and then initialized the middle of
|
|
|
|
|
# the preallocation area using Direct IO write, then overwrite part of
|
|
|
|
|
# initialized area. Later after truncate the file (to the middle of the
|
|
|
|
|
# initialized data), the initialized data *before* the new file size was
|
|
|
|
|
# gone after remount the filesystem.
|
|
|
|
|
|
|
|
|
|
echo "=== falloc, write, sync, truncate, read ==="
|
|
|
|
|
# Allocate, write, sync, truncate (buffered)
|
2013-05-14 08:33:44 -05:00
|
|
|
$XFS_IO_PROG -f \
|
2009-06-24 12:58:11 -05:00
|
|
|
-c 'falloc 0x0 0x65C00' \
|
|
|
|
|
-c 'pwrite -S 0xAA 0x12000 0x10000' \
|
|
|
|
|
-c 'fsync' \
|
|
|
|
|
-c 'truncate 0x16000' \
|
2010-01-12 23:16:53 +00:00
|
|
|
$TEST_DIR/test214-5 | _filter_xfs_io_unique
|
2009-06-24 12:58:11 -05:00
|
|
|
|
|
|
|
|
# now do a direct read and see what's on-disk
|
2013-05-14 08:33:44 -05:00
|
|
|
$XFS_IO_PROG -f -d \
|
2009-06-24 12:58:11 -05:00
|
|
|
-c 'pread -v 0 0x16000' \
|
2010-01-12 23:16:53 +00:00
|
|
|
$TEST_DIR/test214-5 | _filter_xfs_io_unique
|
2009-06-24 12:58:11 -05:00
|
|
|
|
2010-01-06 13:00:18 -06:00
|
|
|
# Reported by Ted Ts'o on linux-ext4, 12/31/2009
|
|
|
|
|
# double-allocation on ext4 when fallocating over delalloc blocks
|
|
|
|
|
# Regression due to d21cd8f163ac44b15c465aab7306db931c606908
|
|
|
|
|
|
|
|
|
|
echo "=== delalloc write 16k; fallocate same range ==="
|
|
|
|
|
# delalloc write 16k, fallocate same range.
|
|
|
|
|
# Should get caught on fsck when we're done.
|
|
|
|
|
|
2013-05-14 08:33:44 -05:00
|
|
|
$XFS_IO_PROG -f \
|
2010-01-06 13:00:18 -06:00
|
|
|
-c "pwrite 0 16k" \
|
|
|
|
|
-c "falloc 0 16k" \
|
|
|
|
|
-c "fsync" \
|
2010-01-12 23:16:53 +00:00
|
|
|
$TEST_DIR/test214-6 | _filter_xfs_io_unique
|
|
|
|
|
|
|
|
|
|
# Another ext4 failure
|
|
|
|
|
|
|
|
|
|
echo "=== ext4 testcase 2 ==="
|
|
|
|
|
|
2013-05-14 08:33:44 -05:00
|
|
|
$XFS_IO_PROG -f \
|
|
|
|
|
-c "fsync" \
|
2010-01-12 23:16:53 +00:00
|
|
|
-c "pwrite 551917 41182" \
|
|
|
|
|
-c "falloc 917633 392230" \
|
|
|
|
|
-c "pwrite 285771 77718" \
|
|
|
|
|
-c "pwrite 1136718 104115" \
|
|
|
|
|
$TEST_DIR/test214-7 | _filter_xfs_io_unique
|
|
|
|
|
|
2009-06-24 12:58:11 -05:00
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|