fstests: check for filesystem FS_IOC_FSSETXATTR support
[xfstests-dev.git] / tests / xfs / 165
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 165
6 #
7 # Test out prealloc, direct writes and buffered read
8 # Some experimentation when looking at 
9 #   pv#962014 - DMF 3.7 reading incorrect data 
10 # Doesn't actually reproduce the problem but it tried to :-)
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     cd /
24     rm -f $tmp.*
25 }
26
27 _filter_io()
28 {
29     tee -a $seqres.full | _filter_xfs_io
30 }
31
32 #
33 # <    1: [8..79]:         6552..6623        0 (6552..6623)        72
34 # >    1: [8..79]:         202544..202615    0 (202544..202615)    72
35 #
36 _filter_bmap()
37 {
38     awk '$3 ~ /hole/ { print $1, $2, $3; next }
39          {print $1, $2}' >> $seqres.full
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # real QA test starts here
47
48 # Modify as appropriate.
49 _supported_fs xfs
50 _supported_os Linux
51 _require_test
52 _require_xfs_io_command "falloc"
53
54 # io tests 
55 testfile=$TEST_DIR/file.$seq
56 rm -f $testfile
57 rm -f $seqres.full
58 len=4
59 end=`expr 10 \* $len`
60
61 # Other test...
62 #$XFS_IO_PROG -f -c "resvsp ${off}k ${end}k" $testfile
63
64 # write the initial file
65 $XFS_IO_PROG -f -c "pwrite 0  ${end}k" $testfile | _filter_io
66
67 off=0
68 while [ $off -le $end ]
69 do
70         offset=${off}k
71         length=${len}k
72
73         $XFS_IO_PROG -c "unresvsp $offset $length" -c "bmap -vp" $testfile | _filter_bmap
74
75         let off=$off+$len # skip over 1
76         let off=$off+$len
77 done
78
79 off=0
80 while [ $off -le $end ]
81 do
82         offset=${off}k
83         length=${len}k
84         bufsize=${len}k
85         echo ""
86         echo "*** offset = $offset ***"
87         echo ""
88
89         # prealloc and write
90         $XFS_IO_PROG -d -c "resvsp $offset $length" -c "pwrite -b $bufsize $offset $length" $testfile | _filter_io
91
92         # Other tests...
93         #$XFS_IO_PROG -c "resvsp $offset $length" $testfile
94         #xfs_bmap -v -p $testfile
95         #$XFS_IO_PROG -d -c "pwrite -b $bufsize $offset $length" $testfile
96         #xfs_bmap -v -p $testfile
97
98         $XFS_IO_PROG -r -c "pread -v -b $bufsize $offset $length" $testfile >$tmp.$off &
99
100         # Other tests...
101         #$XFS_IO_PROG -r -c "pread -v -b $bufsize $offset $length" $testfile
102         #sleep 5
103
104         let off=$off+$len # skip over 1
105         let off=$off+$len
106 done
107
108 wait
109 cat $tmp.* | _filter_io
110
111 # success, all done
112 status=0
113 exit