Use upstream version of fstrim instead of the local one
[xfstests-dev.git] / 240
1 #! /bin/bash
2 # FS QA Test No. 240
3 #
4 # Test that non-block-aligned aio+dio into holes does not leave
5 # zero'd out portions of the file
6 #
7 # QEMU IO to a file-backed device with misaligned partitions
8 # can send this sort of IO
9 #
10 # This test need only be run in the case where the logical block size
11 # of the device can be smaller than the file system block size.
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2010 Red Hat, Inc.  All Rights Reserved.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30 # creator
31 owner=sandeen@sandeen.net
32
33 seq=`basename $0`
34 echo "QA output created by $seq"
35
36 here=`pwd`
37 tmp=/tmp/$$
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43     cd /
44     rm -f $tmp.*
45 }
46
47 # get standard environment, filters and checks
48 . ./common.rc
49 . ./common.filter
50
51 _supported_fs generic
52 _supported_os Linux
53
54 _require_sparse_files
55 _require_aiodio aiodio_sparse2
56
57 echo "Silence is golden."
58
59 # real QA test starts here
60 rm -f $seq.full
61
62 rm -f $TEST_DIR/aiodio_sparse
63
64 logical_block_size=`blockdev --getss $TEST_DEV`
65 fs_block_size=`stat -f $TEST_DIR | grep "Block size:" | awk '{print $3}'`
66
67 if [ $fs_block_size -le $logical_block_size ]; then
68         _notrun "fs block size must be larger than the device block size.  fs block size: $fs_block_size, device block size: $logical_block_size"
69 fi
70
71 # 2 threads, fs block sized writes, 64k filesize, stride through file by
72 # fs block size, start at logical block size offset
73 $AIO_TEST -i 2 -w $fs_block_size -s 64k -n $fs_block_size -o $logical_block_size "$TEST_DIR/aiodio_sparse"
74
75 status=$?
76 exit