lib/: spdx license conversion
[xfstests-dev.git] / tests / generic / 471
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, SUSE Linux Products.  All Rights Reserved.
4 #
5 # FS QA Test No. 471
6 #
7 # write a file with RWF_NOWAIT and it would fail because there are no
8 # blocks allocated. Create a file with direct I/O and re-write it
9 # using RWF_NOWAIT. I/O should finish within 50 microsecods since
10 # block allocations are already performed.
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
20 # get standard environment, filters and checks
21 . ./common/rc
22 . ./common/populate
23 . ./common/filter
24 . ./common/attr
25
26 # real QA test starts here
27 _supported_os Linux
28 _require_odirect
29 _require_test
30 _require_xfs_io_command pwrite -N
31
32 # Remove reminiscence of previously run tests
33 testdir=$TEST_DIR/$seq
34 if [ -e $testdir ]; then
35         rm -Rf $testdir
36 fi
37
38 mkdir $testdir
39
40 # Create a file with pwrite nowait (will fail with EAGAIN)
41 $XFS_IO_PROG -f -d -c "pwrite -N -V 1 -b 1M 0 1M" $testdir/f1
42
43 # Write the file without nowait
44 $XFS_IO_PROG -f -d -c "pwrite -S 0xaa -W -w -V 1 -b 1M 0 8M" $testdir/f1 | _filter_xfs_io
45
46 time_taken=`$XFS_IO_PROG -d -c "pwrite -S 0xbb -N -V 1 -b 1M 2M 1M" $testdir/f1 | awk '/^1/ {print $5}'`
47
48 # RWF_NOWAIT should finish within a short period of time so we are choosing
49 # a conservative value of 50 ms. Anything longer means it is waiting
50 # for something in the kernel which would be a fail.
51 if (( $(echo "$time_taken < 0.05" | bc -l) )); then
52         echo "RWF_NOWAIT time is within limits."
53 else
54         echo "RWF_NOWAIT took $time_taken seconds"
55 fi
56
57 $XFS_IO_PROG -c "pread -v 0 8M" $testdir/f1 | _filter_xfs_io_unique
58
59 # success, all done
60 status=0
61 exit