overlay: run unionmount testsuite test cases
[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 # Btrfs is a COW filesystem, so a RWF_NOWAIT write will always fail with -EAGAIN
41 # when writing to a file range except if it's a NOCOW file and an extent for the
42 # range already exists or if it's a COW file and preallocated/unwritten extent
43 # exists in the target range. So to make sure that the last write succeeds on
44 # all filesystems, use a NOCOW file on btrfs.
45 if [ $FSTYP == "btrfs" ]; then
46         _require_chattr C
47         touch $testdir/f1
48         $CHATTR_PROG +C $testdir/f1
49 fi
50
51 # Create a file with pwrite nowait (will fail with EAGAIN)
52 $XFS_IO_PROG -f -d -c "pwrite -N -V 1 -b 1M 0 1M" $testdir/f1
53
54 # Write the file without nowait
55 $XFS_IO_PROG -f -d -c "pwrite -S 0xaa -W -w -V 1 -b 1M 0 8M" $testdir/f1 | _filter_xfs_io
56
57 time_taken=`$XFS_IO_PROG -d -c "pwrite -S 0xbb -N -V 1 -b 1M 2M 1M" $testdir/f1 | awk '/^1/ {print $5}'`
58
59 # RWF_NOWAIT should finish within a short period of time so we are choosing
60 # a conservative value of 50 ms. Anything longer means it is waiting
61 # for something in the kernel which would be a fail.
62 if (( $(echo "$time_taken < 0.05" | bc -l) )); then
63         echo "RWF_NOWAIT time is within limits."
64 else
65         echo "RWF_NOWAIT took $time_taken seconds"
66 fi
67
68 $XFS_IO_PROG -c "pread -v 0 8M" $testdir/f1 | _filter_xfs_io_unique
69
70 # success, all done
71 status=0
72 exit