From 2bf01dc5c4bd21995524e46e312a1ac646ae0853 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Fri, 20 Jul 2007 04:11:09 +0000 Subject: [PATCH] - OS common filestreams timeout change function - use xfs_io instead of dd (working direct io) - no filestreams directory flags, just use the mount option Merge of master-melb:xfs-cmds:29185a by kenmcd. --- 170 | 12 +++-- 171 | 10 ++-- 172 | 10 ++-- 173 | 10 ++-- 174 | 9 ++-- common.filestreams | 127 +++++++++++++++++++++++++++++---------------- 6 files changed, 118 insertions(+), 60 deletions(-) diff --git a/170 b/170 index c6bc4e15..4e9a9c2e 100644 --- a/170 +++ b/170 @@ -16,13 +16,14 @@ echo "QA output created by $seq" here=`pwd` tmp=/tmp/$$ +rm -f $seq.full status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { - cd / - rm -rf ${SCRATCH_MNT}/stream* + cd / + rm -f $tmp.* } # get standard environment, filters and checks @@ -37,9 +38,12 @@ _require_scratch . ./common.filestreams +_check_filestreams_support || _notrun "filestreams not available" + # test small stream, multiple I/O per file, 30s timeout -# XXX: irix timer mechanism? -echo 3000 > /proc/sys/fs/xfs/filestream_centisecs +_set_stream_timeout_centisecs 3000 + +# test streams does a mkfs and mount _test_streams 8 16 4 8 3 0 0 _test_streams 8 16 4 8 3 1 0 _test_streams 8 16 4 8 3 0 1 diff --git a/171 b/171 index e5cae7b6..b98b5404 100644 --- a/171 +++ b/171 @@ -16,13 +16,14 @@ echo "QA output created by $seq" here=`pwd` tmp=/tmp/$$ +rm -f $seq.full status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { - cd / - rm -rf ${SCRATCH_MNT}/stream* + cd / + rm -f $tmp.* } # get standard environment, filters and checks @@ -37,13 +38,16 @@ _require_scratch . ./common.filestreams +_check_filestreams_support || _notrun "filestreams not available" + # test large numbers of files, single I/O per file, 120s timeout # Get close to filesystem full. # 128 = ENOSPC # 120 = 93.75% full, gets repeatable failures # 112 = 87.5% full, should reliably succeed but doesn't *FIXME* # 100 = 78.1% full, should reliably succeed -echo 12000 > /proc/sys/fs/xfs/filestream_centisecs +_set_stream_timeout_centisecs 12000 + _test_streams 64 16 8 100 1 1 0 _test_streams 64 16 8 100 1 1 1 _test_streams 64 16 8 100 1 0 0 diff --git a/172 b/172 index f80ef517..e76e9e77 100644 --- a/172 +++ b/172 @@ -16,13 +16,14 @@ echo "QA output created by $seq" here=`pwd` tmp=/tmp/$$ +rm -f $seq.full status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { - cd / - rm -rf ${SCRATCH_MNT}/stream* + cd / + rm -f $tmp.* } # get standard environment, filters and checks @@ -37,9 +38,12 @@ _require_scratch . ./common.filestreams +_check_filestreams_support || _notrun "filestreams not available" + # test reaper works by setting timeout low. Expected to fail # for buffered, succeed for direct I/O. -echo 50 > /proc/sys/fs/xfs/filestream_centisecs +_set_stream_timeout_centisecs 50 + _test_streams 8 16 4 8 3 1 0 fail _test_streams 64 16 20 10 1 0 1 diff --git a/173 b/173 index bfb8feab..2d2e0807 100644 --- a/173 +++ b/173 @@ -16,13 +16,14 @@ echo "QA output created by $seq" here=`pwd` tmp=/tmp/$$ +rm -f $seq.full status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { - cd / - rm -rf ${SCRATCH_MNT}/stream* + cd / + rm -f $tmp.* } # get standard environment, filters and checks @@ -37,10 +38,13 @@ _require_scratch . ./common.filestreams +_check_filestreams_support || _notrun "filestreams not available" + # test large number of streams, multiple I/O per file, 120s timeout # Because each stream spills over an AG, the stream count needs to # be less than or equal to half the AG count so we don't run out of AGs. -echo 12000 > /proc/sys/fs/xfs/filestream_centisecs +_set_stream_timeout_centisecs 12000 + _test_streams 64 16 33 8 2 1 1 fail _test_streams 64 16 32 8 2 0 1 _test_streams 64 16 33 8 2 0 0 fail diff --git a/174 b/174 index 21924dc9..9ad23021 100644 --- a/174 +++ b/174 @@ -21,8 +21,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { - cd / - rm -rf ${SCRATCH_MNT}/stream* + cd / + rm -f $tmp.* } # get standard environment, filters and checks @@ -37,8 +37,11 @@ _require_scratch . ./common.filestreams +_check_filestreams_support || _notrun "filestreams not available" + # test number of streams greater than AGs. Expected to fail. -echo 6000 > /proc/sys/fs/xfs/filestream_centisecs +_set_stream_timeout_centisecs 6000 + _test_streams 8 32 65 3 1 1 0 fail _test_streams 8 32 65 3 1 0 1 fail diff --git a/common.filestreams b/common.filestreams index adabffd6..9994b7b1 100644 --- a/common.filestreams +++ b/common.filestreams @@ -5,6 +5,39 @@ # Core of filestreams tests. # +_check_filestreams_support() +{ + local irix_timeout_sysvar="xfs_mfstream_timeout" + local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs" + local streams_avail="" + if [ "$HOSTOS" == "IRIX" ]; then + # check for the filestreams timeout systune variable in irix + streams_avail=`systune $irix_timeout_sysvar 2>&1 | + perl -ne 'if (/'$irix_timeout_sysvar'\s+=\s+\d+/) {print "true"}'` + else + # check for the filestreams timeout proc entry in linux + [ -f $linux_timeout_procvar ] && streams_avail="true" + fi + + if [ "$streams_avail" == "true" ]; then + return 0 + else + return 1 + fi +} + +_set_stream_timeout_centisecs() +{ + local new_timeout_csecs=$1 + local irix_timeout_sysvar="xfs_mfstream_timeout" + local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs" + if [ "$HOSTOS" == "IRIX" ]; then + echo y | systune -r $irix_timeout_sysvar $new_timeout_csecs >/dev/null + else + echo $new_timeout_csecs > $linux_timeout_procvar + fi +} + _do_stream() { local directory_name=$1 @@ -14,9 +47,8 @@ _do_stream() local iflag=$5 local dio=$6 - local count=`expr $file_size / $bsize` mkdir $directory_name - if [ "$iflag" = "1" ]; then + if [ "$iflag" = "1" -a "$HOSTOS" != "IRIX" ]; then $XFS_IO_PROG -x -c "chattr +S" $directory_name \ || _fail "chattr of filestream flag" fi @@ -24,11 +56,12 @@ _do_stream() local i=1 local oflags="" if [ "$dio" = "1" ]; then - oflags="oflag=direct" + oflags="-d" fi while [ $i -le $files ]; do - dd if=/dev/zero of=frame-${i} $oflags \ - bs=$bsize count=$count >/dev/null 2>&1 + $XFS_IO_PROG -f -c \ + "pwrite $oflags -i /dev/zero -b $bsize 0 ${file_size}" \ + frame-${i} >/dev/null i=`expr $i + 1` done } @@ -69,20 +102,6 @@ _check_for_dupes() return 0 } -rm -f $here/$seq.full - -# test that filestreams are available -umount $SCRATCH_MNT > /dev/null 2>&1 - -_scratch_mkfs_xfs > /dev/null 2>&1 \ - || _fail "mkfs failed" - -_scratch_mount "-o filestreams" \ - || _notrun "filestreams mount not available" - -sync -umount $SCRATCH_MNT > /dev/null 2>&1 - _test_streams() { echo "# testing $* ...." @@ -93,28 +112,28 @@ _test_streams() { local stream_file_size=`expr $5 \* 1024 \* 1024` local use_iflag="$6" local use_directio="$7" - local expected_result="$8" + local expected_result="$8" # "fail" if failure is expected local size=`expr $agsize \* 1024 \* 1024 \* $agcount` _scratch_mkfs_xfs -dsize=$size,agcount=$agcount >/dev/null 2>&1 \ || _fail "mkfs failed" - if [ "$use_iflag" = "0" ]; then + if [ "$use_iflag" = "0" -o "$HOSTOS" == "IRIX" ]; then # mount using filestreams mount option _scratch_mount "-o filestreams" \ - || _notrun "filestreams mount not available" + || _fail "filestreams mount failed" else # test will set inode flag - _scratch_mount + _scratch_mount || _fail "mount failed" fi - cd $SCRATCH_MNT - # start four streams, each writing 24m (8 x 3m files) + # start $stream_count streams + # each stream writes ($stream_files x $stream_file_size)M echo "# streaming" - stream_pids="" - stream_index=1 + local stream_pids="" + local stream_index=1 while [ $stream_index -le $stream_count ]; do _do_stream stream${stream_index}-dir $stream_files \ $stream_file_size 1048576 $use_iflag $use_directio & @@ -127,42 +146,62 @@ _test_streams() { wait $stream_pids # sync the buffered streams out in parallel + # _get_stream_ags does a xfs_bmap which syncs delayed allocations echo "# sync AGs..." - stream_pids="" + local ag_sync_pids="" stream_index=1 while [ $stream_index -le $stream_count ]; do _get_stream_ags stream${stream_index}-dir > /dev/null 2>&1 & - stream_pids="$stream_pids $!" + ag_sync_pids="$ag_sync_pids $!" stream_index=`expr $stream_index + 1` done - # wait for streams to finish - wait $stream_pids + # wait for syncs to finish + wait $ag_sync_pids # confirm streams are in seperate AGs echo "# checking stream AGs..." - ags_seen="" + local this_stream_ags="" + local ags_seen="" + local num_streams_with_matching_ags=0 stream_index=1 while [ $stream_index -le $stream_count ]; do - _get_stream_ags stream${stream_index}-dir > $tmp.${stream_index} & this_stream_ags=`_get_stream_ags stream${stream_index}-dir` echo "stream $stream_index AGs: $this_stream_ags" >> $here/$seq.full _check_for_dupes "$ags_seen" "$this_stream_ags" if [ $? -ne 0 ]; then - if [ "$expected_result" = "fail" ]; then - echo "+ expected failure, matching AGs" - expected_result="failed" - break - else - _fail "- failed, streams with matching AGs" - fi + # this stream is not in seperate AGs to previous streams + num_streams_with_matching_ags=`expr $num_streams_with_matching_ags + 1` fi ags_seen="$ags_seen $this_stream_ags" stream_index=`expr $stream_index + 1` done - if [ "$expected_result" != "failed" ]; then - echo "+ passed, streams are in seperate AGs" + + _cleanup_streams_umount + if [ "$expected_result" != "fail" ]; then + if [ $num_streams_with_matching_ags -eq 0 ]; then + # all streams in seperate AGs, as expected + echo "+ passed, streams are in seperate AGs" + else + # streams with matching AGs, should be seperate + _fail "- failed, $num_streams_with_matching_ags streams with matching AGs" + fi + else + # expecting streams to have overlapped + if [ $num_streams_with_matching_ags -eq 0 ]; then + # all streams in seperate AGs, should have overlapped + _fail "- streams are in seperate AGs, expected _matching_" + else + # streams with matching AGs, as expected + echo "+ expected failure, matching AGs" + fi fi - cd $here - umount $SCRATCH_MNT + return 0 +} + +_cleanup_streams_umount() +{ + cd / + rm -rf ${SCRATCH_MNT}/stream* + umount $SCRATCH_DEV 2>/dev/null } -- 2.47.3