3 # Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved.
5 # Core of filestreams tests.
8 _check_filestreams_support()
10 local irix_timeout_sysvar="xfs_mfstream_timeout"
11 local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs"
12 local streams_avail=""
13 if [ "$HOSTOS" == "IRIX" ]; then
14 # check for the filestreams timeout systune variable in irix
15 streams_avail=`systune $irix_timeout_sysvar 2>&1 |
16 perl -ne 'if (/'$irix_timeout_sysvar'\s+=\s+\d+/) {print "true"}'`
18 # check for the filestreams timeout proc entry in linux
19 [ -f $linux_timeout_procvar ] && streams_avail="true"
22 if [ "$streams_avail" == "true" ]; then
29 _set_stream_timeout_centisecs()
31 local new_timeout_csecs=$1
32 local irix_timeout_sysvar="xfs_mfstream_timeout"
33 local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs"
34 if [ "$HOSTOS" == "IRIX" ]; then
35 echo y | systune -r $irix_timeout_sysvar $new_timeout_csecs >/dev/null
37 echo $new_timeout_csecs > $linux_timeout_procvar
43 local directory_name=$1
49 local blocks_in_file=`expr $file_size / $bsize`
52 if [ "$iflag" = "1" -a "$HOSTOS" != "IRIX" ]; then
53 $XFS_IO_PROG -x -c "chattr +S" $directory_name \
54 || _fail "chattr of filestream flag"
59 if [ "$HOSTOS" == "IRIX" ]; then
62 [ "$dio" = "1" ] && dd_cmd="$dd_cmd odirect=1"
66 [ "$dio" = "1" ] && dd_cmd="$dd_cmd oflag=direct"
68 dd_cmd="$dd_cmd if=/dev/zero bs=${bsize} count=${blocks_in_file}"
71 while [ $i -le $files ]; do
72 $dd_cmd of=frame-${i} 2>&1 | grep -v records | grep -v secs
79 # the ag number is in column 4 of xfs_bmap output
81 $ag = (split /\s+/)[4] ;
82 if ($ag =~ /\d+/) {print "$ag "} ;
88 local directory_name=$1
89 local stream_ags=`xfs_bmap -vp ${directory_name}/* | _filter_agno`
95 # check for duplicate numbers between two space seperated vars
101 for this_num_one in $num_str_one; do
102 for this_num_two in $num_str_two; do
103 if [ "$this_num_one" == "$this_num_two" ]; then
104 echo "duplicate AG $this_num_one found" \
115 echo "# testing $* ...."
117 local agsize="$2" # in MB
118 local stream_count="$3"
119 local stream_files="$4"
120 local stream_file_size=`expr $5 \* 1024 \* 1024`
122 local use_directio="$7"
123 local expected_result="$8" # "fail" if failure is expected
125 local size=`expr $agsize \* 1024 \* 1024 \* $agcount`
126 _scratch_mkfs_xfs -dsize=$size,agcount=$agcount >/dev/null 2>&1 \
127 || _fail "mkfs failed"
129 if [ "$use_iflag" = "0" -o "$HOSTOS" == "IRIX" ]; then
130 # mount using filestreams mount option
131 _scratch_mount "-o filestreams" \
132 || _fail "filestreams mount failed"
134 # test will set inode flag
135 _scratch_mount || _fail "mount failed"
140 # start $stream_count streams
141 # each stream writes ($stream_files x $stream_file_size)M
145 while [ $stream_index -le $stream_count ]; do
146 _do_stream stream${stream_index}-dir $stream_files \
147 $stream_file_size 1048576 $use_iflag $use_directio &
148 stream_pids="$stream_pids $!"
149 stream_index=`expr $stream_index + 1`
152 # wait for streams to finish
153 # XXX wait here not needed? -dgc
156 # sync the buffered streams out in parallel
157 # _get_stream_ags does a xfs_bmap which syncs delayed allocations
159 local ag_sync_pids=""
161 while [ $stream_index -le $stream_count ]; do
162 _get_stream_ags stream${stream_index}-dir > /dev/null 2>&1 &
163 ag_sync_pids="$ag_sync_pids $!"
164 stream_index=`expr $stream_index + 1`
167 # wait for syncs to finish
170 # confirm streams are in seperate AGs
171 echo "# checking stream AGs..."
172 local this_stream_ags=""
174 local num_streams_with_matching_ags=0
176 while [ $stream_index -le $stream_count ]; do
177 this_stream_ags=`_get_stream_ags stream${stream_index}-dir`
178 echo "stream $stream_index AGs: $this_stream_ags" >> $here/$seq.full
179 _check_for_dupes "$ags_seen" "$this_stream_ags"
180 if [ $? -ne 0 ]; then
181 # this stream is not in seperate AGs to previous streams
182 num_streams_with_matching_ags=`expr $num_streams_with_matching_ags + 1`
184 ags_seen="$ags_seen $this_stream_ags"
185 stream_index=`expr $stream_index + 1`
188 _cleanup_streams_umount
189 if [ "$expected_result" != "fail" ]; then
190 if [ $num_streams_with_matching_ags -eq 0 ]; then
191 # all streams in seperate AGs, as expected
192 echo "+ passed, streams are in seperate AGs"
194 # streams with matching AGs, should be seperate
195 _fail "- failed, $num_streams_with_matching_ags streams with matching AGs"
198 # expecting streams to have overlapped
199 if [ $num_streams_with_matching_ags -eq 0 ]; then
200 # all streams in seperate AGs, should have overlapped
201 _fail "- streams are in seperate AGs, expected _matching_"
203 # streams with matching AGs, as expected
204 echo "+ expected failure, matching AGs"
210 _cleanup_streams_umount()
213 rm -rf ${SCRATCH_MNT}/stream*
214 umount $SCRATCH_DEV 2>/dev/null