btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / overlay / 016
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 CTERA Networks. All Rights Reserved.
4 #
5 # FSQA Test No. 016
6 #
7 # Test ro/rw fd data inconsistecies
8 #
9 # This simple test demonstrates a known issue with overlayfs:
10 # - process A opens file F for read
11 # - process B writes new data to file F
12 # - process A reads old data from file F
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 # real QA test starts here
33 _supported_fs overlay
34 _require_scratch
35 _require_xfs_io_command "open"
36
37 rm -f $seqres.full
38
39 _scratch_mkfs >>$seqres.full 2>&1
40
41 # Create our test files.
42 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
43 mkdir -p $lowerdir
44 echo "This is old news" > $lowerdir/foo
45
46 _scratch_mount
47
48
49 #
50 # open file for read (rofd)
51 # open file for write (rwfd)
52 # write to rwfd
53 # read from rofd
54 #
55 $XFS_IO_PROG -r $SCRATCH_MNT/foo \
56         -C "open $SCRATCH_MNT/foo" \
57         -C "pwrite -S 0x61 0 16" \
58         -C "file 0" \
59         -C "pread -v 0 16" \
60 | _filter_xfs_io | _filter_scratch
61
62 status=0
63 exit